* [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions @ 2021-02-08 14:23 Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] convert disk list to disk tree and conditionally include partitions Fabian Ebner ` (4 more replies) 0 siblings, 5 replies; 7+ messages in thread From: Fabian Ebner @ 2021-02-08 14:23 UTC (permalink / raw) To: pve-devel The UI part still remains. Changes from v1: * dropped already applied patches * made sure it's backwards compatible (thanks to Thomas for catching this!) widget-toolkit: Fabian Ebner (2): convert disk list to disk tree and conditionally include partitions move DiskList.js from grid/ to panel/ src/Makefile | 2 +- src/{grid => panel}/DiskList.js | 100 ++++++++++++++++++++++++++------ 2 files changed, 82 insertions(+), 20 deletions(-) rename src/{grid => panel}/DiskList.js (73%) manager: Fabian Ebner (1): ui: disk list: include partitions www/manager6/node/Config.js | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v2 widget-toolkit 1/3] convert disk list to disk tree and conditionally include partitions 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner @ 2021-02-08 14:23 ` Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] move DiskList.js from grid/ to panel/ Fabian Ebner ` (3 subsequent siblings) 4 siblings, 0 replies; 7+ messages in thread From: Fabian Ebner @ 2021-02-08 14:23 UTC (permalink / raw) To: pve-devel Assigning the store directly to the treepanel doesn't work, more manual handling is needed. This is mostly based on what we do for PBS's datastore content view. The store monitoring also needs to be changed slightly. The buttons are restricted to work on disks only, based on the parent attribute, that only partitions have. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- Changes from v1: * use the 'include-partitions' parameter only if the parent wants it src/grid/DiskList.js | 100 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 19 deletions(-) diff --git a/src/grid/DiskList.js b/src/grid/DiskList.js index 54f58f8..b67fbd1 100644 --- a/src/grid/DiskList.js +++ b/src/grid/DiskList.js @@ -36,20 +36,35 @@ Ext.define('pmx-disk-list', { }); Ext.define('Proxmox.DiskList', { - extend: 'Ext.grid.GridPanel', + extend: 'Ext.tree.Panel', alias: 'widget.pmxDiskList', + rootVisible: false, + emptyText: gettext('No Disks found'), stateful: true, - stateId: 'grid-node-disks', + stateId: 'tree-node-disks', controller: { xclass: 'Ext.app.ViewController', reload: function() { let me = this; - me.getView().getStore().load(); + let view = me.getView(); + + let extraParams = {}; + if (view.includePartitions) { + extraParams['include-partitions'] = 1; + } + + let url = `${view.baseurl}/list`; + me.store.setProxy({ + type: 'proxmox', + extraParams: extraParams, + url: url, + }); + me.store.load(); }, openSmartWindow: function() { @@ -94,27 +109,63 @@ Ext.define('Proxmox.DiskList', { }, init: function(view) { - Proxmox.Utils.monStoreErrors(view, view.getStore(), true); - let nodename = view.nodename || 'localhost'; view.baseurl = `/api2/json/nodes/${nodename}/disks`; view.exturl = `/api2/extjs/nodes/${nodename}/disks`; - view.getStore().getProxy().setUrl(`${view.baseurl}/list`); - view.getStore().load(); + + this.store = Ext.create('Ext.data.Store', { + model: 'pmx-disk-list', + }); + this.store.on('load', this.onLoad, this); + + Proxmox.Utils.monStoreErrors(view, this.store); + this.reload(); }, - }, - store: { - model: 'pmx-disk-list', - proxy: { - type: 'proxmox', + onLoad: function(store, records, success, operation) { + let me = this; + let view = this.getView(); + + if (!success) { + Proxmox.Utils.setErrorMask( + view, + Proxmox.Utils.getResponseErrorMessage(operation.getError()), + ); + return; + } + + let disks = {}; + + for (const item of records) { + let data = item.data; + data.leaf = true; + data.expanded = true; + data.children = []; + data.iconCls = 'fa fa-fw fa-hdd-o x-fa-tree'; + if (!data.parent) { + disks[data.devpath] = data; + } + } + for (const item of records) { + let data = item.data; + if (data.parent) { + disks[data.parent].leaf = false; + disks[data.parent].children.push(data); + } + } + + let children = []; + for (const [_, device] of Object.entries(disks)) { + children.push(device); + } + + view.setRootNode({ + expanded: true, + children: children, + }); + + Proxmox.Utils.setErrorMask(view, false); }, - sorters: [ - { - property: 'dev', - direction: 'ASC', - }, - ], }, tbar: [ @@ -125,15 +176,25 @@ Ext.define('Proxmox.DiskList', { { xtype: 'proxmoxButton', text: gettext('Show S.M.A.R.T. values'), + parentXType: 'treepanel', disabled: true, + enableFn: function(rec) { + if (!rec || rec.data.parent) { + return false; + } else { + return true; + } + }, handler: 'openSmartWindow', }, { xtype: 'proxmoxButton', text: gettext('Initialize Disk with GPT'), + parentXType: 'treepanel', disabled: true, enableFn: function(rec) { - if (!rec || (rec.data.used && rec.data.used !== 'unused')) { + if (!rec || rec.data.parent || + (rec.data.used && rec.data.used !== 'unused')) { return false; } else { return true; @@ -145,6 +206,7 @@ Ext.define('Proxmox.DiskList', { columns: [ { + xtype: 'treecolumn', header: gettext('Device'), width: 150, sortable: true, -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v2 widget-toolkit 2/3] move DiskList.js from grid/ to panel/ 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] convert disk list to disk tree and conditionally include partitions Fabian Ebner @ 2021-02-08 14:23 ` Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 manager 3/3] ui: disk list: include partitions Fabian Ebner ` (2 subsequent siblings) 4 siblings, 0 replies; 7+ messages in thread From: Fabian Ebner @ 2021-02-08 14:23 UTC (permalink / raw) To: pve-devel because it's a treepanel now. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- src/Makefile | 2 +- src/{grid => panel}/DiskList.js | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{grid => panel}/DiskList.js (100%) diff --git a/src/Makefile b/src/Makefile index fbc2627..46b90ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,7 +37,7 @@ JSSRC= \ button/HelpButton.js \ grid/ObjectGrid.js \ grid/PendingObjectGrid.js \ - grid/DiskList.js \ + panel/DiskList.js \ panel/InputPanel.js \ panel/InfoWidget.js \ panel/LogView.js \ diff --git a/src/grid/DiskList.js b/src/panel/DiskList.js similarity index 100% rename from src/grid/DiskList.js rename to src/panel/DiskList.js -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v2 manager 3/3] ui: disk list: include partitions 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] convert disk list to disk tree and conditionally include partitions Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] move DiskList.js from grid/ to panel/ Fabian Ebner @ 2021-02-08 14:23 ` Fabian Ebner 2021-02-09 8:04 ` [pve-devel] [PATCH v2 storage] Diskmanage: also set type for partitions Fabian Ebner 2021-02-09 12:40 ` [pve-devel] applied-series: [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Thomas Lamprecht 4 siblings, 0 replies; 7+ messages in thread From: Fabian Ebner @ 2021-02-08 14:23 UTC (permalink / raw) To: pve-devel Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- New in v2 Dependency bump manager -> pve-storage needed, because of the indirect dependency via widget-toolkit using the new API parameter. The dependency manager -> widget-toolkit itself is soft, because the parameter is simply ignored when manager is new and widget-toolkit is old. www/manager6/node/Config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index ef3ac32c..8bc1d3f8 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -278,6 +278,7 @@ Ext.define('PVE.node.Config', { expandedOnInit: true, iconCls: 'fa fa-hdd-o', nodename: nodename, + includePartitions: true, }, { xtype: 'pveLVMList', -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v2 storage] Diskmanage: also set type for partitions 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner ` (2 preceding siblings ...) 2021-02-08 14:23 ` [pve-devel] [PATCH v2 manager 3/3] ui: disk list: include partitions Fabian Ebner @ 2021-02-09 8:04 ` Fabian Ebner 2021-02-09 10:57 ` [pve-devel] applied: " Thomas Lamprecht 2021-02-09 12:40 ` [pve-devel] applied-series: [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Thomas Lamprecht 4 siblings, 1 reply; 7+ messages in thread From: Fabian Ebner @ 2021-02-09 8:04 UTC (permalink / raw) To: pve-devel Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- New in v2 Forgot to include this one yesterday. I chose to simply use the generic 'partition', because the information whether it's GPT or not is already present. PVE/Diskmanage.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index 78f7865..e356fb3 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -668,6 +668,7 @@ sub get_disks { $partitions->{$part}->{devpath} = "$partpath/$part"; $partitions->{$part}->{parent} = "$devpath"; $partitions->{$part}->{gpt} = $data->{gpt}; + $partitions->{$part}->{type} = 'partition'; $partitions->{$part}->{size} = get_sysdir_size("$sysdir/$part") // 0; $partitions->{$part}->{used} = -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] applied: [PATCH v2 storage] Diskmanage: also set type for partitions 2021-02-09 8:04 ` [pve-devel] [PATCH v2 storage] Diskmanage: also set type for partitions Fabian Ebner @ 2021-02-09 10:57 ` Thomas Lamprecht 0 siblings, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2021-02-09 10:57 UTC (permalink / raw) To: Proxmox VE development discussion, Fabian Ebner On 09.02.21 09:04, Fabian Ebner wrote: > Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> > --- > > New in v2 > > Forgot to include this one yesterday. I chose to simply use the generic > 'partition', because the information whether it's GPT or not is already present. > > PVE/Diskmanage.pm | 1 + > 1 file changed, 1 insertion(+) > > applied, thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] applied-series: [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner ` (3 preceding siblings ...) 2021-02-09 8:04 ` [pve-devel] [PATCH v2 storage] Diskmanage: also set type for partitions Fabian Ebner @ 2021-02-09 12:40 ` Thomas Lamprecht 4 siblings, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2021-02-09 12:40 UTC (permalink / raw) To: Proxmox VE development discussion, Fabian Ebner On 08.02.21 15:23, Fabian Ebner wrote: > The UI part still remains. > > > Changes from v1: > * dropped already applied patches > * made sure it's backwards compatible (thanks to Thomas for catching this!) > > > widget-toolkit: > > Fabian Ebner (2): > convert disk list to disk tree and conditionally include partitions > move DiskList.js from grid/ to panel/ > > src/Makefile | 2 +- > src/{grid => panel}/DiskList.js | 100 ++++++++++++++++++++++++++------ > 2 files changed, 82 insertions(+), 20 deletions(-) > rename src/{grid => panel}/DiskList.js (73%) > > > manager: > > Fabian Ebner (1): > ui: disk list: include partitions > > www/manager6/node/Config.js | 1 + > 1 file changed, 1 insertion(+) > applied, thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-09 12:41 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-08 14:23 [pve-devel] [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] convert disk list to disk tree and conditionally include partitions Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] move DiskList.js from grid/ to panel/ Fabian Ebner 2021-02-08 14:23 ` [pve-devel] [PATCH v2 manager 3/3] ui: disk list: include partitions Fabian Ebner 2021-02-09 8:04 ` [pve-devel] [PATCH v2 storage] Diskmanage: also set type for partitions Fabian Ebner 2021-02-09 10:57 ` [pve-devel] applied: " Thomas Lamprecht 2021-02-09 12:40 ` [pve-devel] applied-series: [PATCH-SERIES v2] partially fix #2285: extend Diskmanage to also list partitions Thomas Lamprecht
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox