[pve-devel] [PATCH manager] ha resource edit: adapt to new service state

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Nov 18 17:14:34 CET 2016


Add the new stopped state to the ResourceEdit panel.
Rename enabled state to started as done in ha-manager.

As 'enabled' is now the wrong label use the more correct label
'Request state', for both the resource edit window and the grid
column.

Do this by replacing the checkbox with a KVCombogrid.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/ha/ResourceEdit.js | 31 +++++++++++++------------------
 www/manager6/ha/Resources.js    |  2 +-
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/www/manager6/ha/ResourceEdit.js b/www/manager6/ha/ResourceEdit.js
index 79a9836..3b1b51a 100644
--- a/www/manager6/ha/ResourceEdit.js
+++ b/www/manager6/ha/ResourceEdit.js
@@ -13,13 +13,6 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 
 	delete values.vmid;
 
-	if (values.enable) {
-	    values.state = 'enabled';
-	} else {
-	    values.state = 'disabled';
-	}
-	delete values.enable;
-
 	PVE.Utils.delete_if_default(values, 'group', '', me.create);
 	PVE.Utils.delete_if_default(values, 'max_restart', '1', me.create);
 	PVE.Utils.delete_if_default(values, 'max_relocate', '1', me.create);
@@ -67,6 +60,8 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 	    }
 	];
 
+	// value is expected to be integer as it's above, ignore that
+	/*jslint confusion: true */
 	me.column2 = [
 	    {
 		xtype: 'pveHAGroupSelector',
@@ -74,14 +69,18 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 		fieldLabel: gettext('Group')
 	    },
 	    {
-		xtype: 'pvecheckbox',
-		name: 'enable',
-		checked: true,
-		uncheckedValue: 0,
-		fieldLabel: gettext('enabled'),
+		xtype: 'pveKVComboBox',
+		name: 'state',
+		value: 'started',
+		fieldLabel: gettext('Request State'),
+		comboItems: [
+		    ['started', gettext('Started')],
+		    ['stopped', gettext('Stopped')],
+		    ['disabled', gettext('Disabled')]
+		],
 		listeners: {
 		    'change': function(field, newValue) {
-			if (newValue === false) {
+			if (newValue === 'disabled') {
 			    disabledHint.setVisible(true);
 			}
 			else {
@@ -94,6 +93,7 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 	    },
 	    disabledHint
 	];
+	/*jslint confusion: false */
 
 	me.columnB = [
 	    {
@@ -143,11 +143,6 @@ Ext.define('PVE.ha.VMResourceEdit', {
 		success:  function(response, options) {
 		    var values = response.result.data;
 
-		    values.enable = true;
-		    if (values.state === 'disabled') {
-			values.enable = false;
-		    }
-
 		    var regex =  /^(\S+):(\S+)$/;
 		    var res = regex.exec(values.sid);
 
diff --git a/www/manager6/ha/Resources.js b/www/manager6/ha/Resources.js
index 999cf3d..1d2bb12 100644
--- a/www/manager6/ha/Resources.js
+++ b/www/manager6/ha/Resources.js
@@ -119,7 +119,7 @@ Ext.define('PVE.ha.ResourcesView', {
 		    dataIndex: 'sid'
 		},
 		{
-		    header: gettext('State'),
+		    header: gettext('Request State'),
 		    width: 100,
 		    sortable: true,
 		    renderer: function(v) {
-- 
2.1.4





More information about the pve-devel mailing list