all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v3 proxmox-backup] ui: warn of missing gc-schedule, prune/verify jobs
Date: Wed,  6 Dec 2023 12:31:01 +0100	[thread overview]
Message-ID: <20231206113101.139743-1-c.ebner@proxmox.com> (raw)

Warn about a missing garbage collection schedule, prune job or verify
job configurations in the datastore's summary panel.

Show the number of prune/verify job configurations, if there are jobs
configured.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 2:
- move message string initialization to controllers `init` function

changes since version 1:
- add check mark icon for configured jobs/schedule
- add question mark icon for unknown configuration state
- fix typo in garbage collection variable name
- add missing trailing commas found by pve-eslint
- refactor message initialization to allow to use format helper
  functions
 www/datastore/Summary.js | 96 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/www/datastore/Summary.js b/www/datastore/Summary.js
index a932b4e0..273a5bf0 100644
--- a/www/datastore/Summary.js
+++ b/www/datastore/Summary.js
@@ -49,12 +49,30 @@ Ext.define('PBS.DataStoreInfo', {
 	    usage: {},
 	    stillbad: 0,
 	    mountpoint: "",
+	    gcScheduleMsg: "",
+	    pruneJobMsg: "",
+	    verifyJobMsg: "",
 	},
     },
 
     controller: {
 	xclass: 'Ext.app.ViewController',
 
+	fmtConfigured: function(fmtString, params) {
+	    let msg = Ext.String.format(fmtString, params);
+	    return `<i class="fa fa-fw fa-lg fa-check-circle good"></i> ${msg}`;
+	},
+
+	fmtMissing: function(fmtString, params) {
+	    let msg = Ext.String.format(fmtString, params);
+	    return `<i class="fa fa-fw fa-lg fa-question-circle-o warning"></i> ${msg}`;
+	},
+
+	fmtWarning: function(fmtString, params) {
+	    let msg = Ext.String.format(fmtString, params);
+	    return `<i class="fa fa-fw fa-lg fa-exclamation-circle warning"></i> ${msg}`;
+	},
+
 	onLoad: function(store, data, success) {
 	    let me = this;
 	    if (!success) {
@@ -101,6 +119,50 @@ Ext.define('PBS.DataStoreInfo', {
 	    vm.set('ctcount', countstext(counts.ct));
 	    vm.set('vmcount', countstext(counts.vm));
 	    vm.set('hostcount', countstext(counts.host));
+
+	    Proxmox.Utils.API2Request({
+		url: `/config/datastore/${me.view.datastore}`,
+		success: function(response) {
+		    if (response.result.data['gc-schedule']) {
+			vm.set('gcScheduleMsg', me.fmtConfigured(gettext('configured')));
+		    } else {
+			vm.set('gcScheduleMsg', me.fmtWarning(gettext('none configured')));
+		    }
+		},
+		failure: function() {
+		    vm.set('gcScheduleMsg', me.fmtMissing(gettext('unknown')));
+		},
+	    });
+
+	    Proxmox.Utils.API2Request({
+		url: `/admin/prune?store=${me.view.datastore}`,
+		success: function(response) {
+		    let len = response.result.data.length;
+		    if (len > 0) {
+			vm.set('pruneJobMsg', me.fmtConfigured(gettext('{0} configured'), len));
+		    } else {
+			vm.set('pruneJobMsg', me.fmtWarning(gettext('none configured')));
+		    }
+		},
+		failure: function() {
+		    vm.set('pruneJobMsg', me.fmtMissing(gettext('unknown')));
+		},
+	    });
+
+	    Proxmox.Utils.API2Request({
+		url: `/admin/verify?store=${me.view.datastore}`,
+		success: function(response) {
+		    let len = response.result.data.length;
+		    if (len > 0) {
+			vm.set('verifyJobMsg', me.fmtConfigured(gettext('{0} configured'), len));
+		    } else {
+			vm.set('verifyJobMsg', me.fmtWarning(gettext('none configured')));
+		    }
+		},
+		failure: function() {
+		    vm.set('verifyJobMsg', me.fmtMissing(gettext('unknown')));
+		},
+	    });
 	},
 
 	startStore: function() { this.store.startUpdate(); },
@@ -108,6 +170,12 @@ Ext.define('PBS.DataStoreInfo', {
 
 	init: function(view) {
 	    let me = this;
+
+	    let vm = me.getViewModel();
+	    vm.set('gcScheduleMsg', me.fmtMissing(gettext('unknown')));
+	    vm.set('pruneJobMsg', me.fmtMissing(gettext('unknown')));
+	    vm.set('verifyJobMsg', me.fmtMissing(gettext('unknown')));
+
 	    let datastore = encodeURIComponent(view.datastore);
 	    me.store = Ext.create('Proxmox.data.ObjectStore', {
 		interval: 5*1000,
@@ -201,6 +269,34 @@ Ext.define('PBS.DataStoreInfo', {
 		visible: '{stillbad}',
 	    },
 	},
+	{
+	    title: gettext('Garbage Collection Schedule'),
+	    printBar: false,
+	    bind: {
+		data: {
+		    text: '{gcScheduleMsg}',
+		},
+	    },
+	    padding: '10 0 0 0',
+	},
+	{
+	    title: gettext('Prune Jobs'),
+	    printBar: false,
+	    bind: {
+		data: {
+		    text: '{pruneJobMsg}',
+		},
+	    },
+	},
+	{
+	    title: gettext('Verify Jobs'),
+	    printBar: false,
+	    bind: {
+		data: {
+		    text: '{verifyJobMsg}',
+		},
+	    },
+	},
     ],
 });
 
-- 
2.39.2





             reply	other threads:[~2023-12-06 11:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 11:31 Christian Ebner [this message]
2023-12-06 13:37 ` Gabriel Goller
2023-12-06 14:09 ` Fabian Grünbichler
2023-12-06 14:43   ` Christian Ebner
2023-12-11  9:09     ` Thomas Lamprecht
2023-12-11  9:44       ` Christian Ebner
2023-12-11 10:43         ` Thomas Lamprecht
2023-12-11 10:59           ` Christian 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=20231206113101.139743-1-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal