Update components/collection_manager.py
Browse files- components/collection_manager.py +37 -14
components/collection_manager.py
CHANGED
|
@@ -74,7 +74,7 @@ def display_enhanced_collections():
|
|
| 74 |
collections = get_collections(st.session_state.db_conn)
|
| 75 |
if search_query:
|
| 76 |
collections = [c for c in collections
|
| 77 |
-
|
| 78 |
|
| 79 |
st.divider()
|
| 80 |
|
|
@@ -133,19 +133,42 @@ def display_collection_content(collection):
|
|
| 133 |
with filter_cols[2]:
|
| 134 |
st.selectbox("View", ["List", "Grid"])
|
| 135 |
|
| 136 |
-
# Document list
|
|
|
|
| 137 |
if search_query:
|
| 138 |
-
documents =
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
collection['id']
|
| 142 |
-
)
|
| 143 |
-
else:
|
| 144 |
-
documents = get_collection_documents(
|
| 145 |
-
st.session_state.db_conn,
|
| 146 |
-
collection['id']
|
| 147 |
-
)
|
| 148 |
|
|
|
|
| 149 |
for doc in documents:
|
| 150 |
-
with st.
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
collections = get_collections(st.session_state.db_conn)
|
| 75 |
if search_query:
|
| 76 |
collections = [c for c in collections
|
| 77 |
+
if search_query.lower() in c['name'].lower()]
|
| 78 |
|
| 79 |
st.divider()
|
| 80 |
|
|
|
|
| 133 |
with filter_cols[2]:
|
| 134 |
st.selectbox("View", ["List", "Grid"])
|
| 135 |
|
| 136 |
+
# Document list with enhanced display
|
| 137 |
+
documents = get_collection_documents(st.session_state.db_conn, collection['id'])
|
| 138 |
if search_query:
|
| 139 |
+
documents = [doc for doc in documents
|
| 140 |
+
if search_query.lower() in doc['name'].lower() or
|
| 141 |
+
search_query.lower() in doc.get('content', '').lower()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
+
# Display documents in a clean, modern format
|
| 144 |
for doc in documents:
|
| 145 |
+
with st.container():
|
| 146 |
+
doc_cols = st.columns([0.1, 2, 0.5])
|
| 147 |
+
with doc_cols[0]:
|
| 148 |
+
st.checkbox("", key=f"select_{doc['id']}")
|
| 149 |
+
with doc_cols[1]:
|
| 150 |
+
st.markdown(f"**{doc['name']}**")
|
| 151 |
+
st.caption(f"Uploaded: {doc.get('upload_date', 'N/A')}")
|
| 152 |
+
with doc_cols[2]:
|
| 153 |
+
st.button("Preview", key=f"preview_{doc['id']}", use_container_width=True)
|
| 154 |
+
st.button("Remove", key=f"remove_{doc['id']}", use_container_width=True)
|
| 155 |
+
|
| 156 |
+
# Document preview expander
|
| 157 |
+
if st.session_state.get(f"preview_{doc['id']}", False):
|
| 158 |
+
with st.expander("Document Preview", expanded=True):
|
| 159 |
+
st.text_area(
|
| 160 |
+
"Content",
|
| 161 |
+
value=doc['content'][:1000] + "..." if len(doc['content']) > 1000 else doc['content'],
|
| 162 |
+
height=200,
|
| 163 |
+
disabled=True
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
def show_document_preview(document):
|
| 167 |
+
"""Show document preview in a modal."""
|
| 168 |
+
with st.expander(f"Preview: {document['name']}", expanded=True):
|
| 169 |
+
st.text_area(
|
| 170 |
+
"Content",
|
| 171 |
+
value=document['content'][:1000] + "..." if len(document['content']) > 1000 else document['content'],
|
| 172 |
+
height=300,
|
| 173 |
+
disabled=True
|
| 174 |
+
)
|