From 48a9c76c1818867b5cfd44e6d62a145be56c66e5 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Mon, 15 Feb 2021 17:12:17 +0100 Subject: [PATCH] inline header variables --- htdocs/include/header.include.html | 8 ++++---- htdocs/lib/Header.js | 9 --------- owrx/controllers/api.py | 6 ------ owrx/controllers/template.py | 9 ++++++--- owrx/http.py | 1 - 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/htdocs/include/header.include.html b/htdocs/include/header.include.html index 6e7beff..10541ce 100644 --- a/htdocs/include/header.include.html +++ b/htdocs/include/header.include.html @@ -3,8 +3,8 @@ Receiver avatar
-
-
+
${receiver_name}
+
${receiver_location} | Loc: ${locator}, ASL: ${receiver_asl} m

Status
@@ -15,8 +15,8 @@
-
-
+
${photo_title}
+
${photo_desc}
diff --git a/htdocs/lib/Header.js b/htdocs/lib/Header.js index ea64457..be0cc9c 100644 --- a/htdocs/lib/Header.js +++ b/htdocs/lib/Header.js @@ -11,7 +11,6 @@ function Header(el) { }); this.init_rx_photo(); - this.download_details(); }; Header.prototype.setDetails = function(details) { @@ -56,14 +55,6 @@ Header.prototype.toggle_rx_photo = function(ev) { } }; -Header.prototype.download_details = function() { - var self = this; - // TODO: make this use a relative URL again - $.ajax('/api/receiverdetails').done(function(data){ - self.setDetails(data); - }); -}; - $.fn.header = function() { if (!this.data('header')) { this.data('header', new Header(this)); diff --git a/owrx/controllers/api.py b/owrx/controllers/api.py index 4dcde14..4e7a966 100644 --- a/owrx/controllers/api.py +++ b/owrx/controllers/api.py @@ -1,6 +1,5 @@ from . import Controller from owrx.feature import FeatureDetector -from owrx.details import ReceiverDetails import json @@ -8,8 +7,3 @@ class ApiController(Controller): def indexAction(self): data = json.dumps(FeatureDetector().feature_report()) self.send_response(data, content_type="application/json") - - def receiverDetails(self): - receiver_details = ReceiverDetails() - data = json.dumps(receiver_details.__dict__()) - self.send_response(data, content_type="application/json") diff --git a/owrx/controllers/template.py b/owrx/controllers/template.py index 2213b83..253e7b7 100644 --- a/owrx/controllers/template.py +++ b/owrx/controllers/template.py @@ -1,6 +1,7 @@ -from . import Controller -import pkg_resources +from owrx.controllers import Controller +from owrx.details import ReceiverDetails from string import Template +import pkg_resources class TemplateController(Controller): @@ -19,7 +20,9 @@ class TemplateController(Controller): class WebpageController(TemplateController): def header_variables(self): - return {"assets_prefix": ""} + variables = {"assets_prefix": ""} + variables.update(ReceiverDetails().__dict__()) + return variables def template_variables(self): header = self.render_template("include/header.include.html", **self.header_variables()) diff --git a/owrx/http.py b/owrx/http.py index 7e95c8e..4d712d4 100644 --- a/owrx/http.py +++ b/owrx/http.py @@ -108,7 +108,6 @@ class Router(object): StaticRoute("/map", MapController), StaticRoute("/features", FeatureController), StaticRoute("/api/features", ApiController), - StaticRoute("/api/receiverdetails", ApiController, options={"action": "receiverDetails"}), StaticRoute("/metrics", MetricsController, options={"action": "prometheusAction"}), StaticRoute("/metrics.json", MetricsController), StaticRoute("/settings", SettingsController),