commit 6906a0ea3acb9212ba0b939a8dcad09f31f83a8f
parent 74c0b2bc06d411a3bb0b11e6e8f24a2c8bae1069
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 12 Oct 2015 13:10:57 +0200
Skip creating the admin user if a config already exists
Diffstat:
5 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/web/setup/js/Cards/AdminUserCard.js b/web/setup/js/Cards/AdminUserCard.js
@@ -13,7 +13,7 @@ Ext.define('PartKeeprSetup.AdminUserCard', {
autoScroll: true,
breadCrumbTitle: 'Admin User',
-
+ layout: 'card',
defaults: {
labelWidth: 120
},
@@ -56,13 +56,22 @@ Ext.define('PartKeeprSetup.AdminUserCard', {
this.items = [
{
- border: false,
- bodyStyle: 'background:none;padding-bottom: 10px;',
- html: 'Please enter the user which will become the administrator:'
- },
- this.username,
- this.password,
- this.email
+
+ items: [{
+ border: false,
+ bodyStyle: 'background:none;padding-bottom: 10px;',
+ html: 'Please enter the user which will become the administrator:'
+ },
+ this.username,
+ this.password,
+ this.email
+ ]
+ }, {
+ border: false,
+ bodyStyle: 'background:none;padding-bottom: 10px;',
+ html: 'An existing installation has been detected, no new user will be created. Click Next to continue.'
+ }
+
];
this.callParent();
@@ -73,6 +82,12 @@ Ext.define('PartKeeprSetup.AdminUserCard', {
*/
onActivate: function ()
{
+ if (PartKeeprSetup.getApplication().getSetupConfig().existingConfig === true) {
+ this.layout.setActiveItem(1);
+ } else {
+ this.layout.setActiveItem(0);
+ }
+
// Disable the "next" button, this needs to get enabled by the database cards
Ext.ComponentQuery.query('#nextBtn')[0].disable();
this.onUpdateParameters();
diff --git a/web/setup/js/PartKeeprSetup.js b/web/setup/js/PartKeeprSetup.js
@@ -25,6 +25,7 @@ Ext.application({
password: "",
email: ""
},
+ existingConfig: false,
authKey: ""
};
diff --git a/web/setup/js/SetupSteps/AdminUserSetup.js b/web/setup/js/SetupSteps/AdminUserSetup.js
@@ -6,4 +6,12 @@ Ext.define('PartKeeprSetup.AdminUserSetup', {
action: 'createUser',
name: "Database",
message: "Setting up the admin user",
+
+ onBeforeRunTest: function () {
+ this.callParent(arguments);
+
+ if (PartKeeprSetup.getApplication().getSetupConfig().existingConfig) {
+ this.skip = true;
+ }
+ }
});
diff --git a/web/setup/js/SetupTests/AbstractTest.js b/web/setup/js/SetupTests/AbstractTest.js
@@ -36,6 +36,12 @@ Ext.define('PartKeeprSetup.AbstractTest', {
errors: [],
/**
+ * Defines if a test should be skipped. No output will be generated.
+ * @var {Boolean}
+ */
+ skip: false,
+
+ /**
* Defines any warnings for the test.
*/
warnings: null,
@@ -58,8 +64,6 @@ Ext.define('PartKeeprSetup.AbstractTest', {
constructor: function (config)
{
this.mixins.observable.constructor.call(this, config);
-
- //this.addEvents("complete");
},
/**
* Runs a given test, and processes the response
@@ -68,6 +72,10 @@ Ext.define('PartKeeprSetup.AbstractTest', {
{
this.onBeforeRunTest();
+ if (this.skip === true) {
+ this.fireEvent("complete", this);
+ return;
+ }
var url = this.url;
if (this.action !== "") {
@@ -150,6 +158,11 @@ Ext.define('PartKeeprSetup.AbstractTest', {
{
this.params = PartKeeprSetup.getApplication().getSetupConfig();
},
+ /**
+ * Gets called after test exeuction. Useful for post-processing any result
+ *
+ * @param data {Object} The response data as object
+ */
onAfterRunTest: function (data)
{
diff --git a/web/setup/js/SetupTests/ExistingConfigurationTest.js b/web/setup/js/SetupTests/ExistingConfigurationTest.js
@@ -8,11 +8,11 @@ Ext.define('PartKeeprSetup.ExistingConfigurationTest', {
message: "Retrieving existing configuration",
onAfterRunTest: function (data) {
- var config = PartKeeprSetup.getApplication().getSetupConfig();
-
- Ext.apply(config, data.config);
-
- console.log(PartKeeprSetup.getApplication().getSetupConfig());
+ if (data.config) {
+ var config = PartKeeprSetup.getApplication().getSetupConfig();
+ Ext.apply(config, data.config);
+ config.existingConfig = true;
+ }
}
});