Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -684,8 +684,7 @@ def side():
|
|
| 684 |
|
| 685 |
|
| 686 |
st.header("TrustVault®")
|
| 687 |
-
st.
|
| 688 |
-
st.markdown("""
|
| 689 |
<style>
|
| 690 |
.scrollable-container {
|
| 691 |
max-height: 200px;
|
|
@@ -705,7 +704,7 @@ def side():
|
|
| 705 |
""", unsafe_allow_html=True)
|
| 706 |
|
| 707 |
# Saved Documents Section
|
| 708 |
-
st.subheader("Saved Documents")
|
| 709 |
|
| 710 |
# Text area for displaying saved documents
|
| 711 |
doc_texts = ""
|
|
@@ -718,18 +717,18 @@ def side():
|
|
| 718 |
else:
|
| 719 |
doc_texts = "No saved documents found."
|
| 720 |
except Exception as e:
|
| 721 |
-
st.error(f"Error fetching documents: {e}")
|
| 722 |
|
| 723 |
-
savedDoc = st.text_area("", doc_texts, height=200)
|
| 724 |
|
| 725 |
# Button container for Upload and Delete actions
|
| 726 |
-
st.markdown('<div class="button-container">', unsafe_allow_html=True)
|
| 727 |
|
| 728 |
# File uploader
|
| 729 |
-
uploaded_file = st.file_uploader("", key="file_uploader", label_visibility="collapsed")
|
| 730 |
|
| 731 |
# Upload button
|
| 732 |
-
if st.button("Upload", key="upload_button"):
|
| 733 |
if uploaded_file:
|
| 734 |
try:
|
| 735 |
# Convert and upload the file
|
|
@@ -737,33 +736,31 @@ def side():
|
|
| 737 |
if file_content:
|
| 738 |
doc_id = str(uuid.uuid4())
|
| 739 |
db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").child(doc_id).set({"content": file_content})
|
| 740 |
-
st.success(f"Document uploaded successfully!")
|
| 741 |
-
st.
|
| 742 |
else:
|
| 743 |
-
st.warning("Failed to process the uploaded file.")
|
| 744 |
except Exception as e:
|
| 745 |
-
st.error(f"Error uploading document: {e}")
|
| 746 |
else:
|
| 747 |
-
st.warning("Please select a file to upload.")
|
| 748 |
|
| 749 |
# Delete selected documents logic
|
| 750 |
if docs:
|
| 751 |
delete_options = [doc_data.get("content", f"Document {doc_id[:8]}") for doc_id, doc_data in docs.items()]
|
| 752 |
-
selected_docs = st.multiselect("Select documents to delete", options=delete_options)
|
| 753 |
-
if st.button("Delete Selected", key="delete_button"):
|
| 754 |
try:
|
| 755 |
for doc_name in selected_docs:
|
| 756 |
for doc_id, doc_data in docs.items():
|
| 757 |
if doc_data.get("content") == doc_name:
|
| 758 |
db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").child(doc_id).remove()
|
| 759 |
-
st.success("Selected documents deleted successfully!")
|
| 760 |
-
st.
|
| 761 |
except Exception as e:
|
| 762 |
st.sidebar.error(f"Error deleting documents: {e}")
|
| 763 |
|
| 764 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 765 |
-
|
| 766 |
-
|
| 767 |
|
| 768 |
# Show Trust Builders Section
|
| 769 |
st.subheader("Show My TrustBuilders®")
|
|
|
|
| 684 |
|
| 685 |
|
| 686 |
st.header("TrustVault®")
|
| 687 |
+
st.sidebar.markdown("""
|
|
|
|
| 688 |
<style>
|
| 689 |
.scrollable-container {
|
| 690 |
max-height: 200px;
|
|
|
|
| 704 |
""", unsafe_allow_html=True)
|
| 705 |
|
| 706 |
# Saved Documents Section
|
| 707 |
+
st.sidebar.subheader("Saved Documents")
|
| 708 |
|
| 709 |
# Text area for displaying saved documents
|
| 710 |
doc_texts = ""
|
|
|
|
| 717 |
else:
|
| 718 |
doc_texts = "No saved documents found."
|
| 719 |
except Exception as e:
|
| 720 |
+
st.sidebar.error(f"Error fetching documents: {e}")
|
| 721 |
|
| 722 |
+
savedDoc = st.sidebar.text_area("", doc_texts, height=200)
|
| 723 |
|
| 724 |
# Button container for Upload and Delete actions
|
| 725 |
+
st.sidebar.markdown('<div class="button-container">', unsafe_allow_html=True)
|
| 726 |
|
| 727 |
# File uploader
|
| 728 |
+
uploaded_file = st.sidebar.file_uploader("", key="file_uploader", label_visibility="collapsed")
|
| 729 |
|
| 730 |
# Upload button
|
| 731 |
+
if st.sidebar.button("Upload", key="upload_button"):
|
| 732 |
if uploaded_file:
|
| 733 |
try:
|
| 734 |
# Convert and upload the file
|
|
|
|
| 736 |
if file_content:
|
| 737 |
doc_id = str(uuid.uuid4())
|
| 738 |
db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").child(doc_id).set({"content": file_content})
|
| 739 |
+
st.sidebar.success(f"Document uploaded successfully!")
|
| 740 |
+
st.experimental_rerun() # Refresh the display
|
| 741 |
else:
|
| 742 |
+
st.sidebar.warning("Failed to process the uploaded file.")
|
| 743 |
except Exception as e:
|
| 744 |
+
st.sidebar.error(f"Error uploading document: {e}")
|
| 745 |
else:
|
| 746 |
+
st.sidebar.warning("Please select a file to upload.")
|
| 747 |
|
| 748 |
# Delete selected documents logic
|
| 749 |
if docs:
|
| 750 |
delete_options = [doc_data.get("content", f"Document {doc_id[:8]}") for doc_id, doc_data in docs.items()]
|
| 751 |
+
selected_docs = st.sidebar.multiselect("Select documents to delete", options=delete_options)
|
| 752 |
+
if st.sidebar.button("Delete Selected", key="delete_button"):
|
| 753 |
try:
|
| 754 |
for doc_name in selected_docs:
|
| 755 |
for doc_id, doc_data in docs.items():
|
| 756 |
if doc_data.get("content") == doc_name:
|
| 757 |
db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").child(doc_id).remove()
|
| 758 |
+
st.sidebar.success("Selected documents deleted successfully!")
|
| 759 |
+
st.experimental_rerun() # Refresh the display
|
| 760 |
except Exception as e:
|
| 761 |
st.sidebar.error(f"Error deleting documents: {e}")
|
| 762 |
|
| 763 |
+
st.sidebar.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
| 764 |
|
| 765 |
# Show Trust Builders Section
|
| 766 |
st.subheader("Show My TrustBuilders®")
|