]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Dashboard.js
Dashboard: remove autoLoad from updateStores
[pmg-gui.git] / js / Dashboard.js
index c395d149f22a7798885e2d5c77128e6466617236..378efae4c4197a4485fb3f8ae438e91bdd4def27 100644 (file)
@@ -60,7 +60,7 @@ Ext.define('PMG.Dashboard', {
            viewModel.notify();
 
            Ext.Array.forEach(['recentmails', 'receivers'], function(item) {
-               viewModel.get(item).load();
+               viewModel.getStore(item).reload();
            });
 
            if (setState) {
@@ -80,7 +80,7 @@ Ext.define('PMG.Dashboard', {
            var bytes_in = 0;
            var bytes_out = 0;
            var ptime = 0;
-           var avg_ptime;
+           var avg_ptime = 'N/A';
 
            records.forEach(function(item) {
                bytes_in += item.data.bytes_in;
@@ -91,12 +91,12 @@ Ext.define('PMG.Dashboard', {
            });
 
            if (count) {
-               avg_ptime = (ptime/count).toFixed(2);
+               avg_ptime = (ptime/count).toFixed(2) + " s";
            }
 
            viewModel.set('bytes_in', Proxmox.Utils.format_size(bytes_in));
            viewModel.set('bytes_out', Proxmox.Utils.format_size(bytes_out));
-           viewModel.set('avg_ptime', avg_ptime + " s");
+           viewModel.set('avg_ptime', avg_ptime);
        },
 
        updateClusterStats: function(store, records, success) {
@@ -113,6 +113,7 @@ Ext.define('PMG.Dashboard', {
            var mem = 0;
            var hd = 0;
            var count = records.length;
+           var errors = [];
 
            records.forEach(function(item) {
                // subscription level check
@@ -127,9 +128,21 @@ Ext.define('PMG.Dashboard', {
                }
 
                // resources count
-               cpu += item.data.cpu;
-               mem += (item.data.memory.used/item.data.memory.total);
-               hd += (item.data.rootfs.used/item.data.rootfs.total);
+               cpu += item.data.cpu || 0;
+
+               var memory = item.data.memory || { used: 0, total: 1 };
+               mem += (memory.used/memory.total);
+
+               var rootfs = item.data.rootfs || { used: 0, total: 1 };
+               hd += (rootfs.used/rootfs.total);
+
+               if (item.data.conn_error && count > 1) {
+                   count--;
+                   errors.push({
+                       name: item.data.name,
+                       msg: item.data.conn_error
+                   });
+               }
            });
 
            var subscriptionPanel = me.lookup('subscription');
@@ -147,6 +160,15 @@ Ext.define('PMG.Dashboard', {
 
            var hdPanel = me.lookup('hd');
            hdPanel.updateValue(hd);
+
+           if (errors.length && !viewmodel.get('error_shown')) {
+               var text = "";
+               errors.forEach(function(error) {
+                   text += error.name + ':<br>' + error.msg + '<br>';
+               });
+               Ext.Msg.alert(gettext('Error'), text);
+               viewmodel.set('error_shown', true);
+           }
        },
 
        init: function(view) {
@@ -161,6 +183,7 @@ Ext.define('PMG.Dashboard', {
        data: {
            timespan: 300, // in seconds
            hours: 12, // in hours
+           error_shown: false,
            'bytes_in': 0,
            'bytes_out': 0,
            'avg_ptime': 0.0
@@ -172,9 +195,9 @@ Ext.define('PMG.Dashboard', {
                type: 'update',
                interval: 5000,
                autoStart: true,
-               autoLoad: true,
                autoDestroy: true,
                proxy: {
+                   extraParams: { list_single_node: 1 },
                    type: 'proxmox',
                    url: '/api2/json/config/cluster/status'
                },
@@ -187,7 +210,6 @@ Ext.define('PMG.Dashboard', {
                interval: 5000,
                type: 'update',
                autoStart: true,
-               autoLoad: true,
                autoDestroy: true,
                proxy: {
                    type: 'proxmox',
@@ -245,7 +267,6 @@ Ext.define('PMG.Dashboard', {
                interval: 10000,
                type: 'update',
                autoStart: true,
-               autoLoad: true,
                autoDestroy: true,
                proxy: {
                    type: 'proxmox',
@@ -353,9 +374,9 @@ Ext.define('PMG.Dashboard', {
                    height: 180,
                    bind: {
                        data: {
-                           'in': '{bytes_in}',
-                           'out': '{bytes_out}',
-                           'ptime': '{avg_ptime}'
+                           'bytes_in': '{bytes_in}',
+                           'bytes_out': '{bytes_out}',
+                           'avg_ptime': '{avg_ptime}'
                        }
                    }
                },
@@ -372,7 +393,7 @@ Ext.define('PMG.Dashboard', {
        {
            height: 250,
            iconCls: 'fa fa-tasks',
-           title: 'Node Resources',
+           title: gettext('Node Resources'),
            bodyPadding: '0 20 0 20',
            layout: {
                type: 'hbox',