From b55e51fc65dbd368ac0d6d2328b7c8e0f4cd39cc Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 17 Sep 2021 15:37:04 +0200 Subject: [PATCH] fixes not concerning graphics - default is no graphics - use send_file instead of response (proper mimetype) - fix issues with parameter blocks --- client/SEAWebClientStart.html | 8 ++++-- client/jsFiles/SEAWebClientCommunication.js | 17 +++++++------ client/jsFiles/SEAWebClientGraphics.js | 4 ++- client/jsFiles/SEAWebClientGroup.js | 5 ++-- client/jsFiles/SEAWebClientMain.js | 2 +- client/jsFiles/SEAWebClientResponsivity.js | 4 +-- client/jsFiles/SEAWebClientSwiper.js | 4 +-- seaweb.py | 28 ++++++--------------- 8 files changed, 34 insertions(+), 38 deletions(-) mode change 100644 => 100755 seaweb.py diff --git a/client/SEAWebClientStart.html b/client/SEAWebClientStart.html index 789de2c..d649505 100644 --- a/client/SEAWebClientStart.html +++ b/client/SEAWebClientStart.html @@ -18,7 +18,7 @@ select instrument
- + @@ -27,7 +27,7 @@ - + @@ -40,6 +40,10 @@ + + + + diff --git a/client/jsFiles/SEAWebClientCommunication.js b/client/jsFiles/SEAWebClientCommunication.js index ae233a2..389462a 100644 --- a/client/jsFiles/SEAWebClientCommunication.js +++ b/client/jsFiles/SEAWebClientCommunication.js @@ -224,7 +224,7 @@ function updateValues(message, src) { } else if (type == "checkbox") { var row = matches[j].parentNode.parentNode; row.style.backgroundColor = "white"; - console.log('CBX', matches[j].name, message, Boolean(value && value != 'false')); + // console.log('CBX', matches[j].name, message, Boolean(value && value != 'false')); matches[j].checked = Boolean(value && value != 'false'); } else if (type == "enum") { matches[j].style.display = "block"; @@ -287,19 +287,22 @@ function successHandler(s, message) { insertSlide(2, "", "parameters", createContent(2, {components:[]})); } else { if (s < 0) { // redraw: check for slides in all swiper instances + // not used any more? for (var isw = 0; isw < MAXBLOCK; isw ++) { var isl = findSlide(isw, message.path); - var slide = swiper[isl].slides[i]; - if (slide) { - console.log("redraw", isw); - replaceSlideContent(slide, message.title, - createContent(isw, message)); + if (isl !== null) { + var slide = swiper[isw].slides[isl]; + if (slide) { + console.log("redraw", isw, isl); + replaceSlideContent(slide, message.title, + createContent(isw, message)); + } } } } else { // insertSlide(s, message.title, message.path, createContent(s, message)); let sLocal = paramSlider[s]; - isl = insertSlide(sLocal, message.title, "parameters", createContent(sLocal, message)); + isl = insertSlide(sLocal, message.title, "parameters", createContent(sLocal, message)); swiper[sLocal].slideTo(isl); /* go to found slide */ } } diff --git a/client/jsFiles/SEAWebClientGraphics.js b/client/jsFiles/SEAWebClientGraphics.js index fd6cadb..d1dfa72 100644 --- a/client/jsFiles/SEAWebClientGraphics.js +++ b/client/jsFiles/SEAWebClientGraphics.js @@ -798,6 +798,7 @@ let graphs = (function (){ } function resizeHandler() { + if (blocks) { // prevent error when graphics are not used createGraphs(); adjustLegends(); if (cursorLinePos) { @@ -805,6 +806,7 @@ let graphs = (function (){ cursorLine(null); update(); } + } } window.addEventListener('resize', resizeHandler); @@ -1463,4 +1465,4 @@ function updateCharts2(graph){ function createCharts2(arg) { console.log('C2', arg) -} \ No newline at end of file +} diff --git a/client/jsFiles/SEAWebClientGroup.js b/client/jsFiles/SEAWebClientGroup.js index 704ed43..bbca7fd 100644 --- a/client/jsFiles/SEAWebClientGroup.js +++ b/client/jsFiles/SEAWebClientGroup.js @@ -75,7 +75,7 @@ function create_group_row(s, component) { slideNames[s] = component.name; document.title = "SEA "+ clientTitle + " " + slideNames.join(" "); history.pushState({func: "gotoGroups", funarg: slideNames.join("%20")}, document.title, "#" + slideNames.join("%20")); - getGroup(s, name); + getGroup(s, component.name); } if (title === "console" || title === "device config") { @@ -139,7 +139,6 @@ function create_pushbutton_row(s, component) { var name = component.name; var command = component.command; var left = createTitle(component); - console.log(info); left.id = component.name; left.name = component.title; @@ -187,7 +186,7 @@ function create_input_row(s, component) { var name = component.name; var command = component.command; - if (info) { + if (component.info) { var infoBox = createInfo(component); } var left = createTitle(component); diff --git a/client/jsFiles/SEAWebClientMain.js b/client/jsFiles/SEAWebClientMain.js index 1e8602b..7f2ffe7 100644 --- a/client/jsFiles/SEAWebClientMain.js +++ b/client/jsFiles/SEAWebClientMain.js @@ -75,7 +75,7 @@ new Settings() .treat("showMain", "sm", to_bool, true) .treat("showConsole", "sc", to_bool, true) .treat("showOverview", "so", to_bool, true) - .treat("showGraphics", "sg", to_bool, true) + .treat("showGraphics", "sg", to_bool, false) .treat("showAsync", "sa", to_bool, false) function loadFirstBlocks() { diff --git a/client/jsFiles/SEAWebClientResponsivity.js b/client/jsFiles/SEAWebClientResponsivity.js index 5d5708a..eeed0d1 100644 --- a/client/jsFiles/SEAWebClientResponsivity.js +++ b/client/jsFiles/SEAWebClientResponsivity.js @@ -69,7 +69,7 @@ function adjustGrid() { switch (nColumns) { case 1: - if (menuMode) { + if (menuMode) { leftWidth = Math.min(100, MINWIDTH / width * 100); style(0,leftWidth + "vw","100vh"); style(1); // hide @@ -147,4 +147,4 @@ function style(s, width, height) { elements[s].style.float = "left"; } -let isTouchDevice = !!('ontouchstart' in window) || !!('msmaxtouchpoints' in window.navigator); \ No newline at end of file +let isTouchDevice = !!('ontouchstart' in window) || !!('msmaxtouchpoints' in window.navigator); diff --git a/client/jsFiles/SEAWebClientSwiper.js b/client/jsFiles/SEAWebClientSwiper.js index 6bc99e0..a62e23d 100644 --- a/client/jsFiles/SEAWebClientSwiper.js +++ b/client/jsFiles/SEAWebClientSwiper.js @@ -171,7 +171,7 @@ function getSlideNames() { for (var s=0; s 0) { name = sw.slides[sw.activeIndex].slideType; } names.push(); @@ -181,4 +181,4 @@ function getSlideNames() { names.pop(); } return names; -} \ No newline at end of file +} diff --git a/seaweb.py b/seaweb.py old mode 100644 new mode 100755 index 9db0b26..c086175 --- a/seaweb.py +++ b/seaweb.py @@ -37,6 +37,7 @@ def guess_mimetype(filename): mimetype = 'text/css' elif filename.endswith('.ico'): mimetype = 'image/x-icon' + print('mimetype', mimetype) else: mimetype = 'text/html' return mimetype @@ -141,12 +142,7 @@ def reply(): @app.route('/test/') def subdir_test_file(file): gevent.sleep(2) - try: - with open("client/test/"+file, 'r') as content_file: - content = content_file.read() - except IOError: - flask.abort(404) - resp = flask.Response(content, mimetype=guess_mimetype(file)) + resp = flask.send_file("client/test/"+file, mimetype=guess_mimetype(file)) return resp @app.route('/jsFiles/') @@ -154,12 +150,7 @@ def subdir_test_file(file): @app.route('/externalFiles/') def subdir_file(file): subdir = flask.request.path.split('/')[1] - try: - with open("client/" + subdir+"/"+file, 'r') as content_file: - content = content_file.read() - except IOError: - flask.abort(404) - resp = flask.Response(content, mimetype=guess_mimetype(file)) + resp = flask.send_file("client/" + subdir+"/"+file, mimetype=guess_mimetype(file)) #resp.headers['Content-Security-Policy'] = "sandbox; script-src 'unsafe-inline';" return resp @@ -174,12 +165,7 @@ def default(): @app.route('/') def general_file(file): subdir = "client/" - try: - with open(subdir+file, 'r') as content_file: - content = content_file.read() - except IOError: - flask.abort(404) - resp = flask.Response(content, mimetype=guess_mimetype(file)) + resp = flask.send_file(subdir+file, mimetype=guess_mimetype(file)) #resp.headers['Content-Security-Policy'] = "sandbox; script-src 'unsafe-inline';" return resp @@ -332,7 +318,7 @@ class SeaInstrument(Instrument): def poll_groups(self, paths): 'polls values and components of requested groups' - for path in paths: + for path in list(paths): gobj = self.groups[path] now = time.time() if now < gobj.lastpoll + 0.5: @@ -627,7 +613,9 @@ class SeaClient(SeaGraph): def w_getblock(self, path): gobj = instrument.findgroup(path.split(',')[-1]) - self.group_version[path] = gobj.version + # self.group_version[path] = gobj.version + # simplify: allow only one group per client + self.group_version = {path: gobj.version} logging.info('getblock %s %d', path, gobj.version) return dict(type='draw', title=gobj.grouptitle, path=path, components=gobj.components)