[pve-devel] [PATCH manager v2 15/29] use TaskViewer & TaskProgress window from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Dec 19 08:55:07 CET 2017


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/Makefile               |   1 -
 www/manager6/ceph/Monitor.js        |   4 +-
 www/manager6/ceph/OSD.js            |   2 +-
 www/manager6/dc/Tasks.js            |   2 +-
 www/manager6/lxc/CreateWizard.js    |   2 +-
 www/manager6/lxc/MPResize.js        |   2 +-
 www/manager6/lxc/Snapshot.js        |   2 +-
 www/manager6/lxc/SnapshotTree.js    |   4 +-
 www/manager6/node/APT.js            |   2 +-
 www/manager6/node/Disks.js          |   2 +-
 www/manager6/node/ServiceView.js    |   2 +-
 www/manager6/node/Tasks.js          |   2 +-
 www/manager6/qemu/HDMove.js         |   2 +-
 www/manager6/qemu/Snapshot.js       |   2 +-
 www/manager6/qemu/SnapshotTree.js   |   4 +-
 www/manager6/storage/ContentView.js |   2 +-
 www/manager6/window/Backup.js       |   2 +-
 www/manager6/window/BulkAction.js   |   2 +-
 www/manager6/window/Migrate.js      |   2 +-
 www/manager6/window/MigrateAll.js   |   2 +-
 www/manager6/window/Restore.js      |   2 +-
 www/manager6/window/SafeDestroy.js  |   2 +-
 www/manager6/window/TaskViewer.js   | 223 ------------------------------------
 23 files changed, 24 insertions(+), 248 deletions(-)
 delete mode 100644 www/manager6/window/TaskViewer.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4e850ce2..23a9f79f 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -85,7 +85,6 @@ JSSRC= 				                 	\
 	panel/GaugeWidget.js				\
 	panel/HealthWidget.js				\
 	window/LoginWindow.js				\
-	window/TaskViewer.js				\
 	window/Wizard.js				\
 	window/NotesEdit.js				\
 	window/Backup.js				\
diff --git a/www/manager6/ceph/Monitor.js b/www/manager6/ceph/Monitor.js
index a9737983..042c5198 100644
--- a/www/manager6/ceph/Monitor.js
+++ b/www/manager6/ceph/Monitor.js
@@ -96,7 +96,7 @@ Ext.define('PVE.node.CephMonList', {
 		params: { service: "mon." + rec.data.name },
 		success: function(response, options) {
 		    var upid = response.result.data;
-		    var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+		    var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 		    win.show();
 		},
 		failure: function(response, opts) {
@@ -151,7 +151,7 @@ Ext.define('PVE.node.CephMonList', {
 		    method: 'DELETE',
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+			var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 			win.show();
 		    },
 		    failure: function(response, opts) {
diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index cf72a91b..4e333262 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -403,7 +403,7 @@ Ext.define('PVE.node.CephOsdTree', {
 		method: 'POST',
 		success: function(response, options) {
 		    var upid = response.result.data;
-		    var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+		    var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 		    win.show();
 		    me.mon(win, 'close', reload, me);
 		},
diff --git a/www/manager6/dc/Tasks.js b/www/manager6/dc/Tasks.js
index 5d65bd2e..35e54e1e 100644
--- a/www/manager6/dc/Tasks.js
+++ b/www/manager6/dc/Tasks.js
@@ -43,7 +43,7 @@ Ext.define('PVE.dc.Tasks', {
 		return;
 	    }
 
-	    var win = Ext.create('PVE.window.TaskViewer', { 
+	    var win = Ext.create('Proxmox.window.TaskViewer', {
 		upid: rec.data.upid
 	    });
 	    win.show();
diff --git a/www/manager6/lxc/CreateWizard.js b/www/manager6/lxc/CreateWizard.js
index 31f54248..e172ce4a 100644
--- a/www/manager6/lxc/CreateWizard.js
+++ b/www/manager6/lxc/CreateWizard.js
@@ -320,7 +320,7 @@ Ext.define('PVE.lxc.CreateWizard', {
 			    success: function(response, opts){
 				var upid = response.result.data;
 
-				var win = Ext.create('PVE.window.TaskViewer', {
+				var win = Ext.create('Proxmox.window.TaskViewer', {
 				    upid: upid
 				});
 				win.show();
diff --git a/www/manager6/lxc/MPResize.js b/www/manager6/lxc/MPResize.js
index bcda4b60..b1f9b9b7 100644
--- a/www/manager6/lxc/MPResize.js
+++ b/www/manager6/lxc/MPResize.js
@@ -17,7 +17,7 @@ Ext.define('PVE.window.MPResize', {
 	    },
 	    success: function(response, opts) {
 		var upid = response.result.data;
-		var win = Ext.create('PVE.window.TaskViewer', { upid: upid });
+		var win = Ext.create('Proxmox.window.TaskViewer', { upid: upid });
 		win.show();
 		me.close();
 	    }
diff --git a/www/manager6/lxc/Snapshot.js b/www/manager6/lxc/Snapshot.js
index f5e1b242..6e596b34 100644
--- a/www/manager6/lxc/Snapshot.js
+++ b/www/manager6/lxc/Snapshot.js
@@ -26,7 +26,7 @@ Ext.define('PVE.window.LxcSnapshot', {
 	    },
 	    success: function(response, options) {
 		var upid = response.result.data;
-		var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+		var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 		win.show();
 		me.close();
 	    }
diff --git a/www/manager6/lxc/SnapshotTree.js b/www/manager6/lxc/SnapshotTree.js
index c80fb439..1a3c048b 100644
--- a/www/manager6/lxc/SnapshotTree.js
+++ b/www/manager6/lxc/SnapshotTree.js
@@ -181,7 +181,7 @@ Ext.define('PVE.lxc.SnapshotTree', {
 		    },
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+			var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 			win.show();
 		    }
 		});
@@ -217,7 +217,7 @@ Ext.define('PVE.lxc.SnapshotTree', {
 		    },
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+			var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 			win.show();
 		    }
 		});
diff --git a/www/manager6/node/APT.js b/www/manager6/node/APT.js
index 41f6d59f..e8985403 100644
--- a/www/manager6/node/APT.js
+++ b/www/manager6/node/APT.js
@@ -62,7 +62,7 @@ Ext.define('PVE.node.APT', {
 		success: function(response, opts) {
 		    var upid = response.result.data;
 
-		    var win = Ext.create('PVE.window.TaskViewer', { 
+		    var win = Ext.create('Proxmox.window.TaskViewer', {
 			upid: upid
 		    });
 		    win.show();
diff --git a/www/manager6/node/Disks.js b/www/manager6/node/Disks.js
index 9bfaad22..e99065b0 100644
--- a/www/manager6/node/Disks.js
+++ b/www/manager6/node/Disks.js
@@ -204,7 +204,7 @@ Ext.define('PVE.node.DiskList', {
 		    },
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', {
+			var win = Ext.create('Proxmox.window.TaskProgress', {
 			    upid: upid
 			});
 			win.show();
diff --git a/www/manager6/node/ServiceView.js b/www/manager6/node/ServiceView.js
index a676280a..9cc0e3ea 100644
--- a/www/manager6/node/ServiceView.js
+++ b/www/manager6/node/ServiceView.js
@@ -48,7 +48,7 @@ Ext.define('PVE.node.ServiceView', {
 		    rstore.startUpdate();
 		    var upid = response.result.data;
 
-		    var win = Ext.create('PVE.window.TaskProgress', { 
+		    var win = Ext.create('Proxmox.window.TaskProgress', {
 			upid: upid
 		    });
 		    win.show();
diff --git a/www/manager6/node/Tasks.js b/www/manager6/node/Tasks.js
index 7d3b0754..eb97d006 100644
--- a/www/manager6/node/Tasks.js
+++ b/www/manager6/node/Tasks.js
@@ -59,7 +59,7 @@ Ext.define('PVE.node.Tasks', {
 		return;
 	    }
 
-	    var win = Ext.create('PVE.window.TaskViewer', { 
+	    var win = Ext.create('Proxmox.window.TaskViewer', {
 		upid: rec.data.upid
 	    });
 	    win.show();
diff --git a/www/manager6/qemu/HDMove.js b/www/manager6/qemu/HDMove.js
index 656f717e..d737e090 100644
--- a/www/manager6/qemu/HDMove.js
+++ b/www/manager6/qemu/HDMove.js
@@ -27,7 +27,7 @@ Ext.define('PVE.window.HDMove', {
 	    },
 	    success: function(response, options) {
 		var upid = response.result.data;
-		var win = Ext.create('PVE.window.TaskViewer', { upid: upid });
+		var win = Ext.create('Proxmox.window.TaskViewer', { upid: upid });
 		win.show();
 		me.close();
 	    }
diff --git a/www/manager6/qemu/Snapshot.js b/www/manager6/qemu/Snapshot.js
index 5a39e460..1acd398a 100644
--- a/www/manager6/qemu/Snapshot.js
+++ b/www/manager6/qemu/Snapshot.js
@@ -26,7 +26,7 @@ Ext.define('PVE.window.Snapshot', {
 	    },
 	    success: function(response, options) {
 		var upid = response.result.data;
-		var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+		var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 		win.show();
 		me.close();
 	    }
diff --git a/www/manager6/qemu/SnapshotTree.js b/www/manager6/qemu/SnapshotTree.js
index 35b02459..474f88f1 100644
--- a/www/manager6/qemu/SnapshotTree.js
+++ b/www/manager6/qemu/SnapshotTree.js
@@ -179,7 +179,7 @@ Ext.define('PVE.qemu.SnapshotTree', {
 		    },
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+			var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 			win.show();
 		    }
 		});
@@ -215,7 +215,7 @@ Ext.define('PVE.qemu.SnapshotTree', {
 		    },
 		    success: function(response, options) {
 			var upid = response.result.data;
-			var win = Ext.create('PVE.window.TaskProgress', { upid: upid });
+			var win = Ext.create('Proxmox.window.TaskProgress', { upid: upid });
 			win.show();
 		    }
 		});
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index 47bd199a..d5e27f4d 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -124,7 +124,7 @@ Ext.define('PVE.storage.TemplateDownload', {
 		    success: function(response, options) {
 			var upid = response.result.data;
 
-			Ext.create('PVE.window.TaskViewer', {
+			Ext.create('Proxmox.window.TaskViewer', {
 			    upid: upid,
 			    listeners: {
 				destroy: me.reloadGrid
diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js
index 36ffb143..57bdd2ab 100644
--- a/www/manager6/window/Backup.js
+++ b/www/manager6/window/Backup.js
@@ -93,7 +93,7 @@ Ext.define('PVE.window.Backup', {
 
 			var upid = response.result.data;
 			
-			var win = Ext.create('PVE.window.TaskViewer', { 
+			var win = Ext.create('Proxmox.window.TaskViewer', {
 			    upid: upid,
 			    listeners: {
 				close: function() {
diff --git a/www/manager6/window/BulkAction.js b/www/manager6/window/BulkAction.js
index 87e972b3..42907a7b 100644
--- a/www/manager6/window/BulkAction.js
+++ b/www/manager6/window/BulkAction.js
@@ -29,7 +29,7 @@ Ext.define('PVE.window.BulkAction', {
 	    success: function(response, options) {
 		var upid = response.result.data;
 
-		var win = Ext.create('PVE.window.TaskViewer', {
+		var win = Ext.create('Proxmox.window.TaskViewer', {
 		    upid: upid
 		});
 		win.show();
diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index 3b7b6266..34930743 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -43,7 +43,7 @@ Ext.define('PVE.window.Migrate', {
 			    var upid = response.result.data;
 			    var extraTitle = Ext.String.format(' ({0} ---> {1})', view.nodename, params.target);
 
-			    Ext.create('PVE.window.TaskViewer', {
+			    Ext.create('Proxmox.window.TaskViewer', {
 				upid: upid,
 				extraTitle: extraTitle
 			    }).show();
diff --git a/www/manager6/window/MigrateAll.js b/www/manager6/window/MigrateAll.js
index a4ec124d..a0a1f7ee 100644
--- a/www/manager6/window/MigrateAll.js
+++ b/www/manager6/window/MigrateAll.js
@@ -16,7 +16,7 @@ Ext.define('PVE.window.MigrateAll', {
 	    success: function(response, options) {
 		var upid = response.result.data;
 
-		var win = Ext.create('PVE.window.TaskViewer', {
+		var win = Ext.create('Proxmox.window.TaskViewer', {
 		    upid: upid
 		});
 		win.show();
diff --git a/www/manager6/window/Restore.js b/www/manager6/window/Restore.js
index 5a3f628f..005f6da4 100644
--- a/www/manager6/window/Restore.js
+++ b/www/manager6/window/Restore.js
@@ -86,7 +86,7 @@ Ext.define('PVE.window.Restore', {
 		success: function(response, options) {
 		    var upid = response.result.data;
 		    
-		    var win = Ext.create('PVE.window.TaskViewer', { 
+		    var win = Ext.create('Proxmox.window.TaskViewer', {
 			upid: upid
 		    });
 		    win.show();
diff --git a/www/manager6/window/SafeDestroy.js b/www/manager6/window/SafeDestroy.js
index 451ab046..41814ef3 100644
--- a/www/manager6/window/SafeDestroy.js
+++ b/www/manager6/window/SafeDestroy.js
@@ -75,7 +75,7 @@ Ext.define('PVE.window.SafeDestroy', {
 				view.hide();
 
 				var upid = response.result.data;
-				var win = Ext.create('PVE.window.TaskProgress', {
+				var win = Ext.create('Proxmox.window.TaskProgress', {
 				    upid: upid,
 				    listeners: {
 					destroy: function () {
diff --git a/www/manager6/window/TaskViewer.js b/www/manager6/window/TaskViewer.js
deleted file mode 100644
index d3c2fe38..00000000
--- a/www/manager6/window/TaskViewer.js
+++ /dev/null
@@ -1,223 +0,0 @@
-Ext.define('PVE.window.TaskProgress', {
-    extend: 'Ext.window.Window',
-    alias: 'widget.pveTaskProgress',
-
-    initComponent: function() {
-        var me = this;
-
-	if (!me.upid) {
-	    throw "no task specified";
-	}
-
-	var task = PVE.Utils.parse_task_upid(me.upid);
-
-	var statstore = Ext.create('PVE.data.ObjectStore', {
-            url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status",
-	    interval: 1000,
-	    rows: {
-		status: { defaultValue: 'unknown' },
-		exitstatus: { defaultValue: 'unknown' }
-	    }
-	});
-
-	me.on('destroy', statstore.stopUpdate);	
-
-	var getObjectValue = function(key, defaultValue) {
-	    var rec = statstore.getById(key);
-	    if (rec) {
-		return rec.data.value;
-	    }
-	    return defaultValue;
-	};
-
-	var pbar = Ext.create('Ext.ProgressBar', { text: 'running...' });
-
-	me.mon(statstore, 'load', function() {
-	    var status = getObjectValue('status');
-	    if (status === 'stopped') {
-		var exitstatus = getObjectValue('exitstatus');
-		if (exitstatus == 'OK') {
-		    pbar.reset();
-		    pbar.updateText("Done!");
-		    Ext.Function.defer(me.close, 1000, me);
-		} else {
-		    me.close();
-		    Ext.Msg.alert('Task failed', exitstatus);
-		}
-	    }
-	});
-
-	var descr = PVE.Utils.format_task_description(task.type, task.id);
-
-	Ext.apply(me, {
-	    title: "Task: " + descr,
-	    width: 300,
-	    layout: 'auto',
-	    modal: true,
-	    bodyPadding: 5,
-	    items: pbar,
-	    buttons: [
-		{ 
-		    text: gettext('Details'),
-		    handler: function() {			
-			var win = Ext.create('PVE.window.TaskViewer', { 
-			    upid: me.upid
-			});
-			win.show();
-			me.close();
-		    }
-		}
-	    ]
-	});
-
-	me.callParent();
-
-	statstore.startUpdate();
-
-	pbar.wait();
-    }
-});
-
-// fixme: how can we avoid those lint errors?
-/*jslint confusion: true */
-
-Ext.define('PVE.window.TaskViewer', {
-    extend: 'Ext.window.Window',
-    alias: 'widget.pveTaskViewer',
-    extraTitle: '', // string to prepend after the generic task title
-
-    initComponent: function() {
-        var me = this;
-
-	if (!me.upid) {
-	    throw "no task specified";
-	}
-
-	var task = PVE.Utils.parse_task_upid(me.upid);
-
-	var statgrid;
-
-	var rows = {
-	    status: {
-		header: gettext('Status'),
-		defaultValue: 'unknown',
-		renderer: function(value) {
-		    if (value != 'stopped') {
-			return value;
-		    }
-		    var es = statgrid.getObjectValue('exitstatus');
-		    if (es) {
-			return value + ': ' + es;
-		    }
-		}
-	    },
-	    exitstatus: { 
-		visible: false
-	    },
-	    type: {
-		header: gettext('Task type'),
-		required: true
-	    },
-	    user: {
-		header: gettext('User name'),
-		required: true 
-	    },
-	    node: {
-		header: gettext('Node'),
-		required: true 
-	    },
-	    pid: {
-		header: gettext('Process ID'),
-		required: true
-	    },
-	    starttime: {
-		header: gettext('Start Time'),
-		required: true, 
-		renderer: PVE.Utils.render_timestamp
-	    },
-	    upid: {
-		header: gettext('Unique task ID')
-	    }
-	};
-
-	var statstore = Ext.create('PVE.data.ObjectStore', {
-            url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status",
-	    interval: 1000,
-	    rows: rows
-	});
-
-	me.on('destroy', statstore.stopUpdate);	
-
-	var stop_task = function() {
-	    PVE.Utils.API2Request({
-		url: "/nodes/" + task.node + "/tasks/" + me.upid,
-		waitMsgTarget: me,
-		method: 'DELETE',
-		failure: function(response, opts) {
-		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-		}
-	    });
-	};
-
-	var stop_btn1 = new Ext.Button({
-	    text: gettext('Stop'),
-	    disabled: true,
-	    handler: stop_task
-	});
-
-	var stop_btn2 = new Ext.Button({
-	    text: gettext('Stop'),
-	    disabled: true,
-	    handler: stop_task
-	});
-
-	statgrid = Ext.create('Proxmox.grid.ObjectGrid', {
-	    title: gettext('Status'),
-	    layout: 'fit',
-	    tbar: [ stop_btn1 ],
-	    rstore: statstore,
-	    rows: rows,
-	    border: false
-	});
-
-	var logView = Ext.create('PVE.panel.LogView', {
-	    title: gettext('Output'),
-	    tbar: [ stop_btn2 ],
-	    border: false,
-	    url: "/api2/extjs/nodes/" + task.node + "/tasks/" + me.upid + "/log"
-	});
-
-	me.mon(statstore, 'load', function() {
-	    var status = statgrid.getObjectValue('status');
-	    
-	    if (status === 'stopped') {
-		logView.requestUpdate(undefined, true);
-		logView.scrollToEnd = false;
-		statstore.stopUpdate();
-	    }
-
-	    stop_btn1.setDisabled(status !== 'running');
-	    stop_btn2.setDisabled(status !== 'running');
-	});
-
-	statstore.startUpdate();
-
-	Ext.apply(me, {
-	    title: "Task viewer: " + task.desc + me.extraTitle,
-	    width: 800,
-	    height: 400,
-	    layout: 'fit',
-	    modal: true,
-	    items: [{
-		xtype: 'tabpanel',
-		region: 'center',
-		items: [ logView, statgrid ]
-	    }]
-        });
-
-	me.callParent();
-
-	logView.fireEvent('show', logView);
-    }
-});
-
-- 
2.11.0





More information about the pve-devel mailing list