public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH proxmox-widget-toolkit 1/1] utils: add helper to format node's repository status
@ 2021-07-09 12:44 Fabian Ebner
  2021-07-09 12:44 ` [pve-devel] [PATCH pve-manager 1/1] ui: node status: use helper for formatting " Fabian Ebner
  2021-07-09 12:44 ` [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status Fabian Ebner
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2021-07-09 12:44 UTC (permalink / raw)
  To: pve-devel, pbs-devel

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/Utils.js | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/Utils.js b/src/Utils.js
index 8e1f9d4..19ce1f2 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1150,6 +1150,28 @@ utilities: {
 
 	return icon;
     },
+
+    formatNodeRepoStatus: function(status, product) {
+	let fmt = (txt, cls) => `<i class="fa fa-fw fa-lg fa-${cls}"></i>${txt}`;
+
+	let getUpdates = Ext.String.format(gettext('{0} updates'), product);
+	let noRepo = Ext.String.format(gettext('No {0} repository enabled!'), product);
+
+	if (status === 'ok') {
+	    return fmt(getUpdates, 'check-circle good') + ' ' +
+		fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good');
+	} else if (status === 'no-sub') {
+	    return fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good') + ' ' +
+		    fmt(gettext('Enterprise repository needs valid subscription'), 'exclamation-circle warning');
+	} else if (status === 'non-production') {
+	    return fmt(getUpdates, 'check-circle good') + ' ' +
+		   fmt(gettext('Non production-ready repository enabled!'), 'exclamation-circle warning');
+	} else if (status === 'no-repo') {
+	    return fmt(noRepo, 'exclamation-circle critical');
+	}
+
+	return Proxmox.Utils.unknownText;
+    },
 },
 
     singleton: true,
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH pve-manager 1/1] ui: node status: use helper for formatting repository status
  2021-07-09 12:44 [pve-devel] [PATCH proxmox-widget-toolkit 1/1] utils: add helper to format node's repository status Fabian Ebner
@ 2021-07-09 12:44 ` Fabian Ebner
  2021-07-09 12:44 ` [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status Fabian Ebner
  1 sibling, 0 replies; 4+ messages in thread
From: Fabian Ebner @ 2021-07-09 12:44 UTC (permalink / raw)
  To: pve-devel, pbs-devel

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

Dependency bump for widget-toolkit is needed.

 www/manager6/node/StatusView.js | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/www/manager6/node/StatusView.js b/www/manager6/node/StatusView.js
index d7a08529..3c52ce95 100644
--- a/www/manager6/node/StatusView.js
+++ b/www/manager6/node/StatusView.js
@@ -27,26 +27,7 @@ Ext.define('PVE.node.StatusView', {
 		return 'unknown';
 	    },
 	    repoStatusMessage: function(get) {
-		const status = get('repoStatus');
-
-		let fmt = (txt, cls) => `<i class="fa fa-fw fa-lg fa-${cls}"></i>${txt}`;
-
-		let getUpdates = Ext.String.format(gettext('{0} updates'), 'Proxmox VE');
-
-		if (status === 'ok') {
-		    return fmt(getUpdates, 'check-circle good') + ' ' +
-		        fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good');
-		} else if (status === 'no-sub') {
-		    return fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good') + ' ' +
-			    fmt(gettext('Enterprise repository needs valid subscription'), 'exclamation-circle warning');
-		} else if (status === 'non-production') {
-		    return fmt(getUpdates, 'check-circle good') + ' ' +
-			   fmt(gettext('Non production-ready repository enabled!'), 'exclamation-circle warning');
-		} else if (status === 'no-repo') {
-		    return fmt(gettext('No Proxmox VE repository enabled!'), 'exclamation-circle critical');
-		}
-
-		return Proxmox.Utils.unknownText;
+		return Proxmox.Utils.formatNodeRepoStatus(get('repoStatus'), 'Proxmox VE');
 	    },
 	},
     },
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status
  2021-07-09 12:44 [pve-devel] [PATCH proxmox-widget-toolkit 1/1] utils: add helper to format node's repository status Fabian Ebner
  2021-07-09 12:44 ` [pve-devel] [PATCH pve-manager 1/1] ui: node status: use helper for formatting " Fabian Ebner
@ 2021-07-09 12:44 ` Fabian Ebner
  2021-07-12  5:19   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Fabian Ebner @ 2021-07-09 12:44 UTC (permalink / raw)
  To: pve-devel, pbs-devel

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 <f.ebner@proxmox.com>
---

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [pbs-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status
  2021-07-09 12:44 ` [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status Fabian Ebner
@ 2021-07-12  5:19   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-07-12  5:19 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Fabian Ebner, pve-devel

On 09.07.21 14:44, Fabian Ebner wrote:
> 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 <f.ebner@proxmox.com>
> ---
> 
> 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(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-12  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 12:44 [pve-devel] [PATCH proxmox-widget-toolkit 1/1] utils: add helper to format node's repository status Fabian Ebner
2021-07-09 12:44 ` [pve-devel] [PATCH pve-manager 1/1] ui: node status: use helper for formatting " Fabian Ebner
2021-07-09 12:44 ` [pve-devel] [PATCH proxmox-backup 1/1] ui: dashboard: show node's repository/subscription status Fabian Ebner
2021-07-12  5:19   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal