]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Dashboard.js
mobile: fix subscription check
[pmg-gui.git] / js / Dashboard.js
index 123c6ff9e764a6f6c2d74c896acbc9e6ee4052cd..b1ca8ddeb97a4a7966578bbe33fdca41fc5e94ab 100644 (file)
@@ -1,11 +1,3 @@
-/*global Proxmox*/
-/*jslint confusion: true*/
-/* load is a function and string
- * hours is a number and string
- * timespan is a number and string
- * bind is a function and object
- * handler is a function and string
- */
 Ext.define('PMG.Dashboard', {
     extend: 'Ext.panel.Panel',
     xtype: 'pmgDashboard',
@@ -127,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;
 
@@ -148,6 +145,9 @@ Ext.define('PMG.Dashboard', {
            var subscriptionPanel = me.lookup('subscription');
            subscriptionPanel.setSubStatus(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;
            hd = hd/count;
@@ -171,6 +171,16 @@ Ext.define('PMG.Dashboard', {
            }
        },
 
+       updateRepositoryStatus: function(store, records, success) {
+           if (!success) {
+               return;
+           }
+
+           let me = this;
+           let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+           repoStatus.setRepositoryInfo(records[0].data['standard-repos']);
+       },
+
        init: function(view) {
            var me = this;
            var sp = Ext.state.Manager.getProvider();
@@ -280,6 +290,21 @@ Ext.define('PMG.Dashboard', {
                    { type: 'string', name: 'receiver' },
                ],
            },
+           repositories: {
+               storeid: 'dash-repositories',
+               type: 'update',
+               interval: 15000,
+               autoStart: true,
+               autoLoad: true,
+               autoDestroy: true,
+               proxy: {
+                   type: 'proxmox',
+                   url: '/api2/json/nodes/localhost/apt/repositories',
+               },
+               listeners: {
+                   load: 'updateRepositoryStatus',
+               },
+           },
        },
     },
 
@@ -391,36 +416,14 @@ Ext.define('PMG.Dashboard', {
            ],
        },
        {
-           height: 250,
+           xtype: 'pmgNodeInfoPanel',
+           reference: 'nodeInfo',
+           height: 275,
+           bodyPadding: '15 5 15 5',
            iconCls: 'fa fa-tasks',
-           title: gettext('Node Resources'),
-           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',
-               },
-           ],
        },
        {
-           height: 250,
+           height: 275,
            iconCls: 'fa fa-list',
            title: gettext('Top Receivers'),
 
@@ -435,9 +438,7 @@ Ext.define('PMG.Dashboard', {
                bind: {
                    store: '{receivers}',
                },
-
                emptyText: gettext('No data in database'),
-
                // remove all borders/lines/headers
                border: false,
                bodyBorder: false,
@@ -448,7 +449,6 @@ Ext.define('PMG.Dashboard', {
                viewConfig: {
                    stripeRows: false,
                },
-
                columns: [
                    {
                        dataIndex: 'receiver',
@@ -463,5 +463,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',
+               },
+           ],
+       },
     ],
 });