User configuration applies at start, jump and goToNow
This commit is contained in:
@ -44,6 +44,7 @@
|
|||||||
<script src="externalFiles/Chart.bundle.min.js"></script>
|
<script src="externalFiles/Chart.bundle.min.js"></script>
|
||||||
<script src="externalFiles/hammer.js"></script>
|
<script src="externalFiles/hammer.js"></script>
|
||||||
<script src="externalFiles/chartjs-zoom.js"></script>
|
<script src="externalFiles/chartjs-zoom.js"></script>
|
||||||
|
<script src="jsFiles/SEAWebClientLocalStorage.js"></script>
|
||||||
<script src="jsFiles/SEAWebClientResponsivity.js"></script>
|
<script src="jsFiles/SEAWebClientResponsivity.js"></script>
|
||||||
<script src="jsFiles/SEAWebClientSwiper.js"></script>
|
<script src="jsFiles/SEAWebClientSwiper.js"></script>
|
||||||
<script src="jsFiles/SEAWebClientGroup.js"></script>
|
<script src="jsFiles/SEAWebClientGroup.js"></script>
|
||||||
|
@ -7,7 +7,7 @@ class CurvesSettingsPopup extends HTMLElement{
|
|||||||
|
|
||||||
initTable(){
|
initTable(){
|
||||||
|
|
||||||
let userConfiguration = this.getUserConfiguration();
|
let userConfiguration = getUserConfiguration();
|
||||||
let tbody = this.querySelector("#curves-settings-popup-table tbody");
|
let tbody = this.querySelector("#curves-settings-popup-table tbody");
|
||||||
tbody.innerHTML = "";
|
tbody.innerHTML = "";
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ class CurvesSettingsPopup extends HTMLElement{
|
|||||||
let formattedUserConfiguration = this.getFormattedUserConfiguration(localStorageBuffer);
|
let formattedUserConfiguration = this.getFormattedUserConfiguration(localStorageBuffer);
|
||||||
|
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
this.saveUserConfiguration(localStorageBuffer);
|
saveUserConfiguration(localStorageBuffer);
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
this.applySettingsCallback(formattedUserConfiguration);
|
this.applySettingsCallback(formattedUserConfiguration);
|
||||||
|
@ -350,7 +350,7 @@ function successHandler(s, message) {
|
|||||||
begin = timeRange[0] - timeRange[1];
|
begin = timeRange[0] - timeRange[1];
|
||||||
select.value = begin;
|
select.value = begin;
|
||||||
// Server-request for variable-list.*/
|
// Server-request for variable-list.*/
|
||||||
reqJSON(0, "http://" + hostPort + "/getvars?time=" + timeRange + "&id="
|
reqJSON(0, "http://" + hostPort + "/getvars?time=" + timeRange + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="
|
||||||
+ clientID, successHandler, errorHandler);
|
+ clientID, successHandler, errorHandler);
|
||||||
break;
|
break;
|
||||||
// Response to a "getvars"-server-request.
|
// Response to a "getvars"-server-request.
|
||||||
|
@ -831,7 +831,7 @@ let graphs = (function (){
|
|||||||
msRightTimestampGetVars = dateTimestampMs + timeValueMs;
|
msRightTimestampGetVars = dateTimestampMs + timeValueMs;
|
||||||
msRightTimestampGetGraph = dateTimestampMs + 24*60*60*1000;
|
msRightTimestampGetGraph = dateTimestampMs + 24*60*60*1000;
|
||||||
|
|
||||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestampGetVars/1000 + "," + msRightTimestampGetVars/1000 + "&id="+ clientID).getJSON().then(function(data){
|
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestampGetVars/1000 + "," + msRightTimestampGetVars/1000 + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="+ clientID).getJSON().then(function(data){
|
||||||
blocks = data.blocks;
|
blocks = data.blocks;
|
||||||
document.getElementById("device").innerHTML = data.device
|
document.getElementById("device").innerHTML = data.device
|
||||||
maxTime = msRightTimestampGetGraph;
|
maxTime = msRightTimestampGetGraph;
|
||||||
@ -901,7 +901,7 @@ let graphs = (function (){
|
|||||||
let msLeftTimestamp = msRightTimestamp - 30*60*1000;
|
let msLeftTimestamp = msRightTimestamp - 30*60*1000;
|
||||||
cursorLine(null);
|
cursorLine(null);
|
||||||
|
|
||||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestamp/1000 + "," + msRightTimestamp/1000 + "&id="+ clientID).getJSON().then(function(data){
|
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestamp/1000 + "," + msRightTimestamp/1000 + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="+ clientID).getJSON().then(function(data){
|
||||||
currentMaxTime = msRightTimestamp + 60000;
|
currentMaxTime = msRightTimestamp + 60000;
|
||||||
currentMinTime = msLeftTimestamp;
|
currentMinTime = msLeftTimestamp;
|
||||||
|
|
||||||
|
31
client/jsFiles/SEAWebClientLocalStorage.js
Normal file
31
client/jsFiles/SEAWebClientLocalStorage.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
function getUserConfiguration(){
|
||||||
|
let userConfiguration = [];
|
||||||
|
for(let i = 0; i < localStorage.length; i++){
|
||||||
|
userConfiguration.push(JSON.parse(localStorage.getItem(localStorage.key(i))));
|
||||||
|
}
|
||||||
|
return userConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveUserConfiguration(userConfiguration){
|
||||||
|
for(let i = 0; i < userConfiguration.length; i++){
|
||||||
|
localStorage.setItem(i, JSON.stringify(userConfiguration[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFormattedUserConfigurationFromLocalStorage(){
|
||||||
|
let formatedUserConfiguration = {};
|
||||||
|
|
||||||
|
for(let configurationLineObject of getUserConfiguration()){
|
||||||
|
// Every entry in the localStorage has a variable field and at least one field cat, color or unit,
|
||||||
|
// so there is no need to check their presence
|
||||||
|
|
||||||
|
let key = configurationLineObject["variable"];
|
||||||
|
delete configurationLineObject["variable"];
|
||||||
|
if(configurationLineObject.hasOwnProperty("parameter")){
|
||||||
|
key += "." + configurationLineObject["parameter"];
|
||||||
|
delete configurationLineObject["parameter"];
|
||||||
|
}
|
||||||
|
formatedUserConfiguration[key] = configurationLineObject;
|
||||||
|
}
|
||||||
|
return formatedUserConfiguration;
|
||||||
|
}
|
Reference in New Issue
Block a user