re-route settings urls

This commit is contained in:
Jakob Ketterl 2021-02-13 16:44:14 +01:00
parent ae76470612
commit cda43b5c5c
10 changed files with 55 additions and 41 deletions

View File

@ -1,7 +1,7 @@
<div class="webrx-top-container">
<div class="webrx-top-bar">
<a href="https://www.openwebrx.de/" target="_blank"><img src="static/gfx/openwebrx-top-logo.png" class="webrx-top-logo" alt="OpenWebRX Logo"/></a>
<img class="webrx-rx-avatar openwebrx-photo-trigger" src="static/gfx/openwebrx-avatar.png" alt="Receiver avatar"/>
<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"/>
<div class="webrx-rx-texts openwebrx-photo-trigger">
<div class="webrx-rx-title"></div>
<div class="webrx-rx-desc"></div>
@ -10,8 +10,8 @@
<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-log"><span class="sprite sprite-panel-log"></span><br/>Log</div>
<div class="button" data-toggle-panel="openwebrx-panel-receiver"><span class="sprite sprite-panel-receiver"></span><br/>Receiver</div>
<a class="button" href="map" target="openwebrx-map"><span class="sprite sprite-panel-map"></span><br/>Map</a>
<a class="button" href="settings" target="openwebrx-settings"><span class="sprite sprite-panel-settings"></span><br/>Settings</a>
<a class="button" href="${assets_prefix}map" target="openwebrx-map"><span class="sprite sprite-panel-map"></span><br/>Map</a>
<a class="button" href="${assets_prefix}settings" target="openwebrx-settings"><span class="sprite sprite-panel-settings"></span><br/>Settings</a>
</section>
</div>
<div class="openwebrx-description-container">

View File

@ -58,7 +58,8 @@ Header.prototype.toggle_rx_photo = function(ev) {
Header.prototype.download_details = function() {
var self = this;
$.ajax('api/receiverdetails').done(function(data){
// TODO: make this use a relative URL again
$.ajax('/api/receiverdetails').done(function(data){
self.setDetails(data);
});
};

View File

@ -1,21 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>OpenWebRX Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<link rel="stylesheet" href="static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="static/css/admin.css" />
<script src="compiled/settings.js"></script>
<meta charset="utf-8">
</head>
<body>
${header}
<div class="container">
<div class="col-12">
<h1>SDR device settings</h1>
</div>
<div class="col-12">
${devices}
</div>
</div>
</body>

View File

@ -15,10 +15,10 @@ ${header}
<h1>Settings</h1>
</div>
<div class="col-12">
<a href="generalsettings">General settings</a>
<a href="settings/general">General settings</a>
</div>
<div class="col-12">
<a href="sdrsettings">SDR device settings</a>
<a href="settings/sdr">SDR device settings</a>
</div>
<div class="col-12">
<a href="features">Feature report</a>

View File

@ -2,11 +2,11 @@
<html>
<head>
<title>OpenWebRX Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<link rel="stylesheet" href="static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="static/css/admin.css" />
<link rel="shortcut icon" type="image/x-icon" href="../static/favicon.ico" />
<link rel="stylesheet" href="../static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../static/css/admin.css" />
<script src="https://unpkg.com/location-picker/dist/location-picker.min.js"></script>
<script src="compiled/settings.js"></script>
<script src="../compiled/settings.js"></script>
<meta charset="utf-8">
</head>
<body>

21
htdocs/settings/sdr.html Normal file
View File

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<html>
<head>
<title>OpenWebRX Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="../static/favicon.ico" />
<link rel="stylesheet" href="../static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../static/css/admin.css" />
<script src="../compiled/settings.js"></script>
<meta charset="utf-8">
</head>
<body>
${header}
<div class="container">
<div class="col-12">
<h1>SDR device settings</h1>
</div>
<div class="col-12">
${devices}
</div>
</div>
</body>

View File

@ -64,6 +64,11 @@ class SettingsController(AuthorizationMixin, WebpageController):
class SdrSettingsController(AuthorizationMixin, WebpageController):
def header_variables(self):
variables = super().header_variables()
variables["assets_prefix"] = "../"
return variables
def template_variables(self):
variables = super().template_variables()
variables["devices"] = self.render_devices()
@ -94,7 +99,7 @@ class SdrSettingsController(AuthorizationMixin, WebpageController):
)
def indexAction(self):
self.serve_template("sdrsettings.html", **self.template_variables())
self.serve_template("settings/sdr.html", **self.template_variables())
class GeneralSettingsController(AuthorizationMixin, WebpageController):
@ -372,7 +377,12 @@ class GeneralSettingsController(AuthorizationMixin, WebpageController):
)
def indexAction(self):
self.serve_template("generalsettings.html", **self.template_variables())
self.serve_template("settings/general.html", **self.template_variables())
def header_variables(self):
variables = super().header_variables()
variables["assets_prefix"] = "../"
return variables
def template_variables(self):
variables = super().template_variables()
@ -417,4 +427,4 @@ class GeneralSettingsController(AuthorizationMixin, WebpageController):
else:
config[k] = v
config.store()
self.send_redirect("/generalsettings")
self.send_redirect("/settings/general")

View File

@ -18,8 +18,11 @@ class TemplateController(Controller):
class WebpageController(TemplateController):
def header_variables(self):
return {"assets_prefix": ""}
def template_variables(self):
header = self.render_template("include/header.include.html")
header = self.render_template("include/header.include.html", **self.header_variables())
return {"header": header}

View File

@ -36,7 +36,7 @@ class ImageInput(Input, metaclass=ABCMeta):
class AvatarInput(ImageInput):
def getUrl(self) -> str:
return "static/gfx/openwebrx-avatar.png"
return "../static/gfx/openwebrx-avatar.png"
def getImgClasses(self) -> list:
return ["webrx-rx-avatar"]
@ -44,7 +44,7 @@ class AvatarInput(ImageInput):
class TopPhotoInput(ImageInput):
def getUrl(self) -> str:
return "static/gfx/openwebrx-top-photo.jpg"
return "../static/gfx/openwebrx-top-photo.jpg"
def getImgClasses(self) -> list:
return ["webrx-top-photo"]

View File

@ -103,11 +103,11 @@ class Router(object):
StaticRoute("/metrics", MetricsController, options={"action": "prometheusAction"}),
StaticRoute("/metrics.json", MetricsController),
StaticRoute("/settings", SettingsController),
StaticRoute("/generalsettings", GeneralSettingsController),
StaticRoute("/settings/general", GeneralSettingsController),
StaticRoute(
"/generalsettings", GeneralSettingsController, method="POST", options={"action": "processFormData"}
"/settings/general", GeneralSettingsController, method="POST", options={"action": "processFormData"}
),
StaticRoute("/sdrsettings", SdrSettingsController),
StaticRoute("/settings/sdr", SdrSettingsController),
StaticRoute("/login", SessionController, options={"action": "loginAction"}),
StaticRoute("/login", SessionController, method="POST", options={"action": "processLoginAction"}),
StaticRoute("/logout", SessionController, options={"action": "logoutAction"}),