Update pages/document_store.py
Browse files- pages/document_store.py +20 -8
pages/document_store.py
CHANGED
|
@@ -1,8 +1,13 @@
|
|
| 1 |
# pages/document_store.py
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
-
from utils.
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def display_collection_manager():
|
| 8 |
"""Display the collection management interface."""
|
|
@@ -15,10 +20,10 @@ def display_collection_manager():
|
|
| 15 |
with st.expander("Create New Collection", expanded=False):
|
| 16 |
col1, col2 = st.columns([3, 1])
|
| 17 |
with col1:
|
| 18 |
-
name = st.text_input("Collection Name")
|
| 19 |
-
description = st.text_area("Description")
|
| 20 |
with col2:
|
| 21 |
-
if st.button("Create Collection") and name:
|
| 22 |
if create_collection(conn, name, description):
|
| 23 |
st.success(f"Collection '{name}' created!")
|
| 24 |
st.rerun()
|
|
@@ -63,7 +68,7 @@ def handle_document_upload_with_collection(uploaded_files, collection_id):
|
|
| 63 |
conn = st.session_state.db_conn
|
| 64 |
|
| 65 |
for uploaded_file in uploaded_files:
|
| 66 |
-
#
|
| 67 |
document_id = process_and_store_document(uploaded_file)
|
| 68 |
|
| 69 |
if document_id:
|
|
@@ -79,4 +84,11 @@ if 'show_upload' not in st.session_state:
|
|
| 79 |
if 'selected_collection' not in st.session_state:
|
| 80 |
st.session_state.selected_collection = None
|
| 81 |
if 'editing_collection' not in st.session_state:
|
| 82 |
-
st.session_state.editing_collection = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# pages/document_store.py
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
+
from utils.database import (
|
| 4 |
+
create_collection,
|
| 5 |
+
get_collections,
|
| 6 |
+
get_collection_documents,
|
| 7 |
+
delete_collection,
|
| 8 |
+
add_document_to_collection,
|
| 9 |
+
process_and_store_document
|
| 10 |
+
)
|
| 11 |
|
| 12 |
def display_collection_manager():
|
| 13 |
"""Display the collection management interface."""
|
|
|
|
| 20 |
with st.expander("Create New Collection", expanded=False):
|
| 21 |
col1, col2 = st.columns([3, 1])
|
| 22 |
with col1:
|
| 23 |
+
name = st.text_input("Collection Name", key="new_collection_name")
|
| 24 |
+
description = st.text_area("Description", key="new_collection_desc")
|
| 25 |
with col2:
|
| 26 |
+
if st.button("Create Collection", key="create_collection_btn") and name:
|
| 27 |
if create_collection(conn, name, description):
|
| 28 |
st.success(f"Collection '{name}' created!")
|
| 29 |
st.rerun()
|
|
|
|
| 68 |
conn = st.session_state.db_conn
|
| 69 |
|
| 70 |
for uploaded_file in uploaded_files:
|
| 71 |
+
# Process and store the document
|
| 72 |
document_id = process_and_store_document(uploaded_file)
|
| 73 |
|
| 74 |
if document_id:
|
|
|
|
| 84 |
if 'selected_collection' not in st.session_state:
|
| 85 |
st.session_state.selected_collection = None
|
| 86 |
if 'editing_collection' not in st.session_state:
|
| 87 |
+
st.session_state.editing_collection = None
|
| 88 |
+
|
| 89 |
+
# Add this if you need it for the page
|
| 90 |
+
def main():
|
| 91 |
+
display_collection_manager()
|
| 92 |
+
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
main()
|