From 5249d2c11bda1acd3d49f4df5e1ee6d85a3ba69f Mon Sep 17 00:00:00 2001 From: Philip <mail@philjak.de> Date: Thu, 14 Jul 2016 15:52:29 +0200 Subject: [PATCH] Auto refresh in Dashboard --- web/include/_head.php | 7 ++----- web/index.php | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/web/include/_head.php b/web/include/_head.php index 4902939..b528d12 100644 --- a/web/include/_head.php +++ b/web/include/_head.php @@ -45,13 +45,10 @@ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li> - <a href="#">About</a> + <a href="index.php">Dashbaord</a> </li> <li> - <a href="#">Services</a> - </li> - <li> - <a href="#">Contact</a> + <a href="admin/" target="_blank">Admin</a> </li> </ul> </div> diff --git a/web/index.php b/web/index.php index 39d7d2d..d7dba18 100755 --- a/web/index.php +++ b/web/index.php @@ -14,6 +14,7 @@ include("include/_head.php"); <?php $sql = new SQL(); $link = $sql->getLink(); +$graphs = array(); $query = "SELECT * FROM (tbl_register INNER JOIN tbl_parameter ON tbl_register.id = tbl_parameter.fid_register) INNER JOIN tbl_data ON tbl_parameter.id = tbl_data.fid_parameter WHERE tbl_register.id IN (SELECT max(id) FROM tbl_register group by clientAddress) AND tbl_data.id IN (SELECT max(id) FROM tbl_data group by fid_parameter) GROUP BY name"; @@ -51,8 +52,9 @@ while($row = $result->fetch_assoc()) { }else{ echo ' <a href="details.php?param='.$row2["fid_parameter"].'"> - <img class="img-responsive" src="graph.php?param='.$row2["fid_parameter"].'" alt=""> + <img class="img-responsive" src="graph.php?param='.$row2["fid_parameter"].'" alt="" id="p'.$row2["fid_parameter"].'"> </a>'; + array_push($graphs, $row2["fid_parameter"]); } echo ' <h3> @@ -66,6 +68,20 @@ while($row = $result->fetch_assoc()) { <!-- /.row -->'; } + +echo ' +<script> +setInterval(function() { + '; + + foreach ($graphs as &$param){ + echo "document.getElementById('p".$param."').src = 'graph.php?param=".$param."&rand=' + Math.random(); + "; + } +echo ' +}, 1000); +</script> +'; ?> -- GitLab