|
|
|
@ -8,9 +8,11 @@ from textual.containers import Grid, Horizontal
|
|
|
|
|
|
|
|
|
|
from ffx.model.pattern import Pattern
|
|
|
|
|
|
|
|
|
|
from .show_controller import ShowController
|
|
|
|
|
from .pattern_controller import PatternController
|
|
|
|
|
# from .show_controller import ShowController
|
|
|
|
|
# from .pattern_controller import PatternController
|
|
|
|
|
from .track_controller import TrackController
|
|
|
|
|
|
|
|
|
|
from .track_type import TrackType
|
|
|
|
|
|
|
|
|
|
# Screen[dict[int, str, int]]
|
|
|
|
|
class TrackDeleteScreen(Screen):
|
|
|
|
@ -46,43 +48,57 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, patternId = None, showId = None):
|
|
|
|
|
TRACK_TYPE_LABELS = [
|
|
|
|
|
'video',
|
|
|
|
|
'audio',
|
|
|
|
|
'subtitle'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, trackType : TrackType, trackId = None):
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
self.context = self.app.getContext()
|
|
|
|
|
self.Session = self.context['database_session'] # convenience
|
|
|
|
|
|
|
|
|
|
self.__pc = PatternController(context = self.context)
|
|
|
|
|
self.__sc = ShowController(context = self.context)
|
|
|
|
|
self.__tc = TrackController(context = self.context)
|
|
|
|
|
# self.__pc = PatternController(context = self.context)
|
|
|
|
|
# self.__sc = ShowController(context = self.context)
|
|
|
|
|
|
|
|
|
|
self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
|
|
|
|
self.show_obj = self.__sc.getShowDesciptor(showId) if showId is not None else {}
|
|
|
|
|
# self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
|
|
|
|
# self.show_obj = self.__sc.getShowDesciptor(showId) if showId is not None else {}
|
|
|
|
|
|
|
|
|
|
self.trackType = trackType
|
|
|
|
|
self.track_obj = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_mount(self):
|
|
|
|
|
if self.show_obj:
|
|
|
|
|
self.query_one("#showlabel", Static).update(f"{self.show_obj['id']} - {self.show_obj['name']} ({self.show_obj['year']})")
|
|
|
|
|
if self.pattern_obj:
|
|
|
|
|
self.query_one("#patternlabel", Static).update(str(self.pattern_obj['pattern']))
|
|
|
|
|
pass
|
|
|
|
|
# if self.show_obj:
|
|
|
|
|
# self.query_one("#showlabel", Static).update(f"{self.show_obj['id']} - {self.show_obj['name']} ({self.show_obj['year']})")
|
|
|
|
|
# if self.pattern_obj:
|
|
|
|
|
# self.query_one("#patternlabel", Static).update(str(self.pattern_obj['pattern']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compose(self):
|
|
|
|
|
|
|
|
|
|
typeLabel = TrackDeleteScreen.TRACK_TYPE_LABELS[int(self.trackType.value)-1]
|
|
|
|
|
|
|
|
|
|
yield Header()
|
|
|
|
|
|
|
|
|
|
with Grid():
|
|
|
|
|
|
|
|
|
|
yield Static("Are you sure to delete the following filename pattern?", id="toplabel", classes="two")
|
|
|
|
|
yield Static(f"Are you sure to delete the following {typeLabel} stream?", id="toplabel", classes="two")
|
|
|
|
|
|
|
|
|
|
yield Static("", classes="two")
|
|
|
|
|
|
|
|
|
|
yield Static("Pattern")
|
|
|
|
|
yield Static("", id="patternlabel")
|
|
|
|
|
|
|
|
|
|
yield Static("", classes="two")
|
|
|
|
|
|
|
|
|
|
yield Static("from show")
|
|
|
|
|
yield Static("", id="showlabel")
|
|
|
|
|
# yield Static("", classes="two")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("Pattern")
|
|
|
|
|
# yield Static("", id="patternlabel")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("", classes="two")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("from show")
|
|
|
|
|
# yield Static("", id="showlabel")
|
|
|
|
|
|
|
|
|
|
yield Static("", classes="two")
|
|
|
|
|
|
|
|
|
@ -95,20 +111,20 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
# Event handler for button press
|
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
|
|
|
|
|
|
|
|
if event.button.id == "delete_button":
|
|
|
|
|
|
|
|
|
|
if self.__pc.deletePattern(self.pattern_obj['id']):
|
|
|
|
|
|
|
|
|
|
screenResult = {}
|
|
|
|
|
screenResult['show_id'] = self.show_obj['id']
|
|
|
|
|
screenResult['pattern'] = self.pattern_obj['pattern']
|
|
|
|
|
|
|
|
|
|
self.dismiss(screenResult)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
#TODO: Meldung
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|
# if event.button.id == "delete_button":
|
|
|
|
|
#
|
|
|
|
|
# if self.__pc.deletePattern(self.pattern_obj['id']):
|
|
|
|
|
#
|
|
|
|
|
# screenResult = {}
|
|
|
|
|
# screenResult['show_id'] = self.show_obj['id']
|
|
|
|
|
# screenResult['pattern'] = self.pattern_obj['pattern']
|
|
|
|
|
#
|
|
|
|
|
# self.dismiss(screenResult)
|
|
|
|
|
#
|
|
|
|
|
# else:
|
|
|
|
|
# #TODO: Meldung
|
|
|
|
|
# self.app.pop_screen()
|
|
|
|
|
#
|
|
|
|
|
if event.button.id == "cancel_button":
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|