From d9e0cc13dd27016a732c99bf90337ace32486cb1 Mon Sep 17 00:00:00 2001 From: deathbybadaid Date: Fri, 8 Jan 2021 09:29:15 -0500 Subject: [PATCH] Web Enhancements --- fHDHR_web/api/settings.py | 18 +- fHDHR_web/templates/base.html | 67 ++++--- fHDHR_web/templates/channels.html | 126 ++++++------ fHDHR_web/templates/channels_editor.html | 233 +++++++++++------------ fHDHR_web/templates/cluster.html | 79 ++++---- fHDHR_web/templates/diagnostics.html | 5 +- fHDHR_web/templates/guide.html | 72 +++---- fHDHR_web/templates/index.html | 22 +-- fHDHR_web/templates/settings.html | 74 ++++--- fHDHR_web/templates/tools.html | 10 +- fHDHR_web/templates/tuners.html | 60 +++--- fHDHR_web/templates/version.html | 23 ++- fHDHR_web/templates/xmltv.html | 57 +++--- fHDHR_web/www_dir/style.css | 14 +- 14 files changed, 428 insertions(+), 432 deletions(-) diff --git a/fHDHR_web/api/settings.py b/fHDHR_web/api/settings.py index 53a4d48..c601cbd 100644 --- a/fHDHR_web/api/settings.py +++ b/fHDHR_web/api/settings.py @@ -1,5 +1,7 @@ from flask import request, redirect, session import urllib.parse +import threading +import time class Settings(): @@ -10,6 +12,9 @@ class Settings(): def __init__(self, fhdhr): self.fhdhr = fhdhr + self.restart_url = "/api/settings?method=restart_actual" + self.restart_sleep = 5 + def __call__(self, *args): return self.get(*args) @@ -35,11 +40,18 @@ class Settings(): self.fhdhr.config.write(config_section, config_name, config_value) elif method == "restart": - instance_id = request.args.get('instance_id', default=None, type=str) - if instance_id == session["instance_id"]: - session["restart"] = True + restart_thread = threading.Thread(target=self.restart_thread) + restart_thread.start() + return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("Restarting in %s seconds" % self.restart_sleep)) + + elif method == "restart_actual": + session["restart"] = True if redirect_url: return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) else: return "%s Success" % method + + def restart_thread(self): + time.sleep(self.restart_sleep) + self.fhdhr.api.get(self.restart_url) diff --git a/fHDHR_web/templates/base.html b/fHDHR_web/templates/base.html index c514359..f3d751a 100644 --- a/fHDHR_web/templates/base.html +++ b/fHDHR_web/templates/base.html @@ -1,28 +1,28 @@ + {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} - - - -

- {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} - - fHDHR Logo -

-

-

-
- - + + + +

+ {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} + + fHDHR Logo +

+

+

+ +
+ + {% for page_dict in session["route_list"]["pages"] %} {% if session["route_list"]["pages"][page_dict]["name"] != "page_index_html" and fhdhr.config.dict["web_ui"]["access_level"] >= session["route_list"]["pages"][page_dict]["endpoint_access_level"] %} - + {% endif %} {% endfor %} @@ -50,29 +50,26 @@ {% endif %} -
-
+
+
- {% if fhdhr.config.dict["web_ui"]["cluster_bar"] %} - {% set locations = fhdhr.device.cluster.get_cluster_dicts_web() %} - {% if locations %} -
+ {% if fhdhr.config.dict["web_ui"]["cluster_bar"] %} + {% set locations = fhdhr.device.cluster.get_cluster_dicts_web() %} + {% if locations %} +
{% for location in locations %} - + {% endfor %} -
-
- {% endif %} +
+
{% endif %} + {% endif %} - {% set retmessage = request.args.get('retmessage', default=None) %} - {% if retmessage %} -

{{ retmessage }}

- {% endif %} + {% set retmessage = request.args.get('retmessage', default=None) %} + {% if retmessage %} +

{{ retmessage }}

+ {% endif %} - {% block content %}{% endblock %} - + {% block content %}{% endblock %} + - diff --git a/fHDHR_web/templates/channels.html b/fHDHR_web/templates/channels.html index 74a8f20..02ea9d7 100644 --- a/fHDHR_web/templates/channels.html +++ b/fHDHR_web/templates/channels.html @@ -2,82 +2,82 @@ {% block content %} -

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels

+

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels

-
-

Note: This may take some time.

-
-
+
+ +

Note: This may take some time.

+
+
-
- - - {% for key in list(channels_dict.keys()) %} - - - - - {% endfor %} - +
+
{{ key }}{{ channels_dict[key] }}
+ + {% for key in list(channels_dict.keys()) %} + + + + + {% endfor %} +
{{ key }}{{ channels_dict[key] }}
-
+ -
-
- -
-
+
+
+ +
+
-
+
- - - - - - - - - + + + + + + + + + - - {% for chan_dict in channelslist %} - + + {% for chan_dict in channelslist %} + + - + + + - - - + {% if chan_dict["thumbnail"] %} + + {% else %} + + {% endif %} - {% if chan_dict["thumbnail"] %} - - {% else %} - - {% endif %} + {% if chan_dict["enabled"] %} + + {% else %} + + {% endif %} - {% if chan_dict["enabled"] %} - - {% else %} - - {% endif %} - - {% if chan_dict["favorite"] %} - - {% else %} - - {% endif %} - - {% endfor %} - + {% if chan_dict["favorite"] %} + + {% else %} + + {% endif %} + + {% endfor %} +
PlayChannel NameChannel CallSignChannel NumberChannel ThumbnailEnabledFavorite
PlayChannel NameChannel CallSignChannel NumberChannel ThumbnailEnabledFavorite
+ {% if chan_dict["enabled"] %} + Play + {% else %} + Play + {% endif %} + - {% if chan_dict["enabled"] %} - Play - {% else %} - Play - {% endif %} - {{ chan_dict["name"] }}{{ chan_dict["callsign"] }}{{ chan_dict["number"] }}{{ chan_dict["name"] }}{{ chan_dict["callsign"] }}{{ chan_dict["number"] }}{{ chan_dict[No Image Available{{ chan_dict[No Image AvailableEnabledDisabledEnabledDisabledYesNo
YesNo
{% endblock %} diff --git a/fHDHR_web/templates/channels_editor.html b/fHDHR_web/templates/channels_editor.html index b512f7c..e52eb7d 100644 --- a/fHDHR_web/templates/channels_editor.html +++ b/fHDHR_web/templates/channels_editor.html @@ -1,129 +1,128 @@ {% extends "base.html" %} {% block content %} - - - - + + + +

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor

+ +
+
+ + +
+
- @bind("#chanSubmit", "submit") - def submit_fixup(evt): - for element in document.get(selector='input[type="checkbox"]'): - if element.name.endswith("enabled"): - if element.checked == False: - element.checked = True - element.value = False - if element.name.endswith("favorite"): - if element.checked == False: - element.checked = True - element.value = 0 - - items = document.select(".channels") - chanlist = [] - chandict = {} - - for element in items: - if element.name == "id": - if len(chandict.keys()): - chanlist.append(chandict) - chandict = {} - chandict[element.name] = element.value - element.clear() - - postForm = document.createElement('form') - postData = document.createElement('input') - postForm.method = "POST" - postForm.action = "/api/channels?method=modify&redirect=%2Fchannels_editor" - postForm.setRequestHeader = "('Content-Type', 'application/json')" - postData.name = "channels" - postData.value = chanlist - postForm.appendChild(postData) - - document.body.appendChild(postForm) - - postForm.submit() - - evt.preventDefault() - - - -

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor

- -
-
- - -
-
- - -
- +
+
- - - - - - - - - + + + + + + + + + - - {% for chan_dict in channelslist %} - - - - - - {% if chan_dict["enabled"] %} - - {% else %} - - {% endif %} - {% if chan_dict["favorite"] %} - - {% else %} - - {% endif %} - - - - {% endfor %} - + + {% for chan_dict in channelslist %} + + + + + + {% if chan_dict["enabled"] %} + + {% else %} + + {% endif %} + {% if chan_dict["favorite"] %} + + {% else %} + + {% endif %} + + + {% endfor %} +
Channel NameChannel CallSignChannel NumberChannel ThumbnailEnabledFavoriteActions
Channel NameChannel CallSignChannel NumberChannel ThumbnailEnabledFavoriteActions
- -
- - - - - - - -
-
+ + +
+ + + + + + + +
+
-
+
{% endblock %} diff --git a/fHDHR_web/templates/cluster.html b/fHDHR_web/templates/cluster.html index 86a477e..f96c56b 100644 --- a/fHDHR_web/templates/cluster.html +++ b/fHDHR_web/templates/cluster.html @@ -2,51 +2,48 @@ {% block content %} -

Cluster/SSDP

- {% if not fhdhr.config.dict["fhdhr"]["discovery_address"] %} -

Discovery Address must be set for Cluster/SSDP

- {% else %} +

Cluster/SSDP

+ {% if not fhdhr.config.dict["fhdhr"]["discovery_address"] %} +

Discovery Address must be set for Cluster/SSDP

+ {% else %} -
- - - -
-
+
+ + + +
+
- - - - - - - - - - - {% for location in locations_list %} - - - - - +
NameLocationJoinedOptions
{{ location["name"] }}{{ location["location"] }}{{ location["joined"] }} - {% if location["joined"] in ["True", "False"] %} - - {% endif %} - - {% if location["joined"] == "True" %} - - {% elif location["joined"] == "False" %} - - {% endif %} - -
+ + + + + + - {% endfor %} - -
NameLocationJoinedOptions
+ + {% for location in locations_list %} + + {{ location["name"] }} + {{ location["location"] }} + {{ location["joined"] }} + + {% if location["joined"] in ["True", "False"] %} + + {% endif %} + {% if location["joined"] == "True" %} + + {% elif location["joined"] == "False" %} + + {% endif %} + + + {% endfor %} + +
- {% endif %} + {% endif %} {% endblock %} diff --git a/fHDHR_web/templates/diagnostics.html b/fHDHR_web/templates/diagnostics.html index c9683cf..fef8fb2 100644 --- a/fHDHR_web/templates/diagnostics.html +++ b/fHDHR_web/templates/diagnostics.html @@ -16,13 +16,10 @@ - {% for button_item in button_dict[route_group] %} - - + - {% endfor %} diff --git a/fHDHR_web/templates/guide.html b/fHDHR_web/templates/guide.html index 28b0e96..512825f 100644 --- a/fHDHR_web/templates/guide.html +++ b/fHDHR_web/templates/guide.html @@ -2,18 +2,18 @@ {% block content %} -

What's On {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}

+

What's On {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}

-

- {% for epg_method in epg_methods %} - - {% endfor %} -

+

+ {% for epg_method in epg_methods %} + + {% endfor %} +

-
+
- - + + {% if source in ["blocks", "origin", fhdhr.config.dict["main"]["dictpopname"]] %} {% endif %} @@ -26,34 +26,34 @@ - - + + - - {% for chan_dict in chan_guide_list %} - - {% if source in ["blocks", "origin", fhdhr.config.dict["main"]["dictpopname"]] %} - - {% endif %} - - - - - - - - - - - {% endfor %} - + + {% for chan_dict in chan_guide_list %} + + {% if source in ["blocks", "origin", fhdhr.config.dict["main"]["dictpopname"]] %} + + {% endif %} + + + + + + + + + + + {% endfor %} +
PlayStart Time (UTC) End Time (UTC) Content Remaining Time
- {% if chan_dict["enabled"] %} - Play - {% else %} - Play - {% endif %} - {{ chan_dict["name"] }}{{ chan_dict["number"] }}{{ chan_dict[{{ chan_dict["listing_title"] }}{{ chan_dict[{{ chan_dict["listing_description"] }}{{ chan_dict["listing_time_start"] }}{{ chan_dict["listing_time_end"] }}{{ chan_dict["listing_remaining_time"] }}
+ {% if chan_dict["enabled"] %} + Play + {% else %} + Play + {% endif %} + {{ chan_dict["name"] }}{{ chan_dict["number"] }}{{ chan_dict[{{ chan_dict["listing_title"] }}{{ chan_dict[{{ chan_dict["listing_description"] }}{{ chan_dict["listing_time_start"] }}{{ chan_dict["listing_time_end"] }}{{ chan_dict["listing_remaining_time"] }}
-
+
{% endblock %} diff --git a/fHDHR_web/templates/index.html b/fHDHR_web/templates/index.html index 579ef9d..fe713e4 100644 --- a/fHDHR_web/templates/index.html +++ b/fHDHR_web/templates/index.html @@ -2,21 +2,21 @@ {% block content %} -

fHDHR Status

+

fHDHR Status

- +
- + - {% for key in list(fhdhr_status_dict.keys()) %} - - - - - {% endfor %} + {% for key in list(fhdhr_status_dict.keys()) %} + + + + + {% endfor %} - +
{{ key }}{{ fhdhr_status_dict[key] }}
{{ key }}{{ fhdhr_status_dict[key] }}
-
+ {% endblock %} diff --git a/fHDHR_web/templates/settings.html b/fHDHR_web/templates/settings.html index c85a3a1..fa9d1a7 100644 --- a/fHDHR_web/templates/settings.html +++ b/fHDHR_web/templates/settings.html @@ -7,7 +7,8 @@

Some Settings will require a manual restart.

-

Note: This may take some time, and you will have to refresh your page.

+ +

Note: This may take some time, and you will have to refresh your page.


@@ -29,45 +30,40 @@ Action - + - {% for config_item in list(web_settings_dict[config_section].keys()) %} - - - {{ config_item }} - - {{ web_settings_dict[config_section][config_item]["value_default"] }} - - -
- - - - {% if web_settings_dict[config_section][config_item]["hide"] %} - - {% else %} - - {% endif %} - - - - - -
-
- - - - - -
- - - - - {% endfor %} - - + {% for config_item in list(web_settings_dict[config_section].keys()) %} + + {{ config_item }} + {{ web_settings_dict[config_section][config_item]["value_default"] }} + +
+ + + + {% if web_settings_dict[config_section][config_item]["hide"] %} + + {% else %} + + {% endif %} + + + + + +
+
+ + + + + +
+ + + {% endfor %} + + {% endfor %} diff --git a/fHDHR_web/templates/tools.html b/fHDHR_web/templates/tools.html index 2366785..de7281e 100644 --- a/fHDHR_web/templates/tools.html +++ b/fHDHR_web/templates/tools.html @@ -2,11 +2,11 @@ {% block content %} -

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Tools

+

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Tools

-
- - -
+
+ + +
{% endblock %} diff --git a/fHDHR_web/templates/tuners.html b/fHDHR_web/templates/tuners.html index a903d63..1a82516 100644 --- a/fHDHR_web/templates/tuners.html +++ b/fHDHR_web/templates/tuners.html @@ -2,12 +2,12 @@ {% block content %} -

fHDHR Streams

+

fHDHR Streams

-
+
- - + + @@ -17,36 +17,36 @@ - {% for tuner_dict in tuner_list %} - - - - {% if tuner_dict["status"] in ["Active", "Acquired"] %} - - {% else %} - - {% endif %} - {% if tuner_dict["status"] == "Active" %} - - - - {% else %} - - - - {% endif %} - + + + {% if tuner_dict["status"] in ["Active", "Acquired"] %} + + {% else %} + + {% endif %} + {% if tuner_dict["status"] == "Active" %} + + + + {% else %} + + + + {% endif %} + - - {% endfor %} - + + + {% endfor %} +
Status Channel MethodAction
{{ tuner_dict["number"] }}{{ tuner_dict["status"] }}{{ tuner_dict["channel_number"] }}N/A{{ tuner_dict["method"] }}{{ tuner_dict["play_duration"] }}{{ tuner_dict["downloaded"] }}N/AN/AN/A + {% for tuner_dict in tuner_list %} +
{{ tuner_dict["number"] }}{{ tuner_dict["status"] }}{{ tuner_dict["channel_number"] }}N/A{{ tuner_dict["method"] }}{{ tuner_dict["play_duration"] }}{{ tuner_dict["downloaded"] }}N/AN/AN/A {% if tuner_dict["status"] != "Inactive" %} - + {% endif %} {% if not tuner_scanning and tuner_dict["status"] == "Inactive" %} - + {% endif %} -
-
+
{% endblock %} diff --git a/fHDHR_web/templates/version.html b/fHDHR_web/templates/version.html index 595a4fc..0307cfb 100644 --- a/fHDHR_web/templates/version.html +++ b/fHDHR_web/templates/version.html @@ -2,21 +2,20 @@ {% block content %} -

fHDHR Version Information

+

fHDHR Version Information

-
+
- - - {% for key in list(version_dict.keys()) %} - - - - - {% endfor %} - + + {% for key in list(version_dict.keys()) %} + + + + + {% endfor %} +
{{ key }}{{ version_dict[key] }}
{{ key }}{{ version_dict[key] }}
-
+
{% endblock %} diff --git a/fHDHR_web/templates/xmltv.html b/fHDHR_web/templates/xmltv.html index ceed6b2..56fe549 100644 --- a/fHDHR_web/templates/xmltv.html +++ b/fHDHR_web/templates/xmltv.html @@ -2,41 +2,36 @@ {% block content %} -

xmltv

+

xmltv

-
+
- - - - - - - - - {% for epg_method in fhdhr.config.dict["epg"]["valid_epg_methods"] %} - {% if epg_method not in [None, "None"] %} - {% set epg_method_name = epg_method %} - {% if epg_method == "origin" %} - {% set epg_method_name = fhdhr.config.dict["main"]["dictpopname"] %} - {% endif %} - + - - - - - + + + + - - {% endif %} - - {% endfor %} - + {% for epg_method in fhdhr.config.dict["epg"]["valid_epg_methods"] %} + {% if epg_method not in [None, "None"] %} + {% set epg_method_name = epg_method %} + {% if epg_method == "origin" %} + {% set epg_method_name = fhdhr.config.dict["main"]["dictpopname"] %} + {% endif %} + + + + + + + {% endif %} + {% endfor %} +
VersionXMLTV LinkEPG LinkActions
{{ epg_method_name }}{{ epg_method_name }}{{ epg_method_name }} - - - VersionXMLTV LinkEPG LinkActions
{{ epg_method_name }}{{ epg_method_name }}{{ epg_method_name }} + + +
-
+
{% endblock %} diff --git a/fHDHR_web/www_dir/style.css b/fHDHR_web/www_dir/style.css index 59fd8fd..fe61487 100644 --- a/fHDHR_web/www_dir/style.css +++ b/fHDHR_web/www_dir/style.css @@ -1,3 +1,7 @@ +table {border: 1px solid black;} +th {border: 1px solid black;} +td {border: 1px solid black;} + .pull-right { float: right; } .pull-left { float: left; } @@ -47,7 +51,7 @@ /*width:100%; */ display: block; empty-cells: show; - + /* Decoration */ border-spacing: 0; border: 1px solid; @@ -78,7 +82,7 @@ } .table-settings thead{ - background-color: #f1f1f1; + background-color: #f1f1f1; position:relative; display: block; width:100%; @@ -103,11 +107,11 @@ padding: .25rem; } .table-scroll thead{ - background-color: #f1f1f1; + background-color: #f1f1f1; position:relative; display: block; width:100%; - overflow-y: scroll; + overflow-y: scroll; } .table-scroll tbody{ @@ -149,7 +153,7 @@ } .action-col td:last-child{ - flex:1; + flex:1; } .table-small tbody tr:nth-child(2n){