return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
},
+ format_expire: function(date) {
+ if (!date) {
+ return Proxmox.Utils.neverText;
+ }
+ return Ext.Date.format(date, "Y-m-d");
+ },
+
+ format_duration_long: function(ut) {
+
+ var days = Math.floor(ut / 86400);
+ ut -= days*86400;
+ var hours = Math.floor(ut / 3600);
+ ut -= hours*3600;
+ var mins = Math.floor(ut / 60);
+ ut -= mins*60;
+
+ var hours_str = '00' + hours.toString();
+ hours_str = hours_str.substr(hours_str.length - 2);
+ var mins_str = "00" + mins.toString();
+ mins_str = mins_str.substr(mins_str.length - 2);
+ var ut_str = "00" + ut.toString();
+ ut_str = ut_str.substr(ut_str.length - 2);
+
+ if (days) {
+ var ds = days > 1 ? Proxmox.Utils.daysText : Proxmox.Utils.dayText;
+ return days.toString() + ' ' + ds + ' ' +
+ hours_str + ':' + mins_str + ':' + ut_str;
+ } else {
+ return hours_str + ':' + mins_str + ':' + ut_str;
+ }
+ },
+
+ format_duration_short: function(ut) {
+
+ if (ut < 60) {
+ return ut.toString() + 's';
+ }
+
+ if (ut < 3600) {
+ var mins = ut / 60;
+ return mins.toFixed(0) + 'm';
+ }
+
+ if (ut < 86400) {
+ var hours = ut / 3600;
+ return hours.toFixed(0) + 'h';
+ }
+
+ var days = ut / 86400;
+ return days.toFixed(0) + 'd';
+ },
+
+ compute_min_label_width: function(text, width) {
+
+ if (width === undefined) { width = 100; }
+
+ var tm = new Ext.util.TextMetrics();
+ var min = tm.getWidth(text + ':');
+
+ return min < width ? width : min;
+ },
+
authOK: function() {
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
},
}
},
- monStoreErrors: function(me, store) {
- me.mon(store, 'beforeload', function(s, operation, eOpts) {
- if (!me.loadCount) {
- me.loadCount = 0; // make sure it is numeric
- Proxmox.Utils.setErrorMask(me, true);
- }
- });
+ monStoreErrors: function(me, store, clearMaskBeforeLoad) {
+ if (clearMaskBeforeLoad) {
+ me.mon(store, 'beforeload', function(s, operation, eOpts) {
+ Proxmox.Utils.setErrorMask(me, false);
+ })
+ } else {
+ me.mon(store, 'beforeload', function(s, operation, eOpts) {
+ if (!me.loadCount) {
+ me.loadCount = 0; // make sure it is numeric
+ Proxmox.Utils.setErrorMask(me, true);
+ }
+ });
+ }
// only works with 'proxmox' proxy
me.mon(store.proxy, 'afterload', function(proxy, request, success) {
return Proxmox.Utils.format_task_description(type, id);
},
+ render_uptime: function(value) {
+
+ var uptime = value;
+
+ if (uptime === undefined) {
+ return '';
+ }
+
+ if (uptime <= 0) {
+ return '-';
+ }
+
+ return Proxmox.Utils.format_duration_long(uptime);
+ },
+
parse_task_upid: function(upid) {
var task = {};