mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Factorized the tools to create/update a given installation (environment)
SVN:trunk[1761]
This commit is contained in:
146
setup/setup.js
146
setup/setup.js
@@ -161,103 +161,69 @@ function DoSubmit(sMsg, iStep)
|
|||||||
|
|
||||||
function DoCompileDataModel()
|
function DoCompileDataModel()
|
||||||
{
|
{
|
||||||
try
|
$('#log').html('');
|
||||||
{
|
$('#setup').block({message: '<p><span id="setup_msg">Preparing data model...</span><br/><div id=\"progress\">0%</div></p>'});
|
||||||
// Call the asynchronous page that performs the compilation of the data model and the creation of the configuration file
|
$('#progress').progression( {Current:5, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
||||||
$('#log').html('');
|
|
||||||
$('#setup').block({message: '<p><span id="setup_msg">Preparing data model...</span><br/><div id=\"progress\">0%</div></p>'});
|
var sSelectedModules = GetSelectedModules();
|
||||||
$('#progress').progression( {Current:5, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
var sMode = $(':input[name=mode]').val();
|
||||||
$('#log').load( 'ajax.dataloader.php',
|
var sSourceDir = $(':input[name=source_dir]').val();
|
||||||
{
|
var sTargetDir = $(':input[name=target_dir]').val();
|
||||||
'operation': 'compile_data_model',
|
|
||||||
'selected_modules': GetSelectedModules(),
|
// Call the asynchronous page that performs the compilation of the data model and the creation of the configuration file
|
||||||
'mode': $(':input[name=mode]').val(),
|
AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, function(response, status, xhr) {
|
||||||
'source_dir': $(':input[name=source_dir]').val(),
|
$('#log').html(response);
|
||||||
'target_dir': $(':input[name=target_dir]').val()
|
DoUpdateDBSchema();
|
||||||
},
|
});
|
||||||
DoUpdateDBSchema, 'html');
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
alert('An exception occured: '+err);
|
|
||||||
}
|
|
||||||
return false; // Do NOT submit the form yet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function DoUpdateDBSchema()
|
function DoUpdateDBSchema()
|
||||||
{
|
{
|
||||||
try
|
$('#log').html('');
|
||||||
{
|
$('#setup').block({message: '<p><span id="setup_msg">Updating DB schema...</span><br/><div id=\"progress\">5%</div></p>'});
|
||||||
// Call the asynchronous page that performs the creation/update of the DB Schema
|
$('#progress').progression( {Current:10, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
||||||
$('#log').html('');
|
|
||||||
$('#setup').block({message: '<p><span id="setup_msg">Updating DB schema...</span><br/><div id=\"progress\">5%</div></p>'});
|
var sSelectedModules = GetSelectedModules();
|
||||||
$('#progress').progression( {Current:10, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
var sMode = $(':input[name=mode]').val();
|
||||||
$('#log').load( 'ajax.dataloader.php',
|
var sModulesDir = $(':input[name=target_dir]').val();
|
||||||
{
|
var sDBServer = $(':input[name=db_server]').val();
|
||||||
'operation': 'update_db_schema',
|
var sDBUser = $(':input[name=db_user]').val();
|
||||||
'selected_modules': GetSelectedModules(),
|
var sDBPwd = $(':input[name=db_pwd]').val();
|
||||||
'mode': $(':input[name=mode]').val(),
|
var sDBName = $(':input[name=db_name]').val();
|
||||||
'db_server': $(':input[name=db_server]').val(),
|
var sNewDBName = $(':input[name=new_db_name]').val();
|
||||||
'db_user': $(':input[name=db_user]').val(),
|
var sDBPrefix = $(':input[name=db_prefix]').val();
|
||||||
'db_pwd': $(':input[name=db_pwd]').val(),
|
|
||||||
'db_name': $(':input[name=db_name]').val(),
|
// Call the asynchronous page that performs the creation/update of the DB Schema
|
||||||
'new_db_name': $(':input[name=new_db_name]').val(),
|
AsyncUpdateDBSchema(sSelectedModules, sMode, sModulesDir, sDBServer, sDBUser, sDBPwd, sDBName, sNewDBName, sDBPrefix, function(response, status, xhr) {
|
||||||
'db_prefix': $(':input[name=db_prefix]').val(),
|
$('#log').html(response);
|
||||||
'modules_dir': $(':input[name=target_dir]').val()
|
DoUpdateProfiles();
|
||||||
},
|
});
|
||||||
DoUpdateProfiles, 'html');
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
alert('An exception occured: '+err);
|
|
||||||
}
|
|
||||||
return false; // Do NOT submit the form yet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function DoUpdateProfiles(response, status, xhr)
|
function DoUpdateProfiles()
|
||||||
{
|
{
|
||||||
if (status == 'error')
|
$('#log').html('');
|
||||||
{
|
$('#setup_msg').text('Updating Profiles...');
|
||||||
$('#setup').unblock();
|
$('#progress').progression( {Current:40, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
||||||
return; // An error occurred !
|
|
||||||
}
|
var sSelectedModules = GetSelectedModules();
|
||||||
try
|
var sMode = $(':input[name=mode]').val();
|
||||||
{
|
var sModulesDir = $(':input[name=target_dir]').val();
|
||||||
// Call the asynchronous page that performs the creation/update of the DB Schema
|
var sDBServer = $(':input[name=db_server]').val();
|
||||||
$('#log').html('');
|
var sDBUser = $(':input[name=db_user]').val();
|
||||||
$('#setup_msg').text('Updating Profiles...');
|
var sDBPwd = $(':input[name=db_pwd]').val();
|
||||||
$('#progress').progression( {Current:40, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
var sDBName = $(':input[name=db_name]').val();
|
||||||
$('#log').load( 'ajax.dataloader.php',
|
var sNewDBName = $(':input[name=new_db_name]').val();
|
||||||
{
|
var sDBPrefix = $(':input[name=db_prefix]').val();
|
||||||
'operation': 'after_db_create',
|
var sAuthUser = $(':input[name=auth_user]').val();
|
||||||
'selected_modules': GetSelectedModules(),
|
var sAuthPwd = $(':input[name=auth_pwd]').val();
|
||||||
'mode': $(':input[name=mode]').val(),
|
var sLanguage = $(':input[name=language]').val();
|
||||||
'db_server': $(':input[name=db_server]').val(),
|
|
||||||
'db_user': $(':input[name=db_user]').val(),
|
// Call the asynchronous page that performs the creation/update of the DB Schema
|
||||||
'db_pwd': $(':input[name=db_pwd]').val(),
|
AsyncUpdateProfiles(sSelectedModules, sMode, sModulesDir, sDBServer, sDBUser, sDBPwd, sDBName, sNewDBName, sDBPrefix, sAuthUser, sAuthPwd, sLanguage, function(response, status, xhr) {
|
||||||
'db_name': $(':input[name=db_name]').val(),
|
$('#log').html(response);
|
||||||
'new_db_name': $(':input[name=new_db_name]').val(),
|
DoLoadDataAsynchronous();
|
||||||
'db_prefix': $(':input[name=db_prefix]').val(),
|
});
|
||||||
'modules_dir': $(':input[name=target_dir]').val(),
|
|
||||||
'auth_user': $(':input[name=auth_user]').val(),
|
|
||||||
'auth_pwd': $(':input[name=auth_pwd]').val(),
|
|
||||||
'language': $(':input[name=language]').val()
|
|
||||||
},
|
|
||||||
DoLoadDataAsynchronous, 'html');
|
|
||||||
// $('#log').ajaxError(
|
|
||||||
// function(e, xhr, settings, exception)
|
|
||||||
// {
|
|
||||||
// bStopAysncProcess = true;
|
|
||||||
// alert('Fatal error detected: '+ xhr.responseText);
|
|
||||||
// $('#log').append(xhr.responseText);
|
|
||||||
// $('#setup').unblock();
|
|
||||||
// } );
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
alert('An exception occured: '+err);
|
|
||||||
}
|
|
||||||
return true; // Continue loading the data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var aFilesToLoad = new Array();
|
var aFilesToLoad = new Array();
|
||||||
|
|||||||
111
setup/setup_environment.js
Normal file
111
setup/setup_environment.js
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* Wrapper for the compilation of the whole data model into a given environment
|
||||||
|
*
|
||||||
|
* @param string sSelectedModules CSV list of selected modules
|
||||||
|
* @param string sMode 'install' or 'upgrade'
|
||||||
|
* @param string sSourceDir The directory containing the source modules (some may be already compiled)
|
||||||
|
* @param string sTargetDir The target directory (is created if needed) for compiled modules
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, OnCompleteFn)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$.post( 'ajax.dataloader.php',
|
||||||
|
{
|
||||||
|
'operation': 'compile_data_model',
|
||||||
|
'selected_modules': sSelectedModules,
|
||||||
|
'mode': sMode,
|
||||||
|
'source_dir': sSourceDir,
|
||||||
|
'target_dir': sTargetDir
|
||||||
|
},
|
||||||
|
OnCompleteFn, 'html');
|
||||||
|
}
|
||||||
|
catch(err)
|
||||||
|
{
|
||||||
|
alert('An exception occured: '+err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for the creation/update of a given DB/environment
|
||||||
|
*
|
||||||
|
* @param string sSelectedModules CSV list of selected modules
|
||||||
|
* @param string sMode 'install' or 'upgrade'
|
||||||
|
* @param string sModulesDir The directory in which the modules have been compiled
|
||||||
|
* @param string sDBServer Database access...
|
||||||
|
* @param string sDBUser ...
|
||||||
|
* @param string sDBPwd ...
|
||||||
|
* @param string sDBName Name of an existing DB
|
||||||
|
* @param string sNewDBName Name of the new DB if sDBName is omitted
|
||||||
|
* @param string sDBPrefix Prefix the tables (shared database)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function AsyncUpdateDBSchema(sSelectedModules, sMode, sModulesDir, sDBServer, sDBUser, sDBPwd, sDBName, sNewDBName, sDBPrefix, OnCompleteFn)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$.post( 'ajax.dataloader.php',
|
||||||
|
{
|
||||||
|
'operation': 'update_db_schema',
|
||||||
|
'selected_modules': sSelectedModules,
|
||||||
|
'mode': sMode,
|
||||||
|
'modules_dir': sModulesDir,
|
||||||
|
'db_server': sDBServer,
|
||||||
|
'db_user': sDBUser,
|
||||||
|
'db_pwd': sDBPwd,
|
||||||
|
'db_name': sDBName,
|
||||||
|
'new_db_name': sNewDBName,
|
||||||
|
'db_prefix': sDBPrefix,
|
||||||
|
},
|
||||||
|
OnCompleteFn, 'html');
|
||||||
|
}
|
||||||
|
catch(err)
|
||||||
|
{
|
||||||
|
alert('An exception occured: '+err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for the creation/update for the user profiles (does create the admin user at creation), in a given environment
|
||||||
|
* @param string sSelectedModules CSV list of selected modules
|
||||||
|
* @param string sMode 'install' or 'upgrade'
|
||||||
|
* @param string sModulesDir The directory in which the modules have been compiled
|
||||||
|
* @param string sDBServer Database access...
|
||||||
|
* @param string sDBUser ...
|
||||||
|
* @param string sDBPwd ...
|
||||||
|
* @param string sDBName Name of an existing DB
|
||||||
|
* @param string sNewDBName Name of the new DB if sDBName is omitted
|
||||||
|
* @param string sDBPrefix Prefix the tables (shared database)
|
||||||
|
* @param string sAuthUser Credentials for the administrator
|
||||||
|
* @param string sAuthPwd
|
||||||
|
* @param string sLanguage Language code for the administrator (e.g. 'EN US')
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function AsyncUpdateProfiles(sSelectedModules, sMode, sModulesDir, sDBServer, sDBUser, sDBPwd, sDBName, sNewDBName, sDBPrefix, sAuthUser, sAuthPwd, sLanguage, OnCompleteFn)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$.post( 'ajax.dataloader.php',
|
||||||
|
{
|
||||||
|
'operation': 'after_db_create',
|
||||||
|
'selected_modules': sSelectedModules,
|
||||||
|
'mode': sMode,
|
||||||
|
'modules_dir': sModulesDir,
|
||||||
|
'db_server': sDBServer,
|
||||||
|
'db_user': sDBUser,
|
||||||
|
'db_pwd': sDBPwd,
|
||||||
|
'db_name': sDBName,
|
||||||
|
'new_db_name': sNewDBName,
|
||||||
|
'db_prefix': sDBPrefix,
|
||||||
|
'auth_user': sAuthUser,
|
||||||
|
'auth_pwd': sAuthPwd,
|
||||||
|
'language': sLanguage,
|
||||||
|
},
|
||||||
|
OnCompleteFn, 'html');
|
||||||
|
}
|
||||||
|
catch(err)
|
||||||
|
{
|
||||||
|
alert('An exception occured: '+err);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,7 @@ class SetupPage extends NiceWebPage
|
|||||||
parent::__construct($sTitle);
|
parent::__construct($sTitle);
|
||||||
$this->add_linked_script("../js/jquery.blockUI.js");
|
$this->add_linked_script("../js/jquery.blockUI.js");
|
||||||
$this->add_linked_script("./setup.js");
|
$this->add_linked_script("./setup.js");
|
||||||
|
$this->add_linked_script("./setup_environment.js");
|
||||||
$this->add_style("
|
$this->add_style("
|
||||||
body {
|
body {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
|||||||
Reference in New Issue
Block a user