* [pve-devel] [PATCH v4 proxmox-widget-toolkit 1/10] safe-destroy: move SafeDestroy from pve-manager here
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 2/10] safe-destroy: eslint --fix Hannes Laimer
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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..4cc1d89
--- /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 ? 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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-widget-toolkit 2/10] safe-destroy: eslint --fix
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 1/10] safe-destroy: move SafeDestroy from pve-manager here Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 3/10] safe-destroy: replace type with purgeable and taskName Hannes Laimer
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/window/SafeDestroy.js | 58 +++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index 4cc1d89..dfb0185 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -11,17 +11,17 @@ Ext.define('Proxmox.window.SafeDestroy', {
buttonAlign: 'center',
bodyPadding: 10,
width: 450,
- layout: { type:'hbox' },
+ layout: { type: 'hbox' },
defaultFocus: 'confirmField',
showProgress: false,
config: {
item: {
id: undefined,
- type: undefined
+ type: undefined,
},
url: undefined,
- params: {}
+ params: {},
},
getParams: function() {
@@ -51,12 +51,12 @@ Ext.define('Proxmox.window.SafeDestroy', {
removeButton.disable();
}
},
- specialkey: function (field, event) {
+ specialkey: function(field, event) {
var removeButton = this.lookupReference('removeButton');
- if (!removeButton.isDisabled() && event.getKey() == event.ENTER) {
+ if (!removeButton.isDisabled() && event.getKey() === event.ENTER) {
removeButton.fireEvent('click', removeButton, event);
}
- }
+ },
},
'button[reference=removeButton]': {
click: function() {
@@ -70,8 +70,8 @@ Ext.define('Proxmox.window.SafeDestroy', {
Ext.Msg.alert('Error', response.htmlStatus);
},
success: function(response, options) {
- var hasProgressBar = view.showProgress &&
- response.result.data ? true : false;
+ var hasProgressBar = !!(view.showProgress &&
+ response.result.data);
if (hasProgressBar) {
// stay around so we can trigger our close events
@@ -82,40 +82,40 @@ Ext.define('Proxmox.window.SafeDestroy', {
var win = Ext.create('Proxmox.window.TaskProgress', {
upid: upid,
listeners: {
- destroy: function () {
+ destroy: function() {
view.close();
- }
- }
+ },
+ },
});
win.show();
} else {
view.close();
}
- }
+ },
});
- }
- }
- }
+ },
+ },
+ },
},
items: [
{
xtype: 'component',
- cls: [ Ext.baseCSSPrefix + 'message-box-icon',
+ cls: [Ext.baseCSSPrefix + 'message-box-icon',
Ext.baseCSSPrefix + 'message-box-warning',
- Ext.baseCSSPrefix + 'dlg-icon']
+ Ext.baseCSSPrefix + 'dlg-icon'],
},
{
xtype: 'container',
flex: 1,
layout: {
type: 'vbox',
- align: 'stretch'
+ align: 'stretch',
},
items: [
{
xtype: 'component',
- reference: 'messageCmp'
+ reference: 'messageCmp',
},
{
itemId: 'confirmField',
@@ -124,7 +124,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
name: 'confirm',
labelWidth: 300,
hideTrigger: true,
- allowBlank: false
+ allowBlank: false,
},
{
xtype: 'proxmoxcheckbox',
@@ -134,21 +134,21 @@ Ext.define('Proxmox.window.SafeDestroy', {
checked: false,
autoEl: {
tag: 'div',
- 'data-qtip': gettext('Remove from replication and backup jobs')
- }
- }
- ]
- }
+ 'data-qtip': gettext('Remove from replication and backup jobs'),
+ },
+ },
+ ],
+ },
],
buttons: [
{
reference: 'removeButton',
text: gettext('Remove'),
- disabled: true
- }
+ disabled: true,
+ },
],
- initComponent : function() {
+ initComponent: function() {
var me = this;
me.callParent();
@@ -190,5 +190,5 @@ Ext.define('Proxmox.window.SafeDestroy', {
msg = gettext('Please enter the ID to confirm') +
' (' + item.id + ')';
confirmField.setFieldLabel(msg);
- }
+ },
});
--
2.20.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-widget-toolkit 3/10] safe-destroy: replace type with purgeable and taskName
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 1/10] safe-destroy: move SafeDestroy from pve-manager here Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 2/10] safe-destroy: eslint --fix Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 4/10] safe-destroy: replace var with let/const Hannes Laimer
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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 dfb0185..fb27659 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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-widget-toolkit 4/10] safe-destroy: replace var with let/const
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (2 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 3/10] safe-destroy: replace type with purgeable and taskName Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 5/10] safe-destroy: add possibility to show a small note Hannes Laimer
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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 fb27659..39706b9 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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-widget-toolkit 5/10] safe-destroy: add possibility to show a small note
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (3 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 4/10] safe-destroy: replace var with let/const Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 6/10] utils: add task description for directory removal Hannes Laimer
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/window/SafeDestroy.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index 39706b9..87f81b7 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,25 @@ Ext.define('Proxmox.window.SafeDestroy', {
'data-qtip': gettext('Remove from replication and backup jobs'),
},
},
+ {
+ xtype: 'container',
+ reference: 'noteContainer',
+ flex: 1,
+ hidden: true,
+ layout: {
+ type: 'vbox',
+ align: 'middle',
+ },
+ height: 25,
+ items: [
+ {
+ xtype: 'component',
+ reference: 'noteCmp',
+ width: '300px',
+ style: 'font-size: smaller; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;',
+ },
+ ],
+ },
],
},
],
@@ -161,8 +181,16 @@ Ext.define('Proxmox.window.SafeDestroy', {
}
const messageCmp = me.lookupReference('messageCmp');
+ const noteCmp = me.lookupReference('noteCmp');
let msg;
+ if (Ext.isDefined(me.getNote())) {
+ noteCmp.setHtml(`<span title="${me.getNote()}">${me.getNote()}</span>`);
+ const noteContainer = me.lookupReference('noteContainer');
+ noteContainer.setHidden(false);
+ noteContainer.setDisabled(false);
+ }
+
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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-widget-toolkit 6/10] utils: add task description for directory removal
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (4 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 5/10] safe-destroy: add possibility to show a small note Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 pve-manager 7/10] safe-destroy: use SafeDestroy from proxmox-widget-toolkit Hannes Laimer
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/Utils.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Utils.js b/src/Utils.js
index 8595cce..9017277 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -645,6 +645,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] 12+ messages in thread
* [pve-devel] [PATCH v4 pve-manager 7/10] safe-destroy: use SafeDestroy from proxmox-widget-toolkit
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (5 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-widget-toolkit 6/10] utils: add task description for directory removal Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 pve-manager 8/10] remove SafeDestroy from pve-manager Hannes Laimer
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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 194ad42e..6680e711 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -485,11 +485,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] 12+ messages in thread
* [pve-devel] [PATCH v4 pve-manager 8/10] remove SafeDestroy from pve-manager
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (6 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 pve-manager 7/10] safe-destroy: use SafeDestroy from proxmox-widget-toolkit Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-backup 09/10] api2: add name of mount-point to DatastoreMountInfo Hannes Laimer
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-backup 09/10] api2: add name of mount-point to DatastoreMountInfo
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (7 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 pve-manager 8/10] remove SafeDestroy from pve-manager Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-backup 10/10] ui: add remove-button for directories/mount-units Hannes Laimer
2020-10-22 6:50 ` [pve-devel] partially-applied: [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Thomas Lamprecht
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
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..38a0ba74 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 = MOUNT_NAME_REGEX.captures(&name).unwrap().get(1).unwrap().as_str().to_string();
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] 12+ messages in thread
* [pve-devel] [PATCH v4 proxmox-backup 10/10] ui: add remove-button for directories/mount-units
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (8 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-backup 09/10] api2: add name of mount-point to DatastoreMountInfo Hannes Laimer
@ 2020-09-15 9:54 ` Hannes Laimer
2020-10-22 6:50 ` [pve-devel] partially-applied: [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Thomas Lamprecht
10 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2020-09-15 9:54 UTC (permalink / raw)
To: pbs-devel, pve-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
www/DirectoryList.js | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/www/DirectoryList.js b/www/DirectoryList.js
index 00531fd0..e605a685 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: 'removeDirectory',
+ disabled: true,
+ iconCls: 'fa fa-trash-o',
+ },
],
columns: [
--
2.20.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pve-devel] partially-applied: [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI
2020-09-15 9:54 [pve-devel] [PATCH v4 proxmox-widget-toolkit 0/10] removal of directories in PBS WebUI Hannes Laimer
` (9 preceding siblings ...)
2020-09-15 9:54 ` [pve-devel] [PATCH v4 proxmox-backup 10/10] ui: add remove-button for directories/mount-units Hannes Laimer
@ 2020-10-22 6:50 ` Thomas Lamprecht
10 siblings, 0 replies; 12+ messages in thread
From: Thomas Lamprecht @ 2020-10-22 6:50 UTC (permalink / raw)
To: Proxmox VE development discussion, Hannes Laimer, pbs-devel
On 15.09.20 11:54, Hannes Laimer wrote:
> Add functionality to remove directories in the PBS WebUI. In order to do that SafeDestroy had to be moved from
> pve-manager into proxmox-widget-toolkit and the possibility to show a small note in the dialog had to be added.
> Furthermore specifics to pve-manager in SafeRemove were replaces with a more general approach, namely: 'type' was
> replaced with 'purgeable' and 'taskName'. Due to the moving and refactorization the usages of SafeDestroy in pve-manager
> had to be corrected. In order to avoid the extraction of the directory name from the path in the frontend, the api2
> now also returns the name of a directory.
>
> proxmox-widget-toolkit needs a version bump, pve-manager and proxmox-backup require that new version.
>
>
> v4: - added patch for eslint fixes
> - api2: use only unwrap in backend, not unwrap and map_or
> - safe-destroy: note is now text-overflow: ellipsis and a tooltip
> with the whole note is added
> - safe-destroy: note component is now hidden by default
> - pve-manager: fixed remove-button handler name
>
> v3: - smaller patches with each doing a single thing
> - correct indentation for JS files
>
> v2: - SafeRemove -> SafeDestroy (keep original name)
> - generalized SafeDestroy
> - fixed eslint related issues
> - split patch [3/5]v1 into two patches
>
> proxmox-widget-toolkit: Hannes Laimer (6):
> safe-destroy: move SafeDestroy from pve-manager here
> safe-destroy: eslint --fix
> safe-destroy: replace type with purgeable and taskName
> safe-destroy: replace var with let/const
> safe-destroy: add possibility to show a small note
> utils: add task description for directory removal
>
> src/Makefile | 1 +
> src/Utils.js | 1 +
> src/window/SafeDestroy.js | 212 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 214 insertions(+)
> create mode 100644 src/window/SafeDestroy.js
>
applied above, i.e., the widget toolkit part for now, thanks!
>
> pve-manager: Hannes Laimer (2):
> safe-destroy: use SafeDestroy from proxmox-widget-toolkit
> remove SafeDestroy from pve-manager
>
> www/manager6/Makefile | 1 -
> www/manager6/ceph/Pool.js | 5 +-
> www/manager6/lxc/Config.js | 5 +-
> www/manager6/qemu/Config.js | 5 +-
> www/manager6/storage/ContentView.js | 5 +-
> www/manager6/window/SafeDestroy.js | 194 ----------------------------
> 6 files changed, 12 insertions(+), 203 deletions(-)
> delete mode 100644 www/manager6/window/SafeDestroy.js
>
>
> proxmox-backup: Hannes Laimer (2):
> api2: add name of mount-point to DatastoreMountInfo
> ui: add remove-button for directories/mount-units
>
> src/api2/node/disks/directory.rs | 4 ++++
> www/DirectoryList.js | 25 +++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
^ permalink raw reply [flat|nested] 12+ messages in thread