From 66644104de951f8fe6eddab5022bcd88f1cfa4a2 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 16 Jan 2018 17:26:37 +0100 Subject: [PATCH 01/12] Loader, bugs solved --- debian/changelog | 2 +- forms/ecomerce/ticket/ui.xml | 4 +- hedera-web.php | 1 - js/htk/htk.js | 1 + js/htk/loader.js | 79 ++++++++++++++++++++++++++++++++++++ js/htk/style.css | 8 +++- js/vn/mutators.js | 16 ++++---- package.json | 2 +- 8 files changed, 99 insertions(+), 14 deletions(-) create mode 100644 js/htk/loader.js diff --git a/debian/changelog b/debian/changelog index f5bf8847..62d9d372 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.66) stable; urgency=low +hedera-web (1.405.67) stable; urgency=low * Initial Release. diff --git a/forms/ecomerce/ticket/ui.xml b/forms/ecomerce/ticket/ui.xml index 6faa6287..c9bab81d 100644 --- a/forms/ecomerce/ticket/ui.xml +++ b/forms/ecomerce/ticket/ui.xml @@ -26,7 +26,7 @@
-
+

@ @@ -61,7 +61,7 @@

-
+ run (); - diff --git a/js/htk/htk.js b/js/htk/htk.js index 496b9777..6707c0f7 100644 --- a/js/htk/htk.js +++ b/js/htk/htk.js @@ -17,6 +17,7 @@ Htk = module.exports = { ,ImageEditor : require ('./image-editor') ,Assistant : require ('./assistant') ,AssistantBar : require ('./assistant-bar') + ,Loader : require ('./loader') ,Field : require ('./field') ,Column : require ('./column') }; diff --git a/js/htk/loader.js b/js/htk/loader.js new file mode 100644 index 00000000..8ca67313 --- /dev/null +++ b/js/htk/loader.js @@ -0,0 +1,79 @@ + +var Widget = require ('./widget'); + +module.exports = new Class +({ + Tag: 'htk-loader' + ,Extends: Widget + ,Properties: { + form: + { + type: Db.Form + ,set: function (x) + { + this.link ({_form: x}, {'status-changed': this.onFormChange}); + this.onFormChange (); + } + ,get: function () + { + return this._form; + } + } + } + + ,initialize: function () + { + var node = this.createRoot ('div'); + node.className = 'htk-loader'; + + var div = this.createElement ('div'); + div.className = 'spinner'; + + var spinner = new Htk.Spinner (); + div.appendChild (spinner.node); + + var childs = this.createElement ('div'); + + this.spinner = spinner; + this.div = div; + this.childs = childs; + this.isLoading = true; + this.stop (); + } + + ,appendChild: function (child) + { + this.childs.appendChild (child); + } + + ,stop: function () + { + if (!this.isLoading) + return; + + this.isLoading = false; + this.spinner.stop (); + Vn.Node.removeChilds (this.node); + this.node.appendChild (this.childs); + } + + ,start: function () + { + if (this.isLoading) + return; + + this.isLoading = true; + this.spinner.start (); + Vn.Node.removeChilds (this.node); + this.node.appendChild (this.div); + } + + ,onFormChange: function () + { + if (this._form.ready) + this.stop (); + else + this.start (); + } +}); + diff --git a/js/htk/style.css b/js/htk/style.css index 62231a33..6d9f836b 100644 --- a/js/htk/style.css +++ b/js/htk/style.css @@ -593,7 +593,7 @@ td.cell-image .htk-image background-color: initial; } -/* Loader */ +/* Spinner */ .htk-spinner { @@ -630,3 +630,9 @@ td.cell-image .htk-image to {-webkit-transform: rotate(360deg);} } +/* Loader */ + +.htk-loader > .spinner +{ + text-align: center; +} diff --git a/js/vn/mutators.js b/js/vn/mutators.js index 85ca1531..6ee6576e 100644 --- a/js/vn/mutators.js +++ b/js/vn/mutators.js @@ -3,17 +3,17 @@ vnCustomTags = {}; var Mutators = Class.Mutators; +var _Extends = Mutators.Extends; + +Mutators.Extends = function () +{ + _Extends.apply (this, arguments); + this.implement ({Properties: {}}); +} + Mutators.Tag = function (tagName) { vnCustomTags[tagName] = this; - - if (this.parent) - { - this.implement ({Parent: this.parent.Parent}); - this.implement ({Child: this.parent.Child}); - this.implement ({Properties: {}}); - } - this.extend ({Tag: tagName}); }; diff --git a/package.json b/package.json index ac38d638..cd6acb2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.66", + "version": "1.405.67", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { From 7d484fcb7e98d0e68bd2aee7cec45dc134627edb Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jan 2018 12:49:09 +0100 Subject: [PATCH 02/12] Production adjustments and bugs --- debian/changelog | 2 +- package.json | 2 +- pages/production/main.js | 75 ++++++++++++++++++++++++-------------- pages/production/style.css | 12 ++++++ rest/misc/production.php | 15 ++++---- 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/debian/changelog b/debian/changelog index 62d9d372..d3894bc8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.67) stable; urgency=low +hedera-web (1.405.68) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index cd6acb2f..1e0bd2b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.67", + "version": "1.405.68", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/pages/production/main.js b/pages/production/main.js index 3cbb71b3..c872923e 100644 --- a/pages/production/main.js +++ b/pages/production/main.js @@ -2,17 +2,26 @@ /** * Time in seconds between every request. */ -var INTERVAL = 10; +var INTERVAL = 15; var requestInterval = INTERVAL; var failedRequests = 0; var timeoutId = null; var request = null; -var lastText = null; -var lastError = null; +var lastText; +var lastStatus; +var lastError; function onBodyLoad () { + setText (); +} + +function setText () +{ + lastText = null; + lastStatus = null; + lastError = null; updateText (); } @@ -25,6 +34,9 @@ function onSettingsClick () deviceId = prompt ('Enter the device identifier', deviceId); + if (deviceId == null) + return; + if (deviceId) localStorage.setItem ('hederaDeviceId', deviceId); else if (deviceId === '') @@ -41,7 +53,7 @@ function onSettingsClick () request = null; } - updateText (); + setText (); } function updateText () @@ -50,7 +62,7 @@ function updateText () if (!deviceId) { - display ('Device id not set', true); + display (null, null, 'Device id not set'); return; } @@ -74,27 +86,29 @@ function onRequestChange (request) switch (request.status) { case 200: - var json = JSON.parse (request.responseText); - display (json.data); + var data = JSON.parse (request.responseText).data; + display (data.displayText, data.status, null); requestInterval = INTERVAL; failedRequests = 0; break; case 400: var json = JSON.parse (request.responseText); throw new Error (json.data.message); + case 0: + throw new Error ('Connection lost'); default: throw new Error ('HTTP '+ request.status +': '+ request.statusText); } } catch (e) { - display (e.message, true); + display (null, null, e.message); console.error (e.message); failedRequests++; if (failedRequests > 10 && requestInterval < 60) { - requestInterval += parseInt (Math.random() * 10) + 1; + requestInterval += parseInt (Math.random() * INTERVAL) + 1; console.warn ('Request interval increased to %d seconds.', requestInterval); } } @@ -103,33 +117,39 @@ function onRequestChange (request) request = null; } -function display (text, error) +function display (text, status, error) { - var bgColor; - - if (!error) + if (error) + { + text = lastText; + status = lastStatus; + } + + if (text === lastText && status === lastStatus && error === lastError) + return; + + var bgColor; + $('text').textContent = text; + + if (error) + { + $('error').textContent = error; + $('error').style.display = 'block'; + bgColor = 'red'; + } + else { - $('text').textContent = text; $('error').textContent = ''; $('error').style.display = 'none'; bgColor = 'green'; } - else - { - $('text').textContent = 'Er'; - $('error').textContent = text; - $('error').style.display = 'block'; - bgColor = 'red'; - } - if (text != lastText || lastError != error) - { - var body = document.body; - body.addEventListener ('transitionend', onTransitionEnd); - body.style.backgroundColor = bgColor; - } + var body = document.body; + body.addEventListener ('transitionend', onTransitionEnd); + body.style.backgroundColor = bgColor; lastText = text; + lastStatus = status; lastError = error; } @@ -138,6 +158,7 @@ function onTransitionEnd () var body = document.body; body.removeEventListener ('transitionend', onTransitionEnd); body.style.backgroundColor = ''; + body.className = lastStatus ? lastStatus : ''; } function $ (elementId) diff --git a/pages/production/style.css b/pages/production/style.css index d5beb353..9bb6becd 100644 --- a/pages/production/style.css +++ b/pages/production/style.css @@ -8,6 +8,18 @@ body font-family: Sans; transition: background-color 500ms ease-in; } +body.idle +{ + background-color: #08d; +} +body.doing +{ + background-color: #333; +} +body.done +{ + background-color: #4a0; +} #container { width: 100%; diff --git a/rest/misc/production.php b/rest/misc/production.php index 62ee72b4..91f7e0b6 100644 --- a/rest/misc/production.php +++ b/rest/misc/production.php @@ -6,14 +6,15 @@ class Production extends Vn\Web\JsonRequest function run ($db) { - $row = $db->getObject ( - 'SELECT displayText FROM vn.routeGate WHERE deviceId = #', - [$_REQUEST['deviceId']] - ); + $row = $db->getObject ( + 'SELECT displayText, status + FROM vn.routeGate WHERE deviceId = #', + [$_REQUEST['deviceId']] + ); - if (!isset($row)) - throw new Vn\Lib\UserException ('Device not found'); + if (!isset($row)) + throw new Vn\Lib\UserException ('Device not found'); - return $row->displayText; + return $row; } } From 8739fd4094af602ec21a83567158ff442b36b47e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jan 2018 14:16:52 +0100 Subject: [PATCH 03/12] Production bugs --- debian/changelog | 2 +- package.json | 2 +- pages/production/main.js | 36 +++++++++++++++--------------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/debian/changelog b/debian/changelog index d3894bc8..0b4ff8ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.68) stable; urgency=low +hedera-web (1.405.69) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index 1e0bd2b3..85d529a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.68", + "version": "1.405.69", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/pages/production/main.js b/pages/production/main.js index c872923e..d9a26d57 100644 --- a/pages/production/main.js +++ b/pages/production/main.js @@ -8,20 +8,18 @@ var requestInterval = INTERVAL; var failedRequests = 0; var timeoutId = null; var request = null; -var lastText; -var lastStatus; -var lastError; +var myText; +var myStatus; +var myError; function onBodyLoad () { - setText (); + setTimeout (setText, 1000); } function setText () { - lastText = null; - lastStatus = null; - lastError = null; + display (null, null, null); updateText (); } @@ -102,7 +100,7 @@ function onRequestChange (request) } catch (e) { - display (null, null, e.message); + display (myText, myStatus, e.message); console.error (e.message); failedRequests++; @@ -119,20 +117,15 @@ function onRequestChange (request) function display (text, status, error) { - if (error) - { - text = lastText; - status = lastStatus; - } - - if (text === lastText && status === lastStatus && error === lastError) + if (text === myText && status === myStatus && error === myError) return; var bgColor; - $('text').textContent = text; + var body = document.body; if (error) { + text = text ? text : 'Er'; $('error').textContent = error; $('error').style.display = 'block'; bgColor = 'red'; @@ -144,13 +137,15 @@ function display (text, status, error) bgColor = 'green'; } - var body = document.body; + $('text').textContent = text; + body.className = status ? status : ''; + body.addEventListener ('transitionend', onTransitionEnd); body.style.backgroundColor = bgColor; - lastText = text; - lastStatus = status; - lastError = error; + myText = text; + myStatus = status; + myError = error; } function onTransitionEnd () @@ -158,7 +153,6 @@ function onTransitionEnd () var body = document.body; body.removeEventListener ('transitionend', onTransitionEnd); body.style.backgroundColor = ''; - body.className = lastStatus ? lastStatus : ''; } function $ (elementId) From 86674c2a30769fc23f9c2aa9dfe14a5db4ccf965 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jan 2018 14:18:30 +0100 Subject: [PATCH 04/12] Production bugs --- debian/changelog | 2 +- package.json | 2 +- pages/production/main.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0b4ff8ba..6cdbb233 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.69) stable; urgency=low +hedera-web (1.405.70) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index 85d529a0..f4e95863 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.69", + "version": "1.405.70", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/pages/production/main.js b/pages/production/main.js index d9a26d57..ab388a4d 100644 --- a/pages/production/main.js +++ b/pages/production/main.js @@ -17,12 +17,6 @@ function onBodyLoad () setTimeout (setText, 1000); } -function setText () -{ - display (null, null, null); - updateText (); -} - function onSettingsClick () { var deviceId = localStorage.getItem ('hederaDeviceId'); @@ -54,6 +48,12 @@ function onSettingsClick () setText (); } +function setText () +{ + display (null, null, null); + updateText (); +} + function updateText () { var deviceId = localStorage.getItem ('hederaDeviceId'); From 5ddfaf1d6cf649fc9bf8367431bbe99e5c4160e8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jan 2018 15:00:13 +0100 Subject: [PATCH 05/12] Version displayed in testing mode --- debian/changelog | 2 +- js/hedera/gui.css | 23 ++++++++++++++++++++--- js/hedera/gui.js | 18 +++++++++++++++--- js/hedera/gui.xml | 6 +++++- package.json | 2 +- pages/production/style.css | 4 ++-- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6cdbb233..654b616a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.70) stable; urgency=low +hedera-web (1.405.71) stable; urgency=low * Initial Release. diff --git a/js/hedera/gui.css b/js/hedera/gui.css index 127e1f9b..e747901e 100644 --- a/js/hedera/gui.css +++ b/js/hedera/gui.css @@ -195,9 +195,8 @@ .vn-gui .test-link { - display: block; - margin: 1em auto; - max-width: 70%; + display: none; + margin: .5em; background-color: #3f51b5; color: white; padding: 0 1em; @@ -209,6 +208,24 @@ { background-color: #4f61c5; } +.vn-gui .dev-info +{ + display: none; + padding: .3em .5em; + color: white; + background-color: #3f51b5; + font-size: .9em; + margin: .5em; + border-radius: .1em; +} +.vn-gui .dev-info > p +{ + margin: .2em 0; +} +.vn-gui .dev-info > .mode +{ + color: #BBF; +} /* Menu */ diff --git a/js/hedera/gui.js b/js/hedera/gui.js index b097a645..c27ebf81 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -58,6 +58,7 @@ module.exports = new Class var sql = 'SELECT nickname FROM account.userView;' +'SELECT default_form FROM config;' +'SELECT url FROM imageConfig;' + +'SELECT dbproduccion FROM vn2008.tblContadores;' +'SELECT production_domain, test_domain FROM config;'; this._conn.execQuery (sql, this.onMainQueryDone.bind (this)); @@ -154,26 +155,37 @@ module.exports = new Class // Retrieving configuration parameters + var isTesting = !resultSet.fetchValue (); + + if (isTesting) + { + this.$('dev-info').style.display = 'block'; + this.$('version').textContent = Vn.Cookie.get ('vnVersion'); + } + + // Retrieving configuration parameters + var res = resultSet.fetchResult (); if (res.next () && res.get ('test_domain')) { if (location.host != res.get ('production_domain')) { - var linkText = 'ReturnToOldWebsite'; + var linkText = 'Old website'; var linkField = 'production_domain'; } else { - var linkText = 'TestTheNewWebsite'; + var linkText = 'Test the new website'; var linkField = 'test_domain'; } Vn.Node.setText (this.$('test-link'), _(linkText)); this.$('test-link').href = '//'+ res.get (linkField); + this.$('test-link').style.display = 'block'; } else - Vn.Node.hide (this.$('test-link')); + this.$('test-link').style.display = 'none'; // Loading the default form diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml index ab26d747..261c6b64 100644 --- a/js/hedera/gui.xml +++ b/js/hedera/gui.xml @@ -25,7 +25,11 @@

- +
+

Testing

+

Version

+
+
Old website