Update app.py
Browse files
app.py
CHANGED
|
@@ -95,42 +95,50 @@ 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 == "View
|
| 99 |
-
st.
|
| 100 |
-
|
| 101 |
-
for
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|
| 134 |
+
if submit and task:
|
| 135 |
+
db.collection("tasks").add({
|
| 136 |
+
"user": email,
|
| 137 |
+
"task": task,
|
| 138 |
+
"type": task_type,
|
| 139 |
+
"project": selected_project,
|
| 140 |
+
"status": status,
|
| 141 |
+
"date": str(date)
|
| 142 |
+
})
|
| 143 |
+
st.success("Task Added Successfully!")
|
| 144 |
+
st.rerun()
|