From 07433951b1b2a36e075571c84b11448667ad47ec Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 17 Dec 2015 20:41:27 +0100 Subject: [PATCH] steps in the server handling mod --- .../js/saimod_mojotrollz_server_handling.js | 231 +++++++++++++++--- .../saimod_mojotrollz_server_handling.php | 57 ++++- .../sql/mysql/system_api.sql | 6 +- .../tpl/main.tpl | 56 +++-- 4 files changed, 293 insertions(+), 57 deletions(-) diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js b/mojotrollz/sai/saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js index 576071b..f3b17c6 100644 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js @@ -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(''+entry[0]+''+entry[1]+''); - }); - data.result.remove.forEach(function(entry){ - $('#table_changes').append(''+entry[0]+''+entry[1]+''); - }); - } 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(''+entry[0]+''+entry[1]+''); + }); + data.result.remove.forEach(function(entry){ + $('#table_changes').append(''+entry[0]+''+entry[1]+''); + }); + } 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}, diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php b/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php index 08b83ee..b7f5aea 100644 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php @@ -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 '
  •   Mojotrollz Server
  • ';} 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');} } \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql b/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql index 6813b50..dea6c58 100644 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql @@ -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); \ No newline at end of file +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'); \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/tpl/main.tpl b/mojotrollz/sai/saimod_mojotrollz_server_handling/tpl/main.tpl index 0b1ea3c..b3550cf 100644 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/tpl/main.tpl +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/tpl/main.tpl @@ -10,7 +10,20 @@

    Classic

    - Status: + + + + + + + + + + + + + +
    realmstatus
    worldstatus
    world_teststatus
    @@ -80,7 +93,20 @@

    TBC

    - Status: + + + + + + + + + + + + + +
    realm${tbc_realm_status}
    world${tbc_world_status}
    world_test${tbc_world_test_status}
    @@ -89,11 +115,11 @@ - + - +
    livecompile
    testcompile
    @@ -125,22 +151,22 @@
    - - - - + + + + - - - - + + + + - - - + + +
    worldstartstopstatusrealm
    realmstartstopstatusworld
    world_teststartstopstatus