JSenkCC commited on
Commit
adaac82
·
verified ·
1 Parent(s): be656e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -42
app.py CHANGED
@@ -641,7 +641,7 @@ def saved_documentation_page():
641
  def project_view_page():
642
  # Sidebar with logout and return buttons
643
  st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
644
- st.sidebar.title(f"Project: {st.session_state.current_project if st.session_state.current_project else 'No Project Selected'}")
645
  if st.sidebar.button("Back to Project Staging"):
646
  st.session_state.page = "workspace"
647
  st.rerun()
@@ -651,68 +651,44 @@ def project_view_page():
651
  st.session_state.page = "login"
652
  st.rerun()
653
 
654
- # Ensure a project is selected
655
- if not st.session_state.current_project:
656
- st.error("No project selected. Please select a project from the Project Staging page.")
657
- return
658
-
659
  # Main content for project page
660
  st.subheader(f"Project: {st.session_state.current_project}")
661
  st.write("Manage your project and explore its files.")
662
 
663
- # Get project folder path
664
  user_folder = os.path.join("user_projects", st.session_state.username)
665
  project_folder = os.path.join(user_folder, st.session_state.current_project)
 
 
 
666
 
667
- # Check if the project folder exists
668
- if not os.path.exists(project_folder):
669
- st.error(f"Project folder not found: {project_folder}")
670
- return
671
-
672
- # Calculate number of files and lines of code
673
- file_count = 0
674
- total_lines = 0
675
-
676
- for root, dirs, files in os.walk(project_folder):
677
- file_count += len(files)
678
- for file in files:
679
- file_path = os.path.join(root, file)
680
- try:
681
- with open(file_path, "r", encoding="utf-8") as f:
682
- total_lines += sum(1 for line in f)
683
- except (UnicodeDecodeError, FileNotFoundError):
684
- # Skip non-text files or files that can't be read
685
- continue
686
-
687
- # Display project metrics
688
- st.write("### Project Metrics")
689
- st.metric(label="Total Files", value=file_count)
690
- st.metric(label="Lines of Code", value=total_lines)
691
-
692
- # Buttons for documentation functionality (side-by-side)
693
- st.write("### Actions")
694
- col1, col2, col3 = st.columns(3)
695
-
696
  with col1:
 
 
 
 
 
 
 
697
  if st.button("Generate Documentation"):
698
  st.session_state.page = "generate_documentation"
699
  st.rerun()
700
-
701
- with col2:
702
  if st.button("Saved Documentation"):
703
  st.session_state.page = "saved_documentation"
704
  st.rerun()
705
-
706
- with col3:
707
  if st.button("Show File Structure"):
708
  st.session_state.show_file_structure = not st.session_state.show_file_structure
709
 
710
- # Toggle file structure display (if required)
711
  if "show_file_structure" not in st.session_state:
712
  st.session_state.show_file_structure = False
713
 
714
  if st.session_state.show_file_structure:
715
- st.write("### Project File Structure")
716
  for root, dirs, files in os.walk(project_folder):
717
  level = root.replace(project_folder, "").count(os.sep)
718
  indent = " " * 4 * level
@@ -727,6 +703,7 @@ def project_view_page():
727
 
728
 
729
 
 
730
  if __name__ == "__main__":
731
  main()
732
 
 
641
  def project_view_page():
642
  # Sidebar with logout and return buttons
643
  st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
644
+ st.sidebar.title(f"Project: {st.session_state.current_project}")
645
  if st.sidebar.button("Back to Project Staging"):
646
  st.session_state.page = "workspace"
647
  st.rerun()
 
651
  st.session_state.page = "login"
652
  st.rerun()
653
 
 
 
 
 
 
654
  # Main content for project page
655
  st.subheader(f"Project: {st.session_state.current_project}")
656
  st.write("Manage your project and explore its files.")
657
 
658
+ # Calculate project metrics
659
  user_folder = os.path.join("user_projects", st.session_state.username)
660
  project_folder = os.path.join(user_folder, st.session_state.current_project)
661
+ num_files = sum([len(files) for _, _, files in os.walk(project_folder)])
662
+ num_lines = sum([sum(1 for _ in open(os.path.join(root, file), 'r', encoding="utf-8"))
663
+ for root, _, files in os.walk(project_folder) for file in files if file.endswith(".py")])
664
 
665
+ # Display metrics side by side
666
+ col1, col2 = st.columns(2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  with col1:
668
+ st.metric(label="Number of Files", value=num_files)
669
+ with col2:
670
+ st.metric(label="Lines of Code", value=num_lines)
671
+
672
+ # Buttons for documentation functionality displayed side by side
673
+ col3, col4, col5 = st.columns(3)
674
+ with col3:
675
  if st.button("Generate Documentation"):
676
  st.session_state.page = "generate_documentation"
677
  st.rerun()
678
+ with col4:
 
679
  if st.button("Saved Documentation"):
680
  st.session_state.page = "saved_documentation"
681
  st.rerun()
682
+ with col5:
 
683
  if st.button("Show File Structure"):
684
  st.session_state.show_file_structure = not st.session_state.show_file_structure
685
 
686
+ # Display file structure if toggled
687
  if "show_file_structure" not in st.session_state:
688
  st.session_state.show_file_structure = False
689
 
690
  if st.session_state.show_file_structure:
691
+ st.write("File structure:")
692
  for root, dirs, files in os.walk(project_folder):
693
  level = root.replace(project_folder, "").count(os.sep)
694
  indent = " " * 4 * level
 
703
 
704
 
705
 
706
+
707
  if __name__ == "__main__":
708
  main()
709