-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
112 lines (95 loc) · 4.36 KB
/
app.py
File metadata and controls
112 lines (95 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Horizontal, Vertical
from textual.widgets import ContentSwitcher, Footer, Header, Label, ListItem, ListView
from core.organizer import FileOrganizer
from ui.screens.ai_assistant import AIAssistantScreen
from ui.screens.analytics import AnalyticsScreen
from ui.screens.dashboard import DashboardScreen
from ui.screens.history import HistoryScreen
from ui.screens.organize import OrganizeScreen
from ui.screens.search import SearchScreen
from ui.screens.settings import SettingsScreen
from utils.config import load_config
class FileFlowApp(App):
CSS_PATH = "ui/styles.tcss"
BINDINGS = [
Binding("1", "switch_screen('dash')", "Dashboard"),
Binding("2", "switch_screen('org')", "Organize"),
Binding("3", "switch_screen('search')", "Search"),
Binding("4", "switch_screen('ai')", "AI Assistant"),
Binding("5", "switch_screen('analytics')", "Analytics"),
Binding("6", "switch_screen('history')", "History"),
Binding("7", "switch_screen('settings')", "Settings"),
Binding("ctrl+q", "quit", "Quit"),
Binding("ctrl+o", "trigger_organize", "Organize Now"),
Binding("escape", "cancel_operation", "Cancel"),
]
def __init__(self):
super().__init__()
self.organizer = FileOrganizer()
from core.watcher import FileWatcher
self.watcher = FileWatcher(self.organizer)
self.config = load_config()
def on_mount(self):
self.update_watcher_state()
def update_watcher_state(self):
source = self.config.get("source_folder", "")
if self.config.get("auto_mode") and source:
try:
self.watcher.start(source)
self.notify("File Monitor started. [green]Active[/green]")
except Exception as error:
self.notify(f"Failed to start monitor: {error}", severity="error")
else:
self.watcher.stop()
self.notify("File Monitor stopped. [yellow]Inactive[/yellow]")
def action_cancel_operation(self):
if self.organizer.is_running:
self.organizer.cancel()
self.notify("Operation cancelled")
def compose(self) -> ComposeResult:
yield Header(show_clock=True)
with Horizontal():
with Vertical(id="sidebar"):
with Vertical(id="sidebar-header"):
yield Label("FileFlow", id="app-title")
yield Label("SEAMLESS DATA MANAGEMENT", id="app-tagline")
yield ListView(
ListItem(Label("Dashboard"), id="nav-dash"),
ListItem(Label("Organize"), id="nav-org"),
ListItem(Label("Search"), id="nav-search"),
ListItem(Label("AI Assistant"), id="nav-ai"),
ListItem(Label("Analytics"), id="nav-analytics"),
ListItem(Label("History"), id="nav-history"),
ListItem(Label("Settings"), id="nav-settings"),
id="nav-list",
)
yield Label("v1.0.0", id="app-version")
with ContentSwitcher(initial="dash"):
yield DashboardScreen(id="dash")
yield OrganizeScreen(id="org")
yield SearchScreen(id="search")
yield AIAssistantScreen(id="ai")
yield AnalyticsScreen(id="analytics")
yield HistoryScreen(id="history")
yield SettingsScreen(id="settings")
yield Footer()
def on_list_view_selected(self, event: ListView.Selected):
nav_id = event.item.id
if nav_id:
self.query_one(ContentSwitcher).current = nav_id.replace("nav-", "")
def action_switch_screen(self, screen_id: str):
self.query_one(ContentSwitcher).current = screen_id
nav_list = self.query_one("#nav-list", ListView)
for index, item in enumerate(nav_list.children):
if item.id == f"nav-{screen_id}":
nav_list.index = index
break
def action_trigger_organize(self):
self.action_switch_screen("org")
organize_screen = self.query_one("#org", OrganizeScreen)
if not organize_screen.is_running:
organize_screen.start_organization(dry_run=False)
if __name__ == "__main__":
FileFlowApp().run()