-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempGraph.php
More file actions
162 lines (136 loc) · 4.33 KB
/
Copy pathtempGraph.php
File metadata and controls
162 lines (136 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Personalizar</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<style>
a
{
font-size: 24px;
}
#bar
{
background-color: rgba(0, 0, 0, 0.3);
border-radius: 12px;
max-height: 120px;
}
#logout
{
top: 50%;
}
</style>
</head>
<body>
<?php
session_start();
if (!isset($_SESSION['user']))
{
header("refresh:0,index.php");
die();
}
echo "<link href='style/". $_SESSION['user'] .".css' rel='stylesheet'>";
if (isset($_POST['css']))
{
file_put_contents("style/". $_SESSION['user'] .".css", $_POST['css']);
}
?>
<br>
<div class="container text-center">
<form action="dashboard.php" method="POST">
<div class="row" id="bar">
<div class="col-sm-3">
<input type="text" name="search" class="form-control" placeholder="pesquisa">
</div>
<div class="col-sm-1">
<input type="submit" value="Pesquisar" class="btn btn-primary">
</div>
<div class="col-sm-3">
</div>
<div class="col-sm-2">
<a href="newUser.php">
<div class="btn btn-warning" id="style">
Criar Utilizador
</div>
</a>
</div>
<div class="col-sm-1">
<a href="upload.php">
<div class="btn btn-info" id="style">
carregar
</div>
</a>
</div>
<div class="col-sm-1">
<a href="editstyle.php">
<div class="btn btn-success" id="style">
Personalizar
</div>
</a>
</div>
<div class="col-sm-1">
<a href="logout.php">
<div class="btn btn-danger" id="logout">
Logout
</div>
</a>
</div>
</div>
</form>
</div>
<br>
<script
src="https://www.gstatic.com/charts/loader.js">
</script>
<div class="container text-center" style="width:90%; height:90%">
<div id="myChart" style="width:90%; height:90%"></div>
</div>
<script>
var indice = 1;
var max = 10;
setInterval(() => {
google.charts.load('current',{packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
var data = google.visualization.arrayToDataTable([
['Temperature', 'Size'],
[0,0],[1,0],[2,0],[3,0],[4,0],
[5,0],[6,0],[7,0],
[8,0],[9,0],[10,0]
]);
var url = "http://192.168.1.15/api/stats/thermal.php";
var HTTP = new XMLHttpRequest();
HTTP.open( "GET", url); // false for synchronous request
HTTP.send();
HTTP.onload =function()
{
if (HTTP.status == 200)
{
console.log(data[0]);
var temp = HTTP.responseText.replace("<h2>", "").replace("</h2>", "");
data[indice][1] = temp;
indice+=1;
if (indice > max)
{
indice=1;
}
}
}
// Set Options
var options = {
title: 'Temperatura vs. Tempo',
hAxis: {title: 'Tempo'},
vAxis: {title: 'Temperatura'},
legend: 'none'
};
// Draw
var chart = new google.visualization.LineChart(document.getElementById('myChart'));
chart.draw(data, options);
}
}, 1000);
</script>
</body>
</html>