Update app.py
Browse files
app.py
CHANGED
@@ -102,10 +102,14 @@ def workspace_page():
|
|
102 |
st.session_state.username = None
|
103 |
st.session_state.page = "login"
|
104 |
|
105 |
-
#
|
106 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
107 |
os.makedirs(user_folder, exist_ok=True)
|
|
|
|
|
108 |
projects = [d for d in os.listdir(user_folder) if os.path.isdir(os.path.join(user_folder, d))]
|
|
|
|
|
109 |
selected_project = st.sidebar.selectbox("Projects", ["Select a project"] + projects)
|
110 |
|
111 |
if selected_project != "Select a project":
|
@@ -150,7 +154,10 @@ def workspace_page():
|
|
150 |
st.error(f"File {uploaded_file.name} is not a valid .zip file.")
|
151 |
else:
|
152 |
st.success(f"File {uploaded_file.name} saved successfully!")
|
|
|
153 |
st.success(f"Project '{project_name}' uploaded successfully!")
|
|
|
|
|
154 |
|
155 |
elif action == "Clone GitHub Repository":
|
156 |
st.subheader("Clone GitHub Repository")
|
@@ -164,9 +171,12 @@ def workspace_page():
|
|
164 |
try:
|
165 |
Repo.clone_from(repo_url, project_folder)
|
166 |
st.success(f"Project '{project_name}' cloned successfully!")
|
|
|
|
|
167 |
except Exception as e:
|
168 |
st.error(f"Failed to clone repository: {e}")
|
169 |
|
|
|
170 |
def project_view_page():
|
171 |
# Sidebar with logout and return buttons
|
172 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|
|
|
102 |
st.session_state.username = None
|
103 |
st.session_state.page = "login"
|
104 |
|
105 |
+
# User's folder for projects
|
106 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
107 |
os.makedirs(user_folder, exist_ok=True)
|
108 |
+
|
109 |
+
# Refresh project list after every interaction
|
110 |
projects = [d for d in os.listdir(user_folder) if os.path.isdir(os.path.join(user_folder, d))]
|
111 |
+
|
112 |
+
# Display "Projects" dropdown
|
113 |
selected_project = st.sidebar.selectbox("Projects", ["Select a project"] + projects)
|
114 |
|
115 |
if selected_project != "Select a project":
|
|
|
154 |
st.error(f"File {uploaded_file.name} is not a valid .zip file.")
|
155 |
else:
|
156 |
st.success(f"File {uploaded_file.name} saved successfully!")
|
157 |
+
|
158 |
st.success(f"Project '{project_name}' uploaded successfully!")
|
159 |
+
# Refresh the project list immediately
|
160 |
+
projects.append(project_name)
|
161 |
|
162 |
elif action == "Clone GitHub Repository":
|
163 |
st.subheader("Clone GitHub Repository")
|
|
|
171 |
try:
|
172 |
Repo.clone_from(repo_url, project_folder)
|
173 |
st.success(f"Project '{project_name}' cloned successfully!")
|
174 |
+
# Refresh the project list immediately
|
175 |
+
projects.append(project_name)
|
176 |
except Exception as e:
|
177 |
st.error(f"Failed to clone repository: {e}")
|
178 |
|
179 |
+
|
180 |
def project_view_page():
|
181 |
# Sidebar with logout and return buttons
|
182 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|