Wajahat698 commited on
Commit
f6eff22
·
verified ·
1 Parent(s): 3880189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -681,17 +681,20 @@ def side():
681
  padding: 10px;
682
  border-radius: 5px;
683
  background-color: #f9f9f9;
 
684
  }
685
  .button-container {
686
  display: flex;
687
- flex-direction: column;
688
- margin-top: 10px;
689
  }
690
  </style>
691
  """, unsafe_allow_html=True)
692
 
693
- # Sidebar: Saved Documents
 
694
  st.sidebar.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
 
695
  try:
696
  # Fetch and display saved documents
697
  docs = db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").get().val()
@@ -700,32 +703,34 @@ def side():
700
  if docs:
701
  for doc_id, doc_data in docs.items():
702
  doc_name = doc_data.get('content', 'Document')
703
- st.sidebar.markdown(f"**{doc_name}**")
704
  doc_names.append(doc_name)
705
  doc_ids.append(doc_id)
706
  else:
707
  st.sidebar.write("No saved documents found.")
708
  except Exception as e:
709
  st.sidebar.error(f"Error fetching documents: {e}")
 
710
  st.sidebar.markdown('</div>', unsafe_allow_html=True)
711
 
712
  # Below saved documents: Upload and Delete buttons
713
  st.sidebar.markdown('<div class="button-container">', unsafe_allow_html=True)
714
 
715
  # File uploader
716
- uploaded_file = st.sidebar.file_uploader("", key="file_uploader")
717
 
718
  # Upload button
719
- if st.sidebar.button("Upload"):
720
  if uploaded_file:
721
- save_document(st.sess, uploaded_file.name)
 
722
  else:
723
  st.sidebar.warning("Please select a file to upload.")
724
 
725
- # Multi-select for deleting documents
726
  if docs:
727
  selected_docs = st.sidebar.multiselect("Select documents to delete", options=doc_names)
728
- if st.sidebar.button("Delete Selected"):
729
  for doc_name in selected_docs:
730
  # Find the doc_id corresponding to the doc_name
731
  doc_id_to_delete = None
@@ -740,6 +745,7 @@ def side():
740
  st.sidebar.write("No documents to delete.")
741
 
742
  st.sidebar.markdown('</div>', unsafe_allow_html=True)
 
743
 
744
  # Show Trust Builders Section
745
  st.subheader("Show My TrustBuilders®")
@@ -751,7 +757,7 @@ def side():
751
  st.write("or")
752
  brand = st.text_input("Brand/Product/Person", key="brand_input_show")
753
  st.write("")
754
- if st.button("Show"):
755
  st.write(f"Filtering TrustBuilders for keyword='{search_query}', brand='{brand}', and bucket='{selected_bucket}'")
756
  trustbuilders = fetch_trustbuilders(st.session_state["wix_user_id"])
757
  results = []
 
681
  padding: 10px;
682
  border-radius: 5px;
683
  background-color: #f9f9f9;
684
+ margin-bottom: 10px;
685
  }
686
  .button-container {
687
  display: flex;
688
+ justify-content: space-between;
689
+ gap: 10px;
690
  }
691
  </style>
692
  """, unsafe_allow_html=True)
693
 
694
+ # Sidebar: Saved Documents Section
695
+ st.sidebar.subheader("Saved Documents")
696
  st.sidebar.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
697
+
698
  try:
699
  # Fetch and display saved documents
700
  docs = db.child("users").child(st.session_state["wix_user_id"]).child("KnowledgeBase").get().val()
 
703
  if docs:
704
  for doc_id, doc_data in docs.items():
705
  doc_name = doc_data.get('content', 'Document')
706
+ st.sidebar.markdown(f"- {doc_name}")
707
  doc_names.append(doc_name)
708
  doc_ids.append(doc_id)
709
  else:
710
  st.sidebar.write("No saved documents found.")
711
  except Exception as e:
712
  st.sidebar.error(f"Error fetching documents: {e}")
713
+
714
  st.sidebar.markdown('</div>', unsafe_allow_html=True)
715
 
716
  # Below saved documents: Upload and Delete buttons
717
  st.sidebar.markdown('<div class="button-container">', unsafe_allow_html=True)
718
 
719
  # File uploader
720
+ uploaded_file = st.sidebar.file_uploader("", key="file_uploader", label_visibility="collapsed")
721
 
722
  # Upload button
723
+ if st.sidebar.button("Upload", key="upload_button"):
724
  if uploaded_file:
725
+ save_document(st.session_state["wix_user_id"], uploaded_file.name)
726
+ st.sidebar.success(f"Document '{uploaded_file.name}' uploaded successfully.")
727
  else:
728
  st.sidebar.warning("Please select a file to upload.")
729
 
730
+ # Delete Selected Button
731
  if docs:
732
  selected_docs = st.sidebar.multiselect("Select documents to delete", options=doc_names)
733
+ if st.sidebar.button("Delete Selected", key="delete_button"):
734
  for doc_name in selected_docs:
735
  # Find the doc_id corresponding to the doc_name
736
  doc_id_to_delete = None
 
745
  st.sidebar.write("No documents to delete.")
746
 
747
  st.sidebar.markdown('</div>', unsafe_allow_html=True)
748
+
749
 
750
  # Show Trust Builders Section
751
  st.subheader("Show My TrustBuilders®")
 
757
  st.write("or")
758
  brand = st.text_input("Brand/Product/Person", key="brand_input_show")
759
  st.write("")
760
+ if st.button("Show"):
761
  st.write(f"Filtering TrustBuilders for keyword='{search_query}', brand='{brand}', and bucket='{selected_bucket}'")
762
  trustbuilders = fetch_trustbuilders(st.session_state["wix_user_id"])
763
  results = []