]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
ui: lxc: pass full property name to for-each dev & mountpoint helpers
[pve-manager.git] / www / manager6 / Utils.js
index 6d4842df2578cfe466d38f93a0c53458ede1c8cc..54aa8bacae5e2f91b210f627c987b6cac31e80b6 100644 (file)
@@ -839,6 +839,12 @@ Ext.define('PVE.Utils', {
            hideAdd: true,
            backups: false,
        },
+       esxi: {
+           name: 'ESXi',
+           ipanel: 'ESXIInputPanel',
+           faIcon: 'cloud-download',
+           backups: false,
+       },
     },
 
     sdnvnetSchema: {
@@ -895,6 +901,11 @@ Ext.define('PVE.Utils', {
            ipanel: 'BgpInputPanel',
            faIcon: 'crosshairs',
        },
+       isis: {
+           name: 'isis',
+           ipanel: 'IsisInputPanel',
+           faIcon: 'crosshairs',
+       },
     },
 
     sdnipamSchema: {
@@ -1011,6 +1022,8 @@ Ext.define('PVE.Utils', {
            result = "CH " +
                Ext.String.leftPad(data.channel, 2, '0') +
                " ID " + data.id + " LUN " + data.lun;
+       } else if (data.content === 'import') {
+           result = data.volid.replace(/^.*?:/, '');
        } else {
            result = data.volid.replace(/^.*?:(.*?\/)?/, '');
        }
@@ -1231,6 +1244,8 @@ Ext.define('PVE.Utils', {
            // templates
            objType = 'template';
            status = type;
+       } else if (type === 'storage' && record.content.indexOf('import') !== -1) {
+           return 'fa fa-cloud-download';
        } else {
            // everything else
            status = record.status + ' ha-' + record.hastate;
@@ -1401,10 +1416,11 @@ Ext.define('PVE.Utils', {
                css: 'display:none;visibility:hidden;height:0px;',
            });
 
-           // Note: we need to tell Android and Chrome the correct file name extension
+           // Note: we need to tell Android, AppleWebKit and Chrome
+           // the correct file name extension
            // but we do not set 'download' tag for other environments, because
            // It can have strange side effects (additional user prompt on firefox)
-           if (navigator.userAgent.match(/Android|Chrome/i)) {
+           if (navigator.userAgent.match(/Android|AppleWebKit|Chrome/i)) {
                link.download = name;
            }
 
@@ -1574,14 +1590,14 @@ Ext.define('PVE.Utils', {
        }
     },
 
-    mp_counts: {
+    lxc_mp_counts: {
        mp: 256,
        unused: 256,
     },
 
-    forEachMP: function(func, includeUnused) {
-       for (let i = 0; i < PVE.Utils.mp_counts.mp; i++) {
-           let cont = func('mp', i);
+    forEachLxcMP: function(func, includeUnused) {
+       for (let i = 0; i < PVE.Utils.lxc_mp_counts.mp; i++) {
+           let cont = func('mp', i, `mp${i}`);
            if (!cont && cont !== undefined) {
                return;
            }
@@ -1591,8 +1607,19 @@ Ext.define('PVE.Utils', {
            return;
        }
 
-       for (let i = 0; i < PVE.Utils.mp_counts.unused; i++) {
-           let cont = func('unused', i);
+       for (let i = 0; i < PVE.Utils.lxc_mp_counts.unused; i++) {
+           let cont = func('unused', i, `unused${i}`);
+           if (!cont && cont !== undefined) {
+               return;
+           }
+       }
+    },
+
+    lxc_dev_count: 256,
+
+    forEachLxcDev: function(func) {
+       for (let i = 0; i < PVE.Utils.lxc_dev_count; i++) {
+           let cont = func(i, `dev${i}`);
            if (!cont && cont !== undefined) {
                return;
            }
@@ -1855,8 +1882,8 @@ Ext.define('PVE.Utils', {
        return undefined;
     },
 
-    nextFreeMP: function(type, config) {
-       for (let i = 0; i < PVE.Utils.mp_counts[type]; i++) {
+    nextFreeLxcMP: function(type, config) {
+       for (let i = 0; i < PVE.Utils.lxc_mp_counts[type]; i++) {
            let confid = `${type}${i}`;
            if (!Ext.isDefined(config[confid])) {
                return {
@@ -1915,6 +1942,22 @@ Ext.define('PVE.Utils', {
        'ok': 2,
        '__default__': 3,
     },
+
+    isStandaloneNode: function() {
+       return PVE.data.ResourceStore.getNodes().length < 2;
+    },
+
+    // main use case of this helper is the login window
+    getUiLanguage: function() {
+       let languageCookie = Ext.util.Cookies.get('PVELangCookie');
+       if (languageCookie === 'kr') {
+           // fix-up 'kr' being used for Korean by mistake FIXME: remove with PVE 9
+           let dt = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
+           languageCookie = 'ko';
+           Ext.util.Cookies.set('PVELangCookie', languageCookie, dt);
+       }
+       return languageCookie || Proxmox.defaultLang || 'en';
+    },
 },
 
     singleton: true,
@@ -1961,7 +2004,7 @@ Ext.define('PVE.Utils', {
            lvmremove: ['Volume Group', gettext('Remove')],
            lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
            lvmthinremove: ['Thinpool', gettext('Remove')],
-           migrateall: ['', gettext('Migrate all VMs and Containers')],
+           migrateall: ['', gettext('Bulk migrate VMs and Containers')],
            'move_volume': ['CT', gettext('Move Volume')],
            'pbs-download': ['VM/CT', gettext('File Restore Download')],
            pull_file: ['CT', gettext('Pull file')],
@@ -1988,8 +2031,9 @@ Ext.define('PVE.Utils', {
            resize: ['VM/CT', gettext('Resize')],
            spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
            spiceshell: ['', gettext('Shell') + ' (Spice)'],
-           startall: ['', gettext('Start all VMs and Containers')],
-           stopall: ['', gettext('Stop all VMs and Containers')],
+           startall: ['', gettext('Bulk start VMs and Containers')],
+           stopall: ['', gettext('Bulk shutdown VMs and Containers')],
+           suspendall: ['', gettext('Suspend all VMs')],
            unknownimgdel: ['', gettext('Destroy image from unknown guest')],
            wipedisk: ['Device', gettext('Wipe Disk')],
            vncproxy: ['VM/CT', gettext('Console')],