implement device and profile delete modals
This commit is contained in:
parent
eab1c6ce80
commit
d123232f28
7
htdocs/lib/bootstrap.bundle.min.js
vendored
Normal file
7
htdocs/lib/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -17,4 +17,5 @@ ${header}
|
|||||||
</div>
|
</div>
|
||||||
${content}
|
${content}
|
||||||
</div>
|
</div>
|
||||||
|
${modal}
|
||||||
</body>
|
</body>
|
@ -144,6 +144,7 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController):
|
|||||||
],
|
],
|
||||||
"settings.js": [
|
"settings.js": [
|
||||||
"lib/jquery-3.2.1.min.js",
|
"lib/jquery-3.2.1.min.js",
|
||||||
|
"lib/bootstrap.bundle.min.js",
|
||||||
"lib/Header.js",
|
"lib/Header.js",
|
||||||
"lib/settings/MapInput.js",
|
"lib/settings/MapInput.js",
|
||||||
"lib/settings/ImageUpload.js",
|
"lib/settings/ImageUpload.js",
|
||||||
|
@ -54,17 +54,24 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB
|
|||||||
|
|
||||||
def render_sections(self):
|
def render_sections(self):
|
||||||
sections = "".join(section.render(self.getData()) for section in self.getSections())
|
sections = "".join(section.render(self.getData()) for section in self.getSections())
|
||||||
|
buttons = self.render_buttons()
|
||||||
return """
|
return """
|
||||||
<form class="settings-body" method="POST">
|
<form class="settings-body" method="POST">
|
||||||
{sections}
|
{sections}
|
||||||
<div class="buttons container">
|
<div class="buttons container">
|
||||||
<button type="submit" class="btn btn-primary">Apply and save</button>
|
{buttons}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
""".format(
|
""".format(
|
||||||
sections=sections
|
sections=sections,
|
||||||
|
buttons=buttons,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def render_buttons(self):
|
||||||
|
return """
|
||||||
|
<button type="submit" class="btn btn-primary">Apply and save</button>
|
||||||
|
"""
|
||||||
|
|
||||||
def indexAction(self):
|
def indexAction(self):
|
||||||
self.serve_template("settings/general.html", **self.template_variables())
|
self.serve_template("settings/general.html", **self.template_variables())
|
||||||
|
|
||||||
@ -72,6 +79,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["modal"] = self.buildModal()
|
||||||
return variables
|
return variables
|
||||||
|
|
||||||
def parseFormData(self):
|
def parseFormData(self):
|
||||||
@ -97,3 +105,6 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB
|
|||||||
|
|
||||||
def store(self):
|
def store(self):
|
||||||
Config.get().store()
|
Config.get().store()
|
||||||
|
|
||||||
|
def buildModal(self):
|
||||||
|
return ""
|
||||||
|
@ -9,7 +9,7 @@ from urllib.parse import quote, unquote
|
|||||||
from owrx.sdr import SdrService
|
from owrx.sdr import SdrService
|
||||||
from owrx.form import TextInput, DropdownInput, Option
|
from owrx.form import TextInput, DropdownInput, Option
|
||||||
from owrx.property import PropertyLayer, PropertyStack
|
from owrx.property import PropertyLayer, PropertyStack
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
class SdrDeviceListController(AuthorizationMixin, WebpageController):
|
class SdrDeviceListController(AuthorizationMixin, WebpageController):
|
||||||
@ -114,6 +114,40 @@ class SdrFormController(SettingsFormController, metaclass=ABCMeta):
|
|||||||
return None, None
|
return None, None
|
||||||
return device_id, config["sdrs"][device_id]
|
return device_id, config["sdrs"][device_id]
|
||||||
|
|
||||||
|
def buildModal(self):
|
||||||
|
return """
|
||||||
|
<div class="modal" id="deleteModal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5>Please confirm</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Do you really want to delete this {object_type}?</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<a type="button" class="btn btn-danger" href="{confirm_url}">Delete</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
""".format(
|
||||||
|
object_type=self.getModalObjectType(),
|
||||||
|
confirm_url=self.getModalConfirmUrl(),
|
||||||
|
)
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def getModalObjectType(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def getModalConfirmUrl(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SdrDeviceController(SdrFormController):
|
class SdrDeviceController(SdrFormController):
|
||||||
def getData(self):
|
def getData(self):
|
||||||
@ -127,6 +161,14 @@ class SdrDeviceController(SdrFormController):
|
|||||||
# TODO provide a generic interface that allows to switch the type
|
# TODO provide a generic interface that allows to switch the type
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def render_buttons(self):
|
||||||
|
return (
|
||||||
|
"""
|
||||||
|
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">Remove device...</button>
|
||||||
|
"""
|
||||||
|
+ super().render_buttons()
|
||||||
|
)
|
||||||
|
|
||||||
def getTitle(self):
|
def getTitle(self):
|
||||||
return self.device["name"]
|
return self.device["name"]
|
||||||
|
|
||||||
@ -142,6 +184,12 @@ class SdrDeviceController(SdrFormController):
|
|||||||
return
|
return
|
||||||
return super().processFormData()
|
return super().processFormData()
|
||||||
|
|
||||||
|
def getModalObjectType(self):
|
||||||
|
return "SDR device"
|
||||||
|
|
||||||
|
def getModalConfirmUrl(self):
|
||||||
|
return "{}settings/deletesdr/{}".format(self.get_document_root(), quote(self.device_id))
|
||||||
|
|
||||||
|
|
||||||
class NewSdrDeviceController(SettingsFormController):
|
class NewSdrDeviceController(SettingsFormController):
|
||||||
def __init__(self, handler, request, options):
|
def __init__(self, handler, request, options):
|
||||||
@ -218,3 +266,19 @@ class SdrProfileController(SdrFormController):
|
|||||||
self.send_response("profile not found", code=404)
|
self.send_response("profile not found", code=404)
|
||||||
return
|
return
|
||||||
return super().processFormData()
|
return super().processFormData()
|
||||||
|
|
||||||
|
def render_buttons(self):
|
||||||
|
return (
|
||||||
|
"""
|
||||||
|
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">Remove profile...</button>
|
||||||
|
"""
|
||||||
|
+ super().render_buttons()
|
||||||
|
)
|
||||||
|
|
||||||
|
def getModalObjectType(self):
|
||||||
|
return "profile"
|
||||||
|
|
||||||
|
def getModalConfirmUrl(self):
|
||||||
|
return "{}settings/{}/deleteprofile/{}".format(
|
||||||
|
self.get_document_root(), quote(self.device_id), quote(self.profile_id)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user