]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/dc/Summary.js
ui: Utils: use render functions from widget-toolkit
[pve-manager.git] / www / manager6 / dc / Summary.js
index 6254395bd70472c7dcff1499551f581d4b2c2d47..67d5e95bbb8662bd840cd14418791370ecc31ae0 100644 (file)
@@ -10,25 +10,17 @@ Ext.define('PVE.dc.Summary', {
 
     defaults: {
        padding: 5,
-       plugins: 'responsive',
-       responsiveConfig: {
-           'width < 1900': {
-               columnWidth: 1
-           },
-           'width >= 1900': {
-               columnWidth: 0.5
-           }
-       }
+       columnWidth: 1,
     },
 
     items: [
        {
            itemId: 'dcHealth',
-           xtype: 'pveDcHealth'
+           xtype: 'pveDcHealth',
        },
        {
            itemId: 'dcGuests',
-           xtype: 'pveDcGuests'
+           xtype: 'pveDcGuests',
        },
        {
            title: gettext('Resources'),
@@ -38,27 +30,27 @@ Ext.define('PVE.dc.Summary', {
            layout: 'hbox',
            defaults: {
                xtype: 'proxmoxGauge',
-               flex: 1
+               flex: 1,
            },
-           items:[
+           items: [
                {
                    title: gettext('CPU'),
-                   itemId: 'cpu'
+                   itemId: 'cpu',
                },
                {
                    title: gettext('Memory'),
-                   itemId: 'memory'
+                   itemId: 'memory',
                },
                {
                    title: gettext('Storage'),
-                   itemId: 'storage'
-               }
-           ]
+                   itemId: 'storage',
+               },
+           ],
        },
        {
            itemId: 'nodeview',
            xtype: 'pveDcNodeView',
-           height: 250
+           height: 250,
        },
        {
            title: gettext('Subscriptions'),
@@ -66,12 +58,27 @@ Ext.define('PVE.dc.Summary', {
            items: [
                {
                    itemId: 'subscriptions',
-                   xtype: 'pveHealthWidget'
-               }
-           ]
-       }
+                   xtype: 'pveHealthWidget',
+                   userCls: 'pointer',
+                   listeners: {
+                       element: 'el',
+                       click: function() {
+                           if (this.component.userCls === 'pointer') {
+                               window.open('https://www.proxmox.com/en/proxmox-ve/pricing', '_blank');
+                           }
+                       },
+                   },
+               },
+           ],
+       },
     ],
 
+    listeners: {
+       resize: function(panel) {
+           PVE.Utils.updateColumns(panel);
+       },
+    },
+
     initComponent: function() {
         var me = this;
 
@@ -81,20 +88,20 @@ Ext.define('PVE.dc.Summary', {
            model: 'pve-dc-nodes',
            proxy: {
                 type: 'proxmox',
-                url: "/api2/json/cluster/status"
-           }
+                url: "/api2/json/cluster/status",
+           },
        });
 
        var gridstore = Ext.create('Proxmox.data.DiffStore', {
            rstore: rstore,
            filters: {
                property: 'type',
-               value: 'node'
+               value: 'node',
            },
            sorters: {
                property: 'id',
-               direction: 'ASC'
-           }
+               direction: 'ASC',
+           },
        });
 
        me.callParent();
@@ -124,7 +131,7 @@ Ext.define('PVE.dc.Summary', {
            var total = 0;
            var usableStorages = {};
            var storages = sp.get('dash-storages') || '';
-           storages.split(',').forEach(function(storage){
+           storages.split(',').forEach(function(storage) {
                if (storage !== '') {
                    usableStorages[storage] = true;
                }
@@ -134,13 +141,13 @@ Ext.define('PVE.dc.Summary', {
                running: 0,
                paused: 0,
                stopped: 0,
-               template: 0
+               template: 0,
            };
            var lxc = {
                running: 0,
                paused: 0,
                stopped: 0,
-               template: 0
+               template: 0,
            };
            var error = 0;
 
@@ -148,9 +155,9 @@ Ext.define('PVE.dc.Summary', {
 
            for (i = 0; i < results.length; i++) {
                var item = results[i];
-               switch(item.data.type) {
+               switch (item.data.type) {
                    case 'node':
-                       cpu += (item.data.cpu * item.data.maxcpu);
+                       cpu += item.data.cpu * item.data.maxcpu;
                        maxcpu += item.data.maxcpu || 0;
                        memory += item.data.mem || 0;
                        maxmem += item.data.maxmem || 0;
@@ -176,8 +183,7 @@ Ext.define('PVE.dc.Summary', {
                            break;
                        }
                        if (!countedStorages[item.data.storage] ||
-                           (item.data.storage === 'local' &&
-                           !countedStorages[item.data.id])) {
+                           !item.data.shared && !countedStorages[item.data.id]) {
                            used += item.data.disk;
                            total += item.data.maxdisk;
 
@@ -201,15 +207,15 @@ Ext.define('PVE.dc.Summary', {
            }
 
            var text = Ext.String.format(gettext('of {0} CPU(s)'), maxcpu);
-           cpustat.updateValue((cpu/maxcpu), text);
+           cpustat.updateValue(cpu/maxcpu, text);
 
-           text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(memory), PVE.Utils.render_size(maxmem));
-           memorystat.updateValue((memory/maxmem), text);
+           text = Ext.String.format(gettext('{0} of {1}'), Proxmox.Utils.render_size(memory), Proxmox.Utils.render_size(maxmem));
+           memorystat.updateValue(memory/maxmem, text);
 
-           text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(used), PVE.Utils.render_size(total));
-           storagestat.updateValue((used/total), text);
+           text = Ext.String.format(gettext('{0} of {1}'), Proxmox.Utils.render_size(used), Proxmox.Utils.render_size(total));
+           storagestat.updateValue(used/total, text);
 
-           gueststatus.updateValues(qemu,lxc,error);
+           gueststatus.updateValues(qemu, lxc, error);
 
            me.suspendLayout = false;
            me.updateLayout(true);
@@ -222,49 +228,73 @@ Ext.define('PVE.dc.Summary', {
        me.mon(rstore, 'load', function(store, records, success) {
            var i;
            var level;
-           var curlevel;
+           var mixed = false;
            for (i = 0; i < records.length; i++) {
                if (records[i].get('type') !== 'node') {
                    continue;
                }
-
-               curlevel = records[i].get('level');
-               if (level === undefined || !curlevel) {
-                   level = curlevel;
+               var node = records[i];
+               if (node.get('status') === 'offline') {
                    continue;
                }
 
-               if (level !== curlevel) {
+               var curlevel = node.get('level');
+
+               if (curlevel === '') { // no subscription trumps all, set and break
+                   level = '';
                    break;
                }
+
+               if (level === undefined) { // save level
+                   level = curlevel;
+               } else if (level !== curlevel) { // detect different levels
+                   mixed = true;
+               }
            }
 
+           var data = {
+               title: Proxmox.Utils.unknownText,
+               text: Proxmox.Utils.unknownText,
+               iconCls: PVE.Utils.get_health_icon(undefined, true),
+           };
            if (level === '') {
-               subs.setData({
+               data = {
                    title: gettext('No Subscription'),
                    iconCls: PVE.Utils.get_health_icon('critical', true),
-                   text: gettext('You have at least one node without subscription.')
-               });
-           } else if (level !== curlevel) {
-               subs.setData({
+                   text: gettext('You have at least one node without subscription.'),
+               };
+               subs.setUserCls('pointer');
+           } else if (mixed) {
+               data = {
                    title: gettext('Mixed Subscriptions'),
                    iconCls: PVE.Utils.get_health_icon('warning', true),
-                   text: gettext('Warning: Your subscription levels are not the same.')
-               });
-           } else {
-               subs.setData({
+                   text: gettext('Warning: Your subscription levels are not the same.'),
+               };
+               subs.setUserCls('pointer');
+           } else if (level) {
+               data = {
                    title: PVE.Utils.render_support_level(level),
                    iconCls: PVE.Utils.get_health_icon('good', true),
-                   text: gettext('Your subscription status is valid.')
-               });
+                   text: gettext('Your subscription status is valid.'),
+               };
+               subs.setUserCls('');
            }
+
+           subs.setData(data);
        });
 
-       me.on('destroy', function(){
+       me.on('destroy', function() {
            rstore.stopUpdate();
        });
 
+       me.mon(sp, 'statechange', function(provider, key, value) {
+           if (key !== 'summarycolumns') {
+               return;
+           }
+           PVE.Utils.updateColumns(me);
+       });
+
        rstore.startUpdate();
-    }
+    },
 
 });