[pve-devel] [PATCH manager 40/49] use DiffStore from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jan 23 11:05:57 CET 2018


The alias stayed the same (store.diff) so we need to change direct
usage of 'PVE.data.DiffStore' only.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile            |   1 -
 www/manager6/ceph/Monitor.js     |   2 +-
 www/manager6/ceph/Pool.js        |   2 +-
 www/manager6/data/DiffStore.js   | 114 ---------------------------------------
 www/manager6/dc/Log.js           |   4 +-
 www/manager6/dc/Summary.js       |   2 +-
 www/manager6/dc/Tasks.js         |   2 +-
 www/manager6/grid/Replication.js |   2 +-
 www/manager6/ha/Resources.js     |   2 +-
 www/manager6/ha/StatusView.js    |   2 +-
 10 files changed, 9 insertions(+), 124 deletions(-)
 delete mode 100644 www/manager6/data/DiffStore.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 00ae999f..b285a2bf 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -16,7 +16,6 @@ JSSRC= 				                 	\
 	VNCConsole.js					\
 	data/TimezoneStore.js				\
 	data/PVEProxy.js				\
-	data/DiffStore.js				\
 	data/ObjectStore.js				\
 	data/ResourceStore.js				\
 	data/model/RRDModels.js				\
diff --git a/www/manager6/ceph/Monitor.js b/www/manager6/ceph/Monitor.js
index 27ff3d02..d588441a 100644
--- a/www/manager6/ceph/Monitor.js
+++ b/www/manager6/ceph/Monitor.js
@@ -77,7 +77,7 @@ Ext.define('PVE.node.CephMonList', {
 	    }
 	});
 
-	var store = Ext.create('PVE.data.DiffStore', {
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: rstore,
 	    sorters: [{ property: 'name'}]
 	});
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index d02eedde..58af5cbf 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -162,7 +162,7 @@ Ext.define('PVE.node.CephPoolList', {
 	    }
 	});
 
-	var store = Ext.create('PVE.data.DiffStore', { rstore: rstore });
+	var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore });
 
 	Proxmox.Utils.monStoreErrors(me, rstore);
 
diff --git a/www/manager6/data/DiffStore.js b/www/manager6/data/DiffStore.js
deleted file mode 100644
index c93617a7..00000000
--- a/www/manager6/data/DiffStore.js
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The DiffStore is a in-memory store acting as proxy between a real store
- * instance and a component.
- * Its purpose is to redisplay the component *only* if the data has been changed
- * inside the real store, to avoid the annoying visual flickering of using
- * the real store directly.
- *
- * Implementation:
- * The DiffStore monitors via mon() the 'load' events sent by the real store.
- * On each 'load' event, the DiffStore compares its own content with the target
- * store (call to cond_add_item()) and then fires a 'refresh' event.
- * The 'refresh' event will automatically trigger a view refresh on the component
- * who binds to this store.
- */
-
-/* Config properties:
- * rstore: the realstore which will autorefresh its content from the API
- * Only works if rstore has a model and use 'idProperty'
- * sortAfterUpdate: sort the diffstore before rendering the view
- */
-Ext.define('PVE.data.DiffStore', {
-    extend: 'Ext.data.Store',
-    alias: 'store.diff',
-
-    sortAfterUpdate: false,
-    
-    constructor: function(config) {
-	var me = this;
-
-	config = config || {};
-
-	if (!config.rstore) {
-	    throw "no rstore specified";
-	}
-
-	if (!config.rstore.model) {
-	    throw "no rstore model specified";
-	}
-
-	var rstore = config.rstore;
-
-	Ext.apply(config, {
-	    model: rstore.model,
-	    proxy: { type: 'memory' }
-	});
-
-	me.callParent([config]);
-
-	var first_load = true;
-
-	var cond_add_item = function(data, id) {
-	    var olditem = me.getById(id);
-	    if (olditem) {
-		olditem.beginEdit();
-		Ext.Array.each(me.model.prototype.fields, function(field) {
-		    if (olditem.data[field.name] !== data[field.name]) {
-			olditem.set(field.name, data[field.name]);
-		    }
-		});
-		olditem.endEdit(true);
-		olditem.commit(); 
-	    } else {
-		var newrec = Ext.create(me.model, data);
-		var pos = (me.appendAtStart && !first_load) ? 0 : me.data.length;
-		me.insert(pos, newrec);
-	    }
-	};
-
-	var loadFn = function(s, records, success) {
-
-	    if (!success) {
-		return;
-	    }
-
-	    me.suspendEvents();
-
-	    // getSource returns null if data is not filtered
-	    // if it is filtered it returns all records
-	    var allItems = me.getData().getSource() || me.getData();
-
-	    // remove vanished items
-	    allItems.each(function(olditem) {
-		var item = rstore.getById(olditem.getId());
-		if (!item) {
-		    me.remove(olditem);
-		}
-	    });
-
-	    rstore.each(function(item) {
-		cond_add_item(item.data, item.getId());
-	    });
-
-	    me.filter();
-
-	    if (me.sortAfterUpdate) {
-		me.sort();
-	    }
-
-	    first_load = false;
-
-	    me.resumeEvents();
-	    me.fireEvent('refresh', me);
-	    me.fireEvent('datachanged', me);
-	};
-
-	if (rstore.isLoaded()) {
-	    // if store is already loaded,
-	    // insert items instantly
-	    loadFn(rstore, [], true);
-	}
-
-	me.mon(rstore, 'load', loadFn);
-    }
-});
diff --git a/www/manager6/dc/Log.js b/www/manager6/dc/Log.js
index f4bb5585..0bd7623d 100644
--- a/www/manager6/dc/Log.js
+++ b/www/manager6/dc/Log.js
@@ -19,7 +19,7 @@ Ext.define('PVE.dc.Log', {
 	    }
 	});
 
-	var store = Ext.create('PVE.data.DiffStore', { 
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: logstore,
 	    appendAtStart: true 
 	});
@@ -91,4 +91,4 @@ Ext.define('PVE.dc.Log', {
 
 	me.callParent();
     }
-});
\ No newline at end of file
+});
diff --git a/www/manager6/dc/Summary.js b/www/manager6/dc/Summary.js
index d593f0ba..0b226a1e 100644
--- a/www/manager6/dc/Summary.js
+++ b/www/manager6/dc/Summary.js
@@ -67,7 +67,7 @@ Ext.define('PVE.dc.Summary', {
 	    }
 	});
 
-	var gridstore = Ext.create('PVE.data.DiffStore', {
+	var gridstore = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: rstore,
 	    filters: {
 		property: 'type',
diff --git a/www/manager6/dc/Tasks.js b/www/manager6/dc/Tasks.js
index c38860ba..8b6f9141 100644
--- a/www/manager6/dc/Tasks.js
+++ b/www/manager6/dc/Tasks.js
@@ -19,7 +19,7 @@ Ext.define('PVE.dc.Tasks', {
 	    }
 	});
 
-	var store = Ext.create('PVE.data.DiffStore', { 
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: taskstore,
 	    sortAfterUpdate: true,
 	    appendAtStart: true,
diff --git a/www/manager6/grid/Replication.js b/www/manager6/grid/Replication.js
index 995bf22c..b8f303c7 100644
--- a/www/manager6/grid/Replication.js
+++ b/www/manager6/grid/Replication.js
@@ -441,7 +441,7 @@ Ext.define('PVE.grid.ReplicaView', {
 	    }
 	});
 
-	me.store = Ext.create('PVE.data.DiffStore', {
+	me.store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: me.rstore,
 	    sorters: [
 		{
diff --git a/www/manager6/ha/Resources.js b/www/manager6/ha/Resources.js
index 13419bb3..0b142c8d 100644
--- a/www/manager6/ha/Resources.js
+++ b/www/manager6/ha/Resources.js
@@ -18,7 +18,7 @@ Ext.define('PVE.ha.ResourcesView', {
 
 	Proxmox.Utils.monStoreErrors(me, me.rstore);
 
-	var store = Ext.create('PVE.data.DiffStore', {
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: me.rstore,
 	    filters: {
 		property: 'type',
diff --git a/www/manager6/ha/StatusView.js b/www/manager6/ha/StatusView.js
index 00837a94..ec5fc98e 100644
--- a/www/manager6/ha/StatusView.js
+++ b/www/manager6/ha/StatusView.js
@@ -20,7 +20,7 @@ Ext.define('PVE.ha.StatusView', {
 
 	Proxmox.Utils.monStoreErrors(me, me.rstore);
 
-	var store = Ext.create('PVE.data.DiffStore', {
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: me.rstore,
 	    sortAfterUpdate: true,
 	    sorters: [{
-- 
2.14.2





More information about the pve-devel mailing list