Update components/collection_manager.py
Browse files- components/collection_manager.py +14 -38
components/collection_manager.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
# components/collection_manager.py
|
| 2 |
|
| 3 |
|
|
|
|
|
|
|
| 4 |
def show_collection_creation_dialog():
|
| 5 |
"""Show dialog for creating a new collection."""
|
| 6 |
with st.form("create_collection"):
|
|
@@ -26,51 +28,25 @@ def show_collection_creation_dialog():
|
|
| 26 |
for doc_id in selected_docs:
|
| 27 |
add_document_to_collection(st.session_state.db_conn, doc_id, collection_id)
|
| 28 |
st.success(f"Collection '{name}' created!")
|
|
|
|
| 29 |
st.rerun()
|
| 30 |
|
| 31 |
-
def
|
| 32 |
-
"""
|
| 33 |
-
st.
|
| 34 |
|
| 35 |
-
# Collection Analytics
|
| 36 |
-
col1, col2 = st.columns(2)
|
| 37 |
with col1:
|
| 38 |
-
st.metric("Total Documents", collection['doc_count'])
|
| 39 |
-
with col2:
|
| 40 |
-
st.metric("Last Updated", collection['last_updated'])
|
| 41 |
-
|
| 42 |
-
# Document List
|
| 43 |
-
documents = get_collection_documents(st.session_state.db_conn, collection['id'])
|
| 44 |
-
if documents:
|
| 45 |
-
with st.expander("Manage Documents", expanded=True):
|
| 46 |
-
selected_docs = []
|
| 47 |
-
for doc in documents:
|
| 48 |
-
col1, col2, col3 = st.columns([0.1, 0.7, 0.2])
|
| 49 |
-
with col1:
|
| 50 |
-
selected = st.checkbox("", key=f"select_{doc['id']}")
|
| 51 |
-
if selected:
|
| 52 |
-
selected_docs.append(doc['id'])
|
| 53 |
-
with col2:
|
| 54 |
-
st.write(f"📄 {doc['name']}")
|
| 55 |
-
with col3:
|
| 56 |
-
if st.button("Preview", key=f"preview_{doc['id']}"):
|
| 57 |
-
show_document_preview(doc)
|
| 58 |
-
|
| 59 |
-
if selected_docs:
|
| 60 |
-
if st.button("Remove Selected", key="remove_selected"):
|
| 61 |
-
for doc_id in selected_docs:
|
| 62 |
-
remove_from_collection(st.session_state.db_conn, doc_id, collection['id'])
|
| 63 |
-
st.rerun()
|
| 64 |
-
|
| 65 |
-
def show_document_preview(document):
|
| 66 |
-
"""Show document preview in a modal."""
|
| 67 |
-
with st.expander(f"Preview: {document['name']}", expanded=True):
|
| 68 |
st.text_area(
|
| 69 |
-
"
|
| 70 |
-
value=
|
| 71 |
-
height=
|
| 72 |
disabled=True
|
| 73 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
def display_enhanced_collections():
|
| 76 |
"""Enhanced collections management interface."""
|
|
|
|
| 1 |
# components/collection_manager.py
|
| 2 |
|
| 3 |
|
| 4 |
+
# components/collection_manager.py
|
| 5 |
+
|
| 6 |
def show_collection_creation_dialog():
|
| 7 |
"""Show dialog for creating a new collection."""
|
| 8 |
with st.form("create_collection"):
|
|
|
|
| 28 |
for doc_id in selected_docs:
|
| 29 |
add_document_to_collection(st.session_state.db_conn, doc_id, collection_id)
|
| 30 |
st.success(f"Collection '{name}' created!")
|
| 31 |
+
st.session_state.show_collection_dialog = False
|
| 32 |
st.rerun()
|
| 33 |
|
| 34 |
+
def enhanced_document_preview(doc):
|
| 35 |
+
"""Enhanced document preview with actions."""
|
| 36 |
+
col1, col2 = st.columns([3, 1])
|
| 37 |
|
|
|
|
|
|
|
| 38 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
st.text_area(
|
| 40 |
+
"Preview",
|
| 41 |
+
value=doc['content'][:1000] + "..." if len(doc['content']) > 1000 else doc['content'],
|
| 42 |
+
height=200,
|
| 43 |
disabled=True
|
| 44 |
)
|
| 45 |
+
|
| 46 |
+
with col2:
|
| 47 |
+
st.button("🗑️ Remove", key=f"remove_{doc['id']}", use_container_width=True)
|
| 48 |
+
st.button("📋 Copy", key=f"copy_{doc['id']}", use_container_width=True)
|
| 49 |
+
st.button("💬 Chat", key=f"chat_{doc['id']}", use_container_width=True)
|
| 50 |
|
| 51 |
def display_enhanced_collections():
|
| 52 |
"""Enhanced collections management interface."""
|