cryogenic22 commited on
Commit
cf9bec7
Β·
verified Β·
1 Parent(s): 4152a02

Create components/collection_manager.py

Browse files
Files changed (1) hide show
  1. components/collection_manager.py +95 -0
components/collection_manager.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # components/collection_manager.py
2
+
3
+ def display_enhanced_collections():
4
+ """Enhanced collections management interface."""
5
+ col1, col2 = st.columns([1, 2])
6
+
7
+ with col1:
8
+ st.subheader("Collections")
9
+
10
+ # Search collections
11
+ search_query = st.text_input("πŸ” Search collections", key="collection_search")
12
+
13
+ # Create new collection button
14
+ if st.button("+ New Collection", type="primary", use_container_width=True):
15
+ st.session_state.show_collection_dialog = True
16
+
17
+ # Collection list with stats
18
+ collections = get_collections(st.session_state.db_conn)
19
+ if search_query:
20
+ collections = [c for c in collections
21
+ if search_query.lower() in c['name'].lower()]
22
+
23
+ st.divider()
24
+
25
+ for collection in collections:
26
+ with st.container():
27
+ col_button = st.button(
28
+ f"πŸ“ {collection['name']}",
29
+ key=f"col_{collection['id']}",
30
+ use_container_width=True
31
+ )
32
+
33
+ # Show collection stats
34
+ stats_cols = st.columns(3)
35
+ with stats_cols[0]:
36
+ st.caption(f"πŸ“„ {collection['doc_count']}")
37
+ with stats_cols[1]:
38
+ st.caption(f"πŸ“… {collection['created_at'][:10]}")
39
+ with stats_cols[2]:
40
+ st.caption("βš™οΈ Manage")
41
+
42
+ if col_button:
43
+ st.session_state.selected_collection = collection
44
+ st.rerun()
45
+
46
+ with col2:
47
+ if st.session_state.get('selected_collection'):
48
+ display_collection_content(st.session_state.selected_collection)
49
+ else:
50
+ st.info("Select a collection to view its contents")
51
+
52
+ def display_collection_content(collection):
53
+ """Display enhanced collection contents."""
54
+ st.subheader(collection['name'])
55
+
56
+ # Collection actions
57
+ col1, col2, col3, col4 = st.columns(4)
58
+ with col1:
59
+ st.button("πŸ“₯ Add Documents", use_container_width=True)
60
+ with col2:
61
+ st.button("✏️ Edit Collection", use_container_width=True)
62
+ with col3:
63
+ st.button("πŸ“€ Export", use_container_width=True)
64
+ with col4:
65
+ st.button("πŸ—‘οΈ Delete", use_container_width=True)
66
+
67
+ # Document search within collection
68
+ search_query = st.text_input("πŸ” Search documents in collection")
69
+
70
+ # Filters
71
+ with st.expander("Filters"):
72
+ filter_cols = st.columns(3)
73
+ with filter_cols[0]:
74
+ st.date_input("Date Range")
75
+ with filter_cols[1]:
76
+ st.selectbox("Sort By", ["Name", "Date", "Size"])
77
+ with filter_cols[2]:
78
+ st.selectbox("View", ["List", "Grid"])
79
+
80
+ # Document list
81
+ if search_query:
82
+ documents = search_documents(
83
+ st.session_state.db_conn,
84
+ search_query,
85
+ collection['id']
86
+ )
87
+ else:
88
+ documents = get_collection_documents(
89
+ st.session_state.db_conn,
90
+ collection['id']
91
+ )
92
+
93
+ for doc in documents:
94
+ with st.expander(f"πŸ“„ {doc['name']}", expanded=False):
95
+ enhanced_document_preview(doc)