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 AFD13748B8; Fri, 9 Jul 2021 14:44:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AD33C25D9D; Fri, 9 Jul 2021 14:44:22 +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 746FE25D94; Fri, 9 Jul 2021 14:44:21 +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 4BA9B40AFB; Fri, 9 Jul 2021 14:44:21 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Date: Fri, 9 Jul 2021 14:44:16 +0200 Message-Id: <20210709124416.129299-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709124416.129299-1-f.ebner@proxmox.com> References: <20210709124416.129299-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.524 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status 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: Fri, 09 Jul 2021 12:44:22 -0000 Mostly copied from PVE, slightly adapted to be consistent with other things in the dashboard, e.g. use a store for the repository info. Signed-off-by: Fabian Ebner --- Dependency bump for widget-toolkit is needed. Built on top of Dominik's patches to refactor/extend the node info in the Dashboard [0] (still applied for me). [0]: https://lists.proxmox.com/pipermail/pbs-devel/2021-April/002788.html www/Dashboard.js | 22 ++++++++++++++ www/panel/NodeInfo.js | 68 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/www/Dashboard.js b/www/Dashboard.js index 18f174fe..70c2305b 100644 --- a/www/Dashboard.js +++ b/www/Dashboard.js @@ -59,6 +59,11 @@ Ext.define('PBS.Dashboard', { } }, + updateRepositoryStatus: function(store, records, success) { + if (!success) { return; } + let me = this; + me.lookup('nodeInfo').setRepositoryInfo(records[0].data['standard-repos']); + }, updateSubscription: function(store, records, success) { if (!success) { return; } @@ -67,6 +72,7 @@ Ext.define('PBS.Dashboard', { // 2 = all good, 1 = different leves, 0 = none let subStatus = status.toLowerCase() === 'active' ? 2 : 0; me.lookup('subscription').setSubStatus(subStatus); + me.lookup('nodeInfo').setSubscriptionStatus(subStatus); }, updateTasks: function(store, records, success) { @@ -131,6 +137,21 @@ Ext.define('PBS.Dashboard', { }, stores: { + repositories: { + storeid: 'dash-repositories', + type: 'update', + interval: 15000, + autoStart: true, + autoLoad: true, + autoDestroy: true, + proxy: { + type: 'proxmox', + url: '/api2/json/nodes/localhost/apt/repositories', + }, + listeners: { + load: 'updateRepositoryStatus', + }, + }, subscription: { storeid: 'dash-subscription', type: 'update', @@ -204,6 +225,7 @@ Ext.define('PBS.Dashboard', { items: [ { xtype: 'pbsNodeInfoPanel', + reference: 'nodeInfo', height: 280, }, { diff --git a/www/panel/NodeInfo.js b/www/panel/NodeInfo.js index 17bf3812..fbd5aad5 100644 --- a/www/panel/NodeInfo.js +++ b/www/panel/NodeInfo.js @@ -20,6 +20,37 @@ Ext.define('PBS.NodeInfoPanel', { padding: '0 15 5 15', }, + 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'); + return Proxmox.Utils.formatNodeRepoStatus(status, 'Proxmox Backup Server'); + }, + }, + }, + controller: { xclass: 'Ext.app.ViewController', @@ -147,6 +178,18 @@ Ext.define('PBS.NodeInfoPanel', { textField: 'kversion', 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() { @@ -155,6 +198,31 @@ Ext.define('PBS.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; + + 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.30.2