inline header variables

This commit is contained in:
Jakob Ketterl 2021-02-15 17:12:17 +01:00
parent 7f9c0539bb
commit 48a9c76c18
5 changed files with 10 additions and 23 deletions

View File

@ -3,8 +3,8 @@
<a href="https://www.openwebrx.de/" target="_blank"><img src="${assets_prefix}static/gfx/openwebrx-top-logo.png" class="webrx-top-logo" alt="OpenWebRX Logo"/></a> <a href="https://www.openwebrx.de/" target="_blank"><img src="${assets_prefix}static/gfx/openwebrx-top-logo.png" class="webrx-top-logo" alt="OpenWebRX Logo"/></a>
<img class="webrx-rx-avatar openwebrx-photo-trigger" src="${assets_prefix}static/gfx/openwebrx-avatar.png" alt="Receiver avatar"/> <img class="webrx-rx-avatar openwebrx-photo-trigger" src="${assets_prefix}static/gfx/openwebrx-avatar.png" alt="Receiver avatar"/>
<div class="webrx-rx-texts openwebrx-photo-trigger"> <div class="webrx-rx-texts openwebrx-photo-trigger">
<div class="webrx-rx-title"></div> <div class="webrx-rx-title">${receiver_name}</div>
<div class="webrx-rx-desc"></div> <div class="webrx-rx-desc">${receiver_location} | Loc: ${locator}, ASL: ${receiver_asl} m</div>
</div> </div>
<section class="openwebrx-main-buttons"> <section class="openwebrx-main-buttons">
<div class="button" data-toggle-panel="openwebrx-panel-status"><span class="sprite sprite-panel-status"></span><br/>Status</div> <div class="button" data-toggle-panel="openwebrx-panel-status"><span class="sprite sprite-panel-status"></span><br/>Status</div>
@ -15,8 +15,8 @@
</section> </section>
</div> </div>
<div class="openwebrx-description-container"> <div class="openwebrx-description-container">
<div class="webrx-rx-photo-title"></div> <div class="webrx-rx-photo-title">${photo_title}</div>
<div class="webrx-rx-photo-desc"></div> <div class="webrx-rx-photo-desc">${photo_desc}</div>
</div> </div>
<a class="openwebrx-rx-details-arrow openwebrx-rx-details-arrow--down openwebrx-photo-trigger"><span class="sprite sprite-rx-details-arrow"></span></a> <a class="openwebrx-rx-details-arrow openwebrx-rx-details-arrow--down openwebrx-photo-trigger"><span class="sprite sprite-rx-details-arrow"></span></a>
</div> </div>

View File

@ -11,7 +11,6 @@ function Header(el) {
}); });
this.init_rx_photo(); this.init_rx_photo();
this.download_details();
}; };
Header.prototype.setDetails = function(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() { $.fn.header = function() {
if (!this.data('header')) { if (!this.data('header')) {
this.data('header', new Header(this)); this.data('header', new Header(this));

View File

@ -1,6 +1,5 @@
from . import Controller from . import Controller
from owrx.feature import FeatureDetector from owrx.feature import FeatureDetector
from owrx.details import ReceiverDetails
import json import json
@ -8,8 +7,3 @@ class ApiController(Controller):
def indexAction(self): def indexAction(self):
data = json.dumps(FeatureDetector().feature_report()) data = json.dumps(FeatureDetector().feature_report())
self.send_response(data, content_type="application/json") 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")

View File

@ -1,6 +1,7 @@
from . import Controller from owrx.controllers import Controller
import pkg_resources from owrx.details import ReceiverDetails
from string import Template from string import Template
import pkg_resources
class TemplateController(Controller): class TemplateController(Controller):
@ -19,7 +20,9 @@ class TemplateController(Controller):
class WebpageController(TemplateController): class WebpageController(TemplateController):
def header_variables(self): def header_variables(self):
return {"assets_prefix": ""} variables = {"assets_prefix": ""}
variables.update(ReceiverDetails().__dict__())
return variables
def template_variables(self): def template_variables(self):
header = self.render_template("include/header.include.html", **self.header_variables()) header = self.render_template("include/header.include.html", **self.header_variables())

View File

@ -108,7 +108,6 @@ class Router(object):
StaticRoute("/map", MapController), StaticRoute("/map", MapController),
StaticRoute("/features", FeatureController), StaticRoute("/features", FeatureController),
StaticRoute("/api/features", ApiController), StaticRoute("/api/features", ApiController),
StaticRoute("/api/receiverdetails", ApiController, options={"action": "receiverDetails"}),
StaticRoute("/metrics", MetricsController, options={"action": "prometheusAction"}), StaticRoute("/metrics", MetricsController, options={"action": "prometheusAction"}),
StaticRoute("/metrics.json", MetricsController), StaticRoute("/metrics.json", MetricsController),
StaticRoute("/settings", SettingsController), StaticRoute("/settings", SettingsController),