[pve-devel] [PATCH manager 37/49] use TaskViewer & TaskProgress window from widget toolkit
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jan 23 11:05:54 CET 2018
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 | 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/Disks.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/Restore.js | 2 +-
www/manager6/window/SafeDestroy.js | 2 +-
www/manager6/window/TaskViewer.js | 223 ------------------------------------
19 files changed, 20 insertions(+), 244 deletions(-)
delete mode 100644 www/manager6/window/TaskViewer.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 0278396f..350711e3 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -75,7 +75,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 549fd315..27ff3d02 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 c860e05f..24d98496 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 d290573d..c38860ba 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 70deaaaf..5b069317 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 7918e819..74139237 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 723ea172..5a0b00c2 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 993ce507..4996e2e3 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/Disks.js b/www/manager6/node/Disks.js
index db28e19d..8e79dc84 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/qemu/HDMove.js b/www/manager6/qemu/HDMove.js
index fc9fd442..29d3e1b8 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 85a3ea50..1dffcb65 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 409f60a6..9b7c1fb6 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 7811c857..81563b4d 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 b85544f5..163c85a8 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 41344e3f..7a18e4c9 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 c4bcb922..be4f6676 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/Restore.js b/www/manager6/window/Restore.js
index 9a65da40..14969f09 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 70654aef..f89d0fa7 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 fe097a96..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 = Proxmox.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 = Proxmox.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 = Proxmox.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: Proxmox.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() {
- Proxmox.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.14.2
More information about the pve-devel
mailing list