From 0be9f3a09ce4fcaa7aab61bedc0a15148ddc4013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=98=E7=BC=98?= Date: Mon, 10 Oct 2016 19:58:23 +0800 Subject: [PATCH] use ajax to auto refresh server status page --- .../Module/Server/Controller/StatusController.php | 7 +++++++ src/templates/default/main/body.tpl.html | 3 --- .../default/module/server/status/index.tpl.html | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/psm/Module/Server/Controller/StatusController.php b/src/psm/Module/Server/Controller/StatusController.php index 4ef5aca9..5afde541 100644 --- a/src/psm/Module/Server/Controller/StatusController.php +++ b/src/psm/Module/Server/Controller/StatusController.php @@ -91,6 +91,13 @@ class StatusController extends AbstractServerController { $this->twig->addGlobal('auto_refresh', true); $this->twig->addGlobal('auto_refresh_seconds', $auto_refresh_seconds); } + + if($this->isXHR() || isset($_SERVER["HTTP_X_REQUESTED_WITH"])) { + $this->xhr = true; + //disable auto refresh in ajax return html + $layout_data["auto_refresh"] = 0; + } + return $this->twig->render('module/server/status/index.tpl.html', $layout_data); } diff --git a/src/templates/default/main/body.tpl.html b/src/templates/default/main/body.tpl.html index 2197ac9e..fa7d252a 100644 --- a/src/templates/default/main/body.tpl.html +++ b/src/templates/default/main/body.tpl.html @@ -11,9 +11,6 @@ - {% if auto_refresh %} - - {% endif %} diff --git a/src/templates/default/module/server/status/index.tpl.html b/src/templates/default/module/server/status/index.tpl.html index 4f579206..77fe4c89 100644 --- a/src/templates/default/module/server/status/index.tpl.html +++ b/src/templates/default/module/server/status/index.tpl.html @@ -57,4 +57,17 @@ - \ No newline at end of file + + +{% if auto_refresh %} + +{% endif %} \ No newline at end of file