Update Sensor

This commit is contained in:
Philip Schell 2019-11-21 14:36:06 +01:00
parent da34f0566d
commit 1e0690fed1
4 changed files with 36 additions and 3 deletions

View File

@ -2,6 +2,7 @@
## 1.2.10 ## 1.2.10
### New Features ### New Features
* Posibility to display sensor data on map
### Bugfixes ### Bugfixes
* Parse also all Doublevalues as Int * Parse also all Doublevalues as Int
### Changes ### Changes
@ -14,6 +15,7 @@
* Display GateCounting Boxes in a line not a collumn * Display GateCounting Boxes in a line not a collumn
* Create Aliases for Camera Count * Create Aliases for Camera Count
* Filter Fight under level * Filter Fight under level
* Refactoring
## 1.2.9 ## 1.2.9
### New Features ### New Features

View File

@ -27,6 +27,9 @@
padding: 5px; padding: 5px;
border-radius: 10px; border-radius: 10px;
} }
#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor.alert {
border: 2px solid red;
}
#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor span { #bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor span {
display: block; display: block;
text-align: center; text-align: center;
@ -37,6 +40,9 @@
#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor .wind { #bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor .wind {
font-size: 18px; font-size: 18px;
} }
#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor.alert {
color: red;
}
/* Optional: Makes the sample page fill the window. */ /* Optional: Makes the sample page fill the window. */
html, body { html, body {

View File

@ -255,6 +255,7 @@
} }
}); });
} }
MarkerObject.ScaleSensors("zoom");
}); });
}, },
_SetupClickHandler: function () { _SetupClickHandler: function () {

View File

@ -98,7 +98,6 @@
if (this._SensorSettings.hasOwnProperty(sensorid)) { if (this._SensorSettings.hasOwnProperty(sensorid)) {
var sensordata = sensorjson[sensorid]; var sensordata = sensorjson[sensorid];
var sensorsettings = this._SensorSettings[sensorid]; var sensorsettings = this._SensorSettings[sensorid];
if (!this._Sensors.hasOwnProperty(sensorid)) { //Sensor is not drawn until now if (!this._Sensors.hasOwnProperty(sensorid)) { //Sensor is not drawn until now
var sensor = null; var sensor = null;
var sensorIcon = L.divIcon({ var sensorIcon = L.divIcon({
@ -110,14 +109,39 @@
'<span class="wind">' + sensordata.Windspeed + ' m/s</span>' + '<span class="wind">' + sensordata.Windspeed + ' m/s</span>' +
'<span class="hum">' + sensordata.Humidity + ' %rl</span></div>' '<span class="hum">' + sensordata.Humidity + ' %rl</span></div>'
}); });
sensor = L.marker(sensorsettings.Coordinates, { 'title': sensorsettings.Alias, 'icon': sensorIcon }); sensor = L.marker(sensorsettings.Coordinates, { 'title': sensorsettings.Alias, 'icon': sensorIcon, interactive: false });
this._Sensors[sensorid] = sensor.addTo(MapObject.Map); this._Sensors[sensorid] = sensor.addTo(MapObject.Map);
this.ScaleSensors(document.getElementById('MapSensor_id_' + sensorid));
} else { //Sensor refresh! } else { //Sensor refresh!
document.getElementById('MapSensor_id_' + sensorid).innerHTML = '<span class="name">' + sensorsettings.Alias + '</span>' +
'<span class="temp">' + sensordata.Temperature + ' °C</span>' +
'<span class="wind">' + sensordata.Windspeed + ' m/s</span>' +
'<span class="hum">' + sensordata.Humidity + ' %rl</span>';
}
document.getElementById('MapSensor_id_' + sensorid).className = "mapsensor" + (sensordata.Windspeed > sensorsettings.Level ? ' alert' : '');
} }
} }
} }
},
ScaleSensors: function (el) {
if (el === "zoom") {
for (var sensorid in this._Sensors) {
this.ScaleSensors(document.getElementById('MapSensor_id_' + sensorid));
} }
return;
}
var currentZoom = MapObject.Map.getZoom();
var scale = 1;
if (currentZoom < 14) {
scale = 0;
} else if (currentZoom === 14) {
scale = 0.2;
} else if (currentZoom === 15) {
scale = 0.5;
} else if (currentZoom >= 16) {
scale = 1;
}
el.style.cssText = "transform: scale(" + scale + ");";
}, },
_ParseAJAXSettings: function(json) { _ParseAJAXSettings: function(json) {
this._SensorSettings = json["Sensors"]; this._SensorSettings = json["Sensors"];