diff options
-rw-r--r-- | inc/message.inc.php | 7 | ||||
-rw-r--r-- | inc/render.inc.php | 2 | ||||
-rw-r--r-- | inc/taskmanager.inc.php | 2 | ||||
-rw-r--r-- | inc/trigger.inc.php | 4 | ||||
-rw-r--r-- | inc/util.inc.php | 2 | ||||
-rw-r--r-- | modules/systemstatus.inc.php | 17 | ||||
-rw-r--r-- | templates/main-menu.html | 1 | ||||
-rw-r--r-- | templates/systemstatus/_page.html | 24 |
8 files changed, 50 insertions, 9 deletions
diff --git a/inc/message.inc.php b/inc/message.inc.php index 11735e1b..2ae04779 100644 --- a/inc/message.inc.php +++ b/inc/message.inc.php @@ -36,9 +36,10 @@ $error_text = array( 'taskmanager-format' => 'Taskmanager hat ungültige Daten zurückgeliefert', 'task-error' => 'Ausführung fehlgeschlagen: {{0}}', 'invalid-ip' => 'Kein Interface ist auf die Adresse {{0}} konfiguriert', - 'news-set-success' => 'News erfolgreich aktualisiert.', - 'news-empty' => 'Es wurde keine News in der Datenbank gefunden.', - 'news-del-success' => 'News gelöscht.', + 'news-set-success' => 'News erfolgreich aktualisiert', + 'news-empty' => 'Es wurde keine News in der Datenbank gefunden', + 'news-del-success' => 'News gelöscht', + 'reboot-unconfirmed' => 'Sicherheitsabfrage zum Reboot nicht bestätigt', ); class Message diff --git a/inc/render.inc.php b/inc/render.inc.php index 9bea4639..2d69c322 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -164,7 +164,7 @@ class Render */ public static function parse($template, $params = false) { - if (is_array($params)) + if (is_array($params) || $params === false) $params['token'] = Session::get('token'); return self::$mustache->render(self::getTemplate($template), $params); } diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php index 308d7136..b61714ec 100644 --- a/inc/taskmanager.inc.php +++ b/inc/taskmanager.inc.php @@ -96,7 +96,7 @@ class Taskmanager public static function isFailed($task) { - if (!isset($task['statusCode']) || !isset($task['id'])) + if (!is_array($task) || !isset($task['statusCode']) || !isset($task['id'])) return true; if ($task['statusCode'] !== TASK_WAITING && $task['statusCode'] !== TASK_PROCESSING && $task['statusCode'] !== TASK_FINISHED) return true; diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index c22f8c5b..f483bfc0 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -37,6 +37,10 @@ class Trigger return $task['id']; } + /** + * + * @return boolean|string false on error, id of task otherwise + */ public static function ldadp() { $res = Database::simpleQuery("SELECT moduleid, configtgz.filepath FROM configtgz_module" diff --git a/inc/util.inc.php b/inc/util.inc.php index 63680023..8b5a14e4 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -15,7 +15,7 @@ class Util echo "--------------------\nFlagrant system error:\n$message\n--------------------\n\n"; if (defined('CONFIG_DEBUG') && CONFIG_DEBUG) { debug_print_backtrace(); - echo "\n\n"; + echo "\n\nSome variables for your entertainment:\n"; print_r($GLOBALS); } exit(0); diff --git a/modules/systemstatus.inc.php b/modules/systemstatus.inc.php index 5c670bcb..bfef54ef 100644 --- a/modules/systemstatus.inc.php +++ b/modules/systemstatus.inc.php @@ -2,6 +2,7 @@ class Page_SystemStatus extends Page { + private $rebootTask = false; protected function doPreprocess() { @@ -10,13 +11,25 @@ class Page_SystemStatus extends Page if (!User::isLoggedIn()) { Util::redirect('?do=Main'); } + + if (Request::post('action') === 'reboot') { + if (Request::post('confirm') !== 'yep') { + Message::addError('reboot-unconfirmed'); + Util::redirect('?do=SystemStatus'); + } + $this->rebootTask = Taskmanager::submit('Reboot'); + } } protected function doRender() { + $data = array(); + if (is_array($this->rebootTask) && isset($this->rebootTask['id'])) { + $data['rebootTask'] = $this->rebootTask['id']; + } Render::addScriptTop('custom'); Render::addScriptBottom('circles.min'); - Render::addTemplate('systemstatus/_page'); + Render::addTemplate('systemstatus/_page', $data); } protected function doAjax() @@ -155,7 +168,7 @@ class Page_SystemStatus extends Page if (isset($status['data']['messages'])) $data['ldadpError'] = $status['data']['messages']; else - $data['ldadpError'] = print_r($status, true); //'Taskmanager error'; + $data['ldadpError'] = 'Taskmanager error'; } // TODO: Dozentenmodul, tftp, ... diff --git a/templates/main-menu.html b/templates/main-menu.html index 06c3ed6b..34b18579 100644 --- a/templates/main-menu.html +++ b/templates/main-menu.html @@ -11,7 +11,6 @@ </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> - <li><a href="#about">Hilfe</a></li> <li><a href="?do=SysLog">Client Logs</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Einstellungen<b class="caret"></b></a> diff --git a/templates/systemstatus/_page.html b/templates/systemstatus/_page.html index a62534da..b202181e 100644 --- a/templates/systemstatus/_page.html +++ b/templates/systemstatus/_page.html @@ -1,4 +1,8 @@ <div class="container"> + + {{#rebootTask}} + <div data-tm-id="{{rebootTask}}" data-tm-log="messages">Reboot...</div> + {{/rebootTask}} <div class="row"> @@ -52,6 +56,26 @@ </div> </div> + + <div class="row"> + + <div class="col-md-6"> + <div class="panel panel-default"> + <div class="panel-heading"> + Wartung + </div> + <div class="panel-body"> + <form class="form-adduser" action="?do=SystemStatus" method="post"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="reboot"> + <div>Server Reboot</div> + <label><input type="checkbox" name="confirm" value="yep"> Ja, ich bin sicher</label> + <button class="btn btn-warning btn-xs" type="submit">Reboot</button> + </form> + </div> + </div> + + </div> </div> |