From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5136168B18 for ; Thu, 22 Jul 2021 15:30:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 480B111B59 for ; Thu, 22 Jul 2021 15:30:05 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 569D111B50 for ; Thu, 22 Jul 2021 15:30:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 26386420FC for ; Thu, 22 Jul 2021 15:30:04 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 22 Jul 2021 15:30:00 +0200 Message-Id: <20210722133000.2308803-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.489 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager] ui: node status: use repo status widget from widget-toolkit X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 13:30:05 -0000 Signed-off-by: Fabian Ebner --- Depends on https://lists.proxmox.com/pipermail/pbs-devel/2021-July/003764.html and needs a dependency bump for it. www/manager6/node/StatusView.js | 95 ++++++--------------------------- www/manager6/node/Summary.js | 6 +-- 2 files changed, 18 insertions(+), 83 deletions(-) diff --git a/www/manager6/node/StatusView.js b/www/manager6/node/StatusView.js index d7a08529..d34724f7 100644 --- a/www/manager6/node/StatusView.js +++ b/www/manager6/node/StatusView.js @@ -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) => `${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(); }, }); diff --git a/www/manager6/node/Summary.js b/www/manager6/node/Summary.js index ecc62de8..8680fa5f 100644 --- a/www/manager6/node/Summary.js +++ b/www/manager6/node/Summary.js @@ -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); }, }); }, -- 2.30.2