major rework
using influxdb structure independed of nicos cache
This commit is contained in:
@ -111,8 +111,8 @@ function handleUpdateMessage(src, message) {
|
||||
instrument.style.width = 'auto'
|
||||
device.style.width = 'auto'
|
||||
instrument.innerHTML = message.instrument
|
||||
device.innerHTML = message.device
|
||||
// console.log('ID', initCommands);
|
||||
// device.innerHTML = message.device
|
||||
console.log('ID', initCommands);
|
||||
nextInitCommand();
|
||||
break;
|
||||
// console-update-message: Confirms a command.
|
||||
@ -306,7 +306,7 @@ function reqJSONPOST(s, url, parameters, successHandler, errorHandler) {
|
||||
var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest()
|
||||
: new ActiveXObject('Microsoft.XMLHTTP');
|
||||
if (debugCommunication) {
|
||||
console.log("%cto server (reqJSON): %s",
|
||||
console.log("%cto server (reqJSONPOST): %s",
|
||||
"color:white;background:lightgreen", url);
|
||||
}
|
||||
xhr.open('post', url, true);
|
||||
@ -406,8 +406,11 @@ function successHandler(s, message) {
|
||||
begin = timeRange[0] - timeRange[1];
|
||||
select.value = begin;
|
||||
// Server-request for variable-list.*/
|
||||
reqJSONPOST(0, "http://" + hostPort + "/getvars", "time=" + timeRange[1] + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="
|
||||
+ clientID, successHandler, errorHandler);
|
||||
reqJSONPOST(0, "http://" + hostPort + "/getvars",
|
||||
"time=" + timeRange[1]
|
||||
+ window['clientTags']
|
||||
+ "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ "&id=" + clientID, successHandler, errorHandler);
|
||||
break;
|
||||
// Response to a "getvars"-server-request.
|
||||
case "var_list":
|
||||
@ -427,6 +430,7 @@ function successHandler(s, message) {
|
||||
nextInitCommand();
|
||||
}*/
|
||||
// graphs.receivedVars(message.blocks);
|
||||
document.getElementById("device").innerHTML = message.device
|
||||
graphs.initGraphs(message.blocks);
|
||||
nextInitCommand();
|
||||
break;
|
||||
|
@ -371,10 +371,9 @@ function loadExportPopup(){
|
||||
*/
|
||||
function exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, nan, binning=null){
|
||||
|
||||
let binningParam = "None";
|
||||
if (binning !== null)
|
||||
binningParam = binning
|
||||
let exportURL = "http://" + hostPort + "/export?time=" + startDateTimeMs/1000 + "," + endDateTimeMs/1000 + "&variables=" + selectedVariables + "&nan=" + nan + "&interval=" + binningParam + "&id=" + clientID
|
||||
if (binning === null || binning == "None")
|
||||
binning = "";
|
||||
let exportURL = "http://" + hostPort + "/export?time=" + startDateTimeMs/1000 + "," + endDateTimeMs/1000 + "&variables=" + selectedVariables + "&nan=" + nan + "&interval=" + binning + "&id=" + clientID
|
||||
let a = document.createElement('a');
|
||||
a.href = exportURL
|
||||
a.download = true
|
||||
@ -417,7 +416,7 @@ let graphs = (function (){
|
||||
let minTime, maxTime; // the queried time range
|
||||
let lastTime = 0; // time of most recent data point
|
||||
|
||||
let resolution = undefined; // current window resolution (ms/pixel)
|
||||
// let resolution = undefined; // current window resolution (ms/pixel)
|
||||
|
||||
let activateUpdateTimeout = undefined; // timeout for the activateUpdates function
|
||||
let updateAutoTimeout = undefined; // timeout for the updateAuto function (used in onZoomCompleteCallback)
|
||||
@ -542,11 +541,12 @@ let graphs = (function (){
|
||||
varlist = vars_array[gindex];
|
||||
let graph_elm = graph_elm_array[gindex];
|
||||
|
||||
timeDeltaAxis = maxTime - minTime
|
||||
setResolution(timeDeltaAxis)
|
||||
|
||||
AJAX("http://" + hostPort + "/graph?time=" + minTime/1000 + "," + maxTime/1000 + "&variables=" + varlist + "&interval=" + resolution + "&id=" + clientID).getJSON().then(function(data){
|
||||
resolution = getResolution((maxTime - minTime) / 1000)
|
||||
|
||||
AJAX("http://" + hostPort + "/graph?time=" + minTime/1000 + "," + maxTime/1000
|
||||
+ "&variables=" + varlist
|
||||
+ "&interval=" + resolution
|
||||
+ "&id=" + clientID).getJSON().then(function(data){
|
||||
//console.log('Graph', block, data)
|
||||
let graph = new Graph(gindex, graph_elm, "Time", block.unit, block.tag, type);
|
||||
graph_array[gindex] = graph;
|
||||
@ -777,10 +777,12 @@ let graphs = (function (){
|
||||
max = max/1000;
|
||||
}
|
||||
|
||||
timeDelta = currentMaxTime - currentMinTime
|
||||
setResolution(timeDelta)
|
||||
resolution = getResolution((currentMaxTime - currentMinTime) / 1000)
|
||||
|
||||
AJAX("http://" + hostPort + "/graph?time=" + min + ","+max+"&variables=" + variables() + "&interval=" + resolution + "&id=" + clientID).getJSON().then(function(data){
|
||||
AJAX("http://" + hostPort + "/graph?time=" + min + ","+max
|
||||
+"&variables=" + variables()
|
||||
+ "&interval=" + resolution
|
||||
+ "&id=" + clientID).getJSON().then(function(data){
|
||||
for(let key in data.graph){
|
||||
let pdata = [];
|
||||
for(let e of data.graph[key]){
|
||||
@ -893,10 +895,10 @@ let graphs = (function (){
|
||||
* Sets the resolution of the viewing window in milliseconds
|
||||
* @param {*} timeDelta - The difference between the maximum time and the minimum time of the window
|
||||
*/
|
||||
function setResolution(timeDelta){
|
||||
resolution = Math.ceil((timeDelta / container.getBoundingClientRect().width))
|
||||
function getResolution(timeDelta){
|
||||
return Math.ceil((timeDelta / container.getBoundingClientRect().width))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The callback to be called when the user click on the "Jump" button of the date selector
|
||||
* Gets the vars + device name for the selected date+time, then rebuilds the graphs
|
||||
@ -915,7 +917,11 @@ let graphs = (function (){
|
||||
msRightTimestampGetVars = dateTimestampMs + timeValueMs;
|
||||
msRightTimestampGetGraph = dateTimestampMs + 24*60*60*1000;
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars").postForm("time=" + msRightTimestampGetVars/1000 + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="+ clientID).then(function(data){
|
||||
AJAX("http://" + hostPort + "/getvars").postForm(
|
||||
"time=" + msRightTimestampGetVars/1000
|
||||
+ window['clientTags']
|
||||
+ "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ "&id="+ clientID).then(function(data){
|
||||
blocks = data.blocks;
|
||||
document.getElementById("device").innerHTML = data.device
|
||||
maxTime = msRightTimestampGetGraph;
|
||||
@ -989,7 +995,11 @@ let graphs = (function (){
|
||||
window["wideGraphs"] = false; // will have no effect if hideRightPart is true
|
||||
adjustGrid();
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars").postForm("time=" + msRightTimestamp/1000 + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="+ clientID).then(function(data){
|
||||
AJAX("http://" + hostPort + "/getvars").postForm(
|
||||
"time=" + msRightTimestamp/1000 + "&userconfiguration="
|
||||
+ JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ window['clientTags']
|
||||
+ "&id="+ clientID).then(function(data){
|
||||
currentMaxTime = msRightTimestamp + 60000;
|
||||
currentMinTime = msLeftTimestamp;
|
||||
|
||||
@ -1291,7 +1301,11 @@ let graphs = (function (){
|
||||
function applySettingsCallback(userConfiguration){
|
||||
cursorLine(null);
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars").postForm("time=" + currentMaxTime/1000 + "&userconfiguration=" + JSON.stringify(userConfiguration) + "&id="+ clientID).then(function(data){
|
||||
AJAX("http://" + hostPort + "/getvars").postForm(
|
||||
"time=" + currentMaxTime/1000
|
||||
+ "&userconfiguration=" + JSON.stringify(userConfiguration)
|
||||
+ window['clientTags']
|
||||
+ "&id="+ clientID).then(function(data){
|
||||
blocks = data.blocks;
|
||||
document.getElementById("device").innerHTML = data.device
|
||||
maxTime = currentMaxTime;
|
||||
|
@ -91,6 +91,17 @@ new Settings()
|
||||
.treat("hideRightPart", "hr", to_bool, false) //used to completely disable the right part
|
||||
.treat("wideGraphs", "wg", to_bool, false) //used to toggle the size of the graphs part
|
||||
.treat("showAsync", "sa", to_bool, false)
|
||||
.treat("device", "dev", 0, "*")
|
||||
.treat("server", "srv", 0, "*")
|
||||
.treat("instrument", "ins", 0, "")
|
||||
|
||||
if (window['instrument']) {
|
||||
window['clientTags'] = "&instrument=" + window["instrument"];
|
||||
} else {
|
||||
window['clientTags'] = "&stream=" + window["server"] + "&device=" + window["device"];
|
||||
}
|
||||
|
||||
console.log('TAGS', window['clientTags']);
|
||||
|
||||
function loadFirstBlocks() {
|
||||
if (debug_main_daniel) {
|
||||
@ -196,9 +207,9 @@ window.onload = function() {
|
||||
// var homeButton = document.getElementById("home-icon");
|
||||
|
||||
// TODO : uncomment this code with the right URL to navigate to when the way to select the instrument will be decided.
|
||||
// homeButton.onclick = function () {
|
||||
// window.location = "http://" + location.hostname + ":8800/";
|
||||
// };
|
||||
homeButton.onclick = function () {
|
||||
window.location = "/select";
|
||||
};
|
||||
buildUpdateConnection();
|
||||
// if (location.hash) {
|
||||
// console.log("hash in url", location.hash);
|
||||
|
Reference in New Issue
Block a user