task viewer: show task endtime and duration in status

But only when the caller gives us the endtime, since the status API
call does not give us the endtime.

As we stop updating the store once a task isn't running anymore the
fallback to current unix utc timestamp doesn't needs an additional
check, the last one is shown static then.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[ Thomas: improve commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-06-15 16:07:10 +02:00 committed by Thomas Lamprecht
parent 402991a79d
commit c9d603afff
2 changed files with 26 additions and 0 deletions

View File

@ -60,6 +60,7 @@ Ext.define('Proxmox.node.Tasks', {
let win = Ext.create('Proxmox.window.TaskViewer', {
upid: rec.data.upid,
endtime: rec.data.endtime,
});
win.show();
};

View File

@ -152,6 +152,31 @@ Ext.define('Proxmox.window.TaskViewer', {
},
};
if (me.endtime) {
if (typeof me.endtime === 'object') {
// convert to epoch
me.endtime = parseInt(me.endtime.getTime()/1000, 10);
}
rows.endtime = {
header: gettext('End Time'),
required: true,
renderer: function() {
return Proxmox.Utils.render_timestamp(me.endtime);
},
};
}
rows.duration = {
header: gettext('Duration'),
required: true,
renderer: function() {
let starttime = statgrid.getObjectValue('starttime');
let endtime = me.endtime || Date.now()/1000;
let duration = endtime - starttime;
return Proxmox.Utils.format_duration_human(duration);
},
};
let statstore = Ext.create('Proxmox.data.ObjectStore', {
url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status",
interval: 1000,