diff options
| author | EnricoGuccii <partyka.003@proton.me> | 2026-01-10 22:43:36 +0100 |
|---|---|---|
| committer | EnricoGuccii <partyka.003@proton.me> | 2026-01-10 22:43:36 +0100 |
| commit | 6d7410e286ce0fde31f89185c095fe90e85597f3 (patch) | |
| tree | 5092c99d353382a71f00d8fe18d53b8073cf3f58 /src/streamml/front/options_tab.py | |
| parent | c2f5fbe7fb93ce420caf23c5c0e06144cf953bb8 (diff) | |
bloat removed
Diffstat (limited to 'src/streamml/front/options_tab.py')
| -rw-r--r-- | src/streamml/front/options_tab.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/streamml/front/options_tab.py b/src/streamml/front/options_tab.py new file mode 100644 index 0000000..22bd43a --- /dev/null +++ b/src/streamml/front/options_tab.py @@ -0,0 +1,43 @@ +from textual.app import ComposeResult +from textual.containers import Container, Horizontal +from textual.widgets import Button, Input, Label +from textual import on + +from ..back.notification_service import notification_service + +class OptionsTab(Container): + def __init__(self, detector_manager, *args, **kwargs): + super().__init__(*args, **kwargs) + self.detector_manager = detector_manager + + def compose(self) -> ComposeResult: + notify_section = Container(id="notify-section", classes="section-card") + notify_section.border_title = "Notification config" + with notify_section: + yield Label("Discord Webhook URL:") + yield Input(placeholder="https://discord.com/api/webhooks/...", id="input-webhook-url") + + with Horizontal(classes="modal-footer"): + yield Button("Save config", id="save-config", variant="success") + yield Button("notification test", id="test-notif", variant="primary") + + def on_mount(self): + self.query_one("#input-webhook-url", Input).value = notification_service.webhook_url + + @on(Button.Pressed, "#save-config") + def save_configuration(self): + url = self.query_one("#input-webhook-url", Input).value.strip() + + if notification_service.save_config(url): + self.app.notify("Config saved", severity="information") + else: + self.app.notify("Error during saving", severity="error") + + @on(Button.Pressed, "#test-notif") + def test_notification(self): + success = notification_service.send_message("**Test NetMonitor**\n") + + if success: + self.app.notify("good", severity="information") + else: + self.app.notify("bad", severity="error") |