File size: 2,872 Bytes
4a02afe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from caption_store import get_all_collections

def render_ingest():
    with gr.Column(visible=False, elem_classes="page-container") as page:
        gr.HTML("""

        <div style='margin-bottom: 20px;'>

            <h1 style='font-size: 2rem; font-weight: 700; color: #f8fafc;'>📥 Ingest Photos</h1>

            <p style='color: #94a3b8;'>Upload images to your archive and generate AI descriptions.</p>

        </div>

        """)
        
        with gr.Row(equal_height=True):
            # Left: File Uploader
            with gr.Column(scale=3):
                upload = gr.File(
                    label="Drag & Drop Images Here",
                    file_count="multiple",
                    file_types=[".jpg", ".jpeg", ".png", ".webp", ".tiff"],
                    height=280,
                    elem_classes="upload-zone"
                )
            
            # Right: Destination & Collection Controls
            with gr.Column(scale=2, elem_classes="settings-card"):
                gr.Markdown("### ⚙️ Collection Destination")
                
                use_new_coll = gr.Checkbox(
                    label="Create a brand new collection", 
                    value=False,
                    elem_classes="custom-checkbox"
                )
                
                # Safely parse collection values on first load
                choices = get_all_collections()
                if not choices:
                    choices = ["General"]
                default_val = "General" if "General" in choices else choices[0]
                
                coll_dropdown = gr.Dropdown(
                    choices=choices, 
                    label="Target Collection", 
                    value=default_val,
                    interactive=True,
                    visible=True
                )
                
                new_coll_name = gr.Textbox(
                    label="New Collection Name", 
                    placeholder="e.g. Summer Vacation 2024",
                    visible=False
                )
                
                ingest_btn = gr.Button(
                    "🚀 Start Processing", 
                    variant="primary", 
                    size="lg"
                )
        
        # Bottom: Terminal-style status log
        with gr.Column(elem_classes="console-wrapper"):
            gr.Markdown("### 🖥️ Ingestion Logs")
            ingest_status = gr.Textbox(
                value="System ready. Awaiting file upload...",
                show_label=False,
                interactive=False, 
                lines=6,
                elem_classes="status-console"
            )
            
    return page, upload, coll_dropdown, use_new_coll, new_coll_name, ingest_btn, ingest_status