+
+
+
+ Loading...
+
+ diff --git a/css/dashboard.css b/css/dashboard.css index 3ba90fa..eb8a386 100644 --- a/css/dashboard.css +++ b/css/dashboard.css @@ -120,3 +120,11 @@ body { } } +/* + * + */ + +.opacity-animated { + -webkit-transition: opacity 1s; /* For Safari 3.1 to 6.0 */ + transition: opacity 1s; +} \ No newline at end of file diff --git a/dashboard.html b/dashboard.html index 035dc88..558d5f4 100644 --- a/dashboard.html +++ b/dashboard.html @@ -44,7 +44,7 @@
This is your great dashboard :))
" + + var firstRow = document.createElement("div") + firstRow.classList.add("card-deck") + + for (var i = 0; i < locationData.sensors.length; i++) { + var sensor = locationData.sensors[i] + + // get the valuetype of the current sensor + var valueType; + + for (var s = 0; s < locationData.valuetypes.length; s++) { + var thisValType = locationData.valuetypes[s] + if (parseInt(thisValType.id) === parseInt(sensor.valuetypeid)) { + valueType = thisValType; + break; + } + } + + // get all relevant meassurement values + var vals = [] + + for (s = 0; s < locationData["measvalues"].length; s++) { + var thisValue = locationData["measvalues"][s] + if (parseInt(thisValue['sensorid']) === parseInt(sensor.id)) { + vals.push(thisValue) + } + } + + if(vals.length < 1) { + continue + } + + vals.sort(function(a,b){ + return b.timestamp - a.timestamp + }) + + var latestVal = vals[0] + + // - create html widget - + // create card + var thisWidget = document.createElement("div") + thisWidget.classList.add("card") + + // create header + var thisHeader = document.createElement("div") + thisHeader.classList.add("card-header") + thisHeader.innerHTML = sensor.sensorname + " (" + valueType.valuetype + ")" + thisWidget.appendChild(thisHeader) + + // create body + var thisBody = document.createElement("div") + thisBody.classList.add("card-body") + thisWidget.appendChild(thisBody) + + // create footer + var thisFooter = document.createElement("div") + thisFooter.classList.add("card-footer") + // fill footer + var thisUpdateTime = document.createElement("small") + thisUpdateTime.classList.add("text-muted") + var lastUpdated = new Date(latestVal.timestamp * 1000) + thisUpdateTime.innerHTML = "last updated " + (lastUpdated.getDate() === new Date().getDate() ? "today" : lastUpdated.getFullYear+"-"+lastUpdated.getMonth()+"-"+lastUpdated.getDate()) + " at " + lastUpdated.getHours() + ":" + lastUpdated.getMinutes() + thisFooter.appendChild(thisUpdateTime) + thisWidget.appendChild(thisFooter) + + // - create widget body - + var displayProperties = JSON.parse(valueType.displayproperty).widget + + switch (displayProperties.type) { + case "doughnut": + // the widget is gauge-like + var thisChart = document.createElement("canvas") + thisChart.id = "chartOf" + sensor.sensorname + + var chartData = { + datasets: [ + { + label: sensor.sensorname + " (" + valueType.valuetype + ")", + data: [ + parseInt(latestVal.measvalue), + 100 -parseInt( latestVal.measvalue) + ] + } + ], + labels: false + } + + Object.assign(chartData.datasets[0], displayProperties.properties) + + dashboard.createPercentCircle(thisChart, chartData) + + thisBody.appendChild(thisChart) + + break + case "text": + // the widget is pure text + thisWidget.classList.add("text-center") + thisBody.innerHTML = '