File size: 3,405 Bytes
31072e8
81af267
3e98d7b
403a3b3
3e98d7b
a8d2eb4
81af267
 
 
1621223
a6d1f53
 
81af267
c38172e
94ec62e
3e98d7b
a8d2eb4
31072e8
3e98d7b
31072e8
3e98d7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81af267
31072e8
 
 
 
 
 
 
 
 
 
 
3e98d7b
81af267
3e98d7b
81af267
3e98d7b
 
 
 
 
81af267
 
3e98d7b
 
 
81af267
 
 
 
 
3e98d7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8d2eb4
a82f3f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import datetime
import time
import gradio as gr

# Data structures
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"],
}

# Function to update subtasks based on selected category
def update_subtasks(cat):
    choices = subtask_map.get(cat, [])
    return choices, choices[0] if choices else None

# Pomodoro Timer Function
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)  # Simulate the timer
        secs -= 1
        yield time_str, f"🔥 Focusing on: {current_task}"
    yield "00:00", "✅ Session Complete! Take a break."

# Function to track the task records
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)  # Example: Replace with saving logic

# Build Gradio UI
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")
    
    # Timer Section
    duration = gr.Slider(minimum=1, maximum=60, label="Duration (minutes)", value=25)  # Default to 25 minutes
    timer_output = gr.Textbox(label="Timer")
    status_output = gr.Textbox(label="Status Message")
    
    start_button = gr.Button("Start Pomodoro")
    
    # Functionality to start the timer
    start_button.click(fn=handle_timer,
                       inputs=[duration, task],
                       outputs=[timer_output, status_output])
    
    # Tracking Section
    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)  # No output for this one

demo.launch(share="True")