]> git.proxmox.com Git - pmg-gui.git/commitdiff
dashboard: node status: use repo status widget from widget-toolkit
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 23 Jul 2021 07:20:33 +0000 (09:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 28 Jul 2021 08:25:39 +0000 (10:25 +0200)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
js/Dashboard.js
js/dashboard/NodeInfo.js

index 3cf9cf0ec5be9c40360501f1af1ef7204ed09c65..b1ca8ddeb97a4a7966578bbe33fdca41fc5e94ab 100644 (file)
@@ -120,7 +120,8 @@ Ext.define('PMG.Dashboard', {
                }
 
                if (item.data.name === Proxmox.NodeName) {
-                   me.lookup('nodeInfo').setSubscriptionStatus(!!item.data.level);
+                   let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+                   repoStatus.setSubscriptionStatus(!!item.data.level);
                }
 
                // resources count
@@ -176,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) {
index bdf8f85e56c16ca9ac399fb6f2114eae73d9d754..7952d036efd982d10636e8bc15910ee03349be2f 100644 (file)
@@ -17,41 +17,6 @@ Ext.define('PMG.NodeInfoPanel', {
        padding: '0 10 5 10',
     },
 
-    viewModel: {
-       data: {
-           subscriptionActive: '',
-           noSubscriptionRepo: '',
-           enterpriseRepo: '',
-           testRepo: '',
-       },
-       formulas: {
-           repoStatus: function(get) {
-               if (get('subscriptionActive') === '' || get('enterpriseRepo') === '') {
-                   return '';
-               }
-
-               if (get('noSubscriptionRepo') || get('testRepo')) {
-                   return 'non-production';
-               } else if (get('subscriptionActive') && get('enterpriseRepo')) {
-                   return 'ok';
-               } else if (!get('subscriptionActive') && get('enterpriseRepo')) {
-                   return 'no-sub';
-               } else if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) {
-                   return 'no-repo';
-               }
-               return 'unknown';
-           },
-           repoStatusMessage: function(get) {
-               const status = get('repoStatus');
-               let repoLink = ` <a data-qtip="${gettext("Open Repositories Panel")}"
-                   href="#pmgServerAdministration:aptrepositories">
-                   <i class="fa black fa-chevron-right txt-shadow-hover"></i>
-                   </a>`;
-               return Proxmox.Utils.formatNodeRepoStatus(status, 'Proxmox Mail Gateway') + repoLink;
-           },
-       },
-    },
-
     items: [
        {
            itemId: 'nodecpu',
@@ -127,16 +92,10 @@ Ext.define('PMG.NodeInfoPanel', {
            value: '',
        },
        {
+           xtype: 'pmxNodeInfoRepoStatus',
            itemId: 'repositoryStatus',
-           colspan: 2,
-           printBar: false,
-           title: gettext('Repository Status'),
-           setValue: function(value) { // for binding below
-               this.updateValue(value);
-           },
-           bind: {
-               value: '{repoStatusMessage}',
-           },
+           product: 'Proxmox Mail Gateway',
+           repoLink: '#pmgServerAdministration:aptrepositories',
        },
     ],
 
@@ -146,31 +105,6 @@ Ext.define('PMG.NodeInfoPanel', {
        me.setTitle(Proxmox.NodeName + ' (' + gettext('Uptime') + ': ' + uptime + ')');
     },
 
-    setRepositoryInfo: function(standardRepos) {
-       let me = this;
-       let vm = me.getViewModel();
-
-       for (const standardRepo of standardRepos) {
-           const handle = standardRepo.handle;
-           const status = standardRepo.status || 0;
-
-           if (handle === "enterprise") {
-               vm.set('enterpriseRepo', status);
-           } else if (handle === "no-subscription") {
-               vm.set('noSubscriptionRepo', status);
-           } else if (handle === "test") {
-               vm.set('testRepo', status);
-           }
-       }
-    },
-
-    setSubscriptionStatus: function(status) {
-       let me = this;
-       let vm = me.getViewModel();
-
-       vm.set('subscriptionActive', status);
-    },
-
     initComponent: function() {
        let me = this;