use ajax to auto refresh server status page
parent
d91c544128
commit
80df5b7735
|
@ -91,6 +91,13 @@ class StatusController extends AbstractServerController {
|
||||||
$this->twig->addGlobal('auto_refresh', true);
|
$this->twig->addGlobal('auto_refresh', true);
|
||||||
$this->twig->addGlobal('auto_refresh_seconds', $auto_refresh_seconds);
|
$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);
|
return $this->twig->render('module/server/status/index.tpl.html', $layout_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||||
<link rel="icon" type="image/png" href="favicon.png" />
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
<link rel="apple-touch-icon" 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 -->
|
<!-- Le styles -->
|
||||||
<link href="static/plugin/twitter-bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
<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">
|
<link href="static/plugin/twitter-bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
|
||||||
|
|
|
@ -57,4 +57,17 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</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 %}
|
Loading…
Reference in New Issue