remove id input from new profile page
This commit is contained in:
parent
05ea11f5d1
commit
52b535c608
@ -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.form.validator import RequiredValidator
|
from owrx.form.validator import RequiredValidator
|
||||||
from owrx.property import PropertyLayer, PropertyStack
|
from owrx.property import PropertyLayer
|
||||||
from owrx.breadcrumb import BreadcrumbMixin, Breadcrumb, BreadcrumbItem
|
from owrx.breadcrumb import BreadcrumbMixin, Breadcrumb, BreadcrumbItem
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@ -282,7 +282,7 @@ class NewSdrDeviceController(SettingsFormController):
|
|||||||
def __init__(self, handler, request, options):
|
def __init__(self, handler, request, options):
|
||||||
super().__init__(handler, request, options)
|
super().__init__(handler, request, options)
|
||||||
self.data_layer = PropertyLayer(name="", type="", profiles=PropertyLayer())
|
self.data_layer = PropertyLayer(name="", type="", profiles=PropertyLayer())
|
||||||
self.sdr_id = str(uuid4())
|
self.device_id = str(uuid4())
|
||||||
|
|
||||||
def get_breadcrumb(self) -> Breadcrumb:
|
def get_breadcrumb(self) -> Breadcrumb:
|
||||||
return SdrDeviceBreadcrumb().append(BreadcrumbItem("New device", "settings/sdr/newsdr"))
|
return SdrDeviceBreadcrumb().append(BreadcrumbItem("New device", "settings/sdr/newsdr"))
|
||||||
@ -314,14 +314,14 @@ class NewSdrDeviceController(SettingsFormController):
|
|||||||
config = Config.get()
|
config = Config.get()
|
||||||
sdrs = config["sdrs"]
|
sdrs = config["sdrs"]
|
||||||
# a uuid should be unique, so i'm not sure if there's a point in this check
|
# a uuid should be unique, so i'm not sure if there's a point in this check
|
||||||
if self.sdr_id in sdrs:
|
if self.device_id in sdrs:
|
||||||
raise ValueError("device {} already exists!".format(self.sdr_id))
|
raise ValueError("device {} already exists!".format(self.device_id))
|
||||||
sdrs[self.sdr_id] = self.data_layer
|
sdrs[self.device_id] = self.data_layer
|
||||||
config["sdrs"] = sdrs
|
config["sdrs"] = sdrs
|
||||||
super().store()
|
super().store()
|
||||||
|
|
||||||
def getSuccessfulRedirect(self):
|
def getSuccessfulRedirect(self):
|
||||||
return "{}settings/sdr/{}".format(self.get_document_root(), quote(self.sdr_id))
|
return "{}settings/sdr/{}".format(self.get_document_root(), quote(self.device_id))
|
||||||
|
|
||||||
|
|
||||||
class SdrProfileController(SdrFormControllerWithModal):
|
class SdrProfileController(SdrFormControllerWithModal):
|
||||||
@ -398,11 +398,7 @@ class SdrProfileController(SdrFormControllerWithModal):
|
|||||||
|
|
||||||
class NewProfileController(SdrProfileController):
|
class NewProfileController(SdrProfileController):
|
||||||
def __init__(self, handler, request, options):
|
def __init__(self, handler, request, options):
|
||||||
id_layer = PropertyLayer(id="")
|
|
||||||
self.data_layer = PropertyLayer(name="")
|
self.data_layer = PropertyLayer(name="")
|
||||||
self.stack = PropertyStack()
|
|
||||||
self.stack.addLayer(0, self.data_layer)
|
|
||||||
self.stack.addLayer(1, id_layer)
|
|
||||||
super().__init__(handler, request, options)
|
super().__init__(handler, request, options)
|
||||||
|
|
||||||
def get_breadcrumb(self) -> Breadcrumb:
|
def get_breadcrumb(self) -> Breadcrumb:
|
||||||
@ -413,28 +409,21 @@ class NewProfileController(SdrProfileController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _get_profile(self):
|
def _get_profile(self):
|
||||||
return "new", self.stack
|
return str(uuid4()), self.data_layer
|
||||||
|
|
||||||
def getSections(self):
|
|
||||||
return [
|
|
||||||
Section(
|
|
||||||
"New profile settings",
|
|
||||||
TextInput("id", "Profile ID", validator=RequiredValidator()),
|
|
||||||
)
|
|
||||||
] + super().getSections()
|
|
||||||
|
|
||||||
def isNewProfileActive(self) -> bool:
|
def isNewProfileActive(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def store(self):
|
def store(self):
|
||||||
if self.stack["id"] in self.device["profiles"]:
|
# a uuid should be unique, so i'm not sure if there's a point in this check
|
||||||
raise ValueError("Profile {} already exists!".format(self.stack["id"]))
|
if self.profile_id in self.device["profiles"]:
|
||||||
self.device["profiles"][self.stack["id"]] = self.data_layer
|
raise ValueError("Profile {} already exists!".format(self.profile_id))
|
||||||
|
self.device["profiles"][self.profile_id] = self.data_layer
|
||||||
super().store()
|
super().store()
|
||||||
|
|
||||||
def getSuccessfulRedirect(self):
|
def getSuccessfulRedirect(self):
|
||||||
return "{}settings/sdr/{}/profile/{}".format(
|
return "{}settings/sdr/{}/profile/{}".format(
|
||||||
self.get_document_root(), quote(self.device_id), quote(self.stack["id"])
|
self.get_document_root(), quote(self.device_id), quote(self.profile_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_remove_button(self):
|
def render_remove_button(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user