diff --git a/fHDHR_web/api/channels.py b/fHDHR_web/api/channels.py index 81c9f22..0cbfd9f 100644 --- a/fHDHR_web/api/channels.py +++ b/fHDHR_web/api/channels.py @@ -9,6 +9,9 @@ class Channels(): endpoints = ["/api/channels"] endpoint_name = "api_channels" endpoint_methods = ["GET", "POST"] + endpoint_default_parameters = { + "method": "get" + } def __init__(self, fhdhr): self.fhdhr = fhdhr diff --git a/fHDHR_web/api/cluster.py b/fHDHR_web/api/cluster.py index f14c887..8e092e2 100644 --- a/fHDHR_web/api/cluster.py +++ b/fHDHR_web/api/cluster.py @@ -7,6 +7,9 @@ class Cluster(): endpoints = ["/api/cluster"] endpoint_name = "api_cluster" endpoint_methods = ["GET", "POST"] + endpoint_default_parameters = { + "method": "get" + } def __init__(self, fhdhr): self.fhdhr = fhdhr diff --git a/fHDHR_web/api/images.py b/fHDHR_web/api/images.py index dce67e2..3db8c8f 100644 --- a/fHDHR_web/api/images.py +++ b/fHDHR_web/api/images.py @@ -5,6 +5,11 @@ class Images(): endpoints = ["/api/images"] endpoint_name = "api_images" endpoint_methods = ["GET", "POST"] + endpoint_default_parameters = { + "method": "generate", + "type": "content", + "message": "Internal Image Handling" + } def __init__(self, fhdhr): self.fhdhr = fhdhr diff --git a/fHDHR_web/api/settings.py b/fHDHR_web/api/settings.py index c601cbd..f138ae5 100644 --- a/fHDHR_web/api/settings.py +++ b/fHDHR_web/api/settings.py @@ -1,7 +1,8 @@ -from flask import request, redirect, session +from flask import request, redirect, Response, session import urllib.parse import threading import time +import json class Settings(): @@ -23,7 +24,28 @@ class Settings(): method = request.args.get('method', default="get", type=str) redirect_url = request.args.get('redirect', default=None, type=str) - if method == "update": + if method == "get": + web_settings_dict = {} + for config_section in list(self.fhdhr.config.conf_default.keys()): + web_settings_dict[config_section] = {} + + for config_item in list(self.fhdhr.config.conf_default[config_section].keys()): + real_config_section = config_section + if config_section == self.fhdhr.config.dict["main"]["dictpopname"]: + real_config_section = "origin" + web_settings_dict[config_section][config_item] = { + "value": self.fhdhr.config.dict[real_config_section][config_item], + } + if self.fhdhr.config.conf_default[config_section][config_item]["config_web_hidden"]: + web_settings_dict[config_section][config_item]["value"] = "***********" + + return_json = json.dumps(web_settings_dict, indent=4) + + return Response(status=200, + response=return_json, + mimetype='application/json') + + elif method == "update": config_section = request.form.get('config_section', None) config_name = request.form.get('config_name', None) config_value = request.form.get('config_value', None) diff --git a/fHDHR_web/api/tools.py b/fHDHR_web/api/tools.py index 89af64f..f3cdd2c 100644 --- a/fHDHR_web/api/tools.py +++ b/fHDHR_web/api/tools.py @@ -7,6 +7,9 @@ class API_Tools(): endpoints = ["/api/tools"] endpoint_name = "api_tools" endpoint_methods = ["GET", "POST"] + endpoint_default_parameters = { + "method": "get" + } def __init__(self, fhdhr): self.fhdhr = fhdhr @@ -20,7 +23,15 @@ class API_Tools(): redirect_url = request.args.get('redirect', default=None, type=str) - if method == "prettyjson": + if method == "get": + + return_json = json.dumps({"tools": "api for tools page"}, indent=4) + + return Response(status=200, + response=return_json, + mimetype='application/json') + + elif method == "prettyjson": dirty_json_url = request.form.get('url', None) diff --git a/fHDHR_web/api/tuners.py b/fHDHR_web/api/tuners.py index d3a18ec..2e3353e 100644 --- a/fHDHR_web/api/tuners.py +++ b/fHDHR_web/api/tuners.py @@ -10,6 +10,9 @@ class Tuners(): endpoints = ["/api/tuners"] endpoint_name = "api_tuners" endpoint_methods = ["GET", "POST"] + endpoint_default_parameters = { + "method": "status" + } def __init__(self, fhdhr): self.fhdhr = fhdhr @@ -29,7 +32,7 @@ class Tuners(): method = request.args.get('method', default=self.fhdhr.config.dict["fhdhr"]["stream_type"], type=str) - tuner_number = request.args.get('tuner', None, type=str) + tuner_number = request.args.get('tuner', default=None, type=str) redirect_url = request.args.get('redirect', default=None, type=str) diff --git a/fHDHR_web/pages/__init__.py b/fHDHR_web/pages/__init__.py index b73e6c5..7cf10ca 100644 --- a/fHDHR_web/pages/__init__.py +++ b/fHDHR_web/pages/__init__.py @@ -9,8 +9,8 @@ from .xmltv_html import xmlTV_HTML from .version_html import Version_HTML from .diagnostics_html import Diagnostics_HTML from .settings_html import Settings_HTML -from .channels_editor import Channels_Editor_HTML -from .tools import Tools_HTML +from .channels_editor_html import Channels_Editor_HTML +from .tools_html import Tools_HTML class fHDHR_Pages(): @@ -20,7 +20,7 @@ class fHDHR_Pages(): self.index_html = Index_HTML(fhdhr) self.channels_html = Channels_HTML(fhdhr) - self.channels_editor = Channels_Editor_HTML(fhdhr) + self.channels_editor_html = Channels_Editor_HTML(fhdhr) self.guide_html = Guide_HTML(fhdhr) self.cluster_html = Cluster_HTML(fhdhr) self.tuners_html = Tuners_HTML(fhdhr) @@ -28,4 +28,4 @@ class fHDHR_Pages(): self.version_html = Version_HTML(fhdhr) self.diagnostics_html = Diagnostics_HTML(fhdhr) self.settings_html = Settings_HTML(fhdhr) - self.tools = Tools_HTML(fhdhr) + self.tools_html = Tools_HTML(fhdhr) diff --git a/fHDHR_web/pages/channels_editor.py b/fHDHR_web/pages/channels_editor_html.py similarity index 100% rename from fHDHR_web/pages/channels_editor.py rename to fHDHR_web/pages/channels_editor_html.py diff --git a/fHDHR_web/pages/diagnostics_html.py b/fHDHR_web/pages/diagnostics_html.py index 7bbdd34..c16b1bf 100644 --- a/fHDHR_web/pages/diagnostics_html.py +++ b/fHDHR_web/pages/diagnostics_html.py @@ -35,9 +35,15 @@ class Diagnostics_HTML(): button_link += "%s=%s" % (parameter, parameter_val) button_link = button_link.replace("", self.fhdhr.config.dict["main"]["uuid"]) button_link = button_link.replace("", base_url) - button_dict[route_group].append({ + curr_button_dict = { "label": session["route_list"][route_group][route_item]["pretty_name"], "link": button_link, - }) + "methods": ",".join(session["route_list"][route_group][route_item]["endpoint_methods"]), + "button": True + } + if ("GET" not in session["route_list"][route_group][route_item]["endpoint_methods"] + or "" in button_link or "" in button_link): + curr_button_dict["button"] = False + button_dict[route_group].append(curr_button_dict) return render_template('diagnostics.html', session=session, request=request, fhdhr=self.fhdhr, button_dict=button_dict, list=list) diff --git a/fHDHR_web/pages/tools.py b/fHDHR_web/pages/tools_html.py similarity index 100% rename from fHDHR_web/pages/tools.py rename to fHDHR_web/pages/tools_html.py diff --git a/fHDHR_web/templates/diagnostics.html b/fHDHR_web/templates/diagnostics.html index fef8fb2..2e13532 100644 --- a/fHDHR_web/templates/diagnostics.html +++ b/fHDHR_web/templates/diagnostics.html @@ -13,12 +13,20 @@ Link + Methods {% for button_item in button_dict[route_group] %} - + + {% if button_item["button"] %} + + {% else %} + {{ button_item["link"] }} + {% endif %} + + {{ button_item["methods"] }} {% endfor %}