rework of the server side
main change: the same server may be used for several instruments - client classes are 'Interactors' dealing with the parameters etc. - methods from history are added to the clients + improvements on the js client side
This commit is contained in:
@ -17,9 +17,9 @@ function buildUpdateConnection() {
|
||||
|
||||
// Establishes server-sent-event-connection, which is used for all sorts of
|
||||
// updates and exists as long as the client is running.
|
||||
// Executed at programstart (see also SEAWebClientMain.js).
|
||||
// Executed at program start (see also SEAWebClientMain.js).
|
||||
|
||||
var path = "http://" + hostPort + "/update";
|
||||
var path = "http://" + hostPort + "/update?" + window.clientTags;
|
||||
if (debugCommunication) {
|
||||
console.log("%cto server (SSE): " + path,
|
||||
"color:white;background:lightblue");
|
||||
@ -29,8 +29,7 @@ function buildUpdateConnection() {
|
||||
var src = new EventSource(path);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
alertify.prompt(
|
||||
"NETWORK ERROR",
|
||||
alertify.prompt("NETWORK ERROR",
|
||||
"Failed to establish connection to data-server at the given address!"
|
||||
+ "Try to enter HOST and PORT of the data-server manually!",
|
||||
hostPort, function(evt, value) {
|
||||
@ -50,9 +49,7 @@ function buildUpdateConnection() {
|
||||
src.onerror = function(e) {
|
||||
console.log(e);
|
||||
console.log('EVTSRC error')
|
||||
alertify
|
||||
.prompt(
|
||||
"NETWORK ERROR",
|
||||
alertify.prompt("NETWORK ERROR",
|
||||
"Failed to establish connection to data-server at the given address!"
|
||||
+ "Try to enter HOST and PORT of the data-server manually!",
|
||||
hostPort, function(evt, value) {
|
||||
@ -406,10 +403,9 @@ function successHandler(s, message) {
|
||||
begin = timeRange[0] - timeRange[1];
|
||||
select.value = begin;
|
||||
// Server-request for variable-list.*/
|
||||
console.log('TIME', window['clientTags'], timeRange)
|
||||
console.log('TIME', timeRange)
|
||||
reqJSONPOST(0, "http://" + hostPort + "/getvars",
|
||||
"time=" + timeRange[0] + ',' + timeRange[1]
|
||||
+ window['clientTags']
|
||||
+ "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ "&id=" + clientID, successHandler, errorHandler);
|
||||
break;
|
||||
|
@ -490,7 +490,7 @@ let graphs = (function (){
|
||||
if(idx != -1){ //if the clicked block is displayed somewhere, we create a selection window
|
||||
createSelection(idx); // We will create a selection at the gindex
|
||||
}
|
||||
}
|
||||
}
|
||||
createGraph(gindex, block); // we create at the current shown selector (gindex), the graph corresponding to the one clicked (block)
|
||||
})
|
||||
selection.appendChild(bel);
|
||||
@ -547,7 +547,7 @@ let graphs = (function (){
|
||||
+ "&variables=" + varlist
|
||||
+ "&interval=" + resolution
|
||||
+ "&id=" + clientID).getJSON().then(function(data){
|
||||
//console.log('Graph', block, data)
|
||||
// console.log('Graph', block, data);
|
||||
let graph = new Graph(gindex, graph_elm, "Time", block.unit, block.tag, type);
|
||||
graph_array[gindex] = graph;
|
||||
|
||||
@ -559,7 +559,6 @@ let graphs = (function (){
|
||||
for(let e of data.graph[key]){
|
||||
pdata.push({x: e[0]*1000, y: e[1]});
|
||||
}
|
||||
|
||||
addDataset(gindex, key, pdata, dict[key])
|
||||
// if(pdata.length > 0){
|
||||
// addDataset(gindex, key, pdata, dict[key])
|
||||
@ -919,7 +918,6 @@ let graphs = (function (){
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars").postForm(
|
||||
"time=" + msRightTimestampGetVars/1000
|
||||
+ window['clientTags']
|
||||
+ "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ "&id="+ clientID).then(function(data){
|
||||
blocks = data.blocks;
|
||||
@ -998,7 +996,6 @@ let graphs = (function (){
|
||||
AJAX("http://" + hostPort + "/getvars").postForm(
|
||||
"time=" + msRightTimestamp/1000 + "&userconfiguration="
|
||||
+ JSON.stringify(getFormattedUserConfigurationFromLocalStorage())
|
||||
+ window['clientTags']
|
||||
+ "&id="+ clientID).then(function(data){
|
||||
currentMaxTime = msRightTimestamp + 60000;
|
||||
currentMinTime = msLeftTimestamp;
|
||||
@ -1304,7 +1301,6 @@ let graphs = (function (){
|
||||
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
|
||||
|
@ -91,18 +91,21 @@ 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("device", "dev", 0, "")
|
||||
.treat("server", "srv", 0, "")
|
||||
.treat("instrument", "instrument", 0, "")
|
||||
.treat("timerange", "time", 0, "-1800,0")
|
||||
|
||||
if (window['instrument']) {
|
||||
window['clientTags'] = "&instrument=" + window["instrument"];
|
||||
if (window.instrument) {
|
||||
window.clientTags = "&instrument=" + window.instrument;
|
||||
} else {
|
||||
window['clientTags'] = "&stream=" + window["server"] + "&device=" + window["device"];
|
||||
let args = '';
|
||||
if (window.server) { args += "&stream=" + window.server; }
|
||||
if (window.device) { args += "&device=" + window.device; }
|
||||
window.clientTags = args;
|
||||
}
|
||||
|
||||
console.log('TAGS', window['clientTags']);
|
||||
console.log('TAGS', window.clientTags);
|
||||
|
||||
function loadFirstBlocks() {
|
||||
if (debug_main_daniel) {
|
||||
@ -112,11 +115,19 @@ function loadFirstBlocks() {
|
||||
if (showMain) pushInitCommand("getblock?path=main&", "main")
|
||||
if (showConsole) pushInitCommand("console?", "console")
|
||||
if (nColumns == 1) { // probably mobile phone}
|
||||
if (showGraphics) pushInitCommand("gettime?time=" + window["timerange"] + "&", "graphics")
|
||||
if (showGraphics) pushInitCommand("gettime?time=" + window.timerange + "&", "graphics")
|
||||
if (showOverview) pushInitCommand("getblock?path=_overview&", "overview")
|
||||
var goFS = document.getElementById('header');
|
||||
goFS.addEventListener(
|
||||
'click',
|
||||
function () {
|
||||
document.body.requestFullscreen();
|
||||
},
|
||||
false,
|
||||
);
|
||||
} else {
|
||||
if (showOverview) pushInitCommand("getblock?path=_overview&", "overview")
|
||||
if (showGraphics) pushInitCommand("gettime?time=" + window["timerange"] + "&", "graphics")
|
||||
if (showGraphics) pushInitCommand("gettime?time=" + window.timerange + "&", "graphics")
|
||||
// last is shown first
|
||||
}
|
||||
}
|
||||
@ -169,7 +180,7 @@ window.onload = function() {
|
||||
|
||||
let crossElement = document.getElementById("close-cross");
|
||||
|
||||
if(window["hideRightPart"]){
|
||||
if(window.hideRightPart){
|
||||
document.body.removeChild(crossElement);
|
||||
}else{
|
||||
crossElement.onclick = function(){
|
||||
@ -193,7 +204,7 @@ window.onload = function() {
|
||||
elements[2].style.display = "none"; // hide parameters
|
||||
}
|
||||
}else{ // else it toggles the graphs window's size and triggers the adjustGrid()
|
||||
window["wideGraphs"] = !window['wideGraphs'];
|
||||
window.wideGraphs = ! window.wideGraphs;
|
||||
adjustGrid();
|
||||
}
|
||||
}
|
||||
@ -207,9 +218,8 @@ 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 = "/select";
|
||||
window.location = "/select_experiment";
|
||||
};
|
||||
buildUpdateConnection();
|
||||
// if (location.hash) {
|
||||
|
Reference in New Issue
Block a user