[pve-devel] [PATCH v2 manager 2/4] ui: storage selector: add new clusterView option
Fabian Ebner
f.ebner at proxmox.com
Tue Sep 21 13:22:06 CEST 2021
which allows selecting storages available in the whole cluster and
controls whether usage information or node/shared information is
displayed. It is still possible to filter by node and content type.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
Changes from v1:
* Extend existing storage selector to also support a cluster view
instead of adding a new storage selector.
www/manager6/form/StorageSelector.js | 98 +++++++++++++++++++++++-----
1 file changed, 80 insertions(+), 18 deletions(-)
diff --git a/www/manager6/form/StorageSelector.js b/www/manager6/form/StorageSelector.js
index bb56f159..5a394538 100644
--- a/www/manager6/form/StorageSelector.js
+++ b/www/manager6/form/StorageSelector.js
@@ -1,11 +1,19 @@
Ext.define('PVE.form.StorageSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pveStorageSelector',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ cbindData: {
+ clusterView: false,
+ },
allowBlank: false,
valueField: 'storage',
displayField: 'storage',
listConfig: {
+ cbind: {
+ clusterView: '{clusterView}',
+ },
width: 450,
columns: [
{
@@ -24,37 +32,87 @@ Ext.define('PVE.form.StorageSelector', {
width: 90,
dataIndex: 'avail',
renderer: Proxmox.Utils.format_size,
+ cbind: {
+ hidden: '{clusterView}',
+ },
},
{
header: gettext('Capacity'),
width: 90,
dataIndex: 'total',
renderer: Proxmox.Utils.format_size,
+ cbind: {
+ hidden: '{clusterView}',
+ },
+ },
+ {
+ header: gettext('Nodes'),
+ width: 120,
+ dataIndex: 'nodes',
+ renderer: (value) => value ? value : '-- ' + gettext('All') + ' --',
+ cbind: {
+ hidden: '{!clusterView}',
+ },
+ },
+ {
+ header: gettext('Shared'),
+ width: 70,
+ dataIndex: 'shared',
+ renderer: Proxmox.Utils.format_boolean,
+ cbind: {
+ hidden: '{!clusterView}',
+ },
},
],
},
reloadStorageList: function() {
let me = this;
- if (!me.nodename) {
- return;
- }
- let params = {
- format: 1,
- };
- if (me.storageContent) {
- params.content = me.storageContent;
- }
- if (me.targetNode) {
- params.target = me.targetNode;
- params.enabled = 1; // skip disabled storages
+ if (me.clusterView) {
+ me.getStore().setProxy({
+ type: 'proxmox',
+ url: `/api2/json/storage`,
+ });
+
+ // filter here, back-end does not support it currently
+ let filters = [(storage) => !storage.data.disable];
+
+ if (me.storageContent) {
+ filters.push(
+ (storage) => storage.data.content.split(',').includes(me.storageContent),
+ );
+ }
+
+ if (me.nodename) {
+ filters.push(
+ (storage) => !storage.data.nodes || storage.data.nodes.includes(me.nodename),
+ );
+ }
+
+ me.getStore().clearFilter();
+ me.getStore().setFilters(filters);
+ } else {
+ if (!me.nodename) {
+ return;
+ }
+
+ let params = {
+ format: 1,
+ };
+ if (me.storageContent) {
+ params.content = me.storageContent;
+ }
+ if (me.targetNode) {
+ params.target = me.targetNode;
+ params.enabled = 1; // skip disabled storages
+ }
+ me.store.setProxy({
+ type: 'proxmox',
+ url: `/api2/json/nodes/${me.nodename}/storage`,
+ extraParams: params,
+ });
}
- me.store.setProxy({
- type: 'proxmox',
- url: `/api2/json/nodes/${me.nodename}/storage`,
- extraParams: params,
- });
me.store.load(() => me.validate());
},
@@ -66,6 +124,10 @@ Ext.define('PVE.form.StorageSelector', {
return;
}
+ if (me.clusterView) {
+ throw "setting targetNode with clusterView is not implemented";
+ }
+
me.targetNode = targetNode;
me.reloadStorageList();
@@ -110,7 +172,7 @@ Ext.define('PVE.form.StorageSelector', {
}, function() {
Ext.define('pve-storage-status', {
extend: 'Ext.data.Model',
- fields: ['storage', 'active', 'type', 'avail', 'total'],
+ fields: ['storage', 'active', 'type', 'avail', 'total', 'nodes', 'shared'],
idProperty: 'storage',
});
});
--
2.30.2
More information about the pve-devel
mailing list