shamimjony1000 commited on
Commit
054265f
·
verified ·
1 Parent(s): 316149f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -2,21 +2,30 @@
2
 
3
  import streamlit as st
4
  from task_operations import TaskManager
5
- from task_visualization import TaskVisualizer
6
  import pandas as pd
7
  from datetime import datetime
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def main():
10
  st.title("Daily Task Tracker")
11
 
12
  task_manager = TaskManager()
13
- visualizer = TaskVisualizer()
14
 
15
  # Ensure tasks are loaded from the database into session state
16
  if 'tasks' not in st.session_state:
17
  st.session_state.tasks = task_manager.load_tasks()
18
 
19
- # Task input fields
20
  task_name = st.text_input("Task Name")
21
  task_time = st.time_input("Task Time")
22
  task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d")
@@ -51,13 +60,16 @@ def main():
51
  else:
52
  st.error(f"Task with ID '{task_id_to_delete}' not found.")
53
 
 
 
 
 
54
  # Report options and other visualizations are unchanged
55
  if st.button("Daily Report"):
56
  report = task_manager.generate_report('daily')
57
  if not report.empty:
58
  st.write("Daily Report:")
59
  st.dataframe(report)
60
- visualizer.plot_category_performance('daily', task_manager)
61
  else:
62
  st.warning("No tasks for today.")
63
 
@@ -66,7 +78,6 @@ def main():
66
  if not report.empty:
67
  st.write("Weekly Report:")
68
  st.dataframe(report)
69
- visualizer.plot_category_performance('weekly', task_manager)
70
  else:
71
  st.warning("No tasks for this week.")
72
 
@@ -75,7 +86,6 @@ def main():
75
  if not report.empty:
76
  st.write("Monthly Report:")
77
  st.dataframe(report)
78
- visualizer.plot_category_performance('monthly', task_manager)
79
  else:
80
  st.warning("No tasks for this month.")
81
 
@@ -84,16 +94,8 @@ def main():
84
  if not report.empty:
85
  st.write("Yearly Report:")
86
  st.dataframe(report)
87
- visualizer.plot_category_performance('yearly', task_manager)
88
  else:
89
  st.warning("No tasks for this year.")
90
 
91
- # Performance visualizations
92
- visualizer.plot_performance()
93
- visualizer.plot_overall_category_performance()
94
-
95
- # Option to download the report
96
- visualizer.download_report()
97
-
98
  if __name__ == "__main__":
99
  main()
 
2
 
3
  import streamlit as st
4
  from task_operations import TaskManager
 
5
  import pandas as pd
6
  from datetime import datetime
7
+ import os
8
+
9
+ def download_file(filepath):
10
+ """Allows downloading of the specified file."""
11
+ with open(filepath, "rb") as f:
12
+ st.download_button(
13
+ label="Download Database",
14
+ data=f,
15
+ file_name=os.path.basename(filepath),
16
+ mime="application/octet-stream"
17
+ )
18
 
19
  def main():
20
  st.title("Daily Task Tracker")
21
 
22
  task_manager = TaskManager()
 
23
 
24
  # Ensure tasks are loaded from the database into session state
25
  if 'tasks' not in st.session_state:
26
  st.session_state.tasks = task_manager.load_tasks()
27
 
28
+ # Task input fields for adding new tasks
29
  task_name = st.text_input("Task Name")
30
  task_time = st.time_input("Task Time")
31
  task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d")
 
60
  else:
61
  st.error(f"Task with ID '{task_id_to_delete}' not found.")
62
 
63
+ # Add a button to download the task.db file
64
+ if st.button("Download Database"):
65
+ download_file("tasks.db") # Adjust the filename if needed
66
+
67
  # Report options and other visualizations are unchanged
68
  if st.button("Daily Report"):
69
  report = task_manager.generate_report('daily')
70
  if not report.empty:
71
  st.write("Daily Report:")
72
  st.dataframe(report)
 
73
  else:
74
  st.warning("No tasks for today.")
75
 
 
78
  if not report.empty:
79
  st.write("Weekly Report:")
80
  st.dataframe(report)
 
81
  else:
82
  st.warning("No tasks for this week.")
83
 
 
86
  if not report.empty:
87
  st.write("Monthly Report:")
88
  st.dataframe(report)
 
89
  else:
90
  st.warning("No tasks for this month.")
91
 
 
94
  if not report.empty:
95
  st.write("Yearly Report:")
96
  st.dataframe(report)
 
97
  else:
98
  st.warning("No tasks for this year.")
99
 
 
 
 
 
 
 
 
100
  if __name__ == "__main__":
101
  main()