]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/dc/ClusterEdit.js
ui: guest import: add warning for losing efi state
[pve-manager.git] / www / manager6 / dc / ClusterEdit.js
index 53cd0efc8cb8d6e5ff2c75ae70ef3204505e566a..32964fbf6fdff2bb5f05cc3fd1e65662ba1813f1 100644 (file)
@@ -1,4 +1,3 @@
-/*jslint confusion: true*/
 Ext.define('PVE.ClusterCreateWindow', {
     extend: 'Proxmox.window.Edit',
     xtype: 'pveClusterCreateWindow',
@@ -22,29 +21,20 @@ Ext.define('PVE.ClusterCreateWindow', {
            fieldLabel: gettext('Cluster Name'),
            allowBlank: false,
            maxLength: 15,
-           name: 'clustername'
+           name: 'clustername',
        },
        {
            xtype: 'fieldcontainer',
-           fieldLabel: gettext("Cluster Links"),
-           style: {
-               'padding-top': '5px',
-           },
+           fieldLabel: gettext("Cluster Network"),
            items: [
                {
                    xtype: 'pveCorosyncLinkEditor',
-                   style: {
-                       'padding-bottom': '5px',
-                   },
-                   name: 'links'
+                   infoText: gettext("Multiple links are used as failover, lower numbers have higher priority."),
+                   name: 'links',
                },
-               {
-                   xtype: 'label',
-                   text: gettext("Multiple links are used as failover, lower numbers have higher priority.")
-               }
-           ]
-       }]
-    }
+           ],
+       }],
+    },
 });
 
 Ext.define('PVE.ClusterInfoWindow', {
@@ -60,7 +50,7 @@ Ext.define('PVE.ClusterInfoWindow', {
     joinInfo: {
        ipAddress: undefined,
        fingerprint: undefined,
-       totem: {}
+       totem: {},
     },
 
     items: [
@@ -68,7 +58,7 @@ Ext.define('PVE.ClusterInfoWindow', {
            xtype: 'component',
            border: false,
            padding: '10 10 10 10',
-           html: gettext("Copy the Join Information here and use it on the node you want to add.")
+           html: gettext("Copy the Join Information here and use it on the node you want to add."),
        },
        {
            xtype: 'container',
@@ -79,21 +69,27 @@ Ext.define('PVE.ClusterInfoWindow', {
                {
                    xtype: 'textfield',
                    fieldLabel: gettext('IP Address'),
-                   cbind: { value: '{joinInfo.ipAddress}' },
-                   editable: false
+                   cbind: {
+                       value: '{joinInfo.ipAddress}',
+                   },
+                   editable: false,
                },
                {
                    xtype: 'textfield',
                    fieldLabel: gettext('Fingerprint'),
-                   cbind: { value: '{joinInfo.fingerprint}' },
-                   editable: false
+                   cbind: {
+                       value: '{joinInfo.fingerprint}',
+                   },
+                   editable: false,
                },
                {
                    xtype: 'textarea',
                    inputId: 'pveSerializedClusterInfo',
                    fieldLabel: gettext('Join Information'),
                    grow: true,
-                   cbind: { joinInfo: '{joinInfo}' },
+                   cbind: {
+                       joinInfo: '{joinInfo}',
+                   },
                    editable: false,
                    listeners: {
                        afterrender: function(field) {
@@ -103,11 +99,11 @@ Ext.define('PVE.ClusterInfoWindow', {
                            var jsons = Ext.JSON.encode(field.joinInfo);
                            var base64s = Ext.util.Base64.encode(jsons);
                            field.setValue(base64s);
-                       }
-                   }
-               }
-           ]
-       }
+                       },
+                   },
+               },
+           ],
+       },
     ],
     dockedItems: [{
        dock: 'bottom',
@@ -119,9 +115,9 @@ Ext.define('PVE.ClusterInfoWindow', {
                el.select();
                document.execCommand("copy");
            },
-           text: gettext('Copy Information')
-       }]
-    }]
+           text: gettext('Copy Information'),
+       }],
+    }],
 });
 
 Ext.define('PVE.ClusterJoinNodeWindow', {
@@ -149,8 +145,9 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
            info: {
                fp: '',
                ip: '',
-               clusterName: ''
-           }
+               clusterName: '',
+           },
+           hasAssistedInfo: false,
        },
        formulas: {
            submittxt: function(get) {
@@ -160,6 +157,10 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
                }
                return gettext('Join');
            },
+           showClusterFields: (get) => {
+               let manualMode = !get('assistedEntry.checked');
+               return get('hasAssistedInfo') || manualMode;
+           },
        },
     },
 
@@ -169,18 +170,18 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
            '#': {
                close: function() {
                    delete PVE.Utils.silenceAuthFailures;
-               }
+               },
            },
            'proxmoxcheckbox[name=assistedEntry]': {
-               change: 'onInputTypeChange'
+               change: 'onInputTypeChange',
            },
            'textarea[name=serializedinfo]': {
                change: 'recomputeSerializedInfo',
-               enable: 'resetField'
+               enable: 'resetField',
            },
            'textfield': {
-               disable: 'resetField'
-           }
+               disable: 'resetField',
+           },
        },
        resetField: function(field) {
            field.reset();
@@ -200,8 +201,10 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
            let vm = this.getViewModel();
 
            let assistedEntryBox = this.lookup('assistedEntry');
+
            if (!assistedEntryBox.getValue()) {
                // not in assisted entry mode, nothing to do
+               vm.set('hasAssistedInfo', false);
                return;
            }
 
@@ -213,30 +216,36 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
            let info = {
                fp: '',
                ip: '',
-               clusterName: ''
+               clusterName: '',
            };
 
            if (!(joinInfo && joinInfo.totem)) {
                field.valid = false;
                linkEditor.setLinks([]);
                linkEditor.setInfoText();
+               vm.set('hasAssistedInfo', false);
            } else {
                let interfaces = joinInfo.totem.interface;
                let links = Object.values(interfaces).map(iface => {
+                   let linkNumber = iface.linknumber;
+                   let peerLink;
+                   if (joinInfo.peerLinks) {
+                       peerLink = joinInfo.peerLinks[linkNumber];
+                   }
                    return {
-                       number: iface.linknumber,
+                       number: linkNumber,
                        value: '',
-                       text: '',
-                       allowBlank: false
+                       text: peerLink ? Ext.String.format(gettext("peer's link address: {0}"), peerLink) : '',
+                       allowBlank: false,
                    };
                });
 
                linkEditor.setInfoText();
-               if (links.length == 1 && joinInfo.ring_addr !== undefined &&
-                   joinInfo.ring_addr[0] === joinInfo.ipAddress) {
-
+               if (links.length === 1 && joinInfo.ring_addr !== undefined &&
+                   joinInfo.ring_addr[0] === joinInfo.ipAddress
+               ) {
                    links[0].allowBlank = true;
-                   linkEditor.setInfoText(gettext("Leave empty to use IP resolved by node's hostname"));
+                   links[0].emptyText = gettext("IP resolved by node's hostname");
                }
 
                linkEditor.setLinks(links);
@@ -244,13 +253,13 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
                info = {
                    ip: joinInfo.ipAddress,
                    fp: joinInfo.fingerprint,
-                   clusterName: joinInfo.totem.cluster_name
+                   clusterName: joinInfo.totem.cluster_name,
                };
                field.valid = true;
+               vm.set('hasAssistedInfo', true);
            }
-
            vm.set('info', info);
-       }
+       },
     },
 
     submit: function() {
@@ -266,14 +275,14 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
            Ext.defer(function() {
                window.location.reload(true);
            }, 5000);
-           var txt = gettext('Cluster join task finished, node certificate may have changed, reload GUI!');
+           let txt = gettext('Cluster join task finished, node certificate may have changed, reload GUI!');
            // ensure user cannot do harm
            Ext.getBody().mask(txt, ['pve-static-mask']);
            // TaskView may hide above mask, so tell him directly
            Ext.Msg.show({
                title: gettext('Join Task Finished'),
                icon: Ext.Msg.INFO,
-               msg: txt
+               msg: txt,
            });
        }
     },
@@ -287,9 +296,9 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
        value: true,
        autoEl: {
            tag: 'div',
-           'data-qtip': gettext('Select if join information should be extracted from pasted cluster information, deselect for manual entering')
+           'data-qtip': gettext('Select if join information should be extracted from pasted cluster information, deselect for manual entering'),
        },
-       boxLabel: gettext('Assisted join: Paste encoded cluster join information and enter password.')
+       boxLabel: gettext('Assisted join: Paste encoded cluster join information and enter password.'),
     },
     {
        xtype: 'textarea',
@@ -299,21 +308,23 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
        fieldLabel: gettext('Information'),
        emptyText: gettext('Paste encoded Cluster Information here'),
        validator: function(val) {
-           return val === '' || this.valid ||
-              gettext('Does not seem like a valid encoded Cluster Information!');
+           return val === '' || this.valid || gettext('Does not seem like a valid encoded Cluster Information!');
        },
        bind: {
            disabled: '{!assistedEntry.checked}',
-           hidden: '{!assistedEntry.checked}'
+           hidden: '{!assistedEntry.checked}',
        },
-       value: ''
+       value: '',
     },
     {
        xtype: 'panel',
        width: 776,
        layout: {
            type: 'hbox',
-           align: 'center'
+           align: 'center',
+       },
+       bind: {
+           hidden: '{!showClusterFields}',
        },
        items: [
            {
@@ -324,9 +335,9 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
                allowBlank: false,
                bind: {
                    value: '{info.ip}',
-                   readOnly: '{assistedEntry.checked}'
+                   readOnly: '{assistedEntry.checked}',
                },
-               name: 'hostname'
+               name: 'hostname',
            },
            {
                xtype: 'textfield',
@@ -336,9 +347,9 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
                emptyText: gettext("Peer's root password"),
                fieldLabel: gettext('Password'),
                allowBlank: false,
-               name: 'password'
+               name: 'password',
            },
-       ]
+       ],
     },
     {
        xtype: 'textfield',
@@ -346,20 +357,24 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
        allowBlank: false,
        bind: {
            value: '{info.fp}',
-           readOnly: '{assistedEntry.checked}'
+           readOnly: '{assistedEntry.checked}',
+           hidden: '{!showClusterFields}',
        },
-       name: 'fingerprint'
+       name: 'fingerprint',
     },
     {
        xtype: 'fieldcontainer',
-       fieldLabel: gettext("Cluster Links"),
+       fieldLabel: gettext("Cluster Network"),
+       bind: {
+           hidden: '{!showClusterFields}',
+       },
        items: [
            {
                xtype: 'pveCorosyncLinkEditor',
                itemId: 'linkEditor',
                reference: 'linkEditor',
-               allowNumberEdit: false
+               allowNumberEdit: false,
            },
-       ]
-    }]
+       ],
+    }],
 });