|
@@ -1,37 +1,34 @@
|
1
|
1
|
var arrSensor = Array();
|
2
|
2
|
|
3
|
|
-$(document).ready(function() {
|
|
3
|
+textAvailableSensors = "Available Sensors";
|
|
4
|
+textButtonNext = "Continue";
|
4
|
5
|
|
5
|
|
- $('body').append(`<div class="container-fluid">
|
6
|
|
- <div class="page-header">
|
7
|
|
- <h2>Systemadministration</h2>
|
8
|
|
- </div>
|
9
|
|
- <div class="row" id="contentDiv">
|
10
|
|
- <div class="col-md-5 col-lg-5">
|
11
|
|
- <div class="panel panel-primary">
|
12
|
|
- <div class="panel-heading" id="listSensorsHeading" style="font-size: 18px;">Verfügbare Sensoren (0/0)</div>
|
13
|
|
- <div class="panel-body">
|
14
|
|
- <ul class="list-group" id="listSensors"></ul>
|
15
|
|
- <div id="alertDiv"></div>
|
16
|
|
- <button class="btn btn-primary" disabled="" id="btnSubmit">Weiter</button>
|
17
|
|
- </div>
|
|
6
|
+$(document).ready(function() {
|
|
7
|
+ $('#main-part').append(`
|
|
8
|
+ <div class="row" id="contentDiv">
|
|
9
|
+ <div class="col-md-5 col-lg-5">
|
|
10
|
+ <div class="panel panel-primary">
|
|
11
|
+ <div class="panel-heading" id="listSensorsHeading" style="font-size: 18px;">
|
|
12
|
+ ` + textAvailableSensors + ` (0/0)
|
|
13
|
+ </div>
|
|
14
|
+ <div class="panel-body">
|
|
15
|
+ <ul class="list-group" id="listSensors"></ul>
|
|
16
|
+ <div id="alertDiv"></div>
|
|
17
|
+ <button class="btn btn-primary" disabled="" id="btnSubmit">
|
|
18
|
+ ` + textButtonNext + `
|
|
19
|
+ </button>
|
18
|
20
|
</div>
|
19
|
21
|
</div>
|
20
|
22
|
</div>
|
21
|
|
- </div>
|
22
|
|
- <div class="footer">
|
23
|
|
- <div class="container-fluid">
|
24
|
|
- <p class="text-muted">© Copyright 2016 by Christian Högerle und Thomas Buck</p>
|
25
|
|
- </div>
|
26
|
23
|
</div>`);
|
27
|
24
|
|
28
|
25
|
// aktuelle Uhrzeit fuer die Graphen ermitteln
|
29
|
26
|
var actTime = new Date();
|
30
|
|
- actTime = actTime.getHours() + ":" + (actTime.getMinutes() < 10 ? '0':'') + actTime.getMinutes();
|
|
27
|
+ actTime = actTime.getHours() + ":" + (actTime.getMinutes() < 10 ? '0':'') + actTime.getMinutes();
|
31
|
28
|
|
32
|
29
|
$('#listSensorsHeading').empty();
|
33
|
|
- $('#listSensorsHeading').html("Verfügbare Sensoren (0/" + clients.length + ")");
|
34
|
|
-
|
|
30
|
+ $('#listSensorsHeading').html(textAvailableSensors + " (0/" + clients.length + ")");
|
|
31
|
+
|
35
|
32
|
// Alle clients im Array iterieren und Websocket abfragen
|
36
|
33
|
var count = [0];
|
37
|
34
|
jQuery.each(clients, function(index, client) {
|
|
@@ -59,12 +56,12 @@ function webSocket(wsUri, wsPort, count, clientsCount) {
|
59
|
56
|
});
|
60
|
57
|
sensor.arrEEPROM = arrEEPROM;
|
61
|
58
|
arrSensor.push(sensor);
|
62
|
|
- $('#listSensorsHeading').html("Verfügbare Sensoren (" + sensor.id + "/" + clientsCount + ")");
|
|
59
|
+ $('#listSensorsHeading').html(textAvailableSensors + " (" + sensor.id + "/" + clientsCount + ")");
|
63
|
60
|
$('#listSensors').append('<li class="list-group-item">' +
|
64
|
|
- ' Sensor ' + sensor.id +
|
65
|
|
- ' | IP: ' + sensor.ip +
|
66
|
|
- ' | aktuelle Temperatur: ' + sensor.actualTemp +
|
67
|
|
- ' | aktuelle Luftfeuchtigkeit: ' + sensor.actualHum +
|
|
61
|
+ ' Sensor ' + sensor.id +
|
|
62
|
+ ' | IP: ' + sensor.ip +
|
|
63
|
+ ' | aktuelle Temperatur: ' + sensor.actualTemp +
|
|
64
|
+ ' | aktuelle Luftfeuchtigkeit: ' + sensor.actualHum +
|
68
|
65
|
'</li>');
|
69
|
66
|
|
70
|
67
|
// Alle Sensoren erfolgreich abgefragt
|
|
@@ -82,7 +79,7 @@ function webSocket(wsUri, wsPort, count, clientsCount) {
|
82
|
79
|
}
|
83
|
80
|
console.log(evt.data);
|
84
|
81
|
};
|
85
|
|
-}
|
|
82
|
+}
|
86
|
83
|
|
87
|
84
|
function generateView(arrSensor, actTime) {
|
88
|
85
|
$('#contentDiv').append(`<div class="col-md-12 col-lg-12">
|
|
@@ -100,10 +97,10 @@ function generateView(arrSensor, actTime) {
|
100
|
97
|
jQuery.each(arrSensor, function(index, sensor) {
|
101
|
98
|
$('.nav-pills').append('<li><a class="navtab" data-toggle="tab" href="#' + sensor.id + '">Sensor ' + sensor.id + '</a></li>');
|
102
|
99
|
});
|
103
|
|
-
|
|
100
|
+
|
104
|
101
|
// Flag fuer gemeinsamer Graph -> true
|
105
|
102
|
generateGraph(true, arrSensor, actTime);
|
106
|
|
-
|
|
103
|
+
|
107
|
104
|
$(".navtab").click(function(event) {
|
108
|
105
|
$('#contentPanel').empty();
|
109
|
106
|
if(event.target.text == "Home") {
|
|
@@ -126,17 +123,17 @@ function generateGraph(flag, sensor, actTime) {
|
126
|
123
|
</div>`);
|
127
|
124
|
if(flag) { // ein Graph für alle Sensoren
|
128
|
125
|
var length = 0;
|
129
|
|
- jQuery.each(sensor, function(index, tmp) {
|
|
126
|
+ jQuery.each(sensor, function(index, tmp) {
|
130
|
127
|
if(length < tmp.arrEEPROM.length) {
|
131
|
128
|
length = tmp.arrEEPROM.length;
|
132
|
129
|
}
|
133
|
130
|
});
|
134
|
131
|
|
135
|
|
- var labels = Array();
|
|
132
|
+ var labels = Array();
|
136
|
133
|
actHour = actTime.split(":")[0];
|
137
|
134
|
for(var i = length; i > 0; i--) {
|
138
|
|
- labels.unshift(actHour + ":00");
|
139
|
|
- actHour = (actHour - 1).mod(24);
|
|
135
|
+ labels.unshift(actHour + ":00");
|
|
136
|
+ actHour = (actHour - 1).mod(24);
|
140
|
137
|
}
|
141
|
138
|
labels.push(actTime);
|
142
|
139
|
|
|
@@ -145,18 +142,18 @@ function generateGraph(flag, sensor, actTime) {
|
145
|
142
|
|
146
|
143
|
var tmpDataTemperature = Array();
|
147
|
144
|
var tmpDataHumidity = Array();
|
148
|
|
- jQuery.each(sensor, function(index, tmp) {
|
|
145
|
+ jQuery.each(sensor, function(index, tmp) {
|
149
|
146
|
for(var i = 0; i < (length - tmp.arrEEPROM.length); i++) {
|
150
|
147
|
tmpDataTemperature.push([]);
|
151
|
148
|
tmpDataHumidity.push([]);
|
152
|
149
|
}
|
153
|
|
- jQuery.each(tmp.arrEEPROM, function(index, value) {
|
|
150
|
+ jQuery.each(tmp.arrEEPROM, function(index, value) {
|
154
|
151
|
tmpDataTemperature.push(value['T']);
|
155
|
|
- tmpDataHumidity.push(value['H']);
|
|
152
|
+ tmpDataHumidity.push(value['H']);
|
156
|
153
|
});
|
157
|
154
|
tmpDataTemperature.push(tmp.actualTemp);
|
158
|
155
|
tmpDataHumidity.push(tmp.actualHum);
|
159
|
|
-
|
|
156
|
+
|
160
|
157
|
var lineColor = getRandomColor();
|
161
|
158
|
dataTemperature.push({label: "Sensor " + tmp.id, data: tmpDataTemperature, fill: false,
|
162
|
159
|
borderWidth: 3, borderColor : lineColor,});
|
|
@@ -168,31 +165,31 @@ function generateGraph(flag, sensor, actTime) {
|
168
|
165
|
});
|
169
|
166
|
} else { // Graph für einzelnen Sensor
|
170
|
167
|
var labels = Array();
|
171
|
|
-
|
|
168
|
+
|
172
|
169
|
var tmpDataTemperature = Array();
|
173
|
170
|
var tmpDataHumidity = Array();
|
174
|
171
|
actHour = actTime.split(":")[0];
|
175
|
172
|
actHour = (actHour - sensor.arrEEPROM.length).mod(24);
|
176
|
|
- jQuery.each(sensor.arrEEPROM, function(index, value) {
|
|
173
|
+ jQuery.each(sensor.arrEEPROM, function(index, value) {
|
177
|
174
|
actHour = (actHour + 1).mod(24);
|
178
|
|
- labels.push(actHour + ":00");
|
|
175
|
+ labels.push(actHour + ":00");
|
179
|
176
|
tmpDataTemperature.push(value['T']);
|
180
|
|
- tmpDataHumidity.push(value['H']);
|
|
177
|
+ tmpDataHumidity.push(value['H']);
|
181
|
178
|
});
|
182
|
|
-
|
|
179
|
+
|
183
|
180
|
labels.push(actTime);
|
184
|
181
|
tmpDataTemperature.push(sensor.actualTemp);
|
185
|
182
|
tmpDataHumidity.push(sensor.actualHum);
|
186
|
183
|
|
187
|
|
- var dataTemperature = [{label: 'Temperatur [C]', data: tmpDataTemperature,
|
|
184
|
+ var dataTemperature = [{label: 'Temperatur [C]', data: tmpDataTemperature,
|
|
185
|
+ fill: false, borderWidth: 3, borderColor: '#337ab7',}];
|
|
186
|
+ var dataHumidity = [{label: 'Luftfeuchtigkeit [%RH]', data: tmpDataHumidity,
|
188
|
187
|
fill: false, borderWidth: 3, borderColor: '#337ab7',}];
|
189
|
|
- var dataHumidity = [{label: 'Luftfeuchtigkeit [%RH]', data: tmpDataHumidity,
|
190
|
|
- fill: false, borderWidth: 3, borderColor: '#337ab7',}];
|
191
|
188
|
}
|
192
|
189
|
|
193
|
190
|
var tempCtx = $('#temperaturChart');
|
194
|
191
|
var humCtx = $('#humidityChart');
|
195
|
|
-
|
|
192
|
+
|
196
|
193
|
var tempChart = new Chart(tempCtx, {
|
197
|
194
|
type: 'line',
|
198
|
195
|
data: {
|
|
@@ -234,4 +231,4 @@ function getRandomColor() {
|
234
|
231
|
color += letters[Math.floor(Math.random() * 16)];
|
235
|
232
|
}
|
236
|
233
|
return color;
|
237
|
|
-}
|
|
234
|
+}
|