ui: ceph installer: mask configuration if not needed & add monitor

Signed-off-by: Tim Marx <t.marx@proxmox.com>
This commit is contained in:
Tim Marx 2019-03-28 12:16:04 +01:00 committed by Thomas Lamprecht
parent d264c0cff5
commit 91f234d574

View File

@ -1,3 +1,4 @@
/*jslint confusion: true*/
Ext.define('PVE.ceph.CephInstallWizard', { Ext.define('PVE.ceph.CephInstallWizard', {
extend: 'PVE.window.Wizard', extend: 'PVE.window.Wizard',
alias: 'widget.pveCephInstallWizard', alias: 'widget.pveCephInstallWizard',
@ -6,13 +7,25 @@ Ext.define('PVE.ceph.CephInstallWizard', {
nodename: undefined, nodename: undefined,
viewModel: { viewModel: {
data: { data: {
nodename: '' nodename: '',
configuration: true
} }
}, },
cbindData: { cbindData: {
nodename: undefined nodename: undefined
}, },
title: gettext('Installation'), title: gettext('Installation'),
navigateNext: function() {
var tp = this.down('#wizcontent');
var atab = tp.getActiveTab();
var next = tp.items.indexOf(atab) + 1;
var ntab = tp.items.getAt(next);
if (ntab) {
ntab.enable();
tp.setActiveTab(ntab);
}
},
items: [ items: [
{ {
title: gettext('Info'), title: gettext('Info'),
@ -67,20 +80,18 @@ Ext.define('PVE.ceph.CephInstallWizard', {
}, },
listeners: { listeners: {
load: function(rec, response, success, operation) { load: function(rec, response, success, operation) {
var wizard = me.up('#wizcontent');
var tabs = wizard.items;
var lastTab = tabs.items[tabs.length-1];
if (success) { if (success) {
me.updateStore.stopUpdate(); me.updateStore.stopUpdate();
lastTab.enable(); me.down('textfield').setValue('success');
wizard.setActiveTab(lastTab);
} else if (operation.error.statusText.match("not initialized", "i")) { } else if (operation.error.statusText.match("not initialized", "i")) {
me.updateStore.stopUpdate(); me.updateStore.stopUpdate();
me.up('pveCephInstallWizard').getViewModel().set('configuration',false);
me.down('textfield').setValue('success'); me.down('textfield').setValue('success');
} else if (operation.error.statusText.match("rados_connect failed", "i")) { } else if (operation.error.statusText.match("rados_connect failed", "i")) {
me.updateStore.stopUpdate(); me.updateStore.stopUpdate();
lastTab.enable(); me.up('pveCephInstallWizard').getViewModel().set('configuration',true);
wizard.setActiveTab(lastTab); me.down('textfield').setValue('success');
} else if (!operation.error.statusText.match("not installed", "i")) { } else if (!operation.error.statusText.match("not installed", "i")) {
Proxmox.Utils.setErrorMask(me, operation.error.statusText); Proxmox.Utils.setErrorMask(me, operation.error.statusText);
} }
@ -134,19 +145,29 @@ Ext.define('PVE.ceph.CephInstallWizard', {
activate: function() { activate: function() {
this.up('pveCephInstallWizard').down('#submit').setText(gettext('Next')); this.up('pveCephInstallWizard').down('#submit').setText(gettext('Next'));
}, },
beforeshow: function() {
if (this.up('pveCephInstallWizard').getViewModel().get('configuration')) {
this.mask("Coniguration already initialized",['pve-static-mask']);
} else {
this.unmask();
}
},
deactivate: function() { deactivate: function() {
this.up('pveCephInstallWizard').down('#submit').setText(gettext('Finish')); this.up('pveCephInstallWizard').down('#submit').setText(gettext('Finish'));
} }
}, },
column1: [ column1: [
{
xtype: 'component',
html: '<h3>Create initial Ceph config:</h3>'
},
{ {
xtype: 'displayfield', xtype: 'displayfield',
name: 'nodename', name: 'nodename',
fieldLabel: gettext('Node'), fieldLabel: gettext('Node'),
cbind: { cbind: {
value: '{nodename}' value: '{nodename}'
}, }
padding: 5
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
@ -154,7 +175,13 @@ Ext.define('PVE.ceph.CephInstallWizard', {
vtype: 'IPCIDRAddress', vtype: 'IPCIDRAddress',
value: '', value: '',
fieldLabel: 'Public Network IP/CIDR', fieldLabel: 'Public Network IP/CIDR',
allowBlank: false bind: {
allowBlank: '{configuration}'
},
setAllowBlank: function(allowBlank) {
this.allowBlank = allowBlank;
this.validate();
}
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
@ -165,6 +192,19 @@ Ext.define('PVE.ceph.CephInstallWizard', {
emptyText: gettext('Same as Public Network') emptyText: gettext('Same as Public Network')
} }
], ],
column2: [
{
xtype: 'component',
html: '<h3>Choose a monitor node:<br><small>(create additional ones later via monitor tab)</small></h3>'
},
{
xtype: 'pveNodeSelector',
fieldLabel: gettext('Monitor node'),
name: 'mon-node',
selectCurNode: true,
allowBlank: false
}
],
advancedColumn1: [ advancedColumn1: [
{ {
xtype: 'numberfield', xtype: 'numberfield',
@ -219,31 +259,40 @@ Ext.define('PVE.ceph.CephInstallWizard', {
}, },
onSubmit: function() { onSubmit: function() {
var me = this; var me = this;
var wizard = me.up('window'); if (!this.up('pveCephInstallWizard').getViewModel().get('configuration')) {
var kv = wizard.getValues(); var wizard = me.up('window');
delete kv['delete']; var kv = wizard.getValues();
var nodename = me.nodename; delete kv['delete'];
delete kv.nodename; var monNode = kv['mon-node'];
Proxmox.Utils.API2Request({ delete kv['mon-node'];
url: '/nodes/'+nodename+'/ceph/init', var nodename = me.nodename;
waitMsgTarget: wizard, delete kv.nodename;
method: 'POST', Proxmox.Utils.API2Request({
params: kv, url: '/nodes/' + nodename + '/ceph/init',
success: function() { waitMsgTarget: wizard,
var tp = me.up('#wizcontent'); method: 'POST',
var atab = tp.getActiveTab(); params: kv,
success: function() {
var next = tp.items.indexOf(atab) + 1; Proxmox.Utils.API2Request({
var ntab = tp.items.getAt(next); url: '/nodes/' + monNode + '/ceph/mon',
if (ntab) { waitMsgTarget: wizard,
ntab.enable(); method: 'POST',
tp.setActiveTab(ntab); success: function() {
me.up('pveCephInstallWizard').navigateNext();
},
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
}
});
},
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
} }
}, });
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus); } else {
} me.up('pveCephInstallWizard').navigateNext();
}); }
} }
}, },
{ {