]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - Utils.js
combogrid: always set the initial value, even if not found
[proxmox-widget-toolkit.git] / Utils.js
index 93ccc0175f73e9c80729a5fbb53e34a82920b686..9b62bf6d5dc9fa19ea88e5d218e0ca4e2fdb19cc 100644 (file)
--- a/Utils.js
+++ b/Utils.js
@@ -99,9 +99,21 @@ Ext.define('Proxmox.Utils', { utilities: {
        return data;
     },
 
+    bond_mode_gettext_map: {
+       '802.3ad': 'LACP (802.3ad)',
+       'lacp-balance-slb': 'LACP (balance-slb)',
+       'lacp-balance-tcp': 'LACP (balance-tcp)',
+    },
+
+    render_bond_mode: value => Proxmox.Utils.bond_mode_gettext_map[value] || value || '',
+
+    bond_mode_array: function(modes) {
+       return modes.map(mode => [mode, Proxmox.Utils.render_bond_mode(mode)]);
+    },
+
     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');
+       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 || 'https://www.proxmox.com');
     },
 
     format_boolean_with_default: function(value) {
@@ -593,6 +605,29 @@ Ext.define('Proxmox.Utils', { utilities: {
        return Ext.Date.format(servertime, 'Y-m-d H:i:s');
     },
 
+    get_help_info: function(section) {
+       var helpMap;
+       if (typeof proxmoxOnlineHelpInfo !== 'undefined') {
+           helpMap = proxmoxOnlineHelpInfo;
+       } else if (typeof pveOnlineHelpInfo !== 'undefined') {
+           // be backward compatible with older pve-doc-generators
+           helpMap = pveOnlineHelpInfo;
+       } else {
+           throw "no global OnlineHelpInfo map declared";
+       }
+
+       return helpMap[section];
+    },
+
+    get_help_link: function(section) {
+       var info = Proxmox.Utils.get_help_info(section);
+       if (!info) {
+           return;
+       }
+
+       return window.location.origin + info.link;
+    },
+
     openXtermJsViewer: function(vmtype, vmid, nodename, vmname, cmd) {
        var url = Ext.Object.toQueryString({
            console: vmtype, // kvm, lxc, upgrade or shell
@@ -620,10 +655,12 @@ Ext.define('Proxmox.Utils', { utilities: {
        var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
        var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
        var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
+       var IPV4_CIDR_MASK = "([0-9]{1,2})";
+       var IPV6_CIDR_MASK = "([0-9]{1,3})";
 
 
        me.IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
-       me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
+       me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/" + IPV4_CIDR_MASK + "$");
 
        var IPV6_REGEXP = "(?:" +
            "(?:(?:"                                                  + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
@@ -638,10 +675,11 @@ Ext.define('Proxmox.Utils', { utilities: {
            ")";
 
        me.IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
-       me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
+       me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/" + IPV6_CIDR_MASK + "$");
        me.IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
 
        me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
+       me.IP64_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + "\/" + IPV6_CIDR_MASK + ")|(?:" + IPV4_REGEXP + "\/" + IPV4_CIDR_MASK + ")$");
 
        var DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))";
        me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");