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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EC0A968B12 for ; Thu, 22 Jul 2021 15:27:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EA42311A8B for ; Thu, 22 Jul 2021 15:27:41 +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 E443711A75 for ; Thu, 22 Jul 2021 15:27:40 +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 8E07A424F0 for ; Thu, 22 Jul 2021 15:27:40 +0200 (CEST) From: Fabian Ebner To: pbs-devel@lists.proxmox.com Date: Thu, 22 Jul 2021 15:27:34 +0200 Message-Id: <20210722132735.2260448-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 -1.114 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% ENA_SUBJ_ODD_CASE 3.2 Subject has odd case 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: [pbs-devel] [PATCH proxmox-widget-toolkit 1/1] add NodeInfoRepoStatus X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 13:27:42 -0000 adapted from PMG, because it has an additional fix to avoid setting undefined in the view model, which still affects PBS (see pmg-gui commit 774418f08b10c651357d11ccb161ac075e1ae905). Signed-off-by: Fabian Ebner --- src/Makefile | 1 + src/panel/NodeInfoRepoStatus.js | 102 ++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/panel/NodeInfoRepoStatus.js diff --git a/src/Makefile b/src/Makefile index 36f316c..a490ccd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -51,6 +51,7 @@ JSSRC= \ panel/InputPanel.js \ panel/InfoWidget.js \ panel/LogView.js \ + panel/NodeInfoRepoStatus.js \ panel/JournalView.js \ panel/PermissionView.js \ panel/PruneKeepPanel.js \ diff --git a/src/panel/NodeInfoRepoStatus.js b/src/panel/NodeInfoRepoStatus.js new file mode 100644 index 0000000..df1ca9f --- /dev/null +++ b/src/panel/NodeInfoRepoStatus.js @@ -0,0 +1,102 @@ +Ext.define('Proxmox.widget.NodeInfoRepoStatus', { + extend: 'Proxmox.widget.Info', + alias: 'widget.pmxNodeInfoRepoStatus', + + title: gettext('Repository Status'), + + colspan: 2, + + printBar: false, + + product: undefined, + repoLink: undefined, + + 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) { + let me = this; + let view = me.getView(); + + const status = get('repoStatus'); + + let repoLink = ` + + `; + + return Proxmox.Utils.formatNodeRepoStatus(status, view.product) + repoLink; + }, + }, + }, + + setValue: function(value) { // for binding below + this.updateValue(value); + }, + + bind: { + value: '{repoStatusMessage}', + }, + + 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; + + if (me.product === undefined) { + throw "no product name provided"; + } + + if (me.repoLink === undefined) { + throw "no repo link href provided"; + } + + me.callParent(); + }, +}); -- 2.30.2