]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: node status: use repo status widget from widget-toolkit
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 22 Jul 2021 13:30:00 +0000 (15:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 29 Jul 2021 08:47:02 +0000 (10:47 +0200)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
www/manager6/node/StatusView.js
www/manager6/node/Summary.js

index d7a0852960bbcc03e0dd8c1db14cae3374b43c02..d34724f79c98ebbf72b9b5b2faa3c15c6d2a9fee 100644 (file)
@@ -2,55 +2,6 @@ Ext.define('PVE.node.StatusView', {
     extend: 'Proxmox.panel.StatusView',
     alias: 'widget.pveNodeStatus',
 
-    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 fmt = (txt, cls) => `<i class="fa fa-fw fa-lg fa-${cls}"></i>${txt}`;
-
-               let getUpdates = Ext.String.format(gettext('{0} updates'), 'Proxmox VE');
-
-               if (status === 'ok') {
-                   return fmt(getUpdates, 'check-circle good') + ' ' +
-                       fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good');
-               } else if (status === 'no-sub') {
-                   return fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good') + ' ' +
-                           fmt(gettext('Enterprise repository needs valid subscription'), 'exclamation-circle warning');
-               } else if (status === 'non-production') {
-                   return fmt(getUpdates, 'check-circle good') + ' ' +
-                          fmt(gettext('Non production-ready repository enabled!'), 'exclamation-circle warning');
-               } else if (status === 'no-repo') {
-                   return fmt(gettext('No Proxmox VE repository enabled!'), 'exclamation-circle critical');
-               }
-
-               return Proxmox.Utils.unknownText;
-           },
-       },
-    },
-
     height: 300,
     bodyPadding: '15 5 15 5',
 
@@ -162,18 +113,6 @@ Ext.define('PVE.node.StatusView', {
            textField: 'pveversion',
            value: '',
        },
-       {
-           itemId: 'repositoryStatus',
-           colspan: 2,
-           printBar: false,
-           title: gettext('Repository Status'),
-           setValue: function(value) { // for binding below
-               this.updateValue(value);
-           },
-           bind: {
-               value: '{repoStatusMessage}',
-           },
-       },
     ],
 
     updateTitle: function() {
@@ -182,28 +121,24 @@ Ext.define('PVE.node.StatusView', {
        me.setTitle(me.pveSelNode.data.node + ' (' + gettext('Uptime') + ': ' + uptime + ')');
     },
 
-    setRepositoryInfo: function(standardRepos) {
+    initComponent: function() {
        let me = this;
-       let vm = me.getViewModel();
-
-       for (const standardRepo of standardRepos) {
-           const handle = standardRepo.handle;
-           const status = standardRepo.status;
 
-           if (handle === "enterprise") {
-               vm.set('enterpriseRepo', status);
-           } else if (handle === "no-subscription") {
-               vm.set('noSubscriptionRepo', status);
-           } else if (handle === "test") {
-               vm.set('testRepo', status);
-           }
-       }
-    },
+       let stateProvider = Ext.state.Manager.getProvider();
+       let repoLink = stateProvider.encodeHToken({
+           view: "server",
+           rid: `node/${me.pveSelNode.data.node}`,
+           ltab: "tasks",
+           nodetab: "aptrepositories",
+       });
 
-    setSubscriptionStatus: function(status) {
-       let me = this;
-       let vm = me.getViewModel();
+       me.items.push({
+           xtype: 'pmxNodeInfoRepoStatus',
+           itemId: 'repositoryStatus',
+           product: 'Proxmox VE',
+           repoLink: `#${repoLink}`,
+       });
 
-       vm.set('subscriptionActive', status);
+       me.callParent();
     },
 });
index ecc62de85602e6f45714f500d42e19d149ca4072..8680fa5f36d8519a2c90eac8a5b8da4cf365fe6f 100644 (file)
@@ -85,7 +85,7 @@ Ext.define('PVE.node.Summary', {
 
     updateRepositoryStatus: function() {
        let me = this;
-       let nodeStatus = me.nodeStatus;
+       let repoStatus = me.nodeStatus.down('#repositoryStatus');
 
        let nodename = me.pveSelNode.data.node;
 
@@ -93,7 +93,7 @@ Ext.define('PVE.node.Summary', {
            url: `/nodes/${nodename}/apt/repositories`,
            method: 'GET',
            failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
-           success: response => nodeStatus.setRepositoryInfo(response.result.data['standard-repos']),
+           success: response => repoStatus.setRepositoryInfo(response.result.data['standard-repos']),
        });
 
        Proxmox.Utils.API2Request({
@@ -103,7 +103,7 @@ Ext.define('PVE.node.Summary', {
            success: function(response, opts) {
                const res = response.result;
                const subscription = res?.data?.status.toLowerCase() === 'active';
-               nodeStatus.setSubscriptionStatus(subscription);
+               repoStatus.setSubscriptionStatus(subscription);
            },
        });
     },