# app.py import streamlit as st from task_operations import TaskManager from task_visualization import TaskVisualizer import pandas as pd def main(): st.title("Jony Daily Task Tracker") task_manager = TaskManager() visualizer = TaskVisualizer() # Input fields for adding a task task_name = st.text_input("Task Name") task_time = st.time_input("Task Time") task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d") task_duration_minutes = st.number_input("Task Duration (Minutes)", min_value=0, max_value=59, step=1, format="%d") task_category = st.selectbox("Task Category", TaskManager.CATEGORIES) # Button to add a task if st.button("Add Task"): task_manager.add_task(task_name, task_time, task_duration_hours, task_duration_minutes, task_category) st.success(f"Task '{task_name}' added!") # Display the tasks in a table format with Task ID if st.session_state.tasks: st.write("Today's Tasks:") df = pd.DataFrame(st.session_state.tasks) df['Task Duration (hours)'] = df['Task Duration (hours)'].astype(int) df['Task Duration (minutes)'] = df['Task Duration (minutes)'].astype(int) st.table(df[['Task ID', 'Task Name', 'Task Time', 'Task Duration (hours)', 'Task Duration (minutes)', 'Category']]) # Include Task ID here # Input field for deleting a task by ID task_id_to_delete = st.text_input("Enter Task ID to Delete") # Task ID instead of Task Name if st.button("Delete Task"): if task_manager.delete_task_by_id(task_id_to_delete): # Delete by Task ID st.success(f"Task with ID '{task_id_to_delete}' deleted!") else: st.error(f"Task with ID '{task_id_to_delete}' not found.") # Daily Report if st.button("Daily Report"): report = task_manager.generate_report('daily') if not report.empty: st.write("Daily Report:") st.dataframe(report) visualizer.plot_category_performance('daily', task_manager) else: st.warning("No tasks for today.") # Weekly Report if st.button("Weekly Report"): report = task_manager.generate_report('weekly') if not report.empty: st.write("Weekly Report:") st.dataframe(report) visualizer.plot_category_performance('weekly', task_manager) else: st.warning("No tasks for this week.") # Monthly Report if st.button("Monthly Report"): report = task_manager.generate_report('monthly') if not report.empty: st.write("Monthly Report:") st.dataframe(report) visualizer.plot_category_performance('monthly', task_manager) else: st.warning("No tasks for this month.") # Yearly Report if st.button("Yearly Report"): report = task_manager.generate_report('yearly') if not report.empty: st.write("Yearly Report:") st.dataframe(report) visualizer.plot_category_performance('yearly', task_manager) else: st.warning("No tasks for this year.") # Visualizer Plots visualizer.plot_performance() visualizer.plot_overall_category_performance() visualizer.download_report() if __name__ == "__main__": main()