Wajahat698 commited on
Commit
af82d33
·
verified ·
1 Parent(s): 87d069f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -674,51 +674,51 @@ def side():
674
  st.sidebar.header("TrustVault®")
675
 
676
  st.subheader("Saved Documents")
677
- st.markdown("""
678
  <style>
679
  .scrollable-container {
680
- max-height: 300px;
681
  overflow-y: auto;
682
  border: 1px solid gray;
683
  padding: 10px;
684
  border-radius: 5px;
685
  background-color: #f9f9f9;
686
  }
 
 
 
 
 
687
  </style>
688
  """, unsafe_allow_html=True)
689
- st.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
690
 
691
- # Fetch and display saved documents
 
692
  try:
693
  docs = db.child("users").child(user_id).child("KnowledgeBase").get().val()
694
  if docs:
695
  for doc_id, doc_data in docs.items():
696
- col1, col2 = st.columns([4, 1])
697
- with col1:
698
- st.write(doc_data.get("content", ""))
699
- with col2:
700
- if st.button("Delete", key=f"delete_{doc_id}"):
701
- delete_document(user_id, doc_id)
702
  else:
703
- st.write("No saved documents found.")
704
  except Exception as e:
705
- st.error(f"Error fetching documents: {e}")
 
706
 
707
- st.markdown('</div>', unsafe_allow_html=True)
 
 
708
 
709
- # File Upload Section
710
- st.subheader("Upload New Documents")
711
- uploaded_file = st.file_uploader("Choose a file to upload (PDF, DOCX, TXT):", type=["pdf", "docx", "txt"])
712
- if uploaded_file:
713
- if st.button("Upload"):
714
- try:
715
- doc_id = str(uuid.uuid4())
716
- db.child("users").child(user_id).child("KnowledgeBase").child(doc_id).set({
717
- "content": uploaded_file.name
718
- })
719
- st.success(f"File '{uploaded_file.name}' uploaded successfully!")
720
- except Exception as e:
721
- st.error(f"Error uploading file: {e}")
722
 
723
  # Show Trust Builders Section
724
  st.subheader("Show My TrustBuilders®")
 
674
  st.sidebar.header("TrustVault®")
675
 
676
  st.subheader("Saved Documents")
677
+ st.sidebar.markdown("""
678
  <style>
679
  .scrollable-container {
680
+ max-height: 200px;
681
  overflow-y: auto;
682
  border: 1px solid gray;
683
  padding: 10px;
684
  border-radius: 5px;
685
  background-color: #f9f9f9;
686
  }
687
+ .button-container {
688
+ display: flex;
689
+ justify-content: flex-end;
690
+ margin-top: 10px;
691
+ }
692
  </style>
693
  """, unsafe_allow_html=True)
 
694
 
695
+ # Scrollable container for saved documents
696
+ st.sidebar.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
697
  try:
698
  docs = db.child("users").child(user_id).child("KnowledgeBase").get().val()
699
  if docs:
700
  for doc_id, doc_data in docs.items():
701
+ st.sidebar.markdown(f"**{doc_data.get('content', 'Document')}**")
702
+ if st.sidebar.button("Delete", key=f"delete_{doc_id}"):
703
+ delete_document(user_id, doc_id)
 
 
 
704
  else:
705
+ st.sidebar.write("No saved documents found.")
706
  except Exception as e:
707
+ st.sidebar.error(f"Error fetching documents: {e}")
708
+ st.sidebar.markdown('</div>', unsafe_allow_html=True)
709
 
710
+ # Buttons aligned beneath the text area
711
+ st.sidebar.markdown('<div class="button-container">', unsafe_allow_html=True)
712
+ uploaded_file = st.sidebar.file_uploader("", label_visibility="collapsed", type=["pdf", "docx", "txt"])
713
 
714
+ # Compact Upload Button
715
+ if st.sidebar.button("Upload"):
716
+ if uploaded_file:
717
+ save_document(user_id, uploaded_file.name)
718
+ else:
719
+ st.sidebar.warning("Please select a file to upload.")
720
+ st.sidebar.markdown('</div>', unsafe_allow_html=True)
721
+
 
 
 
 
 
722
 
723
  # Show Trust Builders Section
724
  st.subheader("Show My TrustBuilders®")