From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/5] ui: MainView: adapt router to add changer/drive entries
Date: Mon, 1 Mar 2021 12:22:40 +0100 [thread overview]
Message-ID: <20210301112243.15842-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210301112243.15842-1-d.csapak@proxmox.com>
by generalizing the isDataStorePath logic to a 'parseRouterPath'.
We still have to keep the isDataStore logic for tabpanel handling,
If we add tabs to changer-/drivestatus panels, we have to adapt
that too.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/MainView.js | 70 +++++++++++++++++++++++++++----------------------
1 file changed, 38 insertions(+), 32 deletions(-)
diff --git a/www/MainView.js b/www/MainView.js
index 6ed86b77..e6257f35 100644
--- a/www/MainView.js
+++ b/www/MainView.js
@@ -17,17 +17,28 @@ Ext.define('PBS.MainView', {
},
},
- beforeChangePath: function(path, subpath, action) {
- var me = this;
-
+ parseRouterPath: function(path) {
let xtype = path;
- let datastore;
- let isDataStore = PBS.Utils.isDataStorePath(path);
- if (isDataStore) {
+ let config = {};
+ if (PBS.Utils.isDataStorePath(path)) {
+ config.datastore = PBS.Utils.getDataStoreFromPath(path);
xtype = 'pbsDataStorePanel';
- datastore = PBS.Utils.getDataStoreFromPath(path);
+ } else if (path.indexOf('Changer-') === 0) {
+ config.changer = path.slice('Changer-'.length);
+ xtype = 'pbsChangerStatus';
+ } else if (path.indexOf('Drive-') === 0) {
+ config.drive = path.slice('Drive-'.length);
+ xtype = 'pbsDriveStatus';
}
+ return [xtype, config];
+ },
+
+ beforeChangePath: function(path, subpath, action) {
+ var me = this;
+
+ let [xtype, config] = me.parseRouterPath(path);
+
if (!Ext.ClassManager.getByAlias(`widget.${xtype}`)) {
console.warn(`xtype ${xtype} not found`);
action.stop();
@@ -36,27 +47,26 @@ Ext.define('PBS.MainView', {
var lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
if (lastpanel && lastpanel.xtype === xtype) {
- if (isDataStore) {
- if (datastore === lastpanel.datastore) {
- action.stop();
+ for (const [prop, value] of Object.entries(config)) {
+ if (lastpanel[prop] !== value) {
+ action.resume();
return;
}
- } else {
- // we have the right component already,
- // we just need to select the correct tab
- // default to the first
- subpath = subpath || 0;
- if (lastpanel.getActiveTab) {
- // we assume lastpanel is a tabpanel
- if (lastpanel.getActiveTab().getItemId() !== subpath) {
- // set the active tab
- lastpanel.setActiveTab(subpath);
- }
- // else we are already there
+ }
+ // we have the right component already,
+ // we just need to select the correct tab
+ // default to the first
+ subpath = subpath || 0;
+ if (lastpanel.getActiveTab) {
+ // we assume lastpanel is a tabpanel
+ if (lastpanel.getActiveTab().getItemId() !== subpath) {
+ // set the active tab
+ lastpanel.setActiveTab(subpath);
}
- action.stop();
- return;
+ // else we are already there
}
+ action.stop();
+ return;
}
action.resume();
@@ -79,12 +89,10 @@ Ext.define('PBS.MainView', {
me.redirectTo(newpath);
};
- let xtype = path;
+ let [xtype, config] = me.parseRouterPath(path);
var obj;
- let datastore;
if (PBS.Utils.isDataStorePath(path)) {
- datastore = PBS.Utils.getDataStoreFromPath(path);
- if (lastpanel && lastpanel.xtype === 'pbsDataStorePanel' && !subpath) {
+ if (lastpanel && lastpanel.xtype === xtype && !subpath) {
let activeTab = lastpanel.getActiveTab();
let newpath = path;
if (lastpanel.items.indexOf(activeTab) !== 0) {
@@ -93,18 +101,16 @@ Ext.define('PBS.MainView', {
}
me.redirectTo(newpath);
}
- xtype = 'pbsDataStorePanel';
}
- obj = contentpanel.add({
+ obj = contentpanel.add(Ext.apply(config, {
xtype,
- datastore,
nodename: 'localhost',
border: false,
activeTab: subpath || 0,
listeners: {
tabchange: tabChangeListener,
},
- });
+ }));
var treelist = me.lookupReference('navtree');
--
2.20.1
next prev parent reply other threads:[~2021-03-01 11:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 11:22 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel Dominik Csapak
2021-03-01 11:22 ` Dominik Csapak [this message]
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: NavigationTree: add entries for changers/drives Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape: ChangerStatus: remove changerselector combobox Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/ChangerStatus: handle vanishing view during reload Dominik Csapak
2021-03-01 11:39 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel Dietmar Maurer
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=20210301112243.15842-2-d.csapak@proxmox.com \
--to=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox