| import datetime |
| import time |
| import gradio as gr |
|
|
| |
| subtask_map = { |
| "Investment": ["control and compliance", "Industry/peers research", "Stock information", "Manage and circulate news to existing customers", "Selling"], |
| "Leasing": ["Investment efficiency", "Credit-Nhóm nợ vay", "Debt collect and check-up for business feasibility"], |
| "Admin-Payment/Payroll": ["Chamber's social and communication", "Inquiries/Billings/Invoices", "Payment/Banking", "Accounting Schedules", "managed Stakeholders"], |
| "Psychology": ["Psychology", "Reflection-Journal", "Deep thinking"], |
| "ADHD": ["Focus Strategies", "Workflow", "Organization", "Deep-thinking/Cognitive", "Stressed/Burnout"], |
| "Soft skill": ["Networking-Linkedin"], |
| "Technology": ["Excel Automation", "Data cleaning and manipulation", "AI skills"], |
| } |
|
|
| |
| def update_subtasks(cat): |
| choices = subtask_map.get(cat, []) |
| return choices, choices[0] if choices else None |
|
|
| |
| def handle_timer(duration, current_task): |
| if not current_task: |
| return "00:00", "⚠️ Please select a task!" |
| |
| secs = duration * 60 |
| while secs >= 0: |
| mins, s = divmod(secs, 60) |
| time_str = f"{mins:02d}:{s:02d}" |
| time.sleep(1) |
| secs -= 1 |
| yield time_str, f"🔥 Focusing on: {current_task}" |
| yield "00:00", "✅ Session Complete! Take a break." |
|
|
| |
| def track_task(cat, task, bg, curr, target, root, confirm, follow): |
| new_row = { |
| "Date": datetime.date.today().strftime("%d/%m"), |
| "Category": cat, |
| "Task": task, |
| "Background": bg, |
| "Current condition": curr, |
| "Goal/Target condition": target, |
| "Root Cause Analysis": root, |
| "Confirmation": confirm, |
| "Follow-up": follow |
| } |
| print(new_row) |
|
|
| |
| with gr.Blocks() as demo: |
| with gr.Row(): |
| category = gr.Dropdown(choices=list(subtask_map.keys()), label="Select Category", value=list(subtask_map.keys())[0]) |
| subtask = gr.Dropdown(label="Select Subtask", value="") |
| |
| category.change(fn=update_subtasks, inputs=category, outputs=subtask) |
| |
| task = gr.Textbox(label="Current Task") |
| |
| |
| duration = gr.Slider(minimum=1, maximum=60, label="Duration (minutes)", value=25) |
| timer_output = gr.Textbox(label="Timer") |
| status_output = gr.Textbox(label="Status Message") |
| |
| start_button = gr.Button("Start Pomodoro") |
| |
| |
| start_button.click(fn=handle_timer, |
| inputs=[duration, task], |
| outputs=[timer_output, status_output]) |
| |
| |
| bg = gr.Textbox(label="Background") |
| curr = gr.Textbox(label="Current Condition") |
| target = gr.Textbox(label="Goal/Target Condition") |
| root = gr.Textbox(label="Root Cause Analysis") |
| confirm = gr.Checkbox(label="Confirmation") |
| follow = gr.Textbox(label="Follow-up Actions") |
| |
| submit_btn = gr.Button("Record Task") |
| submit_btn.click(fn=track_task, |
| inputs=[category, subtask, bg, curr, target, root, confirm, follow], |
| outputs=None) |
|
|
| demo.launch(share="True") |