from pve-manager

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
 Utils.js | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Utils.js b/Utils.js
index 56b1c9a..328164d 100644
--- a/Utils.js
+++ b/Utils.js
@@ -145,6 +145,26 @@ Ext.define('Proxmox.Utils', { utilities: {
        return Ext.Date.format(date, "Y-m-d");
     },
 
+    format_duration_short: function(ut) {
+
+       if (ut < 60) {
+           return ut.toFixed(1) + 's';
+       }
+
+       if (ut < 3600) {
+           var mins = ut / 60;
+           return mins.toFixed(1) + 'm';
+       }
+
+       if (ut < 86400) {
+           var hours = ut / 3600;
+           return hours.toFixed(1) + 'h';
+       }
+
+       var days = ut / 86400;
+       return days.toFixed(1) + 'd';
+    },
+
     format_duration_long: function(ut) {
 
        var days = Math.floor(ut / 86400);
@@ -643,6 +663,13 @@ Ext.define('Proxmox.Utils', { utilities: {
        return task;
     },
 
+    render_duration: function(value) {
+       if (value === undefined) {
+           return '-';
+       }
+       return Proxmox.Utils.format_duration_short(value);
+    },
+
     render_timestamp: function(value, metaData, record, rowIndex, colIndex, 
store) {
        var servertime = new Date(value * 1000);
        return Ext.Date.format(servertime, 'Y-m-d H:i:s');
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to