Merge pull request #365 from nutsteam/ajax_auto_refresh

use ajax to auto refresh server status page
This commit is contained in:
Samuel Denis-D'Ortun 2016-10-10 23:01:50 -04:00 committed by GitHub
commit c4551ab59e
3 changed files with 21 additions and 4 deletions

View File

@ -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);
}

View File

@ -11,9 +11,6 @@
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="apple-touch-icon" href="favicon.png" />
{% if auto_refresh %}
<meta http-equiv="refresh" content="{{ auto_refresh_seconds }}" />
{% endif %}
<!-- Le styles -->
<link href="static/plugin/twitter-bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="static/plugin/twitter-bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">

View File

@ -57,4 +57,17 @@
</table>
</div>
</div>
</div>
</div>
{% if auto_refresh %}
<script>
setInterval(function(){
$.ajax({
url:"?",
success: function(html, status){
$("#page-container").html(html);
}
});
}, {{ auto_refresh_seconds }} * 1000);
</script>
{% endif %}