public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE
@ 2021-07-02 10:48 Dominik Csapak
  2021-07-02 10:48 ` [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid Dominik Csapak
  2021-07-02 13:43 ` [pve-devel] applied: [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-07-02 10:48 UTC (permalink / raw)
  To: pve-devel

we'll need it here too

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Utils.js | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/Utils.js b/src/Utils.js
index bc602de..866cd83 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1106,6 +1106,42 @@ utilities: {
 	container.updateLayout();
 	container.updateLayout();
     },
+
+    get_health_icon: function(state, circle) {
+	if (circle === undefined) {
+	    circle = false;
+	}
+
+	if (state === undefined) {
+	    state = 'uknown';
+	}
+
+	var icon = 'faded fa-question';
+	switch (state) {
+	    case 'good':
+		icon = 'good fa-check';
+		break;
+	    case 'upgrade':
+		icon = 'warning fa-upload';
+		break;
+	    case 'old':
+		icon = 'warning fa-refresh';
+		break;
+	    case 'warning':
+		icon = 'warning fa-exclamation';
+		break;
+	    case 'critical':
+		icon = 'critical fa-times';
+		break;
+	    default: break;
+	}
+
+	if (circle) {
+	    icon += '-circle';
+	}
+
+	return icon;
+    },
 },
 
     singleton: true,
-- 
2.30.2





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

* [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid
  2021-07-02 10:48 [pve-devel] [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE Dominik Csapak
@ 2021-07-02 10:48 ` Dominik Csapak
  2021-07-02 13:43   ` [pve-devel] applied: " Thomas Lamprecht
  2021-07-02 13:43 ` [pve-devel] applied: [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Dominik Csapak @ 2021-07-02 10:48 UTC (permalink / raw)
  To: pve-devel

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 <d.csapak@proxmox.com>
---
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 = `<i class='fa fa-fw fa-exclamation-triangle critical'></i>`;
-		let fmt = (msg) => `<div class="black">${icon}${gettext('Warning')}: ${msg}</div>`;
-
-		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: [
+			'<center>',
+			'<i class="fa fa-4x {iconCls}"></i>',
+			'<br/><br/>',
+			'{text}',
+			'</center>',
+		    ],
+		},
+		{
+		    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





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

* [pve-devel] applied: [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE
  2021-07-02 10:48 [pve-devel] [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE Dominik Csapak
  2021-07-02 10:48 ` [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid Dominik Csapak
@ 2021-07-02 13:43 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-07-02 13:43 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 02.07.21 12:48, Dominik Csapak wrote:
> we'll need it here too
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/Utils.js | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
>

applied, thanks!




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

* [pve-devel] applied: [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid
  2021-07-02 10:48 ` [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid Dominik Csapak
@ 2021-07-02 13:43   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-07-02 13:43 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 02.07.21 12:48, Dominik Csapak wrote:
> 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 <d.csapak@proxmox.com>
> ---
> 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(-)
> 
>

applied, thanks!




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

end of thread, other threads:[~2021-07-02 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 10:48 [pve-devel] [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE Dominik Csapak
2021-07-02 10:48 ` [pve-devel] [PATCH widget-toolkit 2/2] node/APTRepositories: rework top status and error grid Dominik Csapak
2021-07-02 13:43   ` [pve-devel] applied: " Thomas Lamprecht
2021-07-02 13:43 ` [pve-devel] applied: [PATCH widget-toolkit 1/2] Utils: add get_health_icon from PVE 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