task view, progress: add taskDone callback

and integrate it into the edit window

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2018-03-27 14:00:49 +02:00 committed by Dominik Csapak
parent 8d8dbfc5b9
commit fde8e8bbb9
2 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,10 @@ Ext.define('Proxmox.window.Edit', {
showTaskViewer: false, showTaskViewer: false,
// gets called if we have a progress bar or taskview and it detected that
// the task finished. function(success)
taskDone: Ext.emptyFn,
// assign a reference from docs, to add a help button docked to the // assign a reference from docs, to add a help button docked to the
// bottom of the window. If undefined we magically fall back to the // bottom of the window. If undefined we magically fall back to the
// onlineHelp of our first item, if set. // onlineHelp of our first item, if set.
@ -144,6 +148,7 @@ Ext.define('Proxmox.window.Edit', {
var viewerClass = me.showTaskViewer ? 'Viewer' : 'Progress'; var viewerClass = me.showTaskViewer ? 'Viewer' : 'Progress';
var win = Ext.create('Proxmox.window.Task' + viewerClass, { var win = Ext.create('Proxmox.window.Task' + viewerClass, {
upid: upid, upid: upid,
taskDone: me.taskDone,
listeners: { listeners: {
destroy: function () { destroy: function () {
me.close(); me.close();

View File

@ -2,6 +2,8 @@ Ext.define('Proxmox.window.TaskProgress', {
extend: 'Ext.window.Window', extend: 'Ext.window.Window',
alias: 'widget.proxmoxTaskProgress', alias: 'widget.proxmoxTaskProgress',
taskDone: Ext.emptyFn,
initComponent: function() { initComponent: function() {
var me = this; var me = this;
@ -44,6 +46,7 @@ Ext.define('Proxmox.window.TaskProgress', {
me.close(); me.close();
Ext.Msg.alert('Task failed', exitstatus); Ext.Msg.alert('Task failed', exitstatus);
} }
me.taskDone(exitstatus == 'OK');
} }
}); });
@ -61,6 +64,7 @@ Ext.define('Proxmox.window.TaskProgress', {
text: gettext('Details'), text: gettext('Details'),
handler: function() { handler: function() {
var win = Ext.create('Proxmox.window.TaskViewer', { var win = Ext.create('Proxmox.window.TaskViewer', {
taskDone: me.taskDone,
upid: me.upid upid: me.upid
}); });
win.show(); win.show();
@ -87,6 +91,8 @@ Ext.define('Proxmox.window.TaskViewer', {
extraTitle: '', // string to prepend after the generic task title extraTitle: '', // string to prepend after the generic task title
taskDone: Ext.emptyFn,
initComponent: function() { initComponent: function() {
var me = this; var me = this;
@ -195,6 +201,7 @@ Ext.define('Proxmox.window.TaskViewer', {
logView.requestUpdate(undefined, true); logView.requestUpdate(undefined, true);
logView.scrollToEnd = false; logView.scrollToEnd = false;
statstore.stopUpdate(); statstore.stopUpdate();
me.taskDone(statgrid.getObjectValue('exitstatus') == 'OK');
} }
stop_btn1.setDisabled(status !== 'running'); stop_btn1.setDisabled(status !== 'running');