From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v5 proxmox-widget-toolkit 08/23] APT repositories: add warnings
Date: Fri, 28 May 2021 16:29:47 +0200 [thread overview]
Message-ID: <20210528143002.16190-9-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210528143002.16190-1-f.ebner@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
Depends on the respective PBS/PVE patch for the checkrepositories call.
Otherwise there's an error message that the call is not implemented, but the
repository window should still work.
Changes from v4:
* Indentation fix.
* rebased on previous change
* set parameters for checkrepositories only if digest is not undefined
src/node/APTRepositories.js | 170 +++++++++++++++++++++++++++++++++++-
1 file changed, 168 insertions(+), 2 deletions(-)
diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js
index 71b141c..5f8b2e5 100644
--- a/src/node/APTRepositories.js
+++ b/src/node/APTRepositories.js
@@ -3,6 +3,7 @@ Ext.define('apt-repolist', {
fields: [
'Path',
'Number',
+ 'OfficialHost',
'FileType',
'Enabled',
'Comment',
@@ -56,6 +57,22 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
sortableColumns: false,
columns: [
+ {
+ header: gettext('Official'),
+ dataIndex: 'OfficialHost',
+ renderer: function(value, cell, record) {
+ let icon = (cls) => `<i class="fa fa-fw ${cls}"></i>`;
+
+ if (value === undefined || value === null) {
+ return icon('fa-question-circle-o');
+ }
+ if (!value) {
+ return icon('fa-times critical');
+ }
+ return icon('fa-check good');
+ },
+ width: 70,
+ },
{
header: gettext('Enabled'),
dataIndex: 'Enabled',
@@ -128,9 +145,90 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
},
],
+ check_repositories: function(gridData) {
+ let me = this;
+ let panel = me.up('proxmoxNodeAPTRepositories');
+ let vm = panel.getViewModel();
+
+ let params = {};
+ if (panel.digest !== undefined) {
+ params.digest = panel.digest;
+ }
+
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${me.nodename}/apt/checkrepositories`,
+ method: 'GET',
+ params: params,
+ failure: function(response, opts) {
+ me.rowBodyFeature.getAdditionalData = function() {
+ return {
+ rowBody: undefined,
+ rowBodyCls: Ext.baseCSSPrefix + 'grid-row-body-hidden',
+ };
+ };
+ me.store.loadData(gridData);
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response, opts) {
+ const data = response.result.data;
+
+ vm.set('enterpriseRepo', data.enterprise);
+ vm.set('noSubscriptionRepo', data.nosubscription);
+
+ let warnings = {};
+ let officialHosts = {};
+
+ let addLine = function(obj, key, line) {
+ if (obj[key]) {
+ obj[key] += "\n";
+ obj[key] += line;
+ } else {
+ obj[key] = line;
+ }
+ };
+
+ for (const info of data.infos) {
+ const key = `${info.path}:${info.number}`;
+ if (info.kind === 'warning' ||
+ (info.kind === 'ignore-pre-upgrade-warning' && !me.majorUpgradeAllowed)) {
+ addLine(warnings, key, gettext('Warning') + ": " + info.message);
+ } else if (info.kind === 'badge' && info.message === 'official host name') {
+ officialHosts[key] = true;
+ }
+ }
+
+ gridData.forEach(function(record) {
+ const key = `${record.Path}:${record.Number}`;
+ record.OfficialHost = !!officialHosts[key];
+ });
+
+ me.rowBodyFeature.getAdditionalData = function(innerData, rowIndex, record, orig) {
+ let headerCt = this.view.headerCt;
+ let colspan = headerCt.getColumnCount();
+
+ const key = `${innerData.Path}:${innerData.Number}`;
+ const warning_text = warnings[key];
+
+ return {
+ rowBody: '<div style="color: red; white-space: pre-line">' +
+ Ext.String.htmlEncode(warning_text) + '</div>',
+ rowBodyCls: warning_text ? '' : Ext.baseCSSPrefix + 'grid-row-body-hidden',
+ rowBodyColspan: colspan,
+ };
+ };
+
+ me.store.loadData(gridData);
+ },
+ });
+ },
+
initComponent: function() {
let me = this;
+ if (!me.nodename) {
+ throw "no node name specified";
+ }
+
let store = Ext.create('Ext.data.Store', {
model: 'apt-repolist',
groupField: 'Path',
@@ -142,6 +240,8 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
],
});
+ let rowBodyFeature = Ext.create('Ext.grid.feature.RowBody', {});
+
let groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: '{[ "File: " + values.name ]} ({rows.length} ' +
'repositor{[values.rows.length > 1 ? "ies" : "y"]})',
@@ -153,7 +253,8 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
Ext.apply(me, {
store: store,
selModel: sm,
- features: [groupingFeature],
+ rowBodyFeature: rowBodyFeature,
+ features: [groupingFeature, rowBodyFeature],
});
me.callParent();
@@ -164,19 +265,59 @@ Ext.define('Proxmox.node.APTRepositories', {
extend: 'Ext.panel.Panel',
xtype: 'proxmoxNodeAPTRepositories',
+ mixins: ['Proxmox.Mixin.CBind'],
digest: undefined,
viewModel: {
data: {
errorCount: 0,
+ subscriptionActive: '',
+ noSubscriptionRepo: '',
+ enterpriseRepo: '',
},
formulas: {
noErrors: (get) => get('errorCount') === 0,
+ mainWarning: function(get) {
+ if (get('subscriptionActive') === '' ||
+ get('noSubscriptionRepo') === '' ||
+ get('enterpriseRepo') === '') {
+ return '';
+ }
+
+ let withStyle = (msg) => "<div style='color:red;'><i class='fa fa-fw " +
+ "fa-exclamation-triangle'></i>" + gettext('Warning') + ': ' + msg + "</div>";
+
+ if (!get('subscriptionActive') && get('enterpriseRepo')) {
+ return withStyle(gettext('The enterprise repository is ' +
+ 'configured, but there is no active subscription!'));
+ }
+
+ if (get('noSubscriptionRepo')) {
+ return withStyle(gettext('The no-subscription repository is ' +
+ 'not recommended for production use!'));
+ }
+
+ if (!get('enterpriseRepo') && !get('noSubscriptionRepo')) {
+ return withStyle(gettext('Neither the enterprise repository ' +
+ 'nor the no-subscription repository is configured!'));
+ }
+
+ return '';
+ },
},
},
items: [
+ {
+ title: gettext('Warning'),
+ name: 'repositoriesMainWarning',
+ xtype: 'panel',
+ bind: {
+ title: '{mainWarning}',
+ hidden: '{!mainWarning}',
+ },
+ },
{
xtype: 'proxmoxNodeAPTRepositoriesErrors',
name: 'repositoriesErrors',
@@ -188,6 +329,10 @@ Ext.define('Proxmox.node.APTRepositories', {
{
xtype: 'proxmoxNodeAPTRepositoriesGrid',
name: 'repositoriesGrid',
+ cbind: {
+ nodename: '{nodename}',
+ majorUpgradeAllowed: '{majorUpgradeAllowed}',
+ },
},
],
@@ -202,6 +347,25 @@ Ext.define('Proxmox.node.APTRepositories', {
},
],
+ check_subscription: function() {
+ let me = this;
+ let vm = me.getViewModel();
+
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${me.nodename}/subscription`,
+ method: 'GET',
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response, opts) {
+ const res = response.result;
+ const subscription = !(res === null || res === undefined ||
+ !res || res.data.status.toLowerCase() !== 'active');
+ vm.set('subscriptionActive', subscription);
+ },
+ });
+ },
+
reload: function() {
let me = this;
let vm = me.getViewModel();
@@ -231,11 +395,13 @@ Ext.define('Proxmox.node.APTRepositories', {
me.digest = digest;
- repoGrid.store.loadData(gridData);
+ repoGrid.check_repositories(gridData); // loads gridData after updating it
vm.set('errorCount', errors.length);
errorGrid.store.loadData(errors);
});
+
+ me.check_subscription();
},
listeners: {
--
2.20.1
next prev parent reply other threads:[~2021-05-28 14:30 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 14:29 [pve-devel] [PATCH-SERIES v5] APT repositories API/UI Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 01/23] initial commit Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 02/23] add files for Debian packaging Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 03/23] add functions to check for Proxmox repositories Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 04/23] add check_repositories function Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 05/23] add common_digest helper Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-apt 06/23] add replace_suite function and constants for the current/next stable suites Fabian Ebner
2021-05-31 13:06 ` [pve-devel] [pbs-devel] " Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-widget-toolkit 07/23] add UI for APT repositories Fabian Ebner
2021-05-28 14:29 ` Fabian Ebner [this message]
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-widget-toolkit 09/23] add upgrade button Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-backup 10/23] depend on new proxmox-apt crate Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-backup 11/23] api: apt: add repositories call Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-backup 12/23] ui: add APT repositories Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [PATCH v5 proxmox-backup 13/23] add check_repositories_call Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 proxmox-backup 14/23] RFC: add upgrade_repositories call Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-rs 15/23] add cargo config Fabian Ebner
2021-05-31 12:53 ` [pve-devel] [pbs-devel] " Wolfgang Bumiller
2021-05-31 13:12 ` Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-rs 16/23] add perlmod crate with initial APT module Fabian Ebner
2021-05-31 12:55 ` [pve-devel] [pbs-devel] " Wolfgang Bumiller
2021-05-31 13:17 ` Fabian Ebner
2021-05-31 13:07 ` Wolfgang Bumiller
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-rs 17/23] add files for Debian packaging Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-rs 18/23] update .gitignore Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-rs 19/23] RFC: add upgrade_repositories wrapper Fabian Ebner
2021-05-28 14:29 ` [pve-devel] [RFC v5 pve-manager 20/23] api: apt: add call to list repositories Fabian Ebner
2021-05-28 14:30 ` [pve-devel] [RFC v5 pve-manager 21/23] ui: add panel for listing APT repositories Fabian Ebner
2021-05-28 14:30 ` [pve-devel] [RFC v5 pve-manager 22/23] api: apt: add call for repository check Fabian Ebner
2021-05-28 14:30 ` [pve-devel] [RFC v5 pve-manager 23/23] api: apt: add upgrade repos call Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210528143002.16190-9-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox