i18 cleanup

This commit is contained in:
2026-02-25 18:31:50 +03:00
parent 99f19ac305
commit 5d42a6b930
48 changed files with 1431 additions and 808 deletions

View File

@@ -10,6 +10,7 @@
import { onMount, onDestroy } from 'svelte';
import { selectedTask } from '../lib/stores.js';
import { api } from '../lib/api.js';
import { t } from '../lib/i18n';
let tasks = [];
let loading = true;
@@ -51,7 +52,7 @@
// @PRE: User confirms deletion via prompt.
// @POST: Tasks are deleted from backend and list is re-fetched.
async function clearTasks(status = null) {
if (!confirm('Are you sure you want to clear tasks?')) return;
if (!confirm($t.tasks?.clear_confirm )) return;
try {
let endpoint = '/tasks';
if (status) endpoint += `?status=${status}`;
@@ -74,7 +75,7 @@
const fullTask = await api.getTask(task.id);
selectedTask.set(fullTask);
} catch (e) {
console.error("Failed to fetch full task details:", e);
console.error($t.tasks?.fetch_task_details_failed , e);
selectedTask.set(task);
}
}
@@ -119,21 +120,21 @@
<div class="bg-white shadow overflow-hidden sm:rounded-lg mb-8">
<div class="px-4 py-5 sm:px-6 flex justify-between items-center">
<h3 class="text-lg leading-6 font-medium text-gray-900">
Recent Tasks
{$t.tasks?.recent }
</h3>
<div class="flex space-x-4 items-center">
<div class="relative inline-block text-left group">
<button class="text-sm text-red-600 hover:text-red-900 focus:outline-none flex items-center py-2">
Clear Tasks
{$t.tasks?.clear_tasks }
<svg class="ml-1 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<!-- Added a transparent bridge to prevent menu closing when moving cursor -->
<div class="absolute h-2 w-full top-full left-0"></div>
<div class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none hidden group-hover:block z-50">
<div class="py-1">
<button on:click={() => clearTasks()} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Clear All Non-Running</button>
<button on:click={() => clearTasks('FAILED')} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Clear Failed</button>
<button on:click={() => clearTasks('AWAITING_INPUT')} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Clear Awaiting Input</button>
<button on:click={() => clearTasks()} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">{$t.tasks?.clear_non_running }</button>
<button on:click={() => clearTasks('FAILED')} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">{$t.tasks?.clear_failed }</button>
<button on:click={() => clearTasks('AWAITING_INPUT')} class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">{$t.tasks?.clear_awaiting_input }</button>
</div>
</div>
</div>
@@ -141,17 +142,17 @@
on:click={fetchTasks}
class="text-sm text-indigo-600 hover:text-indigo-900 focus:outline-none"
>
Refresh
{$t.common?.refresh }
</button>
</div>
</div>
{#if loading && tasks.length === 0}
<div class="p-4 text-center text-gray-500">Loading tasks...</div>
<div class="p-4 text-center text-gray-500">{$t.tasks?.loading }</div>
{:else if error}
<div class="p-4 text-center text-red-500">{error}</div>
{:else if tasks.length === 0}
<div class="p-4 text-center text-gray-500">No recent tasks found.</div>
<div class="p-4 text-center text-gray-500">{$t.tasks?.no_tasks }</div>
{:else}
<ul class="divide-y divide-gray-200">
{#each tasks as task}
@@ -179,13 +180,13 @@
{#if task.params.from_env && task.params.to_env}
{task.params.from_env} &rarr; {task.params.to_env}
{:else}
Params: {Object.keys(task.params).length} keys
{$t.tasks?.parameters }: {Object.keys(task.params).length} {$t.tasks?.keys }
{/if}
</p>
</div>
<div class="mt-2 flex items-center text-sm text-gray-500 sm:mt-0">
<p>
Started: {new Date(task.started_at || task.created_at || Date.now()).toLocaleString()}
{$t.tasks?.started_label }: {new Date(task.started_at || task.created_at || Date.now()).toLocaleString()}
</p>
</div>
</div>
@@ -196,4 +197,4 @@
</ul>
{/if}
</div>
<!-- [/DEF:TaskHistory:Component] -->
<!-- [/DEF:TaskHistory:Component] -->