(multi) disk selector: allow requesting partitions too

No functional change for existing users is intended.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-09-28 13:39:51 +02:00 committed by Thomas Lamprecht
parent c91a73150f
commit f340cf64fc
2 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,9 @@ Ext.define('Proxmox.form.DiskSelector', {
// journal_disk: all disks with gpt
diskType: undefined,
// use include-partitions=1 as a parameter
includePartitions: false,
// the property the backend wnats for the type ('type' by default)
typeProperty: 'type',
@ -53,6 +56,10 @@ Ext.define('Proxmox.form.DiskSelector', {
extraParams[me.typeProperty] = me.diskType;
}
if (me.includePartitions) {
extraParams['include-partitions'] = 1;
}
var store = Ext.create('Ext.data.Store', {
filterOnLoad: true,
model: 'pmx-disk-list',

View File

@ -24,6 +24,9 @@ Ext.define('Proxmox.form.MultiDiskSelector', {
// the type of disks to show
diskType: 'unused',
// add include-partitions=1 as a request parameter
includePartitions: false,
disks: [],
allowBlank: false,
@ -141,22 +144,31 @@ Ext.define('Proxmox.form.MultiDiskSelector', {
initComponent: function() {
let me = this;
let extraParams = {};
if (!me.url) {
if (!me.nodename) {
throw "no url or nodename given";
}
let node = me.nodename;
let param = me.typeParameter;
let type = me.diskType;
me.url = `/api2/json/nodes/${node}/disks/list?${param}=${type}`;
me.url = `/api2/json/nodes/${me.nodename}/disks/list`;
extraParams[me.typeParameter] = me.diskType;
if (me.includePartitions) {
extraParams['include-partitions'] = 1;
}
}
me.disks = [];
me.callParent();
let store = me.getStore();
store.getProxy().setUrl(me.url);
store.setProxy({
type: 'proxmox',
url: me.url,
extraParams,
});
store.load();
store.sort({ property: me.valueField });
},