project map script | semantic parcer

This commit is contained in:
2026-01-01 16:58:21 +03:00
parent a747a163c8
commit 4c6fc8256d
84 changed files with 10178 additions and 537 deletions

View File

@@ -15,6 +15,8 @@
let error = "";
let interval;
// [DEF:fetchTasks:Function]
// @PURPOSE: Fetches the list of recent tasks from the API.
async function fetchTasks() {
try {
const res = await fetch('/api/tasks?limit=10');
@@ -41,7 +43,10 @@
loading = false;
}
}
// [/DEF:fetchTasks:Function]
// [DEF:clearTasks:Function]
// @PURPOSE: Clears tasks from the history, optionally filtered by status.
async function clearTasks(status = null) {
if (!confirm('Are you sure you want to clear tasks?')) return;
try {
@@ -57,7 +62,10 @@
error = e.message;
}
}
// [/DEF:clearTasks:Function]
// [DEF:selectTask:Function]
// @PURPOSE: Selects a task and fetches its full details.
async function selectTask(task) {
try {
// Fetch the full task details (including logs) before setting it as selected
@@ -74,7 +82,10 @@
selectedTask.set(task);
}
}
// [/DEF:selectTask:Function]
// [DEF:getStatusColor:Function]
// @PURPOSE: Returns the CSS color class for a given task status.
function getStatusColor(status) {
switch (status) {
case 'SUCCESS': return 'bg-green-100 text-green-800';
@@ -85,15 +96,22 @@
default: return 'bg-gray-100 text-gray-800';
}
}
// [/DEF:getStatusColor:Function]
// [DEF:onMount:Function]
// @PURPOSE: Initializes the component by fetching tasks and starting polling.
onMount(() => {
fetchTasks();
interval = setInterval(fetchTasks, 5000); // Poll every 5s
});
// [/DEF:onMount:Function]
// [DEF:onDestroy:Function]
// @PURPOSE: Cleans up the polling interval when the component is destroyed.
onDestroy(() => {
clearInterval(interval);
});
// [/DEF:onDestroy:Function]
</script>
<div class="bg-white shadow overflow-hidden sm:rounded-lg mb-8">
@@ -176,4 +194,4 @@
</ul>
{/if}
</div>
<!-- [/DEF:TaskHistory] -->
<!-- [/DEF:TaskHistory:Component] -->