]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - Utils.js
add GaugeWidget from PVE
[proxmox-widget-toolkit.git] / Utils.js
index fd23eb175b83bb6e6dd04e4818466b96192a89bf..93cba81ee8798f5c76daa57df753a82351a373f4 100644 (file)
--- a/Utils.js
+++ b/Utils.js
@@ -1,9 +1,9 @@
 Ext.ns('Proxmox');
 Ext.ns('Proxmox.Setup');
 
-// TODO: implement gettext
-function gettext(buf) { return buf; }
-
+if (!Ext.isFunction(gettext)) {
+    function gettext(buf) { return buf; }
+}
 
 if (!Ext.isDefined(Proxmox.Setup.auth_cookie_name)) {
     throw "Proxmox library not initialized";
@@ -60,6 +60,34 @@ Ext.define('Proxmox.Utils', { utilities: {
     stateText: gettext('State'),
     groupText: gettext('Group'),
 
+    language_map: {
+       en: 'English',
+       fr: 'French',
+       de: 'German',
+       it: 'Italian',
+       es: 'Spanish'
+    },
+
+    render_language: function (value) {
+       if (!value) {
+           return Proxmox.Utils.defaultText + ' (English)';
+       }
+       var text = Proxmox.Utils.language_map[value];
+       if (text) {
+           return text + ' (' + value + ')';
+       }
+       return value;
+    },
+
+    language_array: function() {
+       var data = [['__default__', Proxmox.Utils.render_language('')]];
+       Ext.Object.each(Proxmox.Utils.language_map, function(key, value) {
+           data.push([key, Proxmox.Utils.render_language(value)]);
+       });
+
+       return data;
+    },
+
     getNoSubKeyHtml: function(url) {
        // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
        return Ext.String.format('You do not have a valid subscription for this server. Please visit <a target="_blank" href="{0}">www.proxmox.com</a> to get a list of available options.', url || 'http://www.proxmox.com');
@@ -136,6 +164,20 @@ Ext.define('Proxmox.Utils', { utilities: {
        return days.toFixed(0) + 'd';
     },
 
+    format_subscription_level: function(level) {
+       if (level === 'c') {
+           return 'Community';
+       } else if (level === 'b') {
+           return 'Basic';
+       } else if (level === 's') {
+           return 'Standard';
+       } else if (level === 'p') {
+           return 'Premium';
+       } else {
+           return Proxmox.Utils.noneText;
+       }
+    },
+
     compute_min_label_width: function(text, width) {
 
        if (width === undefined) { width = 100; }