[pve-devel] [RFC manager 18/28] use DiffStore from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 11 16:26:07 CET 2017


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>
---
 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 +-
 www/manager6/node/ServiceView.js |   2 +-
 11 files changed, 10 insertions(+), 125 deletions(-)
 delete mode 100644 www/manager6/data/DiffStore.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index e987ec44..d1e488a7 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -21,7 +21,6 @@ JSSRC= 				                 	\
 	data/PVEProxy.js				\
 	data/UpdateQueue.js				\
 	data/UpdateStore.js				\
-	data/DiffStore.js				\
 	data/ObjectStore.js				\
 	data/ResourceStore.js				\
 	data/RRDStore.js				\
diff --git a/www/manager6/ceph/Monitor.js b/www/manager6/ceph/Monitor.js
index 042c5198..31d968cc 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 78931acd..6b844e89 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 });
 
 	PVE.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 62370eca..ccd1834e 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 f93cc950..1b9473af 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 35e54e1e..10f14df5 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 3f04951a..9b08f187 100644
--- a/www/manager6/grid/Replication.js
+++ b/www/manager6/grid/Replication.js
@@ -458,7 +458,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 a73a38ad..14075af2 100644
--- a/www/manager6/ha/Resources.js
+++ b/www/manager6/ha/Resources.js
@@ -18,7 +18,7 @@ Ext.define('PVE.ha.ResourcesView', {
 
 	PVE.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 212207bc..6c3fc90c 100644
--- a/www/manager6/ha/StatusView.js
+++ b/www/manager6/ha/StatusView.js
@@ -20,7 +20,7 @@ Ext.define('PVE.ha.StatusView', {
 
 	PVE.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: [{
diff --git a/www/manager6/node/ServiceView.js b/www/manager6/node/ServiceView.js
index 9cc0e3ea..6ccfff8b 100644
--- a/www/manager6/node/ServiceView.js
+++ b/www/manager6/node/ServiceView.js
@@ -23,7 +23,7 @@ Ext.define('PVE.node.ServiceView', {
 	    }
 	});
 
-	var store = Ext.create('PVE.data.DiffStore', {
+	var store = Ext.create('Proxmox.data.DiffStore', {
 	    rstore: rstore,
 	    sortAfterUpdate: true,
 	    sorters: [
-- 
2.11.0





More information about the pve-devel mailing list