Files changed (1) hide show
  1. app.py +10 -131
app.py CHANGED
@@ -1,126 +1,3 @@
1
- # import gradio as gr
2
-
3
- # # Ensure the new dropdown helpers are imported
4
- # from logic import (
5
- # run_ingest, run_search, load_caption_browser, load_collections_view,
6
- # update_collections_dropdown, update_search_dropdown
7
- # )
8
- # from caption_store import entry_count, get_all_collections
9
-
10
- # # Import UI Views
11
- # from ui.sidebar import render_sidebar
12
- # from ui.home import render_home
13
- # from ui.ingest import render_ingest
14
- # from ui.search import render_search
15
- # from ui.collections import render_collections
16
- # from ui.captions import render_captions
17
- # from ui.about import render_about
18
-
19
- # # Define explicit Dark Mode theme variables
20
- # # dark_theme = gr.themes.Soft(
21
- # # primary_hue="green",
22
- # # secondary_hue="emerald"
23
- # # ).set(
24
- # # body_background_fill="#0b0f19",
25
- # # body_background_fill_dark="#0b0f19",
26
- # # block_background_fill="#1e293b",
27
- # # block_background_fill_dark="#1e293b",
28
- # # block_border_color="#334155",
29
- # # block_border_color_dark="#334155",
30
- # # input_background_fill="#0f172a",
31
- # # input_background_fill_dark="#0f172a",
32
- # # text_color="#f1f5f9",
33
- # # text_color_dark="#f1f5f9",
34
- # # )
35
-
36
- # # Load Custom Stylesheet
37
- # with open("style.css", "r") as f:
38
- # custom_css = f.read()
39
-
40
- # with gr.Blocks(css=custom_css) as demo:
41
- # # 1. Render Navigation Sidebar
42
- # nav_btns, stats_label = render_sidebar()
43
-
44
- # # 2. Render Main Content Container Pages
45
- # with gr.Column(elem_classes="main-content"):
46
- # home_page, start_btn = render_home()
47
- # ingest_page, upload, coll_dropdown, use_new_coll, new_coll_name, ingest_btn, ingest_status = render_ingest()
48
- # search_page, search_query, search_col_filter, search_btn, search_status_msg, search_gallery = render_search()
49
- # colls_page, view_coll_selector, refresh_coll_btn, coll_status, coll_gallery = render_collections()
50
- # caps_page, refresh_cap_btn, cap_status, caption_table = render_captions()
51
- # about_page = render_about()
52
-
53
- # # Routing definitions
54
- # pages = [home_page, ingest_page, search_page, colls_page, caps_page, about_page]
55
- # page_names = ["home", "ingest", "search", "collections", "captions", "about"]
56
-
57
- # def switch_page(page_name):
58
- # return [gr.update(visible=(name == page_name)) for name in page_names]
59
-
60
- # # --- Page Routing Event Handlers ---
61
- # nav_btns["home"].click(fn=lambda: switch_page("home"), outputs=pages)
62
- # nav_btns["ingest"].click(fn=lambda: switch_page("ingest"), outputs=pages)
63
-
64
- # # Use logic helpers to keep dropdown selections safe when changing tabs
65
- # nav_btns["search"].click(
66
- # fn=lambda: switch_page("search") + [update_search_dropdown()],
67
- # outputs=pages + [search_col_filter]
68
- # )
69
- # nav_btns["collections"].click(
70
- # fn=lambda: switch_page("collections") + [update_collections_dropdown()],
71
- # outputs=pages + [view_coll_selector]
72
- # )
73
-
74
- # nav_btns["captions"].click(fn=lambda: switch_page("captions"), outputs=pages)
75
- # nav_btns["about"].click(fn=lambda: switch_page("about"), outputs=pages)
76
-
77
- # start_btn.click(fn=lambda: switch_page("ingest"), outputs=pages)
78
-
79
- # # --- Component Value Interaction Bindings ---
80
-
81
- # # Toggle dropdown/text field depending on toggle state
82
- # def toggle_collection_inputs(is_new):
83
- # return (
84
- # gr.update(visible=not is_new), # Hide selector if creating new
85
- # gr.update(visible=is_new) # Show text box if creating new
86
- # )
87
-
88
- # use_new_coll.change(
89
- # fn=toggle_collection_inputs,
90
- # inputs=use_new_coll,
91
- # outputs=[coll_dropdown, new_coll_name]
92
- # )
93
-
94
- # ingest_btn.click(
95
- # fn=run_ingest,
96
- # inputs=[upload, coll_dropdown, use_new_coll, new_coll_name],
97
- # outputs=[ingest_status, caption_table, coll_dropdown]
98
- # ).then(
99
- # fn=lambda: f"Total Photos: {entry_count()}",
100
- # outputs=stats_label
101
- # )
102
-
103
- # # Search Logic Action triggers
104
- # search_btn.click(fn=run_search, inputs=[search_query, search_col_filter], outputs=[search_gallery, search_status_msg])
105
- # search_query.submit(fn=run_search, inputs=[search_query, search_col_filter], outputs=[search_gallery, search_status_msg])
106
-
107
- # # Gallery view loaders
108
- # view_coll_selector.change(fn=load_collections_view, inputs=view_coll_selector, outputs=[coll_gallery, coll_status])
109
- # refresh_coll_btn.click(fn=load_collections_view, inputs=view_coll_selector, outputs=[coll_gallery, coll_status])
110
-
111
- # # Captions refresh actions
112
- # refresh_cap_btn.click(fn=load_caption_browser, outputs=[caption_table, cap_status])
113
-
114
- # # Initial startup data population
115
- # demo.load(fn=load_caption_browser, outputs=[caption_table, cap_status])
116
- # demo.load(
117
- # fn=lambda: load_collections_view(get_all_collections()[0] if get_all_collections() else "General"),
118
- # outputs=[coll_gallery, coll_status]
119
- # )
120
-
121
- # if __name__ == "__main__":
122
- # demo.launch()
123
-
124
  import os
125
  import gradio as gr
126
 
@@ -133,7 +10,7 @@ from caption_store import entry_count, get_all_collections
133
 
134
  # Import modular UI Page builders
135
  from ui.sidebar import render_sidebar
136
- from ui.home import render_home
137
  from ui.ingest import render_ingest
138
  from ui.search import render_search
139
  from ui.collections import render_collections
@@ -150,7 +27,7 @@ with gr.Blocks(css=custom_css, title="ShutterSearch — Photo Archive", fill_hei
150
 
151
  # 2. Render Main Content Container Pages
152
  with gr.Column(elem_classes="main-content"):
153
- home_page, start_btn = render_home()
154
  ingest_page, upload, coll_dropdown, use_new_coll, new_coll_name, ingest_btn, ingest_status = render_ingest()
155
 
156
  # Search layout with selection returns
@@ -171,16 +48,18 @@ with gr.Blocks(css=custom_css, title="ShutterSearch — Photo Archive", fill_hei
171
  about_page = render_about()
172
 
173
  # Define page indexes for visibility toggles
174
- pages = [home_page, ingest_page, search_page, colls_page, caps_page, about_page]
175
- page_names = ["home", "ingest", "search", "collections", "captions", "about"]
176
-
 
 
177
  def switch_page(page_name):
178
  """Generates dynamic updates to manage current visible pages."""
179
  return [gr.update(visible=(name == page_name)) for name in page_names]
180
 
181
  # --- Sidebar Navigation Interactions ---
182
- nav_btns["home"].click(fn=lambda: switch_page("home"), outputs=pages)
183
- nav_btns["ingest"].click(fn=lambda: switch_page("ingest"), outputs=pages)
184
 
185
  # Safe helpers are invoked here to avoid component value schema mismatch issues
186
  nav_btns["search"].click(
@@ -195,7 +74,7 @@ with gr.Blocks(css=custom_css, title="ShutterSearch — Photo Archive", fill_hei
195
  nav_btns["captions"].click(fn=lambda: switch_page("captions"), outputs=pages)
196
  nav_btns["about"].click(fn=lambda: switch_page("about"), outputs=pages)
197
 
198
- start_btn.click(fn=lambda: switch_page("ingest"), outputs=pages)
199
 
200
  # --- Ingestion View Handlers ---
201
  def toggle_collection_inputs(is_new):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import gradio as gr
3
 
 
10
 
11
  # Import modular UI Page builders
12
  from ui.sidebar import render_sidebar
13
+ # from ui.home import render_home
14
  from ui.ingest import render_ingest
15
  from ui.search import render_search
16
  from ui.collections import render_collections
 
27
 
28
  # 2. Render Main Content Container Pages
29
  with gr.Column(elem_classes="main-content"):
30
+ # home_page, start_btn = render_home()
31
  ingest_page, upload, coll_dropdown, use_new_coll, new_coll_name, ingest_btn, ingest_status = render_ingest()
32
 
33
  # Search layout with selection returns
 
48
  about_page = render_about()
49
 
50
  # Define page indexes for visibility toggles
51
+ # pages = [home_page, ingest_page, search_page, colls_page, caps_page, about_page]
52
+ # page_names = ["home", "ingest", "search", "collections", "captions", "about"]
53
+ pages = [ingest_page, search_page, colls_page, caps_page, about_page]
54
+ page_names = ["ingest", "search", "collections", "captions", "about"]
55
+
56
  def switch_page(page_name):
57
  """Generates dynamic updates to manage current visible pages."""
58
  return [gr.update(visible=(name == page_name)) for name in page_names]
59
 
60
  # --- Sidebar Navigation Interactions ---
61
+ # nav_btns["home"].click(fn=lambda: switch_page("home"), outputs=pages)
62
+ # nav_btns["ingest"].click(fn=lambda: switch_page("ingest"), outputs=pages)
63
 
64
  # Safe helpers are invoked here to avoid component value schema mismatch issues
65
  nav_btns["search"].click(
 
74
  nav_btns["captions"].click(fn=lambda: switch_page("captions"), outputs=pages)
75
  nav_btns["about"].click(fn=lambda: switch_page("about"), outputs=pages)
76
 
77
+ # start_btn.click(fn=lambda: switch_page("ingest"), outputs=pages)
78
 
79
  # --- Ingestion View Handlers ---
80
  def toggle_collection_inputs(is_new):