steps in the server handling mod

This commit is contained in:
Ulf Gebhardt 2015-12-17 20:41:27 +01:00
parent bc17186d64
commit 07433951b1
4 changed files with 293 additions and 57 deletions

View File

@ -1,42 +1,199 @@
function init_saimod_mojotrollz_server(){
$('#btn_update').click(function(){
growl_start('Updating Server Repository... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'update'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Server Repository updated successfully!");
}
});
});
$('#btn_changes').click(function(){
growl_start("Calculating Diferences on the Server");
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'changes'},
success : function(data) {
if(data.status){
$('#table_changes').html('');
growl_end_success("Calculated diferences");
data.result.revert.forEach(function(entry){
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="revert_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-warning btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> Revert</button></td></tr>');
});
data.result.remove.forEach(function(entry){
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="remove_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-danger btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Remove </button></td></tr>');
});
} else {
growl_end_error("An Error Occurred while calculating Diferences: "+data.result.message);
{
$('#btn_update').click(function(){
growl_start('Updating Server Repository... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'update'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Server Repository updated successfully!");
}
$('#output_log').append(data.result.log);
}
});
});
});
$('#btn_changes').click(function(){
growl_start("Calculating Diferences on the Server");
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'changes'},
success : function(data) {
if(data.status){
$('#table_changes').html('');
growl_end_success("Calculated diferences");
data.result.revert.forEach(function(entry){
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="revert_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-warning btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> Revert</button></td></tr>');
});
data.result.remove.forEach(function(entry){
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="remove_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-danger btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Remove </button></td></tr>');
});
} else {
growl_end_error("An Error Occurred while calculating Diferences: "+data.result.message);
}
$('#output_log').append(data.result.log);
}
});
});
}
{
$('#btn_tbc_realm_start').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_realm_start'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_realm_stop').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_realm_stop'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_realm_status').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_realm_status'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
}
{
$('#btn_tbc_world_start').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_start'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_world_stop').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_stop'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_world_status').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_status'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
}
{
$('#btn_tbc_world_test_start').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_test_start'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_world_test_stop').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_test_stop'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_tbc_world_test_status').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'run_tbc_world_test_status'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
}
{
$('#btn_compile_tbc_live').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'compile_tbc_live'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
$('#btn_compile_tbc_test').click(function(){
growl_start('Doing ... please wait')
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'compile_tbc_test'},
success : function(data) {
$('#output_log').append(data);
growl_end_success("Updated successfully!");
}
});
});
}
$('#btn_clear').click(function(){
$('#output_log').html('');
@ -48,7 +205,7 @@ function revert_file(path,submodule){
growl_start("Reverting path "+path);
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: 'saimod_webcraft_powertool',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'revert',
path: path,
submodule: submodule},
@ -68,7 +225,7 @@ function remove_file(path,submodule){
growl_start("Removing file "+path);
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: 'saimod_webcraft_powertool',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
action: 'remove',
path: path,
submodule: submodule},

View File

@ -3,8 +3,9 @@ namespace SAI;
class saimod_mojotrollz_server_handling extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SAI_saimod_mojotrollz_server_handling(){
$vars = \SYSTEM\PAGE\text::tag('basic');
//$vars['status_realm'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_realmstatus();
//$vars['status_world'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_worldstatus();
$vars['tbc_realm_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_status();
$vars['tbc_world_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_status();
$vars['tbc_world_test_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_status();
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/main.tpl', $vars);}
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz" href="#!mojotrollz_server"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;&nbsp;Mojotrollz Server</a></li>';}
public static function right_public(){return false;}
@ -94,13 +95,61 @@ class saimod_mojotrollz_server_handling extends \SYSTEM\SAI\SaiModule {
}
return \SYSTEM\LOG\JsonResult::toString($result);
}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_remove($path,$submodule = ''){
if(!\unlink('/home/mojotrolls/mojo/'.$submodule.$path)){
throw new \SYSTEM\LOG\ERROR('Could not remove File: /home/mojotrolls/mojo/'.$submodule.$path);}
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_revert($path,$submodule = ''){
\LIB\lib_git::php();
$result = array('log' => '', 'revert' => array(), 'remove' => array(), 'submodules' => array(), 'revert_submodules' => array());
try {
$repo = \GIT\Git::open('/home/mojotrolls/mojo/'.$submodule);
//Find Changes
$log = $repo->run('checkout '.$path);
$result['log'] .= $log;
} catch (\Exception $e){
$result['log'] .= 'Error: '.$e->getMessage();
}
return \SYSTEM\LOG\JsonResult::toString($result);
}
/* programms: run, db, update, compile
* run classic/tbc world/realm/world_test start/stop/status
* db classic/tbc realm live
* db classic/tbc chars/world live/test
* compile classic/tbc live/test
* update
* dif
*/
private static function shell_run($ver,$prog,$cmd){
return str_replace("\n","\r\n",shell_exec('/home/mojotrolls/mojo/run '.$ver.' '.$prog.' '.$cmd.' 2>&1'));}
private static function shell_db($ver,$db,$cmd){
return str_replace("\n","\r\n",shell_exec('/home/mojotrolls/mojo/db '.$ver.' '.$db.' '.$cmd.' 2>&1'));}
private static function shell_compile($ver,$cmd){
return str_replace("\n","\r\n",shell_exec('/home/mojotrolls/mojo/compile '.$ver.' '.$cmd.' 2>&1'));}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_compile_tbc_live(){
return htmlentities(self::shell_compile('tbc', 'live'));}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_compile_tbc_test(){
return htmlentities(self::shell_compile('tbc', 'test'));}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_start(){
return self::shell_run('tbc', 'realm','start');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_start(){
return self::shell_run('tbc', 'world','start');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_start(){
return self::shell_run('tbc', 'world_test','start');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_stop(){
return self::shell_run('tbc', 'realm','stop');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_stop(){
return self::shell_run('tbc', 'world','stop');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_stop(){
return self::shell_run('tbc', 'world_test','stop');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_status(){
return self::shell_run('tbc', 'realm','status');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_status(){
return self::shell_run('tbc', 'world','status');}
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_status(){
return self::shell_run('tbc', 'world_test','status');}
}

View File

@ -1 +1,5 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5100, 42, 0, 0, '_SAI_saimod_mojotrollz_server_handling', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5100, 42, 0, 0, '_SAI_saimod_mojotrollz_server_handling', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5110, 42, 2, 5100, 'revert', 'path', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5111, 42, 3, 5100, 'revert', 'submodule', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5115, 42, 2, 5100, 'remove', 'path', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5116, 42, 3, 5100, 'remove', 'submodule', 'STRING');

View File

@ -10,7 +10,20 @@
<div class="panel panel-default">
<div class="panel-heading"><h4>Classic</h4></div>
<div class="panel-body">
Status:
<table class="table">
<tr>
<th>realm</th>
<td>status</td>
</tr>
<tr>
<th>world</th>
<td>status</td>
</tr>
<tr>
<th>world_test</th>
<td>status</td>
</tr>
</table>
</div>
</div>
<div class="panel panel-default">
@ -80,7 +93,20 @@
<div class="panel panel-default">
<div class="panel-heading"><h4>TBC</h4></div>
<div class="panel-body">
Status:
<table class="table">
<tr>
<th>realm</th>
<td>${tbc_realm_status}</td>
</tr>
<tr>
<th>world</th>
<td>${tbc_world_status}</td>
</tr>
<tr>
<th>world_test</th>
<td>${tbc_world_test_status}</td>
</tr>
</table>
</div>
</div>
<div class="panel panel-default">
@ -89,11 +115,11 @@
<table class="table">
<tr>
<th>live</th>
<td>compile</td>
<td><button id="btn_compile_tbc_live" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> compile</button></td>
</tr>
<tr>
<th>test</th>
<td>compile</td>
<td><button id="btn_compile_tbc_test" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> compile</button></td>
</tr>
</table>
</div>
@ -125,22 +151,22 @@
<div class="panel-body">
<table class="table">
<tr>
<th>world</th>
<td>start</td>
<td>stop</td>
<td>status</td>
<th>realm</th>
<td><button id="btn_tbc_realm_start" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> start</button></td>
<td><button id="btn_tbc_realm_stop" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> stop</button></td>
<td><button id="btn_tbc_realm_status" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> status</button></td>
</tr>
<tr>
<th>realm</th>
<td>start</td>
<td>stop</td>
<td>status</td>
<th>world</th>
<td><button id="btn_tbc_world_start" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> start</button></td>
<td><button id="btn_tbc_world_stop" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> stop</button></td>
<td><button id="btn_tbc_world_status" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> status</button></td>
</tr>
<tr>
<th>world_test</th>
<td>start</td>
<td>stop</td>
<td>status</td>
<td><button id="btn_tbc_world_test_start" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> start</button></td>
<td><button id="btn_tbc_world_test_stop" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> stop</button></td>
<td><button id="btn_tbc_world_test_status" class="btn-primary btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> status</button></td>
</tr>
</table>
</div>