From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: node summary: show repository configuration status
Date: Wed, 23 Jun 2021 18:11:26 +0200 [thread overview]
Message-ID: <20210623161126.218308-1-f.ebner@proxmox.com> (raw)
I tried to use itemid and lookupreference for the nodeStatus item, but couldn't
get it to work, so I factored it out.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
Depends on the APT repositories API/UI series.
https://lists.proxmox.com/pipermail/pve-devel/2021-June/048963.html
www/manager6/node/StatusView.js | 102 ++++++++++++++++++++++++++++++++
www/manager6/node/Summary.js | 49 +++++++++++++--
2 files changed, 145 insertions(+), 6 deletions(-)
diff --git a/www/manager6/node/StatusView.js b/www/manager6/node/StatusView.js
index 564658c4..f4a55d14 100644
--- a/www/manager6/node/StatusView.js
+++ b/www/manager6/node/StatusView.js
@@ -2,6 +2,69 @@ 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('subscriptionActive') && get('enterpriseRepo')) {
+ return 'no-sub';
+ }
+
+ if (get('noSubscriptionRepo') || get('testRepo')) {
+ return 'non-production';
+ }
+
+ if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) {
+ return 'no-repo';
+ }
+
+ return 'ok';
+ },
+ repoStatusMessage: function(get) {
+ const status = get('repoStatus');
+
+ if (status === 'ok') {
+ return gettext('Enterprise repository and subscription active');
+ } else if (status === 'no-sub') {
+ return gettext('Enterprise repository enabled, but no active subscription');
+ } else if (status === 'non-production') {
+ return gettext('No-subscription or test repository in use');
+ } else if (status === 'no-repo') {
+ return gettext('No PVE repository is enabled!');
+ }
+
+ return Proxmox.Utils.unknownText;
+ },
+ repoStatusIconCls: function(get) {
+ const status = get('repoStatus');
+
+ let iconCls = (cls) => `fa fa-fw ${cls}`;
+
+ if (status === 'ok') {
+ return iconCls('fa-check good');
+ } else if (status === 'no-sub') {
+ return iconCls('fa-exclamation-triangle critical');
+ } else if (status === 'non-production') {
+ return iconCls('fa-exclamation-triangle warning');
+ } else if (status === 'no-repo') {
+ return iconCls('fa-exclamation-triangle critical');
+ }
+
+ return iconCls('fa-question-circle-o');
+ },
+ },
+ },
+
height: 300,
bodyPadding: '20 15 20 15',
@@ -113,6 +176,21 @@ Ext.define('PVE.node.StatusView', {
textField: 'pveversion',
value: '',
},
+ {
+ itemId: 'repositoryStatus',
+ colspan: 2,
+ printBar: false,
+ title: gettext('Repository Configuration Status'),
+ // for bind
+ setValue: function(value) {
+ let me = this;
+ me.updateValue(value);
+ },
+ bind: {
+ iconCls: '{repoStatusIconCls}',
+ value: '{repoStatusMessage}',
+ },
+ },
],
updateTitle: function() {
@@ -121,4 +199,28 @@ Ext.define('PVE.node.StatusView', {
me.setTitle(me.pveSelNode.data.node + ' (' + 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);
+ },
});
diff --git a/www/manager6/node/Summary.js b/www/manager6/node/Summary.js
index 1c93ef04..f3709dfc 100644
--- a/www/manager6/node/Summary.js
+++ b/www/manager6/node/Summary.js
@@ -83,6 +83,38 @@ Ext.define('PVE.node.Summary', {
});
},
+ updateRepositoryStatus: function() {
+ let me = this;
+ let nodeStatus = me.nodeStatus;
+
+ let nodename = me.pveSelNode.data.node;
+
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${nodename}/apt/repositories`,
+ method: 'GET',
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response, opts) {
+ nodeStatus.setRepositoryInfo(response.result.data['standard-repos']);
+ },
+ });
+
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${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');
+ nodeStatus.setSubscriptionStatus(subscription);
+ },
+ });
+ },
+
initComponent: function() {
var me = this;
@@ -109,8 +141,16 @@ Ext.define('PVE.node.Summary', {
model: 'pve-rrd-node',
});
+ let nodeStatus = Ext.create('PVE.node.StatusView', {
+ xtype: 'pveNodeStatus',
+ rstore: rstore,
+ width: 770,
+ pveSelNode: me.pveSelNode,
+ });
+
Ext.apply(me, {
tbar: [version_btn, '->', { xtype: 'proxmoxRRDTypeSelector' }],
+ nodeStatus: nodeStatus,
items: [
{
xtype: 'container',
@@ -123,12 +163,7 @@ Ext.define('PVE.node.Summary', {
columnWidth: 1,
},
items: [
- {
- xtype: 'pveNodeStatus',
- rstore: rstore,
- width: 770,
- pveSelNode: me.pveSelNode,
- },
+ nodeStatus,
{
xtype: 'proxmoxRRDChart',
title: gettext('CPU usage'),
@@ -179,6 +214,8 @@ Ext.define('PVE.node.Summary', {
},
});
+ me.updateRepositoryStatus();
+
me.callParent();
let sp = Ext.state.Manager.getProvider();
--
2.30.2
next reply other threads:[~2021-06-23 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 16:11 Fabian Ebner [this message]
2021-07-05 6:52 ` [pve-devel] applied: " Thomas Lamprecht
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=20210623161126.218308-1-f.ebner@proxmox.com \
--to=f.ebner@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