Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add a "wizard mode" in FormManager for installer dialog.
Browse files Browse the repository at this point in the history
Rewrok the whole boot.conf installer with that.
  • Loading branch information
cdujeu committed Oct 7, 2015
1 parent f453007 commit cdbb837
Show file tree
Hide file tree
Showing 10 changed files with 407 additions and 213 deletions.
31 changes: 18 additions & 13 deletions core/src/plugins/boot.conf/class.AjxpInstaller.js
Expand Up @@ -54,10 +54,16 @@ Class.create("AjxpInstaller", AjxpPane, {
connexion.setParameters(params);
connexion.onComplete = function(transport){
var params = this.formManager.parseParameters(transport.responseXML, "//global_param");
this.formManager.createParametersInputs(this.formElement, params, true, false, false, false, false, true);
this.formElement.SF_accordion.observe("animation-finished", function(){
this.formManager.createParametersInputs(this.formElement, params, true, false, false, "wizard", false, true);
var saveButton = this.htmlElement.select('.SF_inlineButton').last();
this.formElement.observe("wizard:refreshed", function(event){
modal.refreshDialogPosition();
});
if(event.memo && event.memo.isLast){
this.formElement.down(".wizard_buttons").insert({bottom:saveButton});
}else{
this.htmlElement.insert({bottom:saveButton});
}
}.bind(this));
this.formElement.select("select").invoke("observe", "change", function(){
modal.refreshDialogPosition();
});
Expand All @@ -79,7 +85,7 @@ Class.create("AjxpInstaller", AjxpPane, {
}

var missing = this.formManager.serializeParametersInputs(this.formElement, new Hash(), '', true);
missing = (missing > 0 || !this.formElement.down('select[name="STORAGE_TYPE"]').getValue() || !passValidating);
missing = (missing > 0 || !passValidating);

if(!missing){
this.htmlElement.select('.SF_inlineButton').last().removeClassName("disabled");
Expand All @@ -91,29 +97,28 @@ Class.create("AjxpInstaller", AjxpPane, {
this.formElement.select('select').invoke("observe", "change", function(){
this.formManager.observeFormChanges(this.formElement, observer, 50);
}.bind(this));
this.updateAndBindButton(this.htmlElement.select('.SF_inlineButton').last());
this.bindPassword(this.formElement.down('input[name="ADMIN_USER_PASS"]').up('div.accordion_content'));
saveButton.hide();
this.updateAndBindButton(saveButton);
this.bindPassword(this.formElement.down('input[name="ADMIN_USER_PASS"]').up('div.wizard-pane'));
this.formElement.ajxpPaneObject.observe("after_replicate_row", function(newRow){
this.bindPassword(newRow);
}.bind(this));
this.htmlElement.down("#start_button").observe("click", function(){
new Effect.Morph(this.htmlElement.down(".install_pydio_logo"), {
style:'height:60px',
duration:0.5
});
this.htmlElement.down(".install_pydio_logo").hide();
this.htmlElement.down(".installerLang").hide();
this.htmlElement.down(".installerWelcome").update(MessageHash["installer.8"]);
this.htmlElement.down(".installerWelcome").hide();
new Effect.Appear(this.formElement, {afterFinish : function(){
this.formElement.SF_accordion.activate(this.formElement.down('.accordion_toggle'));
modal.refreshDialogPosition();
}.bind(this)});
}.bind(this));
document.fire("ajaxplorer:installer_loaded");
}.bind(this);
connexion.sendAsync();
},

bindPassword : function(contentDiv){
var passes = contentDiv.select('input[type="password"]');
var container = new Element("div", {className:'SF_element'});
var container = new Element("div", {className:'SF_element passStrengthContainer'});
passes[1].up('div.SF_element').insert({after:container});
var p = new Protopass(passes[0], {
barContainer:container,
Expand Down
118 changes: 53 additions & 65 deletions core/src/plugins/boot.conf/class.BootConfLoader.php
Expand Up @@ -69,19 +69,9 @@ public function loadManifest()
}
}

/**
* Transmit to the ajxp_conf load_plugin_manifest action
* @param $action
* @param $httpVars
* @param $fileVars
*/
public function loadInstallerForm($action, $httpVars, $fileVars)
{
if(isSet($httpVars["lang"])){
ConfService::setLanguage($httpVars["lang"]);
}
public function printFormFromServerSettings($fullManifest){

AJXP_XMLWriter::header("admin_data");
$fullManifest = $this->getManifestRawContent("", "xml");
$xPath = new DOMXPath($fullManifest->ownerDocument);
$addParams = "";
$pInstNodes = $xPath->query("server_settings/global_param[contains(@type, 'plugin_instance:')]");
Expand Down Expand Up @@ -126,6 +116,21 @@ public function loadInstallerForm($action, $httpVars, $fileVars)

}

/**
* Transmit to the ajxp_conf load_plugin_manifest action
* @param $action
* @param $httpVars
* @param $fileVars
*/
public function loadInstallerForm($action, $httpVars, $fileVars)
{
if(isSet($httpVars["lang"])){
ConfService::setLanguage($httpVars["lang"]);
}
$fullManifest = $this->getManifestRawContent("", "xml");
$this->printFormFromServerSettings($fullManifest);
}

/**
* Transmit to the ajxp_conf load_plugin_manifest action
* @param $action
Expand All @@ -145,51 +150,37 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
if(!isSet($coreAuth["MASTER_INSTANCE_CONFIG"])) $coreAuth["MASTER_INSTANCE_CONFIG"] = array();
$coreConf["AJXP_CLI_SECRET_KEY"] = AJXP_Utils::generateRandomString(24, true);

$storageType = $data["STORAGE_TYPE"]["type"];
if ($storageType == "db") {
// REWRITE BOOTSTRAP.JSON
$coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"];
if (isSet($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) {
$dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
// REWRITE BOOTSTRAP.JSON
$coreConf["DIBI_PRECONFIGURATION"] = $data["db_type"];
if (isSet($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) {
$dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array(
"instance_name"=> "conf.sql",
"group_switch_value"=> "conf.sql",
"SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")
));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array(
"instance_name"=> "auth.sql",
"group_switch_value"=> "auth.sql",
"SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")
));

// DETECT REQUIRED SQL TABLES AND INSTALL THEM
$registry = AJXP_PluginsService::getInstance()->getDetectedPlugins();
$driverData = array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]);
foreach($registry as $type => $plugins){
foreach($plugins as $plugObject){
if($plugObject instanceof SqlTableProvider){
$plugObject->installSQLTables($driverData);
}
}
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array(
"instance_name"=> "conf.sql",
"group_switch_value"=> "conf.sql",
"SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")
));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array(
"instance_name"=> "auth.sql",
"group_switch_value"=> "auth.sql",
"SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")
));

// DETECT REQUIRED SQL TABLES AND INSTALL THEM
$registry = AJXP_PluginsService::getInstance()->getDetectedPlugins();
$driverData = array("SQL_DRIVER" => $data["db_type"]);
foreach($registry as $type => $plugins){
foreach($plugins as $plugObject){
if($plugObject instanceof SqlTableProvider){
$plugObject->installSQLTables($driverData);
}
}

} else {

$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array(
"instance_name"=> "conf.serial",
"group_switch_value"=> "conf.serial"
));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array(
"instance_name"=> "auth.serial",
"group_switch_value"=> "auth.serial"
));

}


$oldBoot = $this->getPluginWorkDir(true)."/bootstrap.json";
if (is_file($oldBoot)) {
copy($oldBoot, $oldBoot.".bak");
Expand All @@ -200,10 +191,9 @@ public function applyInstallerForm($action, $httpVars, $fileVars)


// Write new bootstrap and reload conf plugin!
if ($storageType == "db") {
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
$coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
}
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
$coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];

$newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver");
$newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver");

Expand All @@ -224,14 +214,12 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
$htAccessToUpdate = AJXP_INSTALL_PATH."/.htaccess";
}

if ($storageType == "db") {
$sqlPlugs = array(
"core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql",
"core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql",
"core.mq/UNIQUE_MS_INSTANCE" => "mq.sql"
);
$data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"];
}
$sqlPlugs = array(
"core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql",
"core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql",
"core.mq/UNIQUE_MS_INSTANCE" => "mq.sql"
);
$data["ENABLE_NOTIF"] = true;


// Prepare plugins configs
Expand Down Expand Up @@ -328,7 +316,7 @@ public function testConnexions($action, $httpVars, $fileVars)

if ($action == "boot_test_sql_connexion") {

$p = AJXP_Utils::cleanDibiDriverParameters($data["STORAGE_TYPE"]["db_type"]);
$p = AJXP_Utils::cleanDibiDriverParameters($data["db_type"]);
if ($p["driver"] == "sqlite3") {
$dbFile = AJXP_VarsFilter::filter($p["database"]);
if (!file_exists(dirname($dbFile))) {
Expand Down
16 changes: 8 additions & 8 deletions core/src/plugins/boot.conf/i18n/conf/en.php
Expand Up @@ -20,16 +20,16 @@
*/

$mess = array(
"Admin access" => "<span class='icon-key'></span> Admin access",
"Global options" => "<span class='icon-cogs'></span> Global options",
"Configurations storage" => "<span class='icon-save'></span> Configurations storage",
"Add some users" => "<span class='icon-group'></span> Add some users",
"Admin access" => "Admin access",
"Global options" => "Global options",
"Configurations storage" => "Configurations storage",
"Add some users" => "Add some users",
"Please set up a login and password for the administrator user. This step is necessary to let you login the first time. You can create more administrators later by going to the 'Settings' workspace." => "Please set up a login and password for the administrator user. This step is necessary to let you login the first time. You can create more administrators later by going to the 'Settings' workspace.",
"Admin Login" => "Admin Login",
"Admin Login" => "Administrator Login",
"Alphanumeric login" => "Alphanumeric login",
"Admin Display Name" => "Admin Display Name",
"Admin Display Name" => "Administrator Full Name",
"Name that users will see" => "Name that users will see",
"Admin Password" => "Admin Password",
"Admin Password" => "Administrator Password",
"Use a strong password (more than 8 characters, complicated ones." => "Use a strong password (more than 8 characters, complicated ones.",
"Confirm" => "Confirm",
"Confirm password" => "Confirm password",
Expand All @@ -45,7 +45,7 @@
"Set up the correct value to send emails" => "Set up the correct value to send emails",
"Administrator Email" => "Administrator Email",
"Default 'From' email used to send emails." => "Default 'From' email used to send emails.",
"How the application configuration data will be stored (users, plugins, etc. not how your actual documents are managed). To get started rapidly, select No Database. To enable more advanced features, configure a database connection." => "How the application configuration data will be stored (users, plugins, etc. <b>not</b> how your actual documents are managed). 'No DB' mode can be suited for a quick test of the system, but it's not suited for production and you should always prefer a db-based setup (sqlite does not require any additional service).",
"How the application configuration data will be stored (users, plugins, etc. not how your actual documents are managed). To get started rapidly, select No Database. To enable more advanced features, configure a database connection." => "Database where the application configuration data will be stored (users, parameters, etc). This is <b>not</b> the place where your actual documents are managed. Use the 'Test Connexion' button to check the parameters before going to next step.",
"Storage Type" => "Storage Type",
"Select how the configurations will be stored" => "Select how the configurations will be stored",
"No Database (Quick Start)" => "No DB (Deprecated, use sqlite instead!)",
Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/boot.conf/i18n/en.php
Expand Up @@ -22,10 +22,10 @@
$mess = array(
"1" => "Pydio Setup Wizard",
"2" => "Welcome in the Pydio Setup Wizard",
"3" => "Thank you for installing Pydio!<br> This tool will make sure your new sharing platform is up and running in no time: browse through the various sections to set up the general behaviour of the application. You can fly over the fields labels with your mouse to get more information. <br>Are you ready ? ",
"4" => "Start Wizard!",
"3" => "Thank you for installing Pydio. <br/> Please follow this installation wizard to start sharing and syncing files across all of your devices in no time. Make sure to create a database and prepare your SQL credentials before starting. You can hover over the field labels for more information. <br/> Press start when you are ready",
"4" => "Start Wizard",
"5" => "Please wait while Pydio is being configured! It will be up and running in a couple of seconds...",
"6" => "Install Pydio Now",
"6" => "Install Pydio",
"7" => "Language",
"8" => "Click on each section to edit parameters",
);
79 changes: 79 additions & 0 deletions core/src/plugins/boot.conf/installer.css
@@ -0,0 +1,79 @@
#installer_form #save_button{
font-size: 17px;
clear: left;
width: 220px !important;
padding: 5px !important;
margin: 5px 126px !important;
}
#installer_form #save_button.disabled{
color: rgba(255,255,255,0.5);
cursor: default;
}
#installer_form .installerWelcome{
font-size: 13px;
line-height: initial;
padding: 7px 15px;
padding-bottom: 0;
}
#installer_form div.wizard_progress{
position: absolute;
width: 100%;
left: 0;
top: 0;
}
#installer_form div.wizard_buttons{
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: white;
border-top: 3px solid #D8D7D7;
text-align: right;
padding: 10px 20px;
margin-top: 0;
z-index: 7;
}

#installer_form #the_form{
margin-top:70px !important;
padding-bottom: 70px !important;
}
.form-installer_form > .dialogTitle {
display: none !important;
}
.form-installer_form > .dialogContent {
border-radius: 3px !important;
}
#installer_form .SF_element.form-element-ADMIN_USER_PASS, .SF_element.form-element-ADMIN_USER_PASS2{
float: left;
clear: none;
width: 50% !important;
}
#installer_form .SF_element.passStrengthContainer{
position: relative;
}
#installer_form .SF_element.passStrengthContainer .password-strength-bar-container{
margin-top: -6px !important;
z-index: 6 !important;
position: absolute !important;
width: 205px !important;
}
#installer_form .SF_element.passStrengthContainer .password-strength-bar{
height: 2px !important;
transition: width 550ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
margin-top:0 !important;
}
#installer_form .SF_element.passStrengthContainer .password-strength-info{
text-align:left !important;
padding-top:0 !important;
}
#installer_form .form-element-TEST_SQL .SF_inlineButton {
width: auto;
position: absolute;
bottom: 10px;
left: 20px;
z-index: 8;
}
#installer_form .form-element-TEST_SQL .SF_label {
display: none !important;
}

0 comments on commit cdbb837

Please sign in to comment.