]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
website: update external links to www.proxmox.com
[pve-manager.git] / www / manager6 / Utils.js
index 3dd287e38844706ed89dd187b2b493db58526a47..5839280fab0261c3b9016646b28c4b98e7abdbd6 100644 (file)
@@ -34,12 +34,12 @@ Ext.define('PVE.Utils', {
     },
 
     noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit '
-      +'<a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">'
+      +'<a target="_blank" href="https://www.proxmox.com/en/proxmox-virtual-environment/pricing">'
       +'www.proxmox.com</a> to get a list of available options.',
 
     kvm_ostypes: {
        'Linux': [
-           { desc: '5.x - 2.6 Kernel', val: 'l26' },
+           { desc: '6.x - 2.6 Kernel', val: 'l26' },
            { desc: '2.4 Kernel', val: 'l24' },
        ],
        'Microsoft Windows': [
@@ -393,6 +393,8 @@ Ext.define('PVE.Utils', {
        'efidisk but no OMVF BIOS': gettext('EFI Disk without OMVF BIOS'),
     },
 
+    renderNotFound: what => Ext.String.format(gettext("No {0} found"), what),
+
     get_kvm_osinfo: function(value) {
        var info = { base: 'Other' }; // default
        if (value) {
@@ -1278,6 +1280,21 @@ Ext.define('PVE.Utils', {
        return Ext.htmlEncode(first + " " + last);
     },
 
+    // expecting the following format:
+    // [v2:10.10.10.1:6802/2008,v1:10.10.10.1:6803/2008]
+    render_ceph_osd_addr: function(value) {
+       value = value.trim();
+       if (value.startsWith('[') && value.endsWith(']')) {
+           value = value.slice(1, -1); // remove []
+       }
+       value = value.replaceAll(',', '\n'); // split IPs in lines
+       let retVal = '';
+       for (const i of value.matchAll(/^(v[0-9]):(.*):([0-9]*)\/([0-9]*)$/gm)) {
+           retVal += `${i[1]}: ${i[2]}:${i[3]}<br>`;
+       }
+       return retVal.length < 1 ? value : retVal;
+    },
+
     windowHostname: function() {
        return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
             function(m, addr, offset, original) { return addr; });
@@ -1332,7 +1349,7 @@ Ext.define('PVE.Utils', {
            allowSpice = consoles.spice;
            allowXtermjs = !!consoles.xtermjs;
        }
-       let dv = PVE.UIOptions.console || (type === 'kvm' ? 'vv' : 'xtermjs');
+       let dv = PVE.UIOptions.options.console || (type === 'kvm' ? 'vv' : 'xtermjs');
        if (dv === 'vv' && !allowSpice) {
            dv = allowXtermjs ? 'xtermjs' : 'html5';
        } else if (dv === 'xtermjs' && !allowXtermjs) {
@@ -1683,6 +1700,9 @@ Ext.define('PVE.Utils', {
                    });
                    win.getViewModel().set('isInstalled', isInstalled);
                    container.add(win);
+                   win.on('close', () => {
+                       container.el.unmask();
+                   });
                    win.show();
                    callback(win);
                }
@@ -1702,7 +1722,7 @@ Ext.define('PVE.Utils', {
            rstore,
            /not (installed|initialized)/i,
            (_, error) => {
-               nodename = nodename || 'localhost';
+               nodename = nodename || Proxmox.NodeName;
                let maskTarget = maskOwnerCt ? view.ownerCt : view;
                rstore.stopUpdate();
                PVE.Utils.showCephInstallOrMask(maskTarget, error.statusText, nodename, win => {
@@ -1855,95 +1875,11 @@ Ext.define('PVE.Utils', {
 
     notesTemplateVars: ['cluster', 'guestname', 'node', 'vmid'],
 
-    updateUIOptions: function() {
-       Proxmox.Utils.API2Request({
-           url: '/cluster/options',
-           method: 'GET',
-           success: function(response) {
-               PVE.UIOptions = {
-                   'allowed-tags': [],
-               };
-               for (const option of ['allowed-tags', 'console', 'tag-style']) {
-                   PVE.UIOptions[option] = response?.result?.data?.[option];
-               }
-
-               PVE.Utils.updateTagList(PVE.UIOptions['allowed-tags']);
-               PVE.Utils.updateTagSettings(PVE.UIOptions?.['tag-style']);
-           },
-       });
-    },
-
-    tagList: [],
-
-    updateTagList: function(tags) {
-       PVE.Utils.tagList = [...new Set([...tags])].sort();
-    },
-
-    parseTagOverrides: function(overrides) {
-       let colors = {};
-       (overrides || "").split(';').forEach(color => {
-           if (!color) {
-               return;
-           }
-           let [tag, color_hex, font_hex] = color.split(':');
-           let r = parseInt(color_hex.slice(0, 2), 16);
-           let g = parseInt(color_hex.slice(2, 4), 16);
-           let b = parseInt(color_hex.slice(4, 6), 16);
-           colors[tag] = [r, g, b];
-           if (font_hex) {
-               colors[tag].push(parseInt(font_hex.slice(0, 2), 16));
-               colors[tag].push(parseInt(font_hex.slice(2, 4), 16));
-               colors[tag].push(parseInt(font_hex.slice(4, 6), 16));
-           }
-       });
-       return colors;
-    },
-
-    tagOverrides: {},
-
-    updateTagOverrides: function(colors) {
-       let sp = Ext.state.Manager.getProvider();
-       let color_state = sp.get('colors', '');
-       let browser_colors = PVE.Utils.parseTagOverrides(color_state);
-       PVE.Utils.tagOverrides = Ext.apply({}, browser_colors, colors);
-    },
-
-    updateTagSettings: function(style) {
-       let overrides = style?.['color-map'];
-       PVE.Utils.updateTagOverrides(PVE.Utils.parseTagOverrides(overrides ?? ""));
-
-       let shape = style?.shape ?? 'circle';
-       if (shape === '__default__') {
-           style = 'circle';
-       }
-
-       Ext.ComponentQuery.query('pveResourceTree')[0].setUserCls(`proxmox-tags-${shape}`);
-
-       if (!PVE.data.ResourceStore.isLoading() && PVE.data.ResourceStore.isLoaded()) {
-           PVE.data.ResourceStore.fireEvent('load');
-       }
-       Ext.GlobalEvents.fireEvent('loadedUiOptions');
-    },
-
-    tagTreeStyles: {
-       '__default__': `${Proxmox.Utils.defaultText} (${gettext('Circle')})`,
-       'full': gettext('Full'),
-       'circle': gettext('Circle'),
-       'dense': gettext('Dense'),
-       'none': Proxmox.Utils.NoneText,
-    },
-
-    tagOrderOptions: {
-       '__default__': `${Proxmox.Utils.defaultText} (${gettext('Alphabetical')})`,
-       'config': gettext('Configuration'),
-       'alphabetical': gettext('Alphabetical'),
-    },
-
     renderTags: function(tagstext, overrides) {
        let text = '';
        if (tagstext) {
            let tags = (tagstext.split(/[,; ]/) || []).filter(t => !!t);
-           if (PVE.Utils.shouldSortTags()) {
+           if (PVE.UIOptions.shouldSortTags()) {
                tags = tags.sort((a, b) => {
                    let alc = a.toLowerCase();
                    let blc = b.toLowerCase();
@@ -1958,10 +1894,6 @@ Ext.define('PVE.Utils', {
        return text;
     },
 
-    shouldSortTags: function() {
-       return !(PVE.UIOptions?.['tag-style']?.ordering === 'config');
-    },
-
     tagCharRegex: /^[a-z0-9+_.-]+$/i,
 
     verificationStateOrder: {