add settings button, start with the admin template

This commit is contained in:
Jakob Ketterl 2020-03-08 21:28:15 +01:00
parent 4928f80929
commit 6ab77f958c
6 changed files with 22 additions and 6 deletions

15
htdocs/admin.html Normal file

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html>
<head>
<title>OpenWebRX Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="static/css/login.css" />
<meta charset="utf-8">
</head>
<body>
${header}
<div>
Admin-only area!
</div>
</body>

Binary file not shown.

After

(image error) Size: 1.4 KiB

@ -19,6 +19,7 @@
<li data-toggle-panel="openwebrx-panel-log"><img src="static/gfx/openwebrx-panel-log.png" /><br/>Log</li>
<li data-toggle-panel="openwebrx-panel-receiver"><img src="static/gfx/openwebrx-panel-receiver.png" /><br/>Receiver</li>
<li><a href="map" target="_blank"><img src="static/gfx/openwebrx-panel-map.png" /><br/>Map</a></li>
<li><a href="admin" target="_blank"><img src="static/gfx/openwebrx-panel-settings.png" /><br/>Settings</a></li>
</ul>
</section>
</div>

@ -1,4 +1,4 @@
from . import Controller
from .template import WebpageController
from .session import SessionStorage
@ -10,7 +10,7 @@ class Authentication(object):
return False
class SettingsController(Controller):
class AdminController(WebpageController):
def __init__(self, handler, request, options):
self.authentication = Authentication()
super().__init__(handler, request, options)
@ -22,4 +22,4 @@ class SettingsController(Controller):
self.send_redirect("/login")
def indexAction(self):
self.send_response("actual content here")
self.serve_template("admin.html", **self.template_variables())

@ -47,7 +47,7 @@ class SessionController(WebpageController):
key = SessionStorage.getSharedInstance().startSession({"user": data["user"]})
cookie = SimpleCookie()
cookie["owrx-session"] = key
self.send_redirect("/settings", cookies=cookie)
self.send_redirect("/admin", cookies=cookie)
else:
self.send_redirect("/login")
else:

@ -11,7 +11,7 @@ from owrx.controllers.assets import (
from owrx.controllers.websocket import WebSocketController
from owrx.controllers.api import ApiController
from owrx.controllers.metrics import MetricsController
from owrx.controllers.settings import SettingsController
from owrx.controllers.admin import AdminController
from owrx.controllers.session import SessionController
from http.server import BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
@ -100,7 +100,7 @@ class Router(object):
StaticRoute("/features", FeatureController),
StaticRoute("/api/features", ApiController),
StaticRoute("/metrics", MetricsController),
StaticRoute("/settings", SettingsController),
StaticRoute("/admin", AdminController),
StaticRoute("/login", SessionController, options={"action": "loginAction"}),
StaticRoute("/login", SessionController, method="POST", options={"action": "processLoginAction"}),
StaticRoute("/logout", SessionController, options={"action": "logoutAction"}),