From 8f17b4965a89e68e60bb0a9cae34a9366c3ed54d Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 10 Apr 2019 15:17:47 +0200 Subject: [PATCH] ui: dc/options: allow to edit HA shutdown policy add some helpers handling this, can be re used for adding the migration field, maybe we want to move this to widget-toolkits parent ObjectGrid class, a bit cleaned up. Signed-off-by: Thomas Lamprecht --- www/manager6/Utils.js | 8 +++++ www/manager6/dc/OptionView.js | 67 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index 2d056d3c..5b58395f 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -244,6 +244,14 @@ Ext.define('PVE.Utils', { utilities: { } }, + render_dc_ha_opts: function(value) { + if (!value) { + return Proxmox.Utils.defaultText + ' (conditional)'; + } else { + return PVE.Parser.printPropertyString(value); + } + }, + render_scsihw: function(value) { if (!value) { return Proxmox.Utils.defaultText + ' (LSI 53C895A)'; diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js index ace1fce5..d37606b9 100644 --- a/www/manager6/dc/OptionView.js +++ b/www/manager6/dc/OptionView.js @@ -1,3 +1,4 @@ + /*jslint confusion: true*/ Ext.define('PVE.dc.OptionView', { extend: 'Proxmox.grid.ObjectGrid', alias: ['widget.pveDcOptionView'], @@ -6,9 +7,53 @@ Ext.define('PVE.dc.OptionView', { monStoreErrors: true, + add_inputpanel_row: function(name, text, opts) { + var me = this; + + opts = opts || {}; + me.rows = me.rows || {}; + + var canEdit = (opts.caps === undefined || opts.caps); + me.rows[name] = { + required: true, + defaultValue: opts.defaultValue, + header: text, + renderer: opts.renderer, + editor: canEdit ? { + xtype: 'proxmoxWindowEdit', + width: 350, + subject: text, + fieldDefaults: { + labelWidth: opts.labelWidth || 100 + }, + setValues: function(values) { + var edit_value = values[name]; + Ext.Array.each(this.query('inputpanel'), function(panel) { + panel.setValues(edit_value); + }); + }, + url: opts.url, + items: [{ + xtype: 'inputpanel', + onGetValues: function(values) { + if (values === undefined || Object.keys(values).length === 0) { + return { 'delete': name }; + } + var ret_val = {}; + ret_val[name] = PVE.Parser.printPropertyString(values); + return ret_val; + }, + items: opts.items + }] + } : undefined + }; + }, + initComponent : function() { var me = this; + var caps = Ext.state.Manager.get('GuiCap'); + me.add_combobox_row('keyboard', gettext('Keyboard Layout'), { renderer: PVE.Utils.render_kvm_language, comboItems: PVE.Utils.kvm_keymap_array(), @@ -36,6 +81,28 @@ Ext.define('PVE.dc.OptionView', { vtype: 'MacPrefix', defaultValue: Proxmox.Utils.noneText }); + me.add_inputpanel_row('ha', gettext('HA Settings'), { + renderer: PVE.Utils.render_dc_ha_opts, + caps: caps.vms['Sys.Modify'], + labelWidth: 120, + url: "/api2/extjs/cluster/options", + items: [{ + xtype: 'proxmoxKVComboBox', + name: 'shutdown_policy', + fieldLabel: gettext('Shutdown Policy'), + deleteEmpty: false, + value: '__default__', + comboItems: [ + ['__default__', PVE.Utils.render_dc_ha_opts('')], + ['freeze', 'freeze'], + ['failover', 'failover'], + ['conditional', 'conditional'] + ], + defaultValue: '__default__' + }] + }); + + // TODO: bwlimits, migration net, u2f? me.selModel = Ext.create('Ext.selection.RowModel', {}); -- 2.39.2