Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -64,6 +64,63 @@ def add_new_task_type(new_type):
|
|
| 64 |
def switch_tab(tab_name):
|
| 65 |
return gr.Tabs.update(visible_tab=tab_name)
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
# Gradio App
|
| 68 |
with gr.Blocks() as app:
|
| 69 |
gr.Markdown("# Task Configuration Sharing Space")
|
|
@@ -135,26 +192,6 @@ with gr.Blocks() as app:
|
|
| 135 |
task_display = gr.HTML(label="Submitted Tasks")
|
| 136 |
go_to_submit_tab = gr.Button("Go to Submit Task")
|
| 137 |
|
| 138 |
-
# Function to display tasks as clickable cards
|
| 139 |
-
def display_tasks(task_type):
|
| 140 |
-
tasks = get_tasks_by_type(task_type)
|
| 141 |
-
html_content = "<div style='display: flex; flex-wrap: wrap; gap: 10px;'>"
|
| 142 |
-
for idx, task in enumerate(tasks):
|
| 143 |
-
color = random.choice(CARD_COLORS)
|
| 144 |
-
html_content += f"""
|
| 145 |
-
<div style='background-color: {color}; padding: 10px; border-radius: 5px; cursor: pointer;' onclick="document.getElementById('task-details-{idx}').style.display='block';">
|
| 146 |
-
<b>{task['description']}</b>
|
| 147 |
-
</div>
|
| 148 |
-
<div id='task-details-{idx}' style='display: none; margin-top: 10px;'>
|
| 149 |
-
<b>Task Type:</b> {task['task_type']}<br>
|
| 150 |
-
<b>Description:</b> {task['description']}<br>
|
| 151 |
-
<b>YAML/Text:</b><pre>{task['yaml']}</pre>
|
| 152 |
-
<hr>
|
| 153 |
-
</div>
|
| 154 |
-
"""
|
| 155 |
-
html_content += "</div>"
|
| 156 |
-
return html_content
|
| 157 |
-
|
| 158 |
# Handle task display
|
| 159 |
view_button.click(
|
| 160 |
display_tasks,
|
|
@@ -169,4 +206,4 @@ with gr.Blocks() as app:
|
|
| 169 |
outputs=[tabs]
|
| 170 |
)
|
| 171 |
|
| 172 |
-
app.launch()
|
|
|
|
| 64 |
def switch_tab(tab_name):
|
| 65 |
return gr.Tabs.update(visible_tab=tab_name)
|
| 66 |
|
| 67 |
+
# Function to display tasks as clickable cards with modal popups
|
| 68 |
+
def display_tasks(task_type):
|
| 69 |
+
tasks = get_tasks_by_type(task_type)
|
| 70 |
+
html_content = """
|
| 71 |
+
<style>
|
| 72 |
+
.modal {{
|
| 73 |
+
display: none;
|
| 74 |
+
position: fixed;
|
| 75 |
+
z-index: 1;
|
| 76 |
+
left: 0;
|
| 77 |
+
top: 0;
|
| 78 |
+
width: 100%;
|
| 79 |
+
height: 100%;
|
| 80 |
+
overflow: auto;
|
| 81 |
+
background-color: rgba(0,0,0,0.4);
|
| 82 |
+
}}
|
| 83 |
+
.modal-content {{
|
| 84 |
+
background-color: #fefefe;
|
| 85 |
+
margin: 15% auto;
|
| 86 |
+
padding: 20px;
|
| 87 |
+
border: 1px solid #888;
|
| 88 |
+
width: 80%;
|
| 89 |
+
border-radius: 10px;
|
| 90 |
+
}}
|
| 91 |
+
.close {{
|
| 92 |
+
color: #aaa;
|
| 93 |
+
float: right;
|
| 94 |
+
font-size: 28px;
|
| 95 |
+
font-weight: bold;
|
| 96 |
+
}}
|
| 97 |
+
.close:hover,
|
| 98 |
+
.close:focus {{
|
| 99 |
+
color: black;
|
| 100 |
+
text-decoration: none;
|
| 101 |
+
cursor: pointer;
|
| 102 |
+
}}
|
| 103 |
+
</style>
|
| 104 |
+
"""
|
| 105 |
+
html_content += "<div style='display: flex; flex-wrap: wrap; gap: 10px;'>"
|
| 106 |
+
for idx, task in enumerate(tasks):
|
| 107 |
+
color = random.choice(CARD_COLORS)
|
| 108 |
+
html_content += f"""
|
| 109 |
+
<div style='background-color: {color}; padding: 10px; border-radius: 5px; cursor: pointer;' onclick="document.getElementById('modal-{idx}').style.display='block';">
|
| 110 |
+
<b>{task['description']}</b>
|
| 111 |
+
</div>
|
| 112 |
+
<div id='modal-{idx}' class='modal'>
|
| 113 |
+
<div class='modal-content'>
|
| 114 |
+
<span class='close' onclick="document.getElementById('modal-{idx}').style.display='none';">×</span>
|
| 115 |
+
<b>Task Type:</b> {task['task_type']}<br>
|
| 116 |
+
<b>Description:</b> {task['description']}<br>
|
| 117 |
+
<b>YAML/Text:</b><pre>{task['yaml']}</pre>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
"""
|
| 121 |
+
html_content += "</div>"
|
| 122 |
+
return html_content
|
| 123 |
+
|
| 124 |
# Gradio App
|
| 125 |
with gr.Blocks() as app:
|
| 126 |
gr.Markdown("# Task Configuration Sharing Space")
|
|
|
|
| 192 |
task_display = gr.HTML(label="Submitted Tasks")
|
| 193 |
go_to_submit_tab = gr.Button("Go to Submit Task")
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
# Handle task display
|
| 196 |
view_button.click(
|
| 197 |
display_tasks,
|
|
|
|
| 206 |
outputs=[tabs]
|
| 207 |
)
|
| 208 |
|
| 209 |
+
app.launch()
|