Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -57,25 +57,25 @@ def get_tasks_by_type(task_type):
|
|
| 57 |
def add_new_task_type(new_type):
|
| 58 |
if new_type and new_type not in TASK_TYPES:
|
| 59 |
TASK_TYPES.append(new_type)
|
| 60 |
-
return gr.update(choices=TASK_TYPES), f"Task type '{new_type}' added successfully!"
|
| 61 |
-
return gr.update(choices=TASK_TYPES), "Task type already exists or invalid input."
|
| 62 |
|
| 63 |
# Function to display tasks as clickable cards
|
| 64 |
def display_tasks(task_type):
|
| 65 |
tasks = get_tasks_by_type(task_type)
|
| 66 |
-
html_content = "<div style='display: flex; flex-wrap: wrap; gap: 10px;'>"
|
| 67 |
for idx, task in enumerate(tasks):
|
| 68 |
color = random.choice(CARD_COLORS)
|
| 69 |
html_content += f"""
|
| 70 |
-
<div style='background-color: {color}; padding: 10px; border-radius: 5px; cursor: pointer;' onclick="document.getElementById('task-details-{idx}').style.display='block';">
|
| 71 |
<b>{task['description']}</b>
|
| 72 |
</div>
|
| 73 |
<div id='task-details-{idx}' style='display: none; margin-top: 10px; border: 1px solid #ccc; background: #fff; padding: 10px; border-radius: 5px;'>
|
| 74 |
<b>Task Type:</b> {task['task_type']}<br>
|
| 75 |
<b>Description:</b> {task['description']}<br>
|
| 76 |
<b>YAML/Text:</b><pre>{task['yaml']}</pre>
|
| 77 |
-
<button style='margin-top: 10px;' onclick="document.getElementById('task-details-{idx}').style.display='none';">Close</button>
|
| 78 |
-
<span style='cursor: pointer; float: right; font-size: 18px;' onclick="document.getElementById('task-details-{idx}').style.display='none';">×</span>
|
| 79 |
</div>
|
| 80 |
"""
|
| 81 |
html_content += "</div>"
|
|
@@ -122,7 +122,7 @@ with gr.Blocks() as app:
|
|
| 122 |
add_task_button.click(
|
| 123 |
add_new_task_type,
|
| 124 |
inputs=[new_task_input],
|
| 125 |
-
outputs=[task_type_input, add_task_status] # Update dropdown and status
|
| 126 |
)
|
| 127 |
|
| 128 |
# Handle task submission
|
|
|
|
| 57 |
def add_new_task_type(new_type):
|
| 58 |
if new_type and new_type not in TASK_TYPES:
|
| 59 |
TASK_TYPES.append(new_type)
|
| 60 |
+
return gr.update(choices=TASK_TYPES), gr.update(choices=TASK_TYPES), f"Task type '{new_type}' added successfully!"
|
| 61 |
+
return gr.update(choices=TASK_TYPES), gr.update(choices=TASK_TYPES), "Task type already exists or invalid input."
|
| 62 |
|
| 63 |
# Function to display tasks as clickable cards
|
| 64 |
def display_tasks(task_type):
|
| 65 |
tasks = get_tasks_by_type(task_type)
|
| 66 |
+
html_content = "<div style='display: flex; flex-wrap: wrap; gap: 10px; color: #000;'>"
|
| 67 |
for idx, task in enumerate(tasks):
|
| 68 |
color = random.choice(CARD_COLORS)
|
| 69 |
html_content += f"""
|
| 70 |
+
<div style='background-color: {color}; color: #000; padding: 10px; border-radius: 5px; cursor: pointer;' onclick="document.getElementById('task-details-{idx}').style.display='block';">
|
| 71 |
<b>{task['description']}</b>
|
| 72 |
</div>
|
| 73 |
<div id='task-details-{idx}' style='display: none; margin-top: 10px; border: 1px solid #ccc; background: #fff; padding: 10px; border-radius: 5px;'>
|
| 74 |
<b>Task Type:</b> {task['task_type']}<br>
|
| 75 |
<b>Description:</b> {task['description']}<br>
|
| 76 |
<b>YAML/Text:</b><pre>{task['yaml']}</pre>
|
| 77 |
+
<button style='margin-top: 10px; color: #000;' onclick="document.getElementById('task-details-{idx}').style.display='none';">Close</button>
|
| 78 |
+
<span style='cursor: pointer; float: right; font-size: 18px; color: #000;' onclick="document.getElementById('task-details-{idx}').style.display='none';">×</span>
|
| 79 |
</div>
|
| 80 |
"""
|
| 81 |
html_content += "</div>"
|
|
|
|
| 122 |
add_task_button.click(
|
| 123 |
add_new_task_type,
|
| 124 |
inputs=[new_task_input],
|
| 125 |
+
outputs=[task_type_input, task_type_filter, add_task_status] # Update dropdown and status
|
| 126 |
)
|
| 127 |
|
| 128 |
# Handle task submission
|