public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Markus Frank <m.frank@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 2/2] ui: add Remove button for DirectoryList
Date: Tue, 10 Oct 2023 13:37:48 +0200	[thread overview]
Message-ID: <20231010113748.4325-2-m.frank@proxmox.com> (raw)
In-Reply-To: <20231010113748.4325-1-m.frank@proxmox.com>

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





  reply	other threads:[~2023-10-10 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-10-10 12:00 ` Lukas Wagner
2023-11-07  9:33 ` [pbs-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231010113748.4325-2-m.frank@proxmox.com \
    --to=m.frank@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal