[pve-devel] [PATCH manager 15/49] use Tasks from widget toolkit

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


From: Dominik Csapak <d.csapak at proxmox.com>

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/Makefile       |   1 -
 www/manager6/lxc/Config.js  |   3 +-
 www/manager6/node/Config.js |   3 +-
 www/manager6/node/Tasks.js  | 175 --------------------------------------------
 www/manager6/qemu/Config.js |   3 +-
 5 files changed, 6 insertions(+), 179 deletions(-)
 delete mode 100644 www/manager6/node/Tasks.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index c81cbcae..4db0616c 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -118,7 +118,6 @@ JSSRC= 				                 	\
 	node/StatusView.js				\
 	node/Summary.js					\
 	node/ServiceView.js				\
-	node/Tasks.js					\
 	node/Subscription.js				\
 	node/Config.js					\
 	window/Migrate.js				\
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 56dcb944..9a5a508b 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -200,7 +200,8 @@ Ext.define('PVE.lxc.Config', {
 		title: gettext('Task History'),
 		itemId: 'tasks',
 		iconCls: 'fa fa-list',
-		xtype: 'pveNodeTasks',
+		xtype: 'proxmoxNodeTasks',
+		nodename: nodename,
 		vmidFilter: vmid
 	    }
 	);
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 4bd3519f..77744e03 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -321,7 +321,8 @@ Ext.define('PVE.node.Config', {
 		title: gettext('Task History'),
 		iconCls: 'fa fa-list',
 		itemId: 'tasks',
-		xtype: 'pveNodeTasks'
+		nodename: nodename,
+		xtype: 'proxmoxNodeTasks'
 	    },
 	    {
 		title: gettext('Subscription'),
diff --git a/www/manager6/node/Tasks.js b/www/manager6/node/Tasks.js
deleted file mode 100644
index 7d3b0754..00000000
--- a/www/manager6/node/Tasks.js
+++ /dev/null
@@ -1,175 +0,0 @@
-Ext.define('PVE.node.Tasks', {
-    extend: 'Ext.grid.GridPanel',
-
-    alias: ['widget.pveNodeTasks'],
-    stateful: true,
-    stateId: 'grid-node-tasks',
-    loadMask: true,
-    sortableColumns: false,
-    vmidFilter: 0,
-
-    initComponent : function() {
-	var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) {
-	    throw "no node name specified";
-	}
-
-	var store = Ext.create('Ext.data.BufferedStore', {
-	    pageSize: 500,
-	    autoLoad: true,
-	    remoteFilter: true,
-	    model: 'pve-tasks',
-	    proxy: {
-                type: 'pve',
-		startParam: 'start',
-		limitParam: 'limit',
-                url: "/api2/json/nodes/" + nodename + "/tasks"
-	    }
-	});
-
-	var userfilter = '';
-	var filter_errors = 0;
-
-	var updateProxyParams = function() {
-	    var params = {
-		errors: filter_errors
-	    };
-	    if (userfilter) {
-		params.userfilter = userfilter;
-	    }
-	    if (me.vmidFilter) {
-		params.vmid = me.vmidFilter;
-	    }
-	    store.proxy.extraParams = params;
-	};
-
-	updateProxyParams();
-
-	var reload_task = Ext.create('Ext.util.DelayedTask',function() {
-	    updateProxyParams();
-	    store.reload();
-	});
-
-	var run_task_viewer = function() {
-	    var sm = me.getSelectionModel();
-	    var rec = sm.getSelection()[0];
-	    if (!rec) {
-		return;
-	    }
-
-	    var win = Ext.create('PVE.window.TaskViewer', { 
-		upid: rec.data.upid
-	    });
-	    win.show();
-	};
-
-	var view_btn = new Ext.Button({
-	    text: gettext('View'),
-	    disabled: true,
-	    handler: run_task_viewer
-	});
-
-
-	Ext.apply(me, {
-	    store: store,
-	    viewConfig: {
-		trackOver: false,
-		stripeRows: false, // does not work with getRowClass()
-
-		getRowClass: function(record, index) {
-		    var status = record.get('status');
-
-		    if (status && status != 'OK') {
-			return "pve-invalid-row";
-		    }
-		}
-	    },
-	    tbar: [
-		view_btn, '->', gettext('User name') +':', ' ',
-		{
-		    xtype: 'textfield',
-		    width: 200,
-		    value: userfilter,
-		    enableKeyEvents: true,
-		    listeners: {
-			keyup: function(field, e) {
-			    userfilter = field.getValue();
-			    reload_task.delay(500);
-			}
-		    }
-		}, ' ', gettext('Only Errors') + ':', ' ',
-		{
-		    xtype: 'checkbox',
-		    hideLabel: true,
-		    checked: filter_errors,
-		    listeners: {
-			change: function(field, checked) {
-			    filter_errors = checked ? 1 : 0;
-			    reload_task.delay(10);
-			}
-		    }
-		}, ' '
-	    ],
-	    columns: [
-		{ 
-		    header: gettext("Start Time"), 
-		    dataIndex: 'starttime',
-		    width: 100,
-		    renderer: function(value) { 
-			return Ext.Date.format(value, "M d H:i:s"); 
-		    }
-		},
-		{ 
-		    header: gettext("End Time"), 
-		    dataIndex: 'endtime',
-		    width: 100,
-		    renderer: function(value, metaData, record) {
-			return  Ext.Date.format(value,"M d H:i:s"); 
-		    }
-		},
-		{ 
-		    header: gettext("Node"), 
-		    dataIndex: 'node',
-		    width: 100
-		},
-		{ 
-		    header: gettext("User name"), 
-		    dataIndex: 'user',
-		    width: 150
-		},
-		{ 
-		    header: gettext("Description"), 
-		    dataIndex: 'upid', 
-		    flex: 1,
-		    renderer: PVE.Utils.render_upid
-		},
-		{ 
-		    header: gettext("Status"), 
-		    dataIndex: 'status', 
-		    width: 200,
-		    renderer: function(value, metaData, record) { 
-			if (value == 'OK') {
-			    return 'OK';
-			}
-			// metaData.attr = 'style="color:red;"'; 
-			return "ERROR: " + value;
-		    }
-		}
-	    ],
-	    listeners: {
-		itemdblclick: run_task_viewer,
-		selectionchange: function(v, selections) {
-		    view_btn.setDisabled(!(selections && selections[0]));
-		},
-		show: function() { reload_task.delay(10); },
-		destroy: function() { reload_task.cancel(); }
-	    }
-	});
-
-	me.callParent();
-
-    }
-});
-
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 68d5a268..c10c7e00 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -218,8 +218,9 @@ Ext.define('PVE.qemu.Config', {
 	    {
 		title: gettext('Task History'),
 		itemId: 'tasks',
-		xtype: 'pveNodeTasks',
+		xtype: 'proxmoxNodeTasks',
 		iconCls: 'fa fa-list',
+		nodename: nodename,
 		vmidFilter: vmid
 	    }
 	);
-- 
2.14.2





More information about the pve-devel mailing list