]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: dc/options: allow to edit HA shutdown policy
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Apr 2019 13:17:47 +0000 (15:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Apr 2019 13:31:24 +0000 (15:31 +0200)
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 <t.lamprecht@proxmox.com>
www/manager6/Utils.js
www/manager6/dc/OptionView.js

index 2d056d3cd3d13779bf909d60869f0bbf979c37a0..5b58395f9ce9386daca610b813ba0b0bec2b89eb 100644 (file)
@@ -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)';
index ace1fce54be41a792387a776df8cdc403fbc9524..d37606b90e4a2b8bf6f3d09c85becf11569ea63e 100644 (file)
@@ -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', {});