-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.html
175 lines (175 loc) · 14.5 KB
/
Index.html
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
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html>
<head>
<title>Iot-controller dashboard</title>
<meta name="viewport" content="width=device-width, minimumscale=1.0, maximum-scale=1.0, initial-scale=1" />
<style>
header { text-align: center; min-height: 110px; background-color: lightseagreen; color: white}
h1 { font-size: 60px; margin-top: 0px; font-family: Georgia, 'Times New Roman', Times, serif}
h2 { font-size: 30px; font-family: Arial, Helvetica, sans-serif}
#Settings { display: none; margin-top: 30px; }
#Data { display: block; margin-top: 30px; }
.changeViewButton { clear: both; position:relative; margin-top: 30px; -moz-box-shadow: 0px 1px 0px 0px #fff6af; -webkit-box-shadow: 0px 1px 0px 0px #fff6af; box-shadow: 0px 1px 0px 0px #fff6af; background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffec64), color-stop(1, #ffab23)); background:-moz-linear-gradient(top, #ffec64 5%, #ffab23 100%); background:-webkit-linear-gradient(top, #ffec64 5%, #ffab23 100%); background:-o-linear-gradient(top, #ffec64 5%, #ffab23 100%); background:-ms-linear-gradient(top, #ffec64 5%, #ffab23 100%); background:linear-gradient(to bottom, #ffec64 5%, #ffab23 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64', endColorstr='#ffab23',GradientType=0); background-color:#ffec64; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; border:1px solid #ffaa22; display:inline-block; cursor:pointer; color:#333333; font-family:Arial; font-size:15px; padding:8px 50px; text-decoration:none; text-shadow:0px 1px 0px #ffee66; }
.changeViewButton:hover { background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffab23), color-stop(1, #ffec64)); background:-moz-linear-gradient(top, #ffab23 5%, #ffec64 100%); background:-webkit-linear-gradient(top, #ffab23 5%, #ffec64 100%); background:-o-linear-gradient(top, #ffab23 5%, #ffec64 100%); background:-ms-linear-gradient(top, #ffab23 5%, #ffec64 100%); background:linear-gradient(to bottom, #ffab23 5%, #ffec64 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffab23', endColorstr='#ffec64',GradientType=0); background-color:#ffab23; }
.changeViewButton:active { position:relative; top:4px; }
.onButton { clear: both; position:relative; margin-left: 5px; margin-top: 10px; -moz-box-shadow: 0px 1px 0px 0px #5bda2a; -webkit-box-shadow: 0px 1px 0px 0px #5bda2a; box-shadow: 0px 1px 0px 0px #5bda2a; background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #5bda2a), color-stop(1, #5bda2a)); background:-moz-linear-gradient(top, #5bda2a 5%, #5bda2a 100%); background:-webkit-linear-gradient(top, #5bda2a 5%, #5bda2a 100%); background:-o-linear-gradient(top, #5bda2a 5%, #5bda2a 100%); background:-ms-linear-gradient(top, #5bda2a 5%, #5bda2a 100%); background:linear-gradient(to bottom, #5bda2a 5%, #5bda2a 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64', endColorstr='#ffab23',GradientType=0); background-color:#5bda2a; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; border:1px solid #5bda2a; display:inline-block; cursor:pointer; color:#333333; font-family:Arial; font-size:12px; padding:4px 13px; text-decoration:none; text-shadow:0px 1px 0px #5bda2a; }
.onButton:hover { background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #a7ff8c), color-stop(1, #a7ff8c)); background:-moz-linear-gradient(top, #a7ff8c 5%, #a7ff8c 100%); background:-webkit-linear-gradient(top, #a7ff8c 5%, #a7ff8c 100%); background:-o-linear-gradient(top, #a7ff8c 5%, #a7ff8c 100%); background:-ms-linear-gradient(top, #a7ff8c 5%, #a7ff8c 100%); background:linear-gradient(to bottom, #a7ff8c 5%, #a7ff8c 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#a7ff8c', endColorstr='#a7ff8c',GradientType=0); background-color:#a7ff8c; }
.onButton:active { position:relative; top:4px; }
.offButton { clear: both; position:relative; margin-left: 8px; margin-top: 10px; -moz-box-shadow: 0px 1px 0px 0px #f06262; -webkit-box-shadow: 0px 1px 0px 0px #f06262; box-shadow: 0px 1px 0px 0px #f06262; background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f06262), color-stop(1, #f06262)); background:-moz-linear-gradient(top, #f06262 5%, #f06262 100%); background:-webkit-linear-gradient(top, #f06262 5%, #f06262 100%); background:-o-linear-gradient(top, #f06262 5%, #f06262 100%); background:-ms-linear-gradient(top, #f06262 5%, #f06262 100%); background:linear-gradient(to bottom, #f06262 5%, #f06262 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64', endColorstr='#ffab23',GradientType=0); background-color:#f06262; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; border:1px solid #f06262; display:inline-block; cursor:pointer; color:#333333; font-family:Arial; font-size:12px; padding:4px 11px; text-decoration:none; text-shadow:0px 1px 0px #f06262; }
.offButton:hover { background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #df7e7e), color-stop(1, #df7e7e)); background:-moz-linear-gradient(top, #df7e7e 5%, #df7e7e 100%); background:-webkit-linear-gradient(top, #df7e7e 5%, #df7e7e 100%); background:-o-linear-gradient(top, #df7e7e 5%, #df7e7e 100%); background:-ms-linear-gradient(top, #df7e7e 5%, #df7e7e 100%); background:linear-gradient(to bottom, #df7e7e 5%, #df7e7e 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#df7e7e', endColorstr='#df7e7e',GradientType=0); background-color:#df7e7e; }
.offButton:active { position:relative; top:4px; }
</style>
</head>
<header>
<h1>
Dashboard
</h1>
</header>
<body>
<div id='Data' >
<h2 class="sensorHeader">Sensors:</h2>
<div id='Pod'>
<h3>
Pod:
<div id='PodInfo'>@</div>
</h3>
</div>
<div id='Switch'>
<h3>
Switch:
<div id='SwitchInfo'>@</div>
</h3>
</div>
<h2 class="ledHeader">Leds:</h2>
<form action="/" method="POST">
<div id='Led1'>
<h3>
Led1: <div id="LEDON1info">@</div>
<br>
<button class="onButton" name="LEDON1">ON</button><button class="offButton" name="LEDOFF1">OFF</button>
</h3>
</div>
<div id='Led2'>
<h3>
Led2: <div id="LEDON2info">@</div>
<br>
<button class="onButton" name="LEDON2">ON</button><button class="offButton" name="LEDOFF2">OFF</button>
</h3>
</div>
<div id='Led3'>
<h3>
Led3: <div id="LEDON3info">@</div>
<br>
<button class="onButton" name="LEDON3">ON</button><button class="offButton" name="LEDOFF3">OFF</button>
</h3>
</div>
<div id='Led4'>
<h3>
Led4: <div id="LEDON4info">@</div>
<br>
<button class="onButton" name="LEDON4">ON</button><button class="offButton" name="LEDOFF4">OFF</button>
</h3>
</div>
</form>
</div>
<div id='Settings'>
<h2>Settings:</h2>
<h3>Total Connected Nodes:</h3><div id='TNodes'>@</div><br>
<h3>Update rate:</h3>
<input type="range" style="width: 300px" min="200" max="5000" value="2000" id="fader" step="1" oninput="outputUpdate(value)"> <output for="fader" id="#slide">2000</output>
</div>
<div>
<button onClick="ChangeView()" id="changeView1" class="changeViewButton">Settings</button>
</div>
<script>
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var Changed = false;
var slide = document.querySelector('#fader');
slide.addEventListener('input', function () {
outputUpdate(slide.valueAsNumber);
});
var interval = -1;
document.querySelector('button#changeView1').addEventListener('click', function () {
if (Changed == false) {
document.getElementById('Data').style.display = 'none';
document.getElementById('Settings').style.display = 'block';
document.getElementById('changeView1').innerHTML = "Show Data";
Changed = true;
}
else {
document.getElementById('Data').style.display = 'block';
document.getElementById('Settings').style.display = 'none';
document.getElementById('changeView1').innerHTML = "Settings";
Changed = false;
}
});
function loadDoc() {
return __awaiter(this, void 0, void 0, function () {
var res, obj;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fetch('/data', { credentials: "include" })];
case 1:
res = _a.sent();
return [4 /*yield*/, res.json()];
case 2:
obj = _a.sent();
document.getElementById("PodInfo").innerHTML = obj.data[0].dataValue;
document.getElementById("SwitchInfo").innerHTML = obj.data[1].dataValue;
document.getElementById("LEDON1info").innerHTML = obj.data[2].dataValue;
document.getElementById("LEDON2info").innerHTML = obj.data[3].dataValue;
document.getElementById("LEDON3info").innerHTML = obj.data[4].dataValue;
document.getElementById("LEDON4info").innerHTML = obj.data[5].dataValue;
document.getElementById("TNodes").innerHTML = obj.data[6].dataValue;
return [2 /*return*/];
}
});
});
}
function outputUpdate(vol) {
if (interval > 0)
clearInterval(interval);
interval = setInterval(function () {
loadDoc()["catch"](console.error);
}, vol);
}
outputUpdate(2000);
</script>
</body>
</html>