[pbs-devel] [PATCH proxmox-backup v3 16/24] ui: add partition selector form

Christian Ebner c.ebner at proxmox.com
Tue Apr 16 10:57:27 CEST 2024


a comment inline

On 4/9/24 13:00, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>   www/Makefile                  |  1 +
>   www/form/PartitionSelector.js | 59 +++++++++++++++++++++++++++++++++++
>   2 files changed, 60 insertions(+)
>   create mode 100644 www/form/PartitionSelector.js
> 
> diff --git a/www/Makefile b/www/Makefile
> index 79cb4c04..762d90c5 100644
> --- a/www/Makefile
> +++ b/www/Makefile
> @@ -49,6 +49,7 @@ JSSRC=							\
>   	form/NamespaceMaxDepth.js			\
>   	form/CalendarEvent.js				\
>   	form/PermissionPathSelector.js			\
> +	form/PartitionSelector.js			\
>   	form/GroupSelector.js				\
>   	form/GroupFilter.js				\
>   	form/VerifyOutdatedAfter.js			\
> diff --git a/www/form/PartitionSelector.js b/www/form/PartitionSelector.js
> new file mode 100644
> index 00000000..64e7990a
> --- /dev/null
> +++ b/www/form/PartitionSelector.js
> @@ -0,0 +1,59 @@
> +Ext.define('pbs-partition-list', {
> +    extend: 'Ext.data.Model',
> +    fields: ['name', 'uuid', 'filesystem', 'devpath', 'size'],
> +    proxy: {
> +	type: 'proxmox',
> +	url: "/api2/json/nodes/localhost/disks/list?include-partitions=1&only-unused=1",

without setting the `skipsmart` flag you fetch also the smart stats, not 
used however, so you might set this.

> +	reader: {
> +	    transform: (rawData) => rawData.data
> +		.flatMap(disk => (disk.partitions ?? [])
> +		    .filter(partition => partition.used === 'filesystem')),
> +	},
> +    },
> +    idProperty: 'devpath',
> +
> +});
> +
> +Ext.define('PBS.form.PartitionSelector', {
> +    extend: 'Proxmox.form.ComboGrid',
> +    alias: 'widget.pbsPartitionSelector',
> +
> +    allowBlank: false,
> +    autoSelect: false,
> +    valueField: 'uuid',
> +    displayField: 'devpath',
> +
> +    store: {
> +	model: 'pbs-partition-list',
> +	autoLoad: true,
> +	sorters: 'devpath',
> +    },
> +
> +    listConfig: {
> +	columns: [
> +	    {
> +		header: gettext('Path'),
> +		sortable: true,
> +		dataIndex: 'devpath',
> +		renderer: (v, metaData, rec) => Ext.String.htmlEncode(v),
> +		flex: 1,
> +	    },
> +	    {
> +		header: gettext('Filesystem'),
> +		sortable: true,
> +		dataIndex: 'filesystem',
> +		flex: 1,
> +	    },
> +	    {
> +		header: gettext('Size'),
> +		sortable: true,
> +		dataIndex: 'size',
> +		renderer: Proxmox.Utils.format_size,
> +		flex: 1,
> +	    },
> +	],
> +	viewConfig: {
> +	    emptyText: 'No partitions present',
> +	},
> +    },
> +});





More information about the pbs-devel mailing list