public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui] dashboard: node status: use repo status widget from widget-toolkit
Date: Thu, 22 Jul 2021 15:31:39 +0200	[thread overview]
Message-ID: <20210722133139.2341350-1-f.ebner@proxmox.com> (raw)

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

Depends on
https://lists.proxmox.com/pipermail/pbs-devel/2021-July/003764.html
and needs a dependency bump for it.

 js/Dashboard.js          |  6 ++--
 js/dashboard/NodeInfo.js | 72 ++--------------------------------------
 2 files changed, 7 insertions(+), 71 deletions(-)

diff --git a/js/Dashboard.js b/js/Dashboard.js
index 3d8bca3..03965c6 100644
--- a/js/Dashboard.js
+++ b/js/Dashboard.js
@@ -140,7 +140,8 @@ Ext.define('PMG.Dashboard', {
 	    var subscriptionPanel = me.lookup('subscription');
 	    subscriptionPanel.setSubStatus(subStatus);
 
-	    me.lookup('nodeInfo').setSubscriptionStatus(subStatus);
+	    let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+	    repoStatus.setSubscriptionStatus(subStatus);
 
 	    // the node info already displays this information in case there is no cluster
 	    me.lookup('clusterResources').setHidden(records.length === 1);
@@ -174,7 +175,8 @@ Ext.define('PMG.Dashboard', {
 	    }
 
 	    let me = this;
-	    me.lookup('nodeInfo').setRepositoryInfo(records[0].data['standard-repos']);
+	    let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+	    repoStatus.setRepositoryInfo(records[0].data['standard-repos']);
 	},
 
 	init: function(view) {
diff --git a/js/dashboard/NodeInfo.js b/js/dashboard/NodeInfo.js
index bdf8f85..7952d03 100644
--- a/js/dashboard/NodeInfo.js
+++ b/js/dashboard/NodeInfo.js
@@ -17,41 +17,6 @@ Ext.define('PMG.NodeInfoPanel', {
 	padding: '0 10 5 10',
     },
 
-    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');
-		let repoLink = ` <a data-qtip="${gettext("Open Repositories Panel")}"
-		    href="#pmgServerAdministration:aptrepositories">
-		    <i class="fa black fa-chevron-right txt-shadow-hover"></i>
-		    </a>`;
-		return Proxmox.Utils.formatNodeRepoStatus(status, 'Proxmox Mail Gateway') + repoLink;
-	    },
-	},
-    },
-
     items: [
 	{
 	    itemId: 'nodecpu',
@@ -127,16 +92,10 @@ Ext.define('PMG.NodeInfoPanel', {
 	    value: '',
 	},
 	{
+	    xtype: 'pmxNodeInfoRepoStatus',
 	    itemId: 'repositoryStatus',
-	    colspan: 2,
-	    printBar: false,
-	    title: gettext('Repository Status'),
-	    setValue: function(value) { // for binding below
-		this.updateValue(value);
-	    },
-	    bind: {
-		value: '{repoStatusMessage}',
-	    },
+	    product: 'Proxmox Mail Gateway',
+	    repoLink: '#pmgServerAdministration:aptrepositories',
 	},
     ],
 
@@ -146,31 +105,6 @@ Ext.define('PMG.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 || 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;
 
-- 
2.30.2





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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 13:31 Fabian Ebner [this message]
2021-07-23  7:09 ` Fabian 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=20210722133139.2341350-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pmg-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal