commit 325df348a7bfd917572ee28d94ca8f5304b37c63
parent e1a0f3a7ee66ad8b392494f57694a29945c4d5b7
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 19 Dec 2011 09:14:13 +0100
Added the first few setup cards as well as the setup wizard. Please note that the setup only does pre-setup checks for now, the real database setup will follow later
Diffstat:
17 files changed, 711 insertions(+), 13 deletions(-)
diff --git a/build.xml b/build.xml
@@ -25,11 +25,19 @@
<target name="compile-theme">
<exec dir="theme/sass" command="compass compile partkeepr.scss" passthru="true"/>
<copy file="theme/css/partkeepr.css" tofile="frontend/css/partkeepr-theme.css"/>
+ <copy file="theme/css/partkeepr.css" tofile="setup/css/partkeepr-theme.css"/>
+
<copy todir="frontend/resources/themes/images/">
<fileset dir="theme/themes/images/">
<include name="**/*"/>
</fileset>
</copy>
+
+ <copy todir="setup/resources/themes/images/">
+ <fileset dir="theme/themes/images/">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
</target>
<target name="git-update-submodules">
@@ -38,6 +46,7 @@
<target name="build-setup">
<mkdir dir="setup/"/>
+ <mkdir dir="setup/js/wizard"/>
<copy overwrite="false" todir="setup/extjs/">
<fileset dir="${extjs.path}">
@@ -53,6 +62,12 @@
</fileset>
</copy>
+ <copy overwrite="true" todir="setup/js/wizard">
+ <fileset dir="3rdparty/ext-wizard/Ext.ux.Wizard">
+ <include name="**"/>
+ </fileset>
+ </copy>
+
<copy overwrite="true" todir="setup/">
<fileset dir="src/setup">
<include name="**"/>
diff --git a/src/setup/index.html b/src/setup/index.html
@@ -13,24 +13,41 @@
<link rel="stylesheet" type="text/css" href="js/Ext.ux/statusbar/css/statusbar.css"/>
<link rel="stylesheet" type="text/css" href="css/PartKeepr.css"/>
-
+ <link rel="stylesheet" type="text/css" href="resources/css/setup.css"/>
+ <link href="js/wizard/resources/css/ext-ux-wiz.css" rel="stylesheet" type="text/css" />
+
<link rel="icon" href="favicon.ico"/>
<!-- Include the ExtJS JavaScript Library -->
<script type="text/javascript" src="extjs/bootstrap.js"></script>
-
- <script type="text/javascript" src="extjs/ext-all.js"></script>
+ <script type="text/javascript" src="extjs/ext-all-debug.js"></script>
+
+
+ <!-- Include the Ext.ux.Wizard Library -->
+ <script type="text/javascript" src="js/wizard/Ext.ux.Wizard.CardLayout.js"></script>
+ <script type="text/javascript" src="js/wizard/Ext.ux.Wizard.Card.js"></script>
+ <script type="text/javascript" src="js/wizard/Ext.ux.Wizard.Header.js"></script>
+ <script type="text/javascript" src="js/wizard/Ext.ux.Wizard.js"></script>
<!-- Note that the files here are not minified to make debugging easier -->
- <script type="text/javascript" src="js/PartKeeprSetup.js"></script>
+ <script type="text/javascript" src="js/SetupWizard.js"></script>
<script type="text/javascript" src="js/TestResultPanel.js"></script>
<script type="text/javascript" src="js/TestRunner.js"></script>
+ <script type="text/javascript" src="js/Cards/PrequisitesTestCard.js"></script>
+ <script type="text/javascript" src="js/Cards/DatabaseParametersCard.js"></script>
+ <script type="text/javascript" src="js/Cards/DatabaseParametersCard.MySQL.js"></script>
+ <script type="text/javascript" src="js/Cards/DatabaseParametersCard.PostgreSQL.js"></script>
+ <script type="text/javascript" src="js/Cards/DatabaseConnectivityTestCard.js"></script>
+
<script type="text/javascript" src="js/SetupTests/BaseSetupTest.js"></script>
<script type="text/javascript" src="js/SetupTests/PHPTest.js"></script>
<script type="text/javascript" src="js/SetupTests/PHPPrequisitesTest.js"></script>
<script type="text/javascript" src="js/SetupTests/DoctrineTest.js"></script>
+ <script type="text/javascript" src="js/SetupTests/DatabaseConnectivityTest.js"></script>
+
+ <script type="text/javascript" src="js/PartKeeprSetup.js"></script>
</head>
<body>
</body>
diff --git a/src/setup/js/Cards/DatabaseConnectivityTestCard.js b/src/setup/js/Cards/DatabaseConnectivityTestCard.js
@@ -0,0 +1,89 @@
+
+/**
+ * This card tests the database connectivity for the MySQL database.
+ */
+Ext.define('PartKeeprSetup.DatabaseConnectivityTestCard', {
+ extend: 'Ext.ux.wizard.Card',
+
+ /**
+ * Contains the test results for this card
+ * @var PartKeeprSetup.TestResultPanel
+ */
+ testResultPanel: null,
+
+ /**
+ * Contains the initially hidden "Re-test" button to re-trigger the tests.
+ */
+ retestButton: null,
+
+ /**
+ * Various Style Settings
+ */
+ title: 'Checking Database Connectivity',
+ showTitle: true,
+ titleCls: '',
+ titleStyle: 'font-size: 2.5em;',
+ cls: 'x-partkeepr-setup-basecard',
+
+ autoScroll: true,
+
+
+
+ /**
+ * Inits the component
+ */
+ initComponent: function () {
+ this.testResultPanel = Ext.create("PartKeeprSetup.TestResultPanel");
+ this.testResultPanel.on("test-error", this.onTestError, this);
+
+ this.retestButton = Ext.create("Ext.button.Button", {
+ text: 'Re-run checks',
+ hidden: true
+ });
+
+ this.retestButton.on("click", this.retest, this);
+
+ this.items = [{
+ border: false,
+ bodyStyle: 'background:none;padding-bottom: 10px;',
+ html: 'Setup tests if the database is reachable...'
+ },
+ this.testResultPanel,
+ this.retestButton ];
+
+ this.callParent();
+ this.on("activate", this.onActivate, this);
+ },
+ retest: function () {
+ this.retestButton.hide();
+ this.runTests();
+ },
+ onActivate: function () {
+ console.log("BAR");
+ this.ownerCt.ownerCt.nextButton.setDisabled(true);
+
+ this.runTests();
+ },
+ runTests: function () {
+ this.testResultPanel.clear();
+
+ var tests = new Array();
+
+ var j = Ext.create("PartKeeprSetup.DatabaseConnectivityTest");
+ console.log(Ext.getCmp("database-parameters-card").dbparams);
+ j.params = Ext.getCmp("database-parameters-card").dbparams;
+
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var tr = Ext.create("PartKeeprSetup.TestRunner");
+ tr.run(tests);
+ tr.on("success", this.onTestSuccessful, this);
+ },
+ onTestError: function () {
+ this.retestButton.show();
+ },
+ onTestSuccessful: function () {
+ this.ownerCt.ownerCt.nextButton.setDisabled(false);
+ }
+});
diff --git a/src/setup/js/Cards/DatabaseParametersCard.MySQL.js b/src/setup/js/Cards/DatabaseParametersCard.MySQL.js
@@ -0,0 +1,124 @@
+/**
+ * This card displays the database parameters for the MySQL database.
+ */
+Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', {
+ extend: 'Ext.panel.Panel',
+
+ border: false,
+ layout: 'column',
+ bodyStyle: {
+ background: "none"
+ },
+ defaults: {
+ labelWidth: 120
+ },
+
+ initComponent: function () {
+ this.createHintTemplate = Ext.create("Ext.Template", [
+ "<code>CREATE DATABASE {dbname} CHARACTER SET UTF8;<br/>GRANT USAGE ON *.* TO {user}@{host} IDENTIFIED BY '{password}';<br/>GRANT ALL PRIVILEGES ON {dbname}.* TO {user}@{host};<br/><br/>"
+ ]);
+
+ this.masterTemplate = Ext.create("Ext.Template", ["The database must be manually created prior installation. Please note that we don't support UNIX sockets at this time - only TCP connections are supported." ]);
+
+ this.hostname = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Hostname',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.hostname.on("change", this.onUpdateParameters, this);
+
+ this.username = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Username',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.username.on("change", this.onUpdateParameters, this);
+
+ this.password = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Password',
+ inputType: "password",
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.password.on("change", this.onUpdateParameters, this);
+
+ this.databaseName = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Name',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.databaseName.on("change", this.onUpdateParameters, this);
+
+ this.showHintCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ xtype: 'checkboxfield',
+ boxLabel: 'Show commands to create the database',
+ listeners: {
+ change: this.onUpdateParameters,
+ scope: this
+ }
+ });
+
+ this.items = [{
+ xtype: 'panel',
+ border: false,
+ width: "300px",
+ bodyStyle: {
+ background: "none"
+ },
+ items: [
+ this.hostname,
+ this.databaseName,
+ this.username,
+ this.password
+ ]
+ },{
+ xtype: 'panel',
+ border: false,
+ bodyStyle: {
+ background: "none"
+ },
+ items: [
+ this.showHintCheckbox
+ ,{
+ border: false,
+ style: 'overflow: auto;',
+ width: "450px",
+ height: "100px",
+ autoScroll: true,
+ layout: 'fit',
+ id: 'mysql-parameters-hint',
+ html: " "
+ }]
+ }];
+
+ this.callParent();
+
+ this.on("activate", this.onUpdateParameters, this);
+ },
+ onUpdateParameters: function () {
+ if (this.showHintCheckbox.checked) {
+ this.createHintTemplate.overwrite(Ext.get("mysql-parameters-hint"), {
+ host: this.hostname.getValue(),
+ user: this.username.getValue(),
+ password: this.password.getValue(),
+ dbname: this.databaseName.getValue()
+ });
+
+ this.masterTemplate.append(Ext.get("mysql-parameters-hint"));
+ } else {
+ this.masterTemplate.overwrite(Ext.get("mysql-parameters-hint"));
+ }
+
+ if (this.hostname.getValue() != "" && this.username.getValue() != "" && this.password.getValue() != "" && this.databaseName.getValue() != "") {
+ this.paramsheet.ownerCt.ownerCt.nextButton.setDisabled(false);
+ }
+
+ this.paramsheet.dbparams = {
+ driver: 'mysql',
+ host: this.hostname.getValue(),
+ user: this.username.getValue(),
+ password: this.password.getValue(),
+ dbname: this.databaseName.getValue()
+ };
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/js/Cards/DatabaseParametersCard.PostgreSQL.js b/src/setup/js/Cards/DatabaseParametersCard.PostgreSQL.js
@@ -0,0 +1,46 @@
+/**
+ * This card displays the database parameters for the PostgreSQL database.
+ */
+Ext.define('PartKeeprSetup.DatabaseParametersCard.PostgreSQL', {
+ extend: 'Ext.panel.Panel',
+
+ border: false,
+ bodyStyle: {
+ background: "none"
+ },
+ defaults: {
+ labelWidth: 120
+ },
+
+ initComponent: function () {
+ this.hostname = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Hostname',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.username = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Username',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.password = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Password',
+ inputType: "password",
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.databaseName = Ext.create("Ext.form.field.Text", {
+ fieldLabel: 'Database Name',
+ labelWidth: this.defaults.labelWidth
+ });
+
+ this.items = [
+ this.hostname,
+ this.databaseName,
+ this.username,
+ this.password
+ ];
+
+ this.callParent();
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/js/Cards/DatabaseParametersCard.js b/src/setup/js/Cards/DatabaseParametersCard.js
@@ -0,0 +1,109 @@
+/**
+ * This card displays the database parameters.
+ */
+Ext.define('PartKeeprSetup.DatabaseParametersCard', {
+ extend: 'Ext.ux.wizard.Card',
+
+ /**
+ * Various Style Settings
+ */
+ title: 'Database Parameters',
+ showTitle: true,
+ titleCls: '',
+ titleStyle: 'font-size: 2.5em;',
+ cls: 'x-partkeepr-setup-basecard',
+ id: 'database-parameters-card',
+ autoScroll: true,
+
+
+
+ /**
+ * Inits the component
+ */
+ initComponent: function () {
+
+ this.createDatabaseDropdown();
+
+ this.databaseSettings = Ext.create("Ext.panel.Panel", {
+ layout: 'card',
+ border: false,
+ bodyStyle: {
+ background: "none"
+ },
+ items: [{
+ border: false,
+ bodyStyle: {
+ background: "none"
+ },
+ html: 'Please select a database driver'
+ },
+ Ext.create("PartKeeprSetup.DatabaseParametersCard.MySQL", { paramsheet: this }),
+ Ext.create("PartKeeprSetup.DatabaseParametersCard.PostgreSQL", { paramsheet: this })
+ ]
+ });
+
+ this.items = [{
+ border: false,
+ bodyStyle: 'background:none;padding-bottom: 10px;',
+ html: 'Please enter your database parameters below:'
+ },
+ this.databaseDropdown,
+ this.databaseSettings
+ ];
+
+ this.callParent();
+ this.on("activate", this.onActivate, this);
+ },
+ createDatabaseDropdown: function () {
+ // The data store containing the list of states
+ var databaseTypes = Ext.create('Ext.data.Store', {
+ fields: ['type', 'name'],
+ data : [
+ {"type":"mysql", "name":"MySQL"},
+ //{"type":"postgresql", "name":"PostgreSQL"}
+ ]
+ });
+
+ this.databaseDropdown = Ext.create('Ext.form.ComboBox', {
+ labelWidth: 120,
+ fieldLabel: 'Database Type',
+ store: databaseTypes,
+ queryMode: 'local',
+ displayField: 'name',
+ valueField: 'type',
+ triggerAction: 'all',
+ editable: false
+ });
+
+ this.databaseDropdown.on("select", this.onDriverSelect, this);
+
+ },
+ onDriverSelect: function (a,r) {
+ if (r.length == 1) {
+ switch (r[0].get("type")) {
+ case "mysql":
+ this.databaseSettings.layout.setActiveItem(1);
+ break;
+ case "postgresql":
+ this.databaseSettings.layout.setActiveItem(2);
+ break;
+ default:
+ this.databaseSettings.layout.setActiveItem(0);
+ }
+ } else {
+ this.databaseSettings.layout.setActiveItem(0);
+ }
+
+ this.ownerCt.ownerCt.nextButton.setDisabled(true);
+ },
+ retest: function () {
+ this.retestButton.hide();
+ this.runTests();
+ },
+ onActivate: function () {
+ this.ownerCt.ownerCt.nextButton.setDisabled(true);
+
+ // Manually fire the activate event, in case the user switched cards back/forth.
+ this.databaseSettings.layout.getActiveItem().fireEvent("activate");
+ }
+});
diff --git a/src/setup/js/Cards/PrequisitesTestCard.js b/src/setup/js/Cards/PrequisitesTestCard.js
@@ -0,0 +1,92 @@
+/**
+ * This card runs the prequisites test to make sure basic things like PHP and Doctrine are installed and configured.
+ */
+Ext.define('PartKeeprSetup.PrequisitesTestCard', {
+ extend: 'Ext.ux.wizard.Card',
+
+ /**
+ * Contains the test results for this card
+ * @var PartKeeprSetup.TestResultPanel
+ */
+ testResultPanel: null,
+
+ /**
+ * Contains the initially hidden "Re-test" button to re-trigger the tests.
+ */
+ retestButton: null,
+
+ /**
+ * Various Style Settings
+ */
+ title: 'Checking prequisites',
+ showTitle: true,
+ titleCls: '',
+ titleStyle: 'font-size: 2.5em;',
+ cls: 'x-partkeepr-setup-basecard',
+
+ autoScroll: true,
+
+
+
+ /**
+ * Inits the component
+ */
+ initComponent: function () {
+ this.testResultPanel = Ext.create("PartKeeprSetup.TestResultPanel");
+ this.testResultPanel.on("test-error", this.onTestError, this);
+
+ this.retestButton = Ext.create("Ext.button.Button", {
+ text: 'Re-run checks',
+ hidden: true
+ });
+
+ this.retestButton.on("click", this.retest, this);
+
+ this.items = [{
+ border: false,
+ bodyStyle: 'background:none;padding-bottom: 10px;',
+ html: 'Setup now checks if your server is capable of running PartKeepr.'
+ },
+ this.testResultPanel,
+ this.retestButton ];
+
+ this.callParent();
+ this.on("activate", this.onActivate, this);
+ },
+ retest: function () {
+ this.retestButton.hide();
+ this.runTests();
+ },
+ onActivate: function () {
+ this.ownerCt.ownerCt.nextButton.setDisabled(true);
+
+ this.runTests();
+ },
+ runTests: function () {
+ this.testResultPanel.clear();
+
+ var tests = new Array();
+
+ var j = Ext.create("PartKeeprSetup.PHPTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var j = Ext.create("PartKeeprSetup.PHPPrequisitesTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var j = Ext.create("PartKeeprSetup.DoctrineTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var tr = Ext.create("PartKeeprSetup.TestRunner");
+ tr.run(tests);
+ tr.on("success", this.onTestSuccessful, this);
+ },
+ onTestError: function () {
+ this.retestButton.show();
+ },
+ onTestSuccessful: function () {
+ this.ownerCt.ownerCt.nextButton.setDisabled(false);
+ }
+});
diff --git a/src/setup/js/PartKeeprSetup.js b/src/setup/js/PartKeeprSetup.js
@@ -7,7 +7,7 @@ Ext.application({
var tests = new Array();
- var j = Ext.create("PartKeeprSetup.PHPTest");
+ /*var j = Ext.create("PartKeeprSetup.PHPTest");
j.callback = this.testResultPanel;
tests.push(j);
@@ -20,7 +20,7 @@ Ext.application({
tests.push(j);
var tr = Ext.create("PartKeeprSetup.TestRunner");
- tr.run(tests);
+ tr.run(tests);*/
//j.on("complete", function () { this.testResultPanel.appendTestResult(this); }, j);
},
@@ -28,12 +28,14 @@ Ext.application({
* Creates the main viewport
*/
createLayout: function () {
- this.testResultPanel = Ext.create("PartKeeprSetup.TestResultPanel");
+ var wizard = Ext.create("PartKeeprSetup.SetupWizard");
+ wizard.show();
+ /*this.testResultPanel = Ext.create("PartKeeprSetup.TestResultPanel");
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [this.testResultPanel]
- });
+ });*/
}
});
\ No newline at end of file
diff --git a/src/setup/js/SetupTests/BaseSetupTest.js b/src/setup/js/SetupTests/BaseSetupTest.js
@@ -22,10 +22,12 @@ Ext.define('PartKeeprSetup.BaseSetupTest', {
* Runs a given test, and processes the response
*/
run: function () {
+ console.log(this.params);
Ext.Ajax.request({
url: this.url,
success: this.onSuccess,
- scope: this
+ scope: this,
+ params: this.params
});
},
diff --git a/src/setup/js/SetupTests/DatabaseConnectivityTest.js b/src/setup/js/SetupTests/DatabaseConnectivityTest.js
@@ -0,0 +1,9 @@
+/**
+ * A minimalistic PHP check to make sure PHP is installed on the server and activated as PHP module.
+ */
+Ext.define('PartKeeprSetup.DatabaseConnectivityTest', {
+ extend: 'PartKeeprSetup.BaseSetupTest',
+ url: 'tests/check-database-connectivity.php',
+ name: "Database",
+ message: "Testing for database connectivity"
+});+
\ No newline at end of file
diff --git a/src/setup/js/SetupWizard.js b/src/setup/js/SetupWizard.js
@@ -0,0 +1,87 @@
+Ext.define('PartKeeprSetup.SetupWizard', {
+ extend: 'Ext.ux.Wizard',
+
+ width: 850,
+ height: 800,
+ closable: false,
+ name: 'FOO',
+ title: 'PartKeepr Setup',
+ cardPanelConfig: {
+ defaults: {
+ baseCls: 'x-small-editor',
+ bodyStyle: 'padding:10px 15px 5px 10px;background-color:#F6F6F6;',
+ border: false
+ },
+ layout: 'card'
+ },
+
+ // no headConfig suplied no header will be shown.
+ headConfig: {
+ // title: 'Simple Wizard Head title Example',
+ headerPosition: 'bottom',
+ position: 'top', // or bottom
+ cls: "x-setup-header",
+ stepText: "<center>Step {0} of {1}: {2}</center>"
+ },
+
+ width: 800, height: 500,
+ closable: false,
+
+ includeHeaderPanel: true,
+
+ initComponent: function () {
+ this.cards = this.setupCards();
+ this.callParent();
+
+ this.headPanel.show();
+ },
+
+ setupCards: function () {
+ var cards = new Array();
+
+ cards.push(Ext.create('Ext.ux.wizard.Card', {
+ title: 'Welcome',
+ showTitle: true,
+ titleCls: '',
+ titleStyle: 'font-size: 2.5em;',
+ cls: 'x-partkeepr-setup-basecard',
+ items: [{
+ border: false,
+ bodyStyle: 'background:none;',
+ html: 'This wizard guides you through the setup of <b>PartKeepr</b>.'
+ }]
+ }));
+
+
+ cards.push(Ext.create("PartKeeprSetup.PrequisitesTestCard"));
+ cards.push(Ext.create("PartKeeprSetup.DatabaseParametersCard"));
+ cards.push(Ext.create("PartKeeprSetup.DatabaseConnectivityTestCard"));
+ /*
+ Ext.create('Ext.ux.wizard.Card', {
+ deferredRender: true,
+ title: 'Checking prequisites',
+ showTitle: true,
+ titleCls: '',
+ autoScroll: true,
+ titleStyle: 'font-size: 2.5em;',
+ cls: 'x-partkeepr-setup-basecard',
+ items: [{
+ border: false,
+ bodyStyle: 'background:none;margin-bottom: 2px;',
+ html: 'Setup now checks if your server is capable of running PartKeepr.'
+ }, this.testResultPanel, this.retestPrequisitesButton ],
+ listeners: {
+ activate: function () {
+ this.nextButton.setDisabled(true);
+
+ this.testResultPanel.clear();
+
+
+ },
+ scope: this
+ }
+ }));*/
+
+ return cards;
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/js/TestResultPanel.js b/src/setup/js/TestResultPanel.js
@@ -1,16 +1,42 @@
+/**
+ * Provides a simple panel where tests can be displayed including their status.
+ */
Ext.define('PartKeeprSetup.TestResultPanel', {
extend: 'Ext.panel.Panel',
+
+ /**
+ * Initializes the component.
+ */
+ initComponent: function () {
+ this.addEvents("test-error");
+ this.callParent();
+ },
+ /**
+ * Clears the result output panel.
+ */
+ clear: function () {
+ this.removeAll(true);
+ },
+
+ /**
+ * Appends the specific test to the output panel,
+ * and fires the error event if an error occured.
+ *
+ * @param test PartKeeprSetup.BaseSetupTest
+ */
appendTestResult: function (test) {
var response;
if (test.success) {
- response = "OK";
+ response = '<b style="color: green;">OK</b>';
} else {
- response = "Error. "+test.errorMessage
+ response = '<b style="color: red;">Error</b><br/><br>'+test.errorMessage;
+ this.fireEvent("test-error");
}
this.add({
+ border: false,
html: test.message +"..."+response
});
}
diff --git a/src/setup/js/TestRunner.js b/src/setup/js/TestRunner.js
@@ -1,15 +1,20 @@
Ext.define('PartKeeprSetup.TestRunner', {
extend: 'Ext.util.Observable',
+ initComponent: function () {
+ this.addEvents("success");
+
+ this.callParent();
+ },
run: function (tests) {
test = tests.shift();
if (!test) {
+ this.fireEvent("success");
return;
}
test.on("complete", function () { this.run(tests); }, this);
test.run();
-
}
});
\ No newline at end of file
diff --git a/src/setup/resources/css/setup.css b/src/setup/resources/css/setup.css
@@ -0,0 +1,10 @@
+.x-setup-header {
+ background-image: url(../setup_header.jpg);
+ background-repeat: no-repeat;
+ border-bottom: 3px solid #aaaaaa !important;
+}
+
+.x-partkeepr-setup-basecard .x-panel-header-body {
+ height: 30px;
+}
+
diff --git a/src/setup/resources/setup_header.jpg b/src/setup/resources/setup_header.jpg
Binary files differ.
diff --git a/src/setup/tests/check-database-connectivity.php b/src/setup/tests/check-database-connectivity.php
@@ -0,0 +1,46 @@
+<?php
+require_once 'Doctrine/Common/ClassLoader.php';
+
+use Doctrine\Common\ClassLoader;
+
+$classLoader = new ClassLoader('Doctrine\DBAL');
+$classLoader->register(); // register on SPL autoload stack
+
+$classLoader = new ClassLoader('Doctrine\Common');
+$classLoader->register(); // register on SPL autoload stack
+
+
+$config = new \Doctrine\DBAL\Configuration();
+
+
+switch ($_REQUEST["driver"]) {
+ case "mysql":
+ $driver = "pdo_mysql";
+ break;
+ default:
+ echo json_encode(array("error" => true, "errormessage" => "Unknown driver ".$_REQUEST["driver"]));
+ exit;
+ break;
+}
+
+$connectionOptions = array(
+ 'driver' => $driver,
+ 'dbname' => $_REQUEST["dbname"],
+ 'user' => $_REQUEST["user"],
+ 'password' => $_REQUEST["password"],
+ 'host' => $_REQUEST["host"]
+);
+
+
+$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionOptions, $config);
+try {
+ $conn->connect();
+} catch (\PDOException $e) {
+ echo json_encode(array("error" => true, "errormessage" => "There was an error connecting to the database:<br/><code>".$e->getMessage()."</code>"));
+ exit;
+} catch (\Exception $e) {
+ echo json_encode(array("error" => true, "errormessage" => "An unknown error occured. The error is: <code>".$e->getMessage()."</code>"));
+ exit;
+}
+
+echo json_encode(array("error" => false));
diff --git a/src/setup/tests/check-doctrine.php b/src/setup/tests/check-doctrine.php
@@ -1,10 +1,25 @@
<?php
@include_once 'Doctrine/Common/ClassLoader.php';
+$installDoctrineError = "Doctrine needs to be installed and in the PHP include_path. You can install doctrine on most unix systems using: <br/><br/><code>pear channel-discover pear.doctrine-project.org<br/>pear install pear.doctrine-project.org/DoctrineORM</code>";
+
if (!class_exists("\\Doctrine\\Common\ClassLoader")) {
- echo json_encode(array("error" => true, "errormessage" => "Doctrine needs to be installed and in the PHP include_path. You can install doctrine on most unix systems using 'pear channel-discover pear.doctrine-project.org && pear install pear.doctrine-project.org/DoctrineORM'"));
+ echo json_encode(array("error" => true, "errormessage" => $installDoctrineError));
exit;
}
+use Doctrine\Common\ClassLoader;
+$classLoader = new ClassLoader('Doctrine\ORM');
+$classLoader->register(); // register on SPL autoload stack
+
+if (!$classLoader->canLoadClass("Doctrine\\ORM\\Version")) {
+ echo json_encode(array("error" => true, "errormessage" => $installDoctrineError));
+ exit;
+}
+
+if (\Doctrine\ORM\Version::compare("2.1.0") == 1) {
+ echo json_encode(array("error" => true, "errormessage" => "DoctrineORM is installed, but needs to be at Version 2.1.0 or higher. Please run pear upgrade-all to bring your packages up-to-date."));
+ exit;
+}
echo json_encode(array("error" => false));
exit;