From 48e230790ef0352ed594770c62771875b6a9c64a Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Fri, 23 Jul 2021 09:20:33 +0200 Subject: [PATCH] dashboard: node status: use repo status widget from widget-toolkit Signed-off-by: Fabian Ebner --- js/Dashboard.js | 6 ++-- js/dashboard/NodeInfo.js | 72 ++-------------------------------------- 2 files changed, 7 insertions(+), 71 deletions(-) diff --git a/js/Dashboard.js b/js/Dashboard.js index 3cf9cf0..b1ca8dd 100644 --- a/js/Dashboard.js +++ b/js/Dashboard.js @@ -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) { diff --git a/js/dashboard/NodeInfo.js b/js/dashboard/NodeInfo.js index bdf8f85..7952d03 100644 --- a/js/dashboard/NodeInfo.js +++ b/js/dashboard/NodeInfo.js @@ -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 = ` - - `; - 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; -- 2.39.2