setup device list and routing for device pages
This commit is contained in:
parent
d65743f2ea
commit
872c7a4bfd
@ -13,10 +13,6 @@ html, body {
|
|||||||
margin: 15px 15px 0;
|
margin: 15px 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device {
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-section {
|
.settings-section {
|
||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
}
|
}
|
||||||
@ -84,4 +80,8 @@ table.bookmarks .frequency {
|
|||||||
|
|
||||||
.wsjt-decoding-depths-table td:first-child {
|
.wsjt-decoding-depths-table td:first-child {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdr-device-list .list-group-item {
|
||||||
|
background: initial;
|
||||||
}
|
}
|
@ -2,18 +2,18 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>OpenWebRX Settings</title>
|
<title>OpenWebRX Settings</title>
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="../static/favicon.ico" />
|
<link rel="shortcut icon" type="image/x-icon" href="${assets_prefix}static/favicon.ico" />
|
||||||
<link rel="stylesheet" href="../static/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="${assets_prefix}static/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="../static/css/admin.css" />
|
<link rel="stylesheet" type="text/css" href="${assets_prefix}static/css/admin.css" />
|
||||||
<script src="https://unpkg.com/location-picker/dist/location-picker.min.js"></script>
|
<script src="https://unpkg.com/location-picker/dist/location-picker.min.js"></script>
|
||||||
<script src="../compiled/settings.js"></script>
|
<script src="${assets_prefix}compiled/settings.js"></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
${header}
|
${header}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col-12">${title}s</h1>
|
<h1 class="col-12">${title}</h1>
|
||||||
</div>
|
</div>
|
||||||
${content}
|
${content}
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,6 +69,7 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB
|
|||||||
variables = super().template_variables()
|
variables = super().template_variables()
|
||||||
variables["content"] = self.render_sections()
|
variables["content"] = self.render_sections()
|
||||||
variables["title"] = self.getTitle()
|
variables["title"] = self.getTitle()
|
||||||
|
variables["assets_prefix"] = "../"
|
||||||
return variables
|
return variables
|
||||||
|
|
||||||
def parseFormData(self):
|
def parseFormData(self):
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from owrx.controllers.admin import AuthorizationMixin
|
from owrx.controllers.admin import AuthorizationMixin
|
||||||
from owrx.controllers.template import WebpageController
|
from owrx.controllers.template import WebpageController
|
||||||
from owrx.config import Config
|
from owrx.config import Config
|
||||||
|
from urllib.parse import quote, unquote
|
||||||
|
|
||||||
|
|
||||||
class SdrSettingsController(AuthorizationMixin, WebpageController):
|
class SdrDeviceListController(AuthorizationMixin, WebpageController):
|
||||||
def header_variables(self):
|
def header_variables(self):
|
||||||
variables = super().header_variables()
|
variables = super().header_variables()
|
||||||
variables["assets_prefix"] = "../"
|
variables["assets_prefix"] = "../"
|
||||||
@ -13,30 +14,59 @@ class SdrSettingsController(AuthorizationMixin, WebpageController):
|
|||||||
variables = super().template_variables()
|
variables = super().template_variables()
|
||||||
variables["content"] = self.render_devices()
|
variables["content"] = self.render_devices()
|
||||||
variables["title"] = "SDR device settings"
|
variables["title"] = "SDR device settings"
|
||||||
|
variables["assets_prefix"] = "../"
|
||||||
return variables
|
return variables
|
||||||
|
|
||||||
def render_devices(self):
|
def render_devices(self):
|
||||||
def render_device(device_id, config):
|
def render_device(device_id, config):
|
||||||
return """
|
return """
|
||||||
<div class="card device bg-dark text-white">
|
<li class="list-group-item">
|
||||||
<div class="card-header">
|
<a href="{device_link}">
|
||||||
{device_name}
|
<h3>{device_name}</h3>
|
||||||
|
</a>
|
||||||
|
<div>
|
||||||
|
some more device info here
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
</li>
|
||||||
sdr detail goes here
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
""".format(
|
""".format(
|
||||||
device_name=config["name"]
|
device_name=config["name"],
|
||||||
|
device_link="{}/{}".format(self.request.path, quote(device_id)),
|
||||||
)
|
)
|
||||||
|
|
||||||
return """
|
return """
|
||||||
<div class="col-12">
|
<ul class="row list-group list-group-flush sdr-device-list">
|
||||||
{devices}
|
{devices}
|
||||||
</div>
|
</ul>
|
||||||
""".format(
|
""".format(
|
||||||
devices="".join(render_device(key, value) for key, value in Config.get()["sdrs"].items())
|
devices="".join(render_device(key, value) for key, value in Config.get()["sdrs"].items())
|
||||||
)
|
)
|
||||||
|
|
||||||
def indexAction(self):
|
def indexAction(self):
|
||||||
self.serve_template("settings/general.html", **self.template_variables())
|
self.serve_template("settings/general.html", **self.template_variables())
|
||||||
|
|
||||||
|
|
||||||
|
class SdrDeviceController(AuthorizationMixin, WebpageController):
|
||||||
|
def get_device(self):
|
||||||
|
device_id = unquote(self.request.matches.group(1))
|
||||||
|
if device_id not in Config.get()["sdrs"]:
|
||||||
|
return None
|
||||||
|
return Config.get()["sdrs"][device_id]
|
||||||
|
|
||||||
|
def header_variables(self):
|
||||||
|
variables = super().header_variables()
|
||||||
|
variables["assets_prefix"] = "../../"
|
||||||
|
return variables
|
||||||
|
|
||||||
|
def template_variables(self, device):
|
||||||
|
variables = super().template_variables()
|
||||||
|
variables["title"] = device["name"]
|
||||||
|
variables["content"] = "TODO"
|
||||||
|
variables["assets_prefix"] = "../../"
|
||||||
|
return variables
|
||||||
|
|
||||||
|
def indexAction(self):
|
||||||
|
device = self.get_device()
|
||||||
|
if device is None:
|
||||||
|
self.send_response("device not found", code=404)
|
||||||
|
return
|
||||||
|
self.serve_template("settings/general.html", **self.template_variables(device))
|
||||||
|
@ -6,7 +6,7 @@ from owrx.controllers.api import ApiController
|
|||||||
from owrx.controllers.metrics import MetricsController
|
from owrx.controllers.metrics import MetricsController
|
||||||
from owrx.controllers.settings import SettingsController
|
from owrx.controllers.settings import SettingsController
|
||||||
from owrx.controllers.settings.general import GeneralSettingsController
|
from owrx.controllers.settings.general import GeneralSettingsController
|
||||||
from owrx.controllers.settings.sdr import SdrSettingsController
|
from owrx.controllers.settings.sdr import SdrDeviceListController, SdrDeviceController
|
||||||
from owrx.controllers.settings.reporting import ReportingController
|
from owrx.controllers.settings.reporting import ReportingController
|
||||||
from owrx.controllers.settings.backgrounddecoding import BackgroundDecodingController
|
from owrx.controllers.settings.backgrounddecoding import BackgroundDecodingController
|
||||||
from owrx.controllers.settings.decoding import DecodingSettingsController
|
from owrx.controllers.settings.decoding import DecodingSettingsController
|
||||||
@ -115,7 +115,8 @@ class Router(object):
|
|||||||
StaticRoute(
|
StaticRoute(
|
||||||
"/settings/general", GeneralSettingsController, method="POST", options={"action": "processFormData"}
|
"/settings/general", GeneralSettingsController, method="POST", options={"action": "processFormData"}
|
||||||
),
|
),
|
||||||
StaticRoute("/settings/sdr", SdrSettingsController),
|
StaticRoute("/settings/sdr", SdrDeviceListController),
|
||||||
|
RegexRoute("/settings/sdr/(.+)", SdrDeviceController),
|
||||||
StaticRoute("/settings/bookmarks", BookmarksController),
|
StaticRoute("/settings/bookmarks", BookmarksController),
|
||||||
StaticRoute("/settings/bookmarks", BookmarksController, method="POST", options={"action": "new"}),
|
StaticRoute("/settings/bookmarks", BookmarksController, method="POST", options={"action": "new"}),
|
||||||
RegexRoute("/settings/bookmarks/(.+)", BookmarksController, method="POST", options={"action": "update"}),
|
RegexRoute("/settings/bookmarks/(.+)", BookmarksController, method="POST", options={"action": "update"}),
|
||||||
|
Loading…
Reference in New Issue
Block a user