arif670 commited on
Commit
a03ef71
Β·
verified Β·
1 Parent(s): ca3cafc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -26
app.py CHANGED
@@ -92,42 +92,18 @@ if not st.session_state["authenticated"]:
92
 
93
  # Main Dashboard After Login
94
  st.sidebar.title(f"Welcome, {st.session_state['email']}")
95
- menu = st.sidebar.radio("Go to", ["Dashboard View", "Task Entry", "View Tasks by Status"])
96
  email = st.session_state['email']
97
 
98
- if menu == "Dashboard View":
99
- st.title("πŸ“Š Dashboard Overview")
100
- tasks_ref = db.collection("tasks").where(filter=firestore.FieldFilter("user", "==", email))
101
- tasks = [task.to_dict() for task in tasks_ref.stream()]
102
- df = pd.DataFrame(tasks) if tasks else pd.DataFrame()
103
-
104
- if not df.empty and "status" in df.columns:
105
- col1, col2 = st.columns(2)
106
- col1.metric("Total Tasks", len(df))
107
- col1.metric("Pending Tasks", len(df[df['status'] == "Pending"]))
108
- col2.metric("In Progress Tasks", len(df[df['status'] == "In Progress"]))
109
- col2.metric("Completed Tasks", len(df[df['status'] == "Completed"]))
110
-
111
- fig = px.pie(df, names='status', title='Task Status Distribution')
112
- st.plotly_chart(fig)
113
- else:
114
- st.warning("No tasks found for the user.")
115
-
116
- elif menu == "Task Entry":
117
  st.title("πŸ“ Add New Task")
118
  projects_ref = db.collection("projects")
119
  projects = [proj.id for proj in projects_ref.stream()]
120
- projects.append("Add New Project")
121
 
122
  with st.form("task_form"):
123
  task = st.text_input("Task Description:")
124
  task_type = st.selectbox("Task Type:", ["Design", "Procurement", "Construction", "Testing", "Other"])
125
  selected_project = st.selectbox("Project Name:", projects)
126
- if selected_project == "Add New Project":
127
- new_project = st.text_input("Enter New Project Name:")
128
- if new_project:
129
- db.collection("projects").document(new_project).set({"created_by": email})
130
- selected_project = new_project
131
  status = st.selectbox("Status:", ["Pending", "In Progress", "Completed"])
132
  date = st.date_input("Task Date:")
133
  submit = st.form_submit_button("Add Task")
@@ -142,3 +118,13 @@ elif menu == "Task Entry":
142
  })
143
  st.success("Task Added Successfully!")
144
  st.rerun()
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  # Main Dashboard After Login
94
  st.sidebar.title(f"Welcome, {st.session_state['email']}")
95
+ menu = st.sidebar.radio("Go to", ["Dashboard View", "Task Entry", "View Tasks by Status", "Add New Project"])
96
  email = st.session_state['email']
97
 
98
+ if menu == "Task Entry":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  st.title("πŸ“ Add New Task")
100
  projects_ref = db.collection("projects")
101
  projects = [proj.id for proj in projects_ref.stream()]
 
102
 
103
  with st.form("task_form"):
104
  task = st.text_input("Task Description:")
105
  task_type = st.selectbox("Task Type:", ["Design", "Procurement", "Construction", "Testing", "Other"])
106
  selected_project = st.selectbox("Project Name:", projects)
 
 
 
 
 
107
  status = st.selectbox("Status:", ["Pending", "In Progress", "Completed"])
108
  date = st.date_input("Task Date:")
109
  submit = st.form_submit_button("Add Task")
 
118
  })
119
  st.success("Task Added Successfully!")
120
  st.rerun()
121
+
122
+ elif menu == "Add New Project":
123
+ st.title("πŸ—οΈ Add New Project")
124
+ with st.form("project_form"):
125
+ new_project_name = st.text_input("Enter New Project Name:")
126
+ submit_project = st.form_submit_button("Add Project")
127
+ if submit_project and new_project_name:
128
+ db.collection("projects").document(new_project_name).set({"created_by": email})
129
+ st.success("Project Added Successfully!")
130
+ st.rerun()