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 1243A72920 for ; Fri, 2 Jul 2021 12:49:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 07DA42F95D for ; Fri, 2 Jul 2021 12:49:02 +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 2ECC92F954 for ; Fri, 2 Jul 2021 12:49:01 +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 F0E1E4051A for ; Fri, 2 Jul 2021 12:49:00 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 2 Jul 2021 12:48:59 +0200 Message-Id: <20210702104859.3515832-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210702104859.3515832-1-d.csapak@proxmox.com> References: <20210702104859.3515832-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.687 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. [info.property, res.data] Subject: [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid 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, 02 Jul 2021 10:49:32 -0000 instead of having a title bar and a seperate error grid, add an always visible panel that displays the status (ok, warning, errors) which also contains the error grid (if necessary, ala ceph summary) this makes the panel more consistent to use and it is immediatly visible if something is wrong this also adds a test for the 'test' repositories, as well as a test for not correctly configured suites Signed-off-by: Dominik Csapak --- we should probably only emit a warning for suites for Proxmox and Debian origin, since other vendors may use different suites for their packages (e.g. google ships all chrome debs in the 'stable' suite) src/node/APTRepositories.js | 147 ++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 49 deletions(-) diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js index 134e65d..43d6faf 100644 --- a/src/node/APTRepositories.js +++ b/src/node/APTRepositories.js @@ -108,11 +108,9 @@ Ext.define('Proxmox.node.APTRepositoriesErrors', { xtype: 'proxmoxNodeAPTRepositoriesErrors', - title: gettext('Errors'), - store: {}, - border: false, + scrollable: true, viewConfig: { stripeRows: false, @@ -419,6 +417,50 @@ Ext.define('Proxmox.node.APTRepositories', { let rec = selection[0]; let vm = me.getViewModel(); vm.set('selectionenabled', rec.get('Enabled')); + vm.notify(); + }, + + updateState: function() { + let me = this; + let vm = me.getViewModel(); + + if (vm.get('errorCount') > 0) { + vm.set('state', { + iconCls: Proxmox.Utils.get_health_icon('critical', true), + text: gettext('Error parsing repositories'), + }); + return; + } + + let text = gettext('Repositories are configured in a recommended way'); + let status = 'warning'; + + let activeSubscription = vm.get('subscriptionActive'); + let enterprise = vm.get('enterpriseRepo'); + let nosubscription = vm.get('noSubscriptionRepo'); + let test = vm.get('testRepo'); + let wrongSuites = vm.get('suitesWarning'); + + if (!activeSubscription && enterprise) { + text = gettext('The enterprise repository is enabled, but there is no active subscription!'); + } else if (nosubscription) { + text = gettext('The no-subscription repository is not recommended for production use!'); + } else if (test) { + text = gettext('The test repository is not recommended for production use!'); + } else if (!enterprise && !nosubscription && !test) { + text = Ext.String.format(gettext('No {0} repository is enabled!'), vm.get('product')); + } else if (wrongSuites) { + text = gettext('Some Suites are misconfigured'); + } else { + status = 'good'; + } + + let iconCls = Proxmox.Utils.get_health_icon(status, true); + + vm.set('state', { + iconCls, + text, + }); }, }, @@ -426,40 +468,18 @@ Ext.define('Proxmox.node.APTRepositories', { data: { product: 'Proxmox VE', // default errorCount: 0, + suitesWarning: false, subscriptionActive: '', noSubscriptionRepo: '', enterpriseRepo: '', + testRepo: '', selectionenabled: false, + state: {}, }, formulas: { noErrors: (get) => get('errorCount') === 0, enableButtonText: (get) => get('selectionenabled') ? gettext('Disable') : gettext('Enable'), - mainWarning: function(get) { - // Not yet initialized - if (get('subscriptionActive') === '' || - get('enterpriseRepo') === '') { - return ''; - } - - let icon = ``; - let fmt = (msg) => `
${icon}${gettext('Warning')}: ${msg}
`; - - if (!get('subscriptionActive') && get('enterpriseRepo')) { - return fmt(gettext('The enterprise repository is enabled, but there is no active subscription!')); - } - - if (get('noSubscriptionRepo')) { - return fmt(gettext('The no-subscription repository is not recommended for production use!')); - } - - if (!get('enterpriseRepo') && !get('noSubscriptionRepo')) { - let msg = Ext.String.format(gettext('No {0} repository is enabled!'), get('product')); - return fmt(msg); - } - - return ''; - }, }, }, @@ -471,32 +491,50 @@ Ext.define('Proxmox.node.APTRepositories', { items: [ { - xtype: 'header', - baseCls: 'x-panel-header', - bind: { - hidden: '{!mainWarning}', - title: '{mainWarning}', - }, - }, - { - xtype: 'box', - bind: { - hidden: '{!mainWarning}', - }, - height: 5, - }, - { - xtype: 'proxmoxNodeAPTRepositoriesErrors', - name: 'repositoriesErrors', - hidden: true, - padding: '0 0 5 0', - bind: { - hidden: '{noErrors}', + xtype: 'panel', + border: false, + layout: { + type: 'hbox', + align: 'stretch', }, + height: 150, + title: gettext('Status'), + items: [ + { + xtype: 'box', + flex: 1, + margin: 10, + data: { + iconCls: Proxmox.Utils.get_health_icon(undefined, true), + text: '', + }, + bind: { + data: '{state}', + }, + tpl: [ + '
', + '', + '

', + '{text}', + '
', + ], + }, + { + xtype: 'proxmoxNodeAPTRepositoriesErrors', + name: 'repositoriesErrors', + flex: 2, + hidden: true, + margin: 10, + bind: { + hidden: '{noErrors}', + }, + }, + ], }, { xtype: 'proxmoxNodeAPTRepositoriesGrid', name: 'repositoriesGrid', + flex: 1, cbind: { nodename: '{nodename}', }, @@ -519,6 +557,7 @@ Ext.define('Proxmox.node.APTRepositories', { const res = response.result; const subscription = !(!res || !res.data || res.data.status.toLowerCase() !== 'active'); vm.set('subscriptionActive', subscription); + me.getController().updateState(); }, }); }, @@ -538,7 +577,10 @@ Ext.define('Proxmox.node.APTRepositories', { vm.set('enterpriseRepo', status); } else if (handle === "no-subscription") { vm.set('noSubscriptionRepo', status); + } else if (handle === 'test') { + vm.set('testRepo', status); } + me.getController().updateState(); addButton.repoInfo.push(standardRepo); addButton.digest = me.digest; @@ -557,6 +599,7 @@ Ext.define('Proxmox.node.APTRepositories', { let gridData = []; let errors = []; let digest; + let suitesWarning = false; if (success && records.length > 0) { let data = records[0].data; @@ -585,6 +628,9 @@ Ext.define('Proxmox.node.APTRepositories', { (info.kind === 'ignore-pre-upgrade-warning' && !repoGrid.majorUpgradeAllowed) ) { infos[path][idx].warnings.push(info); + if (!suitesWarning && info.property === 'Suites') { + suitesWarning = true; + } } else { throw 'unknown info'; } @@ -612,6 +658,9 @@ Ext.define('Proxmox.node.APTRepositories', { me.digest = digest; vm.set('errorCount', errors.length); + vm.set('suitesWarning', suitesWarning); + me.getController().updateState(); + errorGrid.store.loadData(errors); }); -- 2.30.2