mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 03:58:26 +00:00
use UpdateStore from widget toolkit
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
0926feeeb4
commit
0c7c0d6bcf
@ -19,8 +19,6 @@ JSSRC= \
|
|||||||
VNCConsole.js \
|
VNCConsole.js \
|
||||||
data/TimezoneStore.js \
|
data/TimezoneStore.js \
|
||||||
data/PVEProxy.js \
|
data/PVEProxy.js \
|
||||||
data/UpdateQueue.js \
|
|
||||||
data/UpdateStore.js \
|
|
||||||
data/DiffStore.js \
|
data/DiffStore.js \
|
||||||
data/ObjectStore.js \
|
data/ObjectStore.js \
|
||||||
data/ResourceStore.js \
|
data/ResourceStore.js \
|
||||||
|
@ -67,7 +67,7 @@ Ext.define('PVE.node.CephMonList', {
|
|||||||
|
|
||||||
var sm = Ext.create('Ext.selection.RowModel', {});
|
var sm = Ext.create('Ext.selection.RowModel', {});
|
||||||
|
|
||||||
var rstore = Ext.create('PVE.data.UpdateStore', {
|
var rstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
interval: 3000,
|
interval: 3000,
|
||||||
storeid: 'ceph-mon-list' + nodename,
|
storeid: 'ceph-mon-list' + nodename,
|
||||||
model: 'ceph-mon-list',
|
model: 'ceph-mon-list',
|
||||||
|
@ -152,7 +152,7 @@ Ext.define('PVE.node.CephPoolList', {
|
|||||||
|
|
||||||
var sm = Ext.create('Ext.selection.RowModel', {});
|
var sm = Ext.create('Ext.selection.RowModel', {});
|
||||||
|
|
||||||
var rstore = Ext.create('PVE.data.UpdateStore', {
|
var rstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
interval: 3000,
|
interval: 3000,
|
||||||
storeid: 'ceph-pool-list' + nodename,
|
storeid: 'ceph-pool-list' + nodename,
|
||||||
model: 'ceph-pool-list',
|
model: 'ceph-pool-list',
|
||||||
|
@ -268,7 +268,7 @@ Ext.define('PVE.node.CephStatus', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
me.store = Ext.create('PVE.data.UpdateStore', {
|
me.store = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
storeid: 'ceph-status-' + nodename,
|
storeid: 'ceph-status-' + nodename,
|
||||||
interval: 5000,
|
interval: 5000,
|
||||||
proxy: {
|
proxy: {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Designed to work with the KeyValue model and the JsonObject data reader
|
* Designed to work with the KeyValue model and the JsonObject data reader
|
||||||
*/
|
*/
|
||||||
Ext.define('PVE.data.ObjectStore', {
|
Ext.define('PVE.data.ObjectStore', {
|
||||||
extend: 'PVE.data.UpdateStore',
|
extend: 'Proxmox.data.UpdateStore',
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Ext.define('PVE.data.ResourceStore', {
|
Ext.define('PVE.data.ResourceStore', {
|
||||||
extend: 'PVE.data.UpdateStore',
|
extend: 'Proxmox.data.UpdateStore',
|
||||||
singleton: true,
|
singleton: true,
|
||||||
|
|
||||||
findVMID: function(vmid) {
|
findVMID: function(vmid) {
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
// Serialize load (avoid too many parallel connections)
|
|
||||||
Ext.define('PVE.data.UpdateQueue', {
|
|
||||||
singleton: true,
|
|
||||||
|
|
||||||
constructor : function(){
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
var queue = [];
|
|
||||||
var queue_idx = {};
|
|
||||||
|
|
||||||
var idle = true;
|
|
||||||
|
|
||||||
var start_update = function() {
|
|
||||||
if (!idle) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var storeid = queue.shift();
|
|
||||||
if (!storeid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var info = queue_idx[storeid];
|
|
||||||
queue_idx[storeid] = null;
|
|
||||||
|
|
||||||
info.updatestart = new Date();
|
|
||||||
|
|
||||||
idle = false;
|
|
||||||
info.store.load({
|
|
||||||
callback: function(records, operation, success) {
|
|
||||||
idle = true;
|
|
||||||
if (info.callback) {
|
|
||||||
var runtime = (new Date()).getTime() - info.updatestart.getTime();
|
|
||||||
info.callback(runtime, success);
|
|
||||||
}
|
|
||||||
start_update();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Ext.apply(me, {
|
|
||||||
queue: function(store, cb) {
|
|
||||||
var storeid = store.storeid;
|
|
||||||
if (!storeid) {
|
|
||||||
throw "unable to queue store without storeid";
|
|
||||||
}
|
|
||||||
if (!queue_idx[storeid]) {
|
|
||||||
queue_idx[storeid] = {
|
|
||||||
store: store,
|
|
||||||
callback: cb
|
|
||||||
};
|
|
||||||
queue.push(storeid);
|
|
||||||
}
|
|
||||||
start_update();
|
|
||||||
},
|
|
||||||
unqueue: function(store) {
|
|
||||||
var storeid = store.storeid;
|
|
||||||
if (!storeid) {
|
|
||||||
throw "unabel to unqueue store without storeid";
|
|
||||||
}
|
|
||||||
if (queue_idx[storeid]) {
|
|
||||||
Ext.Array.remove(queue,storeid);
|
|
||||||
queue_idx[storeid] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,68 +0,0 @@
|
|||||||
/* Extends the Ext.data.Store type
|
|
||||||
* with startUpdate() and stopUpdate() methods
|
|
||||||
* to refresh the store data in the background
|
|
||||||
* Components using this store directly will flicker
|
|
||||||
* due to the redisplay of the element ater 'config.interval' ms
|
|
||||||
*
|
|
||||||
* Note that you have to call yourself startUpdate() for the background load
|
|
||||||
* to begin
|
|
||||||
*/
|
|
||||||
Ext.define('PVE.data.UpdateStore', {
|
|
||||||
extend: 'Ext.data.Store',
|
|
||||||
|
|
||||||
isStopped: true,
|
|
||||||
|
|
||||||
destroy: function() {
|
|
||||||
var me = this;
|
|
||||||
me.load_task.cancel();
|
|
||||||
PVE.data.UpdateQueue.unqueue(me);
|
|
||||||
me.callParent();
|
|
||||||
},
|
|
||||||
|
|
||||||
constructor: function(config) {
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
config = config || {};
|
|
||||||
|
|
||||||
if (!config.interval) {
|
|
||||||
config.interval = 3000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.storeid) {
|
|
||||||
throw "no storeid specified";
|
|
||||||
}
|
|
||||||
|
|
||||||
var load_task = new Ext.util.DelayedTask();
|
|
||||||
|
|
||||||
var run_load_task = function() {
|
|
||||||
if (me.isStopped) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PVE.Utils.authOK()) {
|
|
||||||
PVE.data.UpdateQueue.queue(me, function(runtime, success) {
|
|
||||||
var interval = config.interval + runtime*2;
|
|
||||||
load_task.delay(interval, run_load_task);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
load_task.delay(200, run_load_task);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ext.apply(config, {
|
|
||||||
startUpdate: function() {
|
|
||||||
me.isStopped = false;
|
|
||||||
run_load_task();
|
|
||||||
},
|
|
||||||
stopUpdate: function() {
|
|
||||||
me.isStopped = true;
|
|
||||||
load_task.cancel();
|
|
||||||
PVE.data.UpdateQueue.unqueue(me);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
me.callParent([config]);
|
|
||||||
|
|
||||||
me.load_task = load_task;
|
|
||||||
}
|
|
||||||
});
|
|
@ -167,7 +167,7 @@ Ext.define('PVE.dc.Health', {
|
|||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
me.cephstore = Ext.create('PVE.data.UpdateStore', {
|
me.cephstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
interval: 3000,
|
interval: 3000,
|
||||||
storeid: 'pve-cluster-ceph',
|
storeid: 'pve-cluster-ceph',
|
||||||
proxy: {
|
proxy: {
|
||||||
|
@ -10,7 +10,7 @@ Ext.define('PVE.dc.Log', {
|
|||||||
initComponent : function() {
|
initComponent : function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var logstore = new PVE.data.UpdateStore({
|
var logstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
storeid: 'pve-cluster-log',
|
storeid: 'pve-cluster-log',
|
||||||
model: 'pve-cluster-log',
|
model: 'pve-cluster-log',
|
||||||
proxy: {
|
proxy: {
|
||||||
|
@ -57,7 +57,7 @@ Ext.define('PVE.dc.Summary', {
|
|||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var rstore = Ext.create('PVE.data.UpdateStore', {
|
var rstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
interval: 3000,
|
interval: 3000,
|
||||||
storeid: 'pve-cluster-status',
|
storeid: 'pve-cluster-status',
|
||||||
model: 'pve-dc-nodes',
|
model: 'pve-dc-nodes',
|
||||||
|
@ -10,7 +10,7 @@ Ext.define('PVE.dc.Tasks', {
|
|||||||
initComponent : function() {
|
initComponent : function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var taskstore = new PVE.data.UpdateStore({
|
var taskstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
storeid: 'pve-cluster-tasks',
|
storeid: 'pve-cluster-tasks',
|
||||||
model: 'pve-tasks',
|
model: 'pve-tasks',
|
||||||
proxy: {
|
proxy: {
|
||||||
|
@ -448,7 +448,7 @@ Ext.define('PVE.grid.ReplicaView', {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
me.rstore = Ext.create('PVE.data.UpdateStore', {
|
me.rstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
storeid: 'pve-replica-' + me.nodename + me.vmid,
|
storeid: 'pve-replica-' + me.nodename + me.vmid,
|
||||||
model: (mode === 'dc')? 'pve-replication' : 'pve-replication-state',
|
model: (mode === 'dc')? 'pve-replication' : 'pve-replication-state',
|
||||||
interval: 3000,
|
interval: 3000,
|
||||||
|
@ -13,7 +13,7 @@ Ext.define('PVE.node.ServiceView', {
|
|||||||
throw "no node name specified";
|
throw "no node name specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
var rstore = Ext.create('PVE.data.UpdateStore', {
|
var rstore = Ext.create('Proxmox.data.UpdateStore', {
|
||||||
interval: 1000,
|
interval: 1000,
|
||||||
storeid: 'pve-services' + nodename,
|
storeid: 'pve-services' + nodename,
|
||||||
model: 'pve-services',
|
model: 'pve-services',
|
||||||
|
Loading…
Reference in New Issue
Block a user