]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Dashboard.js
ui: trim whitespaces when adding a subscription key
[pmg-gui.git] / js / Dashboard.js
index 79817b383b8ff5ec9e4ebca7c1a53995896d8c0d..b536cb242420fe1b20a6b2b9239ebf92657f6951 100644 (file)
@@ -119,6 +119,11 @@ Ext.define('PMG.Dashboard', {
                    subStatus = 0;
                }
 
+               if (item.data.name === Proxmox.NodeName) {
+                   let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+                   repoStatus.setSubscriptionStatus(!!item.data.level);
+               }
+
                // resources count
                cpu += item.data.cpu || 0;
 
@@ -140,7 +145,8 @@ Ext.define('PMG.Dashboard', {
            var subscriptionPanel = me.lookup('subscription');
            subscriptionPanel.setSubStatus(subStatus);
 
-           me.lookup('nodeInfo').setSubscriptionStatus(subStatus);
+           // the node info already displays this information in case there is no cluster
+           me.lookup('clusterResources').setHidden(records.length === 1);
 
            cpu = cpu/count;
            mem = mem/count;
@@ -171,7 +177,8 @@ Ext.define('PMG.Dashboard', {
            }
 
            let me = this;
-           me.lookup('nodeInfo').setRepositoryInfo(records[0].data['standard-repos']);
+           let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+           repoStatus.setRepositoryInfo(records[0].data['standard-repos']);
        },
 
        init: function(view) {
@@ -179,9 +186,20 @@ Ext.define('PMG.Dashboard', {
            var sp = Ext.state.Manager.getProvider();
            var hours = sp.get('dashboard-hours') || 12;
            me.setHours(hours, false);
+
+           view.mon(sp, 'statechange', function(provider, key, value) {
+               if (key !== 'summarycolumns') {
+                   return;
+               }
+               Proxmox.Utils.updateColumnWidth(view);
+           });
        },
     },
 
+    listeners: {
+       resize: panel => Proxmox.Utils.updateColumnWidth(panel),
+    },
+
     viewModel: {
        data: {
            timespan: 300, // in seconds
@@ -276,6 +294,7 @@ Ext.define('PMG.Dashboard', {
                    url: '/api2/json/statistics/recentreceivers',
                    extraParams: {
                        hours: '{hours}',
+                       limit: 10, // make this also configurable?
                    },
                },
                fields: [
@@ -314,7 +333,7 @@ Ext.define('PMG.Dashboard', {
     bodyPadding: '20 0 0 20',
 
     defaults: {
-       columnWidth: 0.5,
+       columnWidth: 1,
        xtype: 'panel',
        margin: '0 20 20 0',
     },
@@ -400,7 +419,7 @@ Ext.define('PMG.Dashboard', {
                },
                {
                    iconCls: 'fa fa-ticket',
-                   title: 'Subscription',
+                   title: gettext('Subscription'),
                    reference: 'subscription',
                    xtype: 'pmgSubscriptionInfo',
                    margin: '10 0 0 0',
@@ -408,48 +427,19 @@ Ext.define('PMG.Dashboard', {
                },
            ],
        },
-       {
-           height: 250,
-           iconCls: 'fa fa-tasks',
-           title: gettext('Cluster Resources (average)'),
-           bodyPadding: '0 20 0 20',
-           layout: {
-               type: 'hbox',
-               align: 'center',
-           },
-           defaults: {
-               xtype: 'proxmoxGauge',
-               spriteFontSize: '20px',
-               flex: 1,
-           },
-           items: [
-               {
-                   title: gettext('CPU'),
-                   reference: 'cpu',
-               },
-               {
-                   title: gettext('Memory'),
-                   reference: 'mem',
-               },
-               {
-                   title: gettext('Storage'),
-                   reference: 'hd',
-               },
-           ],
-       },
        {
            xtype: 'pmgNodeInfoPanel',
            reference: 'nodeInfo',
-           height: 250,
-           bodyPadding: '10 5 10 5',
+           height: 300,
+           bodyPadding: '15 5 15 5',
            iconCls: 'fa fa-tasks',
        },
        {
-           height: 250,
+           height: 300,
            iconCls: 'fa fa-list',
            title: gettext('Top Receivers'),
 
-           bodyPadding: '20 20 20 20',
+           bodyPadding: '10 10 10 10',
            layout: {
                type: 'vbox',
                pack: 'center',
@@ -460,9 +450,7 @@ Ext.define('PMG.Dashboard', {
                bind: {
                    store: '{receivers}',
                },
-
                emptyText: gettext('No data in database'),
-
                // remove all borders/lines/headers
                border: false,
                bodyBorder: false,
@@ -473,7 +461,6 @@ Ext.define('PMG.Dashboard', {
                viewConfig: {
                    stripeRows: false,
                },
-
                columns: [
                    {
                        dataIndex: 'receiver',
@@ -488,5 +475,36 @@ Ext.define('PMG.Dashboard', {
                ],
            }],
        },
+       {
+           height: 250,
+           iconCls: 'fa fa-tasks',
+           title: gettext('Cluster Resources (average)'),
+           reference: 'clusterResources',
+           hidden: true,
+           bodyPadding: '0 20 0 20',
+           layout: {
+               type: 'hbox',
+               align: 'center',
+           },
+           defaults: {
+               xtype: 'proxmoxGauge',
+               spriteFontSize: '20px',
+               flex: 1,
+           },
+           items: [
+               {
+                   title: gettext('CPU'),
+                   reference: 'cpu',
+               },
+               {
+                   title: gettext('Memory'),
+                   reference: 'mem',
+               },
+               {
+                   title: gettext('Storage'),
+                   reference: 'hd',
+               },
+           ],
+       },
     ],
 });