* [pve-devel] [PATCH v3 proxmox-widget-toolbox 1/9] safe-destroy: move SafeDestroy from pve-manager here
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 2/9] safe-destroy: replace type with purgeable and taskName Hannes Laimer
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
the file was just moved, nothing except the define changed ('PVE.window.SafeDestroy' -> 'Proxmox.window.SafeDestroy')
src/Makefile | 1 +
src/window/SafeDestroy.js | 194 ++++++++++++++++++++++++++++++++++++++
2 files changed, 195 insertions(+)
create mode 100644 src/window/SafeDestroy.js
diff --git a/src/Makefile b/src/Makefile
index 12dda30..ea71647 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -43,6 +43,7 @@ JSSRC= \
panel/GaugeWidget.js \
window/Edit.js \
window/PasswordEdit.js \
+ window/SafeDestroy.js \
window/TaskViewer.js \
window/LanguageEdit.js \
window/DiskSmart.js \
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
new file mode 100644
index 0000000..b1001a8
--- /dev/null
+++ b/src/window/SafeDestroy.js
@@ -0,0 +1,194 @@
+/* Popup a message window
+ * where the user has to manually enter the resource ID
+ * to enable the destroy button
+ */
+Ext.define('Proxmox.window.SafeDestroy', {
+ extend: 'Ext.window.Window',
+ alias: 'proxmoxSafeDestroy',
+
+ title: gettext('Confirm'),
+ modal: true,
+ buttonAlign: 'center',
+ bodyPadding: 10,
+ width: 450,
+ layout: { type: 'hbox' },
+ defaultFocus: 'confirmField',
+ showProgress: false,
+
+ config: {
+ item: {
+ id: undefined,
+ type: undefined,
+ },
+ url: undefined,
+ params: {},
+ },
+
+ getParams: function() {
+ var me = this;
+ var purgeCheckbox = me.lookupReference('purgeCheckbox');
+ if (purgeCheckbox.checked) {
+ me.params.purge = 1;
+ }
+ if (Ext.Object.isEmpty(me.params)) {
+ return '';
+ }
+ return '?' + Ext.Object.toQueryString(me.params);
+ },
+
+ controller: {
+
+ xclass: 'Ext.app.ViewController',
+
+ control: {
+ 'field[name=confirm]': {
+ change: function(f, value) {
+ var view = this.getView();
+ var removeButton = this.lookupReference('removeButton');
+ if (value === view.getItem().id.toString()) {
+ removeButton.enable();
+ } else {
+ removeButton.disable();
+ }
+ },
+ specialkey: function(field, event) {
+ var removeButton = this.lookupReference('removeButton');
+ if (!removeButton.isDisabled() && event.getKey() == event.ENTER) {
+ removeButton.fireEvent('click', removeButton, event);
+ }
+ },
+ },
+ 'button[reference=removeButton]': {
+ click: function() {
+ var view = this.getView();
+ Proxmox.Utils.API2Request({
+ url: view.getUrl() + view.getParams(),
+ method: 'DELETE',
+ waitMsgTarget: view,
+ failure: function(response, opts) {
+ view.close();
+ Ext.Msg.alert('Error', response.htmlStatus);
+ },
+ success: function(response, options) {
+ var hasProgressBar = !!(view.showProgress &&
+ response.result.data);
+
+ if (hasProgressBar) {
+ // stay around so we can trigger our close events
+ // when background action is completed
+ view.hide();
+
+ var upid = response.result.data;
+ var win = Ext.create('Proxmox.window.TaskProgress', {
+ upid: upid,
+ listeners: {
+ destroy: function() {
+ view.close();
+ },
+ },
+ });
+ win.show();
+ } else {
+ view.close();
+ }
+ },
+ });
+ },
+ },
+ },
+ },
+
+ items: [
+ {
+ xtype: 'component',
+ cls: [Ext.baseCSSPrefix + 'message-box-icon',
+ Ext.baseCSSPrefix + 'message-box-warning',
+ Ext.baseCSSPrefix + 'dlg-icon'],
+ },
+ {
+ xtype: 'container',
+ flex: 1,
+ layout: {
+ type: 'vbox',
+ align: 'stretch',
+ },
+ items: [
+ {
+ xtype: 'component',
+ reference: 'messageCmp',
+ },
+ {
+ itemId: 'confirmField',
+ reference: 'confirmField',
+ xtype: 'textfield',
+ name: 'confirm',
+ labelWidth: 300,
+ hideTrigger: true,
+ allowBlank: false,
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'purge',
+ reference: 'purgeCheckbox',
+ boxLabel: gettext('Purge'),
+ checked: false,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Remove from replication and backup jobs'),
+ },
+ },
+ ],
+ },
+ ],
+ buttons: [
+ {
+ reference: 'removeButton',
+ text: gettext('Remove'),
+ disabled: true,
+ },
+ ],
+
+ initComponent: function() {
+ var me = this;
+
+ me.callParent();
+
+ var item = me.getItem();
+
+ if (!Ext.isDefined(item.id)) {
+ throw "no ID specified";
+ }
+
+ if (!Ext.isDefined(item.type)) {
+ throw "no VM type specified";
+ }
+
+ var messageCmp = me.lookupReference('messageCmp');
+ var msg;
+
+ if (item.type === 'VM') {
+ msg = Proxmox.Utils.format_task_description('qmdestroy', item.id);
+ } else if (item.type === 'CT') {
+ msg = Proxmox.Utils.format_task_description('vzdestroy', item.id);
+ } else if (item.type === 'CephPool') {
+ msg = Proxmox.Utils.format_task_description('cephdestroypool', item.id);
+ } else if (item.type === 'Image') {
+ msg = Proxmox.Utils.format_task_description('unknownimgdel', item.id);
+ } else {
+ throw "unknown item type specified";
+ }
+
+ messageCmp.setHtml(msg);
+
+ if (!(item.type === 'VM' || item.type === 'CT')) {
+ let purgeCheckbox = me.lookupReference('purgeCheckbox');
+ purgeCheckbox.setDisabled(true);
+ purgeCheckbox.setHidden(true);
+ }
+
+ var confirmField = me.lookupReference('confirmField');
+ msg = gettext('Please enter the ID to confirm') +
+ ' (' + item.id + ')';
+ confirmField.setFieldLabel(msg);
+ },
+});
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-widget-toolbox 2/9] safe-destroy: replace type with purgeable and taskName
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 1/9] safe-destroy: move SafeDestroy from pve-manager here Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 3/9] safe-destroy: replace var with let/const Hannes Laimer
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
type is replaced with the two fields purgeable and taskName, type was pve-manager specific
src/window/SafeDestroy.js | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index b1001a8..71dce24 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -18,9 +18,10 @@ Ext.define('Proxmox.window.SafeDestroy', {
config: {
item: {
id: undefined,
- type: undefined,
+ purgeable: false,
},
url: undefined,
+ taskName: undefined,
params: {},
},
@@ -159,28 +160,17 @@ Ext.define('Proxmox.window.SafeDestroy', {
throw "no ID specified";
}
- if (!Ext.isDefined(item.type)) {
- throw "no VM type specified";
- }
-
var messageCmp = me.lookupReference('messageCmp');
var msg;
- if (item.type === 'VM') {
- msg = Proxmox.Utils.format_task_description('qmdestroy', item.id);
- } else if (item.type === 'CT') {
- msg = Proxmox.Utils.format_task_description('vzdestroy', item.id);
- } else if (item.type === 'CephPool') {
- msg = Proxmox.Utils.format_task_description('cephdestroypool', item.id);
- } else if (item.type === 'Image') {
- msg = Proxmox.Utils.format_task_description('unknownimgdel', item.id);
+ if (Ext.isDefined(me.getTaskName())) {
+ msg = Proxmox.Utils.format_task_description(me.getTaskName(), item.id);
+ messageCmp.setHtml(msg);
} else {
- throw "unknown item type specified";
+ throw "no task name specified";
}
- messageCmp.setHtml(msg);
-
- if (!(item.type === 'VM' || item.type === 'CT')) {
+ if (!item.purgeable) {
let purgeCheckbox = me.lookupReference('purgeCheckbox');
purgeCheckbox.setDisabled(true);
purgeCheckbox.setHidden(true);
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-widget-toolbox 3/9] safe-destroy: replace var with let/const
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 1/9] safe-destroy: move SafeDestroy from pve-manager here Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 2/9] safe-destroy: replace type with purgeable and taskName Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 4/9] safe-destroy: add possibility to show a small note Hannes Laimer
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
all instances of var are replaced with either let or const
src/window/SafeDestroy.js | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index 71dce24..a6ad458 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -26,8 +26,8 @@ Ext.define('Proxmox.window.SafeDestroy', {
},
getParams: function() {
- var me = this;
- var purgeCheckbox = me.lookupReference('purgeCheckbox');
+ let me = this;
+ const purgeCheckbox = me.lookupReference('purgeCheckbox');
if (purgeCheckbox.checked) {
me.params.purge = 1;
}
@@ -44,8 +44,8 @@ Ext.define('Proxmox.window.SafeDestroy', {
control: {
'field[name=confirm]': {
change: function(f, value) {
- var view = this.getView();
- var removeButton = this.lookupReference('removeButton');
+ const view = this.getView();
+ const removeButton = this.lookupReference('removeButton');
if (value === view.getItem().id.toString()) {
removeButton.enable();
} else {
@@ -53,7 +53,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
}
},
specialkey: function(field, event) {
- var removeButton = this.lookupReference('removeButton');
+ const removeButton = this.lookupReference('removeButton');
if (!removeButton.isDisabled() && event.getKey() == event.ENTER) {
removeButton.fireEvent('click', removeButton, event);
}
@@ -61,7 +61,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
},
'button[reference=removeButton]': {
click: function() {
- var view = this.getView();
+ const view = this.getView();
Proxmox.Utils.API2Request({
url: view.getUrl() + view.getParams(),
method: 'DELETE',
@@ -71,7 +71,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
Ext.Msg.alert('Error', response.htmlStatus);
},
success: function(response, options) {
- var hasProgressBar = !!(view.showProgress &&
+ const hasProgressBar = !!(view.showProgress &&
response.result.data);
if (hasProgressBar) {
@@ -79,8 +79,8 @@ Ext.define('Proxmox.window.SafeDestroy', {
// when background action is completed
view.hide();
- var upid = response.result.data;
- var win = Ext.create('Proxmox.window.TaskProgress', {
+ const upid = response.result.data;
+ const win = Ext.create('Proxmox.window.TaskProgress', {
upid: upid,
listeners: {
destroy: function() {
@@ -150,18 +150,18 @@ Ext.define('Proxmox.window.SafeDestroy', {
],
initComponent: function() {
- var me = this;
+ let me = this;
me.callParent();
- var item = me.getItem();
+ const item = me.getItem();
if (!Ext.isDefined(item.id)) {
throw "no ID specified";
}
- var messageCmp = me.lookupReference('messageCmp');
- var msg;
+ const messageCmp = me.lookupReference('messageCmp');
+ let msg;
if (Ext.isDefined(me.getTaskName())) {
msg = Proxmox.Utils.format_task_description(me.getTaskName(), item.id);
@@ -171,12 +171,12 @@ Ext.define('Proxmox.window.SafeDestroy', {
}
if (!item.purgeable) {
- let purgeCheckbox = me.lookupReference('purgeCheckbox');
+ const purgeCheckbox = me.lookupReference('purgeCheckbox');
purgeCheckbox.setDisabled(true);
purgeCheckbox.setHidden(true);
}
- var confirmField = me.lookupReference('confirmField');
+ const confirmField = me.lookupReference('confirmField');
msg = gettext('Please enter the ID to confirm') +
' (' + item.id + ')';
confirmField.setFieldLabel(msg);
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-widget-toolbox 4/9] safe-destroy: add possibility to show a small note
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (2 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 3/9] safe-destroy: replace var with let/const Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 pve-manager 5/9] safe-destroy: use SafeDestroy from proxmox-widget-toolkit Hannes Laimer
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
add field to set the note and add ui-container for displaying it
src/window/SafeDestroy.js | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index a6ad458..0027e98 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -21,6 +21,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
purgeable: false,
},
url: undefined,
+ note: undefined,
taskName: undefined,
params: {},
},
@@ -138,6 +139,22 @@ Ext.define('Proxmox.window.SafeDestroy', {
'data-qtip': gettext('Remove from replication and backup jobs'),
},
},
+ {
+ xtype: 'container',
+ reference: 'noteContainer',
+ flex: 1,
+ layout: {
+ type: 'vbox',
+ align: 'middle',
+ },
+ height: 25,
+ items: [
+ {
+ xtype: 'component',
+ reference: 'noteCmp',
+ },
+ ],
+ },
],
},
],
@@ -161,8 +178,17 @@ Ext.define('Proxmox.window.SafeDestroy', {
}
const messageCmp = me.lookupReference('messageCmp');
+ const noteCmp = me.lookupReference('noteCmp');
let msg;
+ if (Ext.isDefined(me.getNote())) {
+ noteCmp.setHtml(`<small>${me.getNote()}</small>`);
+ } else {
+ const noteContainer = me.lookupReference('noteContainer');
+ noteContainer.setDisabled(true);
+ noteContainer.setHidden(true);
+ }
+
if (Ext.isDefined(me.getTaskName())) {
msg = Proxmox.Utils.format_task_description(me.getTaskName(), item.id);
messageCmp.setHtml(msg);
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 pve-manager 5/9] safe-destroy: use SafeDestroy from proxmox-widget-toolkit
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (3 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 4/9] safe-destroy: add possibility to show a small note Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 pve-manager 6/9] remove SafeDestroy from pve-manager Hannes Laimer
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
SafeDestroy from proxmox-widget-toolkit is now used instead of the one from pve-manager
www/manager6/ceph/Pool.js | 5 +++--
www/manager6/lxc/Config.js | 5 +++--
www/manager6/qemu/Config.js | 5 +++--
www/manager6/storage/ContentView.js | 5 +++--
4 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 19eb01e9..ef7c0914 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -229,13 +229,14 @@ Ext.define('PVE.node.CephPoolList', {
var base_url = '/nodes/' + nodename + '/ceph/pools/' +
rec.data.pool_name;
- var win = Ext.create('PVE.window.SafeDestroy', {
+ var win = Ext.create('Proxmox.window.SafeDestroy', {
showProgress: true,
url: base_url,
params: {
remove_storages: 1
},
- item: { type: 'CephPool', id: rec.data.pool_name }
+ item: { id: rec.data.pool_name },
+ taskName: 'cephdestroypool'
}).show();
win.on('destroy', function() {
rstore.load();
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index c2222d3a..bc5c82df 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -149,9 +149,10 @@ Ext.define('PVE.lxc.Config', {
disabled: !caps.vms['VM.Allocate'],
itemId: 'removeBtn',
handler: function() {
- Ext.create('PVE.window.SafeDestroy', {
+ Ext.create('Proxmox.window.SafeDestroy', {
url: base_url,
- item: { type: 'CT', id: vmid }
+ item: { id: vmid, purgeable: true },
+ taskName: 'vzdestroy',
}).show();
},
iconCls: 'fa fa-trash-o'
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index a13bf0c5..c3b244ab 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -124,9 +124,10 @@ Ext.define('PVE.qemu.Config', {
itemId: 'removeBtn',
disabled: !caps.vms['VM.Allocate'],
handler: function() {
- Ext.create('PVE.window.SafeDestroy', {
+ Ext.create('Proxmox.window.SafeDestroy', {
url: base_url,
- item: { type: 'VM', id: vmid }
+ item: { id: vmid, purgeable: true },
+ taskName: 'qmdestroy'
}).show();
},
iconCls: 'fa fa-trash-o'
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index c70c732c..fa288b0f 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -483,11 +483,12 @@ Ext.define('PVE.storage.ContentView', {
return;
}
}
- var win = Ext.create('PVE.window.SafeDestroy', {
+ var win = Ext.create('Proxmox.window.SafeDestroy', {
title: Ext.String.format(gettext("Destroy '{0}'"), rec.data.volid),
showProgress: true,
url: url,
- item: { type: 'Image', id: vmid }
+ item: { id: vmid },
+ taskName: 'unknownimgdel'
}).show();
win.on('destroy', function() {
me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 pve-manager 6/9] remove SafeDestroy from pve-manager
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (4 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 pve-manager 5/9] safe-destroy: use SafeDestroy from proxmox-widget-toolkit Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 7/9] utils: add task description for directory removal Hannes Laimer
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
remove SafeDestroy.js file since it was moved to proxmox-widget-toolkit, entry for SafeDestroy.js in Makefile also removed
www/manager6/Makefile | 1 -
www/manager6/window/SafeDestroy.js | 194 -----------------------------
2 files changed, 195 deletions(-)
delete mode 100644 www/manager6/window/SafeDestroy.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4288acdd..89a45d85 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -247,7 +247,6 @@ JSSRC= \
window/Migrate.js \
window/NotesEdit.js \
window/Restore.js \
- window/SafeDestroy.js \
window/Settings.js \
window/Snapshot.js \
window/StartupEdit.js \
diff --git a/www/manager6/window/SafeDestroy.js b/www/manager6/window/SafeDestroy.js
deleted file mode 100644
index cc32f6e0..00000000
--- a/www/manager6/window/SafeDestroy.js
+++ /dev/null
@@ -1,194 +0,0 @@
-/* Popup a message window
- * where the user has to manually enter the resource ID
- * to enable the destroy button
- */
-Ext.define('PVE.window.SafeDestroy', {
- extend: 'Ext.window.Window',
- alias: 'widget.pveSafeDestroy',
-
- title: gettext('Confirm'),
- modal: true,
- buttonAlign: 'center',
- bodyPadding: 10,
- width: 450,
- layout: { type:'hbox' },
- defaultFocus: 'confirmField',
- showProgress: false,
-
- config: {
- item: {
- id: undefined,
- type: undefined
- },
- url: undefined,
- params: {}
- },
-
- getParams: function() {
- var me = this;
- var purgeCheckbox = me.lookupReference('purgeCheckbox');
- if (purgeCheckbox.checked) {
- me.params.purge = 1;
- }
- if (Ext.Object.isEmpty(me.params)) {
- return '';
- }
- return '?' + Ext.Object.toQueryString(me.params);
- },
-
- controller: {
-
- xclass: 'Ext.app.ViewController',
-
- control: {
- 'field[name=confirm]': {
- change: function(f, value) {
- var view = this.getView();
- var removeButton = this.lookupReference('removeButton');
- if (value === view.getItem().id.toString()) {
- removeButton.enable();
- } else {
- removeButton.disable();
- }
- },
- specialkey: function (field, event) {
- var removeButton = this.lookupReference('removeButton');
- if (!removeButton.isDisabled() && event.getKey() == event.ENTER) {
- removeButton.fireEvent('click', removeButton, event);
- }
- }
- },
- 'button[reference=removeButton]': {
- click: function() {
- var view = this.getView();
- Proxmox.Utils.API2Request({
- url: view.getUrl() + view.getParams(),
- method: 'DELETE',
- waitMsgTarget: view,
- failure: function(response, opts) {
- view.close();
- Ext.Msg.alert('Error', response.htmlStatus);
- },
- success: function(response, options) {
- var hasProgressBar = view.showProgress &&
- response.result.data ? true : false;
-
- if (hasProgressBar) {
- // stay around so we can trigger our close events
- // when background action is completed
- view.hide();
-
- var upid = response.result.data;
- var win = Ext.create('Proxmox.window.TaskProgress', {
- upid: upid,
- listeners: {
- destroy: function () {
- view.close();
- }
- }
- });
- win.show();
- } else {
- view.close();
- }
- }
- });
- }
- }
- }
- },
-
- items: [
- {
- xtype: 'component',
- cls: [ Ext.baseCSSPrefix + 'message-box-icon',
- Ext.baseCSSPrefix + 'message-box-warning',
- Ext.baseCSSPrefix + 'dlg-icon']
- },
- {
- xtype: 'container',
- flex: 1,
- layout: {
- type: 'vbox',
- align: 'stretch'
- },
- items: [
- {
- xtype: 'component',
- reference: 'messageCmp'
- },
- {
- itemId: 'confirmField',
- reference: 'confirmField',
- xtype: 'textfield',
- name: 'confirm',
- labelWidth: 300,
- hideTrigger: true,
- allowBlank: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'purge',
- reference: 'purgeCheckbox',
- boxLabel: gettext('Purge'),
- checked: false,
- autoEl: {
- tag: 'div',
- 'data-qtip': gettext('Remove from replication and backup jobs')
- }
- }
- ]
- }
- ],
- buttons: [
- {
- reference: 'removeButton',
- text: gettext('Remove'),
- disabled: true
- }
- ],
-
- initComponent : function() {
- var me = this;
-
- me.callParent();
-
- var item = me.getItem();
-
- if (!Ext.isDefined(item.id)) {
- throw "no ID specified";
- }
-
- if (!Ext.isDefined(item.type)) {
- throw "no VM type specified";
- }
-
- var messageCmp = me.lookupReference('messageCmp');
- var msg;
-
- if (item.type === 'VM') {
- msg = Proxmox.Utils.format_task_description('qmdestroy', item.id);
- } else if (item.type === 'CT') {
- msg = Proxmox.Utils.format_task_description('vzdestroy', item.id);
- } else if (item.type === 'CephPool') {
- msg = Proxmox.Utils.format_task_description('cephdestroypool', item.id);
- } else if (item.type === 'Image') {
- msg = Proxmox.Utils.format_task_description('unknownimgdel', item.id);
- } else {
- throw "unknown item type specified";
- }
-
- messageCmp.setHtml(msg);
-
- if (!(item.type === 'VM' || item.type === 'CT')) {
- let purgeCheckbox = me.lookupReference('purgeCheckbox');
- purgeCheckbox.setDisabled(true);
- purgeCheckbox.setHidden(true);
- }
-
- var confirmField = me.lookupReference('confirmField');
- msg = gettext('Please enter the ID to confirm') +
- ' (' + item.id + ')';
- confirmField.setFieldLabel(msg);
- }
-});
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-widget-toolbox 7/9] utils: add task description for directory removal
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (5 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 pve-manager 6/9] remove SafeDestroy from pve-manager Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-backup 8/9] api2: add name of mount-point to DatastoreMountInfo Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-backup 9/9] ui: add remove-button for directories/mount-units Hannes Laimer
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
add task description for the removal of directories, so it may be used in the new version of SafeDestroy
src/Utils.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Utils.js b/src/Utils.js
index 4be95b2..6373440 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -641,6 +641,7 @@ utilities: {
stopall: ['', gettext('Stop all VMs and Containers')],
migrateall: ['', gettext('Migrate all VMs and Containers')],
dircreate: [gettext('Directory Storage'), gettext('Create')],
+ dirremove: [gettext('Directory'), gettext('Remove')],
lvmcreate: [gettext('LVM Storage'), gettext('Create')],
lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
zfscreate: [gettext('ZFS Storage'), gettext('Create')],
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-backup 8/9] api2: add name of mount-point to DatastoreMountInfo
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (6 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-widget-toolbox 7/9] utils: add task description for directory removal Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-backup 9/9] ui: add remove-button for directories/mount-units Hannes Laimer
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
for the removal of dirs the id/name is needed in the frontend, therefore it has to be returned by the api
src/api2/node/disks/directory.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 0d9ddeef..1f3cb0ff 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -34,6 +34,8 @@ pub struct DatastoreMountInfo {
pub unitfile: String,
/// The mount path.
pub path: String,
+ /// The name of the mount.
+ pub id: String,
/// The mounted device.
pub device: String,
/// File system type
@@ -76,6 +78,7 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
let item = item?;
let name = item.file_name().to_string_lossy().to_string();
+ let id = String::from(MOUNT_NAME_REGEX.captures(&name).unwrap().get(1).map_or("", |m| m.as_str()));
let unitfile = format!("{}/{}", basedir, name);
let config = systemd::config::parse_systemd_mount(&unitfile)?;
let data: SystemdMountSection = config.lookup("Mount", "Mount")?;
@@ -84,6 +87,7 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
unitfile,
device: data.What,
path: data.Where,
+ id,
filesystem: data.Type,
options: data.Options,
});
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [pve-devel] [PATCH v3 proxmox-backup 9/9] ui: add remove-button for directories/mount-units
2020-08-28 8:46 [pve-devel] [PATCH v3 proxmox-widget-toolbox 0/9] removal of directories in PBS WebUI Hannes Laimer
` (7 preceding siblings ...)
2020-08-28 8:46 ` [pve-devel] [PATCH v3 proxmox-backup 8/9] api2: add name of mount-point to DatastoreMountInfo Hannes Laimer
@ 2020-08-28 8:46 ` Hannes Laimer
8 siblings, 0 replies; 10+ messages in thread
From: Hannes Laimer @ 2020-08-28 8:46 UTC (permalink / raw)
To: pve-devel, pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
add remove button to ui, all previous patches are needed for this one
www/DirectoryList.js | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/www/DirectoryList.js b/www/DirectoryList.js
index 00531fd0..51b30c78 100644
--- a/www/DirectoryList.js
+++ b/www/DirectoryList.js
@@ -21,6 +21,24 @@ Ext.define('PBS.admin.Directorylist', {
}).show();
},
+ removeDirectory: function() {
+ let me = this;
+ const view = me.getView();
+ const rec = view.getSelection()[0];
+ const id = rec.data.id;
+ Ext.create('Proxmox.window.SafeDestroy', {
+ url: `/nodes/localhost/disks/directory/${id}`,
+ item: {
+ id: id,
+ },
+ note: gettext('Data and partitions on the disk will be left untouched.'),
+ taskName: 'dirremove',
+ listeners: {
+ destroy: () => me.reload(),
+ },
+ }).show();
+ },
+
reload: function() {
let me = this;
let store = me.getView().getStore();
@@ -49,6 +67,13 @@ Ext.define('PBS.admin.Directorylist', {
text: gettext('Create') + ': Directory',
handler: 'createDirectory',
},
+ {
+ xtype: 'proxmoxButton',
+ text: gettext('Remove'),
+ handler: 'removeDir',
+ disabled: true,
+ iconCls: 'fa fa-trash-o',
+ },
],
columns: [
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread