all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-widget-toolkit 1/1] add NodeInfoRepoStatus
Date: Thu, 22 Jul 2021 15:27:34 +0200	[thread overview]
Message-ID: <20210722132735.2260448-1-f.ebner@proxmox.com> (raw)

adapted from PMG, because it has an additional fix to avoid setting
undefined in the view model, which still affects PBS (see pmg-gui
commit 774418f08b10c651357d11ccb161ac075e1ae905).

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/Makefile                    |   1 +
 src/panel/NodeInfoRepoStatus.js | 102 ++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 src/panel/NodeInfoRepoStatus.js

diff --git a/src/Makefile b/src/Makefile
index 36f316c..a490ccd 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -51,6 +51,7 @@ JSSRC=					\
 	panel/InputPanel.js		\
 	panel/InfoWidget.js		\
 	panel/LogView.js		\
+	panel/NodeInfoRepoStatus.js	\
 	panel/JournalView.js		\
 	panel/PermissionView.js		\
 	panel/PruneKeepPanel.js		\
diff --git a/src/panel/NodeInfoRepoStatus.js b/src/panel/NodeInfoRepoStatus.js
new file mode 100644
index 0000000..df1ca9f
--- /dev/null
+++ b/src/panel/NodeInfoRepoStatus.js
@@ -0,0 +1,102 @@
+Ext.define('Proxmox.widget.NodeInfoRepoStatus', {
+    extend: 'Proxmox.widget.Info',
+    alias: 'widget.pmxNodeInfoRepoStatus',
+
+    title: gettext('Repository Status'),
+
+    colspan: 2,
+
+    printBar: false,
+
+    product: undefined,
+    repoLink: undefined,
+
+    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) {
+		let me = this;
+		let view = me.getView();
+
+		const status = get('repoStatus');
+
+		let repoLink = ` <a data-qtip="${gettext("Open Repositories Panel")}"
+		    href="${view.repoLink}">
+		    <i class="fa black fa-chevron-right txt-shadow-hover"></i>
+		    </a>`;
+
+		return Proxmox.Utils.formatNodeRepoStatus(status, view.product) + repoLink;
+	    },
+	},
+    },
+
+    setValue: function(value) { // for binding below
+	this.updateValue(value);
+    },
+
+    bind: {
+	value: '{repoStatusMessage}',
+    },
+
+    setRepositoryInfo: function(standardRepos) {
+	let me = this;
+	let vm = me.getViewModel();
+
+	for (const standardRepo of standardRepos) {
+	    const handle = standardRepo.handle;
+	    const status = standardRepo.status || 0;
+
+	    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;
+
+	if (me.product === undefined) {
+	    throw "no product name provided";
+	}
+
+	if (me.repoLink === undefined) {
+	    throw "no repo link href provided";
+	}
+
+	me.callParent();
+    },
+});
-- 
2.30.2





             reply	other threads:[~2021-07-22 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 13:27 Fabian Ebner [this message]
2021-07-22 13:27 ` [pbs-devel] [PATCH proxmox-backup 1/1] ui: dashboard: node status: use repo status widget from widget-toolkit Fabian Ebner
2021-11-30  9:21   ` Fabian Ebner
2021-07-27 14:36 ` [pbs-devel] applied: [PATCH proxmox-widget-toolkit 1/1] add NodeInfoRepoStatus 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=20210722132735.2260448-1-f.ebner@proxmox.com \
    --to=f.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