On 6/16/20 11:19 AM, Thomas Lamprecht wrote:
Am 6/15/20 um 4:07 PM schrieb Dominik Csapak:
but only when the caller gives us the endtime, since the status
api call does not give us the endtime
Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
changes from v1:
* always show duration and calculate the endtime from 'now'
src/node/Tasks.js | 1 +
src/window/TaskViewer.js | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/src/node/Tasks.js b/src/node/Tasks.js
index 5aff06d..c41f0b5 100644
--- a/src/node/Tasks.js
+++ b/src/node/Tasks.js
@@ -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();
};
diff --git a/src/window/TaskViewer.js b/src/window/TaskViewer.js
index 2f31023..51715f8 100644
--- a/src/window/TaskViewer.js
+++ b/src/window/TaskViewer.js
@@ -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;
We'd need to check also the status (running or not) to know if we can still
fallback
to the current time, or? As else, if a running task gets opened we never will
get
supplied the endtime (as we only pass that once on window creation) even if the
task
ends after a bit.
We could solve this by remembering the last duration and then fallback to that
one
if we have no endtime and the task status switches from running to something
else?
we already stop the store when the task is stopped, so the renderer will
also not be called then anymore and is stopped
the only thing i do not completely like is that we do not show the
endtime in that case
i toyed with the idea to also always show
the endtime as '-' and then update it with the last update of the
renderer, but this would then be probably not consistent with
the 'real' endtime and also i could not get it to work...
+ 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,
_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel