From 4a27f3d43e1c53d10c9489f528450d488495d11b Mon Sep 17 00:00:00 2001 From: redPanther Date: Sat, 3 Sep 2016 15:54:33 +0200 Subject: [PATCH] refactoring of webui and event based websocket layer (#219) * make hyperion websocket api event based * implement new websocket handling for generalconf * migrate all webui stuff to new event based websocket api some cleanup ... now all html templates are in content refactoring of web stuff * add hyperionport to global start impl. removing advanced key * separate dashboard serverinfo is updated every 3 seconds automatily add input selection cleanup and remove not needed stuff * prepare infrastructure for server sided file execution * webui minor fixes * fix compile --- .gitignore | 1 + assets/webconfig/content/dashboard.html | 91 +++ assets/webconfig/content/effects.html | 25 + assets/webconfig/content/generalconf.html | 106 +++ assets/webconfig/{ => content}/huebridge.html | 0 assets/webconfig/content/input_selection.html | 34 + assets/webconfig/{ => content}/kodiconf.html | 0 assets/webconfig/{ => content}/lighttest.html | 28 +- .../webconfig/content/remote_components.html | 26 + assets/webconfig/{ => content}/support.html | 2 +- assets/webconfig/content/update.html | 23 + assets/webconfig/effects.html | 39 - assets/webconfig/generalconf.html | 105 --- assets/webconfig/index.html | 719 +++++++----------- assets/webconfig/js/hyperion.js | 158 +++- assets/webconfig/js/ui_utils.js | 12 + assets/webconfig/remote_components.html | 40 - assets/webconfig/select/index.html | 98 --- assets/webconfig/select/starter-template.css | 8 - assets/webconfig/server_scripts/demo.py | 5 + assets/webconfig/server_scripts/demo.sh | 5 + assets/webconfig/update.html | 26 - include/utils/FileUtils.h | 8 + libsrc/effectengine/EffectEngine.cpp | 3 +- libsrc/hyperion/hyperion.schema.json | 24 + libsrc/jsonserver/JsonClientConnection.cpp | 9 +- libsrc/utils/CMakeLists.txt | 2 + libsrc/utils/FileUtils.cpp | 35 + libsrc/utils/Logger.cpp | 10 +- libsrc/utils/Profiler.cpp | 17 +- .../utils/jsonschema/QJsonSchemaChecker.cpp | 2 +- libsrc/webconfig/CgiHandler.cpp | 36 +- libsrc/webconfig/CgiHandler.h | 4 +- libsrc/webconfig/StaticFileServing.cpp | 4 +- libsrc/webconfig/StaticFileServing.h | 2 +- 35 files changed, 842 insertions(+), 865 deletions(-) create mode 100644 assets/webconfig/content/dashboard.html create mode 100644 assets/webconfig/content/effects.html create mode 100644 assets/webconfig/content/generalconf.html rename assets/webconfig/{ => content}/huebridge.html (100%) create mode 100644 assets/webconfig/content/input_selection.html rename assets/webconfig/{ => content}/kodiconf.html (100%) rename assets/webconfig/{ => content}/lighttest.html (63%) create mode 100644 assets/webconfig/content/remote_components.html rename assets/webconfig/{ => content}/support.html (99%) create mode 100644 assets/webconfig/content/update.html delete mode 100644 assets/webconfig/effects.html delete mode 100644 assets/webconfig/generalconf.html create mode 100644 assets/webconfig/js/ui_utils.js delete mode 100644 assets/webconfig/remote_components.html delete mode 100644 assets/webconfig/select/index.html delete mode 100644 assets/webconfig/select/starter-template.css create mode 100644 assets/webconfig/server_scripts/demo.py create mode 100644 assets/webconfig/server_scripts/demo.sh delete mode 100644 assets/webconfig/update.html create mode 100644 include/utils/FileUtils.h create mode 100644 libsrc/utils/FileUtils.cpp diff --git a/.gitignore b/.gitignore index b7b2e79c..272d4c32 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ CMakeCache.txt *.log /HyperionConfig.h /lib +.directory diff --git a/assets/webconfig/content/dashboard.html b/assets/webconfig/content/dashboard.html new file mode 100644 index 00000000..86dc848d --- /dev/null +++ b/assets/webconfig/content/dashboard.html @@ -0,0 +1,91 @@ +
+
+
+

Dashboard

+
+

The dashboard give you a quick overview about the status of Hyperion and show you the latest news of the Hyperion Blog.

+
+
+
+
+
+ + Information +
+
+ + + + + + + + + + + + + + + + + + + +
Your Hyperion version:unknown
Latest version:unknown
LED type:unknown
Device:
+
+ +
+
+
+
+
+
+ + Components status +
+
+ + + + + + + + + + + + + + + + + + + + + +
ComponentStatus
Kodi Watch
Blackborder
Booteffect
+
+
+
+
+
+
+ + Latest blog posts +
+
+ +
+
+
+ +
+ +
+ +
+ + diff --git a/assets/webconfig/content/effects.html b/assets/webconfig/content/effects.html new file mode 100644 index 00000000..6139942c --- /dev/null +++ b/assets/webconfig/content/effects.html @@ -0,0 +1,25 @@ +
+
+
+

Effects

+
+

The Effects remote enables you to set an effect for testing or demonstration purposes. Don't forget to stop it afterwards.

+
+
+
+ Stop Effect
+
+
+
+
+ + diff --git a/assets/webconfig/content/generalconf.html b/assets/webconfig/content/generalconf.html new file mode 100644 index 00000000..284b02e4 --- /dev/null +++ b/assets/webconfig/content/generalconf.html @@ -0,0 +1,106 @@ +
+
+
+

General

+
+

You can edit the general configuration here.

+
+
+
+
+
+ +
+
+
+
+ + + diff --git a/assets/webconfig/huebridge.html b/assets/webconfig/content/huebridge.html similarity index 100% rename from assets/webconfig/huebridge.html rename to assets/webconfig/content/huebridge.html diff --git a/assets/webconfig/content/input_selection.html b/assets/webconfig/content/input_selection.html new file mode 100644 index 00000000..8188915b --- /dev/null +++ b/assets/webconfig/content/input_selection.html @@ -0,0 +1,34 @@ +
+
+
+ + + + diff --git a/assets/webconfig/kodiconf.html b/assets/webconfig/content/kodiconf.html similarity index 100% rename from assets/webconfig/kodiconf.html rename to assets/webconfig/content/kodiconf.html diff --git a/assets/webconfig/lighttest.html b/assets/webconfig/content/lighttest.html similarity index 63% rename from assets/webconfig/lighttest.html rename to assets/webconfig/content/lighttest.html index 76829aac..b93d6d6e 100644 --- a/assets/webconfig/lighttest.html +++ b/assets/webconfig/content/lighttest.html @@ -1,7 +1,7 @@
-
-
-

Colors

+
+
+

Colors

Set color:
@@ -25,12 +25,13 @@ $('#cp2').colorpicker({ format: 'rgb', - colorSelectors: {'default': '#777777', + colorSelectors: { + 'default': '#777777', 'primary': '#337ab7', 'success': '#5cb85c', - 'info': '#5bc0de', + 'info' : '#5bc0de', 'warning': '#f0ad4e', - 'danger': '#d9534f' + 'danger' : '#d9534f' }, customClass: 'colorpicker-2x', sliders: { @@ -48,19 +49,10 @@ }); $('#cp2').colorpicker().on('changeColor', function(e) { - //console.log(e.color.toRGB()); - webSocket.send('{"command":"color", "color":['+e.color.toRGB().r+','+e.color.toRGB().g+','+e.color.toRGB().b+'], "priority":1}'); + color = e.color.toRGB(); + requestSetColor(color.r, color.g, color.b); }); }); - - $("#reset_color").on("click", function() { - webSocket.send('{"command":"clear", "priority":1}'); - }); - - - - webSocket.onmessage = function(event){ - console.log(event.data); - } + $("#reset_color").on("click", requestPriorityClear); diff --git a/assets/webconfig/content/remote_components.html b/assets/webconfig/content/remote_components.html new file mode 100644 index 00000000..e8a5765b --- /dev/null +++ b/assets/webconfig/content/remote_components.html @@ -0,0 +1,26 @@ +
+
+
+

Effects

+
+

The components remote enables you to disable and enable certain components of Hyperion during runtime. Keep in mind this persist just until the next reboot! To enable/disable components permament, use the configuration section.

+
+
+
+
+
+
+
+ + diff --git a/assets/webconfig/support.html b/assets/webconfig/content/support.html similarity index 99% rename from assets/webconfig/support.html rename to assets/webconfig/content/support.html index 0d96648b..fce63158 100644 --- a/assets/webconfig/support.html +++ b/assets/webconfig/content/support.html @@ -110,4 +110,4 @@
-
\ No newline at end of file +
diff --git a/assets/webconfig/content/update.html b/assets/webconfig/content/update.html new file mode 100644 index 00000000..853d1e23 --- /dev/null +++ b/assets/webconfig/content/update.html @@ -0,0 +1,23 @@ +
+
+
+

Update

+
+

This page gives you an overview of all Hyperion versions available. On top you could update or downgrade your version of Hyperion whenever you want. Sorted from newest to oldest

+
+
+

+
+
+
+
+
+
+ + diff --git a/assets/webconfig/effects.html b/assets/webconfig/effects.html deleted file mode 100644 index 917f4e92..00000000 --- a/assets/webconfig/effects.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
-
-

Effects

-
-

The Effects remote enables you to set an effect for testing or demonstration purposes. Don't forget to stop it afterwards.

-
-
-
- Stop Effect
-
-
-
-
- - diff --git a/assets/webconfig/generalconf.html b/assets/webconfig/generalconf.html deleted file mode 100644 index b0d9fda4..00000000 --- a/assets/webconfig/generalconf.html +++ /dev/null @@ -1,105 +0,0 @@ -
-
-
-

General

-
-

You can edit the general configuration here.

-
-
-
-
-
- - -
-
-
-
- - - diff --git a/assets/webconfig/index.html b/assets/webconfig/index.html index 2d82cc24..fcbcd600 100644 --- a/assets/webconfig/index.html +++ b/assets/webconfig/index.html @@ -3,31 +3,32 @@ - - - - + + + + - Hyperion - WebUI + Hyperion - WebUI - + - + + - - + + - - + + - - + + @@ -49,481 +50,279 @@ - - + + - - + + - - + + - - + + - - - + + + -
+
- - - - + +
- - +
+ + +