]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - Utils.js
ObjectGrid: avoid static definition of rows
[proxmox-widget-toolkit.git] / Utils.js
index 86a5de868d97028bf559fd6963dda9539ecaf344..1aff39f64f33fde078a62c8463fea8cfee5b6888 100644 (file)
--- a/Utils.js
+++ b/Utils.js
@@ -41,6 +41,54 @@ Ext.define('Proxmox.Utils', { utilities: {
 
     // this singleton contains miscellaneous utilities
 
+    yesText: gettext('Yes'),
+    noText: gettext('No'),
+    enabledText: gettext('Enabled'),
+    disabledText: gettext('Disabled'),
+    noneText: gettext('none'),
+    errorText: gettext('Error'),
+    unknownText: gettext('Unknown'),
+    defaultText: gettext('Default'),
+    daysText: gettext('days'),
+    dayText: gettext('day'),
+    runningText: gettext('running'),
+    stoppedText: gettext('stopped'),
+    neverText: gettext('never'),
+    totalText: gettext('Total'),
+    usedText: gettext('Used'),
+    directoryText: gettext('Directory'),
+    stateText: gettext('State'),
+    groupText: gettext('Group'),
+
+    format_boolean_with_default: function(value) {
+       if (Ext.isDefined(value) && value !== '__default__') {
+           return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+       }
+       return Proxmox.Utils.defaultText;
+    },
+
+    format_boolean: function(value) {
+       return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+    },
+
+    format_neg_boolean: function(value) {
+       return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+    },
+
+    format_enabled_toggle: function(value) {
+       return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
+    },
+
+    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);
     },
@@ -214,6 +262,21 @@ Ext.define('Proxmox.Utils', { utilities: {
        }
     },
 
+    network_iface_types: {
+       eth: gettext("Network Device"),
+       bridge: 'Linux Bridge',
+       bond: 'Linux Bond',
+       OVSBridge: 'OVS Bridge',
+       OVSBond: 'OVS Bond',
+       OVSPort: 'OVS Port',
+       OVSIntPort: 'OVS IntPort'
+    },
+
+    render_network_iface_type: function(value) {
+       return Proxmox.Utils.network_iface_types[value] ||
+           Proxmox.Utils.unknownText;
+    },
+
     // you can override this to provide nicer task descriptions
     format_task_description: function(type, id) {
        return type + ' ' + id;