* [pbs-devel] [PATCH proxmox-backup v2 2/2] ui: add Remove button for DirectoryList
2023-10-10 11:37 [pbs-devel] [PATCH proxmox-backup v2 1/2] cli: add option to remove systemd mount unit Markus Frank
@ 2023-10-10 11:37 ` Markus Frank
2023-10-10 12:00 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] cli: add option to remove systemd mount unit Lukas Wagner
2023-11-07 9:33 ` [pbs-devel] applied-series: " Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Markus Frank @ 2023-10-10 11:37 UTC (permalink / raw)
To: pbs-devel
With this patch it is possible to remove systemd mount units via the webui.
Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
v2:
* changed dirName from const to let
* added right indentation
www/DirectoryList.js | 79 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/www/DirectoryList.js b/www/DirectoryList.js
index 00531fd0..adefa9ab 100644
--- a/www/DirectoryList.js
+++ b/www/DirectoryList.js
@@ -7,6 +7,15 @@ Ext.define('PBS.admin.Directorylist', {
emptyText: gettext('No Mount-Units found'),
+ viewModel: {
+ data: {
+ path: '',
+ },
+ formulas: {
+ dirName: (get) => get('path')?.replace('/mnt/datastore/', '') || undefined,
+ },
+ },
+
controller: {
xclass: 'Ext.app.ViewController',
@@ -21,6 +30,27 @@ Ext.define('PBS.admin.Directorylist', {
}).show();
},
+ removeDirectory: function() {
+ let me = this;
+ let vm = me.getViewModel();
+
+ let dirName = vm.get('dirName');
+
+ if (!dirName) {
+ throw "no directory name specified";
+ }
+
+ Ext.create('Proxmox.window.SafeDestroy', {
+ url: `/nodes/localhost/disks/directory/${dirName}`,
+ item: { id: dirName },
+ showProgress: true,
+ taskName: 'dirremove',
+ listeners: {
+ destroy: () => me.reload(),
+ },
+ }).show();
+ },
+
reload: function() {
let me = this;
let store = me.getView().getStore();
@@ -49,6 +79,45 @@ Ext.define('PBS.admin.Directorylist', {
text: gettext('Create') + ': Directory',
handler: 'createDirectory',
},
+ '->',
+ {
+ xtype: 'tbtext',
+ data: {
+ dirName: undefined,
+ },
+ bind: {
+ data: {
+ dirName: "{dirName}",
+ },
+ },
+ tpl: [
+ '<tpl if="dirName">',
+ gettext('Directory') + ' {dirName}:',
+ '<tpl else>',
+ Ext.String.format(gettext('No {0} selected'), gettext('directory')),
+ '</tpl>',
+ ],
+ },
+ {
+ text: gettext('More'),
+ iconCls: 'fa fa-bars',
+ disabled: true,
+ bind: {
+ disabled: '{!dirName}',
+ },
+ menu: [
+ {
+ text: gettext('Remove'),
+ itemId: 'remove',
+ iconCls: 'fa fa-fw fa-trash-o',
+ handler: 'removeDirectory',
+ disabled: true,
+ bind: {
+ disabled: '{!dirName}',
+ },
+ },
+ ],
+ },
],
columns: [
@@ -79,6 +148,16 @@ Ext.define('PBS.admin.Directorylist', {
},
],
+ listeners: {
+ activate: "reload",
+ selectionchange: function(model, selected) {
+ let me = this;
+ let vm = me.getViewModel();
+
+ vm.set('path', selected[0]?.data.path || '');
+ },
+ },
+
store: {
fields: ['path', 'device', 'filesystem', 'options', 'unitfile'],
proxy: {
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v2 1/2] cli: add option to remove systemd mount unit
2023-10-10 11:37 [pbs-devel] [PATCH proxmox-backup v2 1/2] cli: add option to remove systemd mount unit Markus Frank
2023-10-10 11:37 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] ui: add Remove button for DirectoryList Markus Frank
@ 2023-10-10 12:00 ` Lukas Wagner
2023-11-07 9:33 ` [pbs-devel] applied-series: " Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Lukas Wagner @ 2023-10-10 12:00 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Markus Frank
Now both patches look fine to me.
Both are now:
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
On 10/10/23 13:37, Markus Frank wrote:
> add commandline option for api function:
> DELETE /api2/json/nodes/{node}/disks/directory/{name}
>
> $ proxmox-backup-manager disk fs delete <datastoreid>
>
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---
> src/bin/proxmox_backup_manager/disk.rs | 29 ++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/src/bin/proxmox_backup_manager/disk.rs b/src/bin/proxmox_backup_manager/disk.rs
> index c3259b65..73cb95e6 100644
> --- a/src/bin/proxmox_backup_manager/disk.rs
> +++ b/src/bin/proxmox_backup_manager/disk.rs
> @@ -317,6 +317,31 @@ async fn create_datastore_disk(
> Ok(Value::Null)
> }
>
> +#[api(
> + input: {
> + properties: {
> + name: {
> + schema: DATASTORE_SCHEMA,
> + },
> + },
> + },
> +)]
> +/// Remove a Filesystem mounted under '/mnt/datastore/<name>'.
> +async fn delete_datastore_disk(
> + mut param: Value,
> + rpcenv: &mut dyn RpcEnvironment,
> +) -> Result<Value, Error> {
> + param["node"] = "localhost".into();
> +
> + let info = &api2::node::disks::directory::API_METHOD_DELETE_DATASTORE_DISK;
> + let _result = match info.handler {
> + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
> + _ => unreachable!(),
> + };
> +
> + Ok(Value::Null)
> +}
> +
> pub fn filesystem_commands() -> CommandLineInterface {
> let cmd_def = CliCommandMap::new()
> .insert("list", CliCommand::new(&API_METHOD_LIST_DATASTORE_MOUNTS))
> @@ -325,6 +350,10 @@ pub fn filesystem_commands() -> CommandLineInterface {
> CliCommand::new(&API_METHOD_CREATE_DATASTORE_DISK)
> .arg_param(&["name"])
> .completion_cb("disk", complete_disk_name),
> + ).insert(
> + "delete",
> + CliCommand::new(&API_METHOD_DELETE_DATASTORE_DISK)
> + .arg_param(&["name"]),
> );
>
> cmd_def.into()
--
- Lukas
^ permalink raw reply [flat|nested] 4+ messages in thread