Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,31 +11,35 @@ def main():
|
|
11 |
task_manager = TaskManager()
|
12 |
visualizer = TaskVisualizer()
|
13 |
|
|
|
14 |
task_name = st.text_input("Task Name")
|
15 |
task_time = st.time_input("Task Time")
|
16 |
task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d")
|
17 |
task_duration_minutes = st.number_input("Task Duration (Minutes)", min_value=0, max_value=59, step=1, format="%d")
|
18 |
-
|
19 |
task_category = st.selectbox("Task Category", TaskManager.CATEGORIES)
|
20 |
|
|
|
21 |
if st.button("Add Task"):
|
22 |
task_manager.add_task(task_name, task_time, task_duration_hours, task_duration_minutes, task_category)
|
23 |
st.success(f"Task '{task_name}' added!")
|
24 |
|
|
|
25 |
if st.session_state.tasks:
|
26 |
st.write("Today's Tasks:")
|
27 |
df = pd.DataFrame(st.session_state.tasks)
|
28 |
df['Task Duration (hours)'] = df['Task Duration (hours)'].astype(int)
|
29 |
df['Task Duration (minutes)'] = df['Task Duration (minutes)'].astype(int)
|
30 |
-
st.table(df[['Task Name', 'Task Time', 'Task Duration (hours)', 'Task Duration (minutes)', 'Category']])
|
31 |
|
32 |
-
|
|
|
33 |
if st.button("Delete Task"):
|
34 |
-
if task_manager.
|
35 |
-
st.success(f"Task '{
|
36 |
else:
|
37 |
-
st.error(f"Task '{
|
38 |
|
|
|
39 |
if st.button("Daily Report"):
|
40 |
report = task_manager.generate_report('daily')
|
41 |
if not report.empty:
|
@@ -45,6 +49,7 @@ def main():
|
|
45 |
else:
|
46 |
st.warning("No tasks for today.")
|
47 |
|
|
|
48 |
if st.button("Weekly Report"):
|
49 |
report = task_manager.generate_report('weekly')
|
50 |
if not report.empty:
|
@@ -54,6 +59,7 @@ def main():
|
|
54 |
else:
|
55 |
st.warning("No tasks for this week.")
|
56 |
|
|
|
57 |
if st.button("Monthly Report"):
|
58 |
report = task_manager.generate_report('monthly')
|
59 |
if not report.empty:
|
@@ -63,6 +69,7 @@ def main():
|
|
63 |
else:
|
64 |
st.warning("No tasks for this month.")
|
65 |
|
|
|
66 |
if st.button("Yearly Report"):
|
67 |
report = task_manager.generate_report('yearly')
|
68 |
if not report.empty:
|
@@ -72,6 +79,7 @@ def main():
|
|
72 |
else:
|
73 |
st.warning("No tasks for this year.")
|
74 |
|
|
|
75 |
visualizer.plot_performance()
|
76 |
visualizer.plot_overall_category_performance()
|
77 |
visualizer.download_report()
|
|
|
11 |
task_manager = TaskManager()
|
12 |
visualizer = TaskVisualizer()
|
13 |
|
14 |
+
# Input fields for adding a task
|
15 |
task_name = st.text_input("Task Name")
|
16 |
task_time = st.time_input("Task Time")
|
17 |
task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d")
|
18 |
task_duration_minutes = st.number_input("Task Duration (Minutes)", min_value=0, max_value=59, step=1, format="%d")
|
|
|
19 |
task_category = st.selectbox("Task Category", TaskManager.CATEGORIES)
|
20 |
|
21 |
+
# Button to add a task
|
22 |
if st.button("Add Task"):
|
23 |
task_manager.add_task(task_name, task_time, task_duration_hours, task_duration_minutes, task_category)
|
24 |
st.success(f"Task '{task_name}' added!")
|
25 |
|
26 |
+
# Display the tasks in a table format with Task ID
|
27 |
if st.session_state.tasks:
|
28 |
st.write("Today's Tasks:")
|
29 |
df = pd.DataFrame(st.session_state.tasks)
|
30 |
df['Task Duration (hours)'] = df['Task Duration (hours)'].astype(int)
|
31 |
df['Task Duration (minutes)'] = df['Task Duration (minutes)'].astype(int)
|
32 |
+
st.table(df[['Task ID', 'Task Name', 'Task Time', 'Task Duration (hours)', 'Task Duration (minutes)', 'Category']]) # Include Task ID here
|
33 |
|
34 |
+
# Input field for deleting a task by ID
|
35 |
+
task_id_to_delete = st.text_input("Enter Task ID to Delete") # Task ID instead of Task Name
|
36 |
if st.button("Delete Task"):
|
37 |
+
if task_manager.delete_task_by_id(task_id_to_delete): # Delete by Task ID
|
38 |
+
st.success(f"Task with ID '{task_id_to_delete}' deleted!")
|
39 |
else:
|
40 |
+
st.error(f"Task with ID '{task_id_to_delete}' not found.")
|
41 |
|
42 |
+
# Daily Report
|
43 |
if st.button("Daily Report"):
|
44 |
report = task_manager.generate_report('daily')
|
45 |
if not report.empty:
|
|
|
49 |
else:
|
50 |
st.warning("No tasks for today.")
|
51 |
|
52 |
+
# Weekly Report
|
53 |
if st.button("Weekly Report"):
|
54 |
report = task_manager.generate_report('weekly')
|
55 |
if not report.empty:
|
|
|
59 |
else:
|
60 |
st.warning("No tasks for this week.")
|
61 |
|
62 |
+
# Monthly Report
|
63 |
if st.button("Monthly Report"):
|
64 |
report = task_manager.generate_report('monthly')
|
65 |
if not report.empty:
|
|
|
69 |
else:
|
70 |
st.warning("No tasks for this month.")
|
71 |
|
72 |
+
# Yearly Report
|
73 |
if st.button("Yearly Report"):
|
74 |
report = task_manager.generate_report('yearly')
|
75 |
if not report.empty:
|
|
|
79 |
else:
|
80 |
st.warning("No tasks for this year.")
|
81 |
|
82 |
+
# Visualizer Plots
|
83 |
visualizer.plot_performance()
|
84 |
visualizer.plot_overall_category_performance()
|
85 |
visualizer.download_report()
|