@svadmin/ui 0.118.0 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.css +198 -52
- package/dist/app.theme.css +198 -52
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AuditLogDrawer.svelte +165 -55
- package/dist/components/AuditLogDrawer.svelte.d.ts +4 -2
- package/dist/components/Authenticated.svelte +2 -2
- package/dist/components/AutoSaveIndicator.svelte +2 -2
- package/dist/components/AutoTable.svelte +1 -1
- package/dist/components/Breadcrumbs.svelte +1 -1
- package/dist/components/Breadcrumbs.svelte.d.ts +1 -1
- package/dist/components/CanAccess.svelte +2 -2
- package/dist/components/CancelTaskButton.svelte +2 -2
- package/dist/components/Cascader.svelte +19 -19
- package/dist/components/Cascader.svelte.d.ts +19 -19
- package/dist/components/ColorPicker.svelte +9 -9
- package/dist/components/ColorPicker.svelte.d.ts +9 -9
- package/dist/components/ComboboxField.svelte +15 -15
- package/dist/components/ComboboxField.svelte.d.ts +15 -15
- package/dist/components/ConcurrentConflictModal.svelte +292 -0
- package/dist/components/ConcurrentConflictModal.svelte.d.ts +24 -0
- package/dist/components/ConfigErrorScreen.svelte +2 -2
- package/dist/components/ConfirmDialog.svelte +6 -4
- package/dist/components/ConfirmDialog.svelte.d.ts +2 -2
- package/dist/components/CronExpressionBuilder.svelte +389 -0
- package/dist/components/CronExpressionBuilder.svelte.d.ts +20 -0
- package/dist/components/DateRangeInput.svelte +22 -22
- package/dist/components/DateRangeInput.svelte.d.ts +22 -22
- package/dist/components/DateTimeInput.svelte +2 -2
- package/dist/components/DateTimeInput.svelte.d.ts +2 -2
- package/dist/components/EmptyState.svelte +2 -2
- package/dist/components/ErrorComponent.svelte +2 -2
- package/dist/components/ErrorSummary.svelte +2 -2
- package/dist/components/FieldRenderer.svelte +3 -3
- package/dist/components/FileUpload.svelte +16 -16
- package/dist/components/FileUpload.svelte.d.ts +16 -16
- package/dist/components/FileUploadField.svelte +7 -7
- package/dist/components/FileUploadField.svelte.d.ts +7 -7
- package/dist/components/FilterDropdown.svelte.d.ts +1 -1
- package/dist/components/ForgotPasswordPage.svelte +2 -2
- package/dist/components/Header.svelte +2 -2
- package/dist/components/LiveIndicator.svelte +2 -2
- package/dist/components/LoginPage.svelte +2 -2
- package/dist/components/MetricGrid.svelte +163 -0
- package/dist/components/MetricGrid.svelte.d.ts +39 -0
- package/dist/components/MicroAppFrame.svelte +290 -0
- package/dist/components/MicroAppFrame.svelte.d.ts +36 -0
- package/dist/components/MoneyInput.svelte +15 -15
- package/dist/components/MoneyInput.svelte.d.ts +15 -15
- package/dist/components/NotificationCenter.svelte +16 -16
- package/dist/components/NotificationCenter.svelte.d.ts +16 -16
- package/dist/components/NumberInput.svelte +13 -13
- package/dist/components/NumberInput.svelte.d.ts +13 -13
- package/dist/components/NumericInput.svelte +16 -16
- package/dist/components/NumericInput.svelte.d.ts +16 -16
- package/dist/components/OfflineGuard.svelte +65 -0
- package/dist/components/OfflineGuard.svelte.d.ts +15 -0
- package/dist/components/OrgChart.svelte +171 -0
- package/dist/components/OrgChart.svelte.d.ts +26 -0
- package/dist/components/PageSkeleton.svelte +2 -2
- package/dist/components/PercentInput.svelte +14 -14
- package/dist/components/PercentInput.svelte.d.ts +14 -14
- package/dist/components/PresenceAvatarGroup.svelte +78 -29
- package/dist/components/PresenceAvatarGroup.svelte.d.ts +14 -8
- package/dist/components/Rate.svelte +9 -9
- package/dist/components/Rate.svelte.d.ts +9 -9
- package/dist/components/RegisterPage.svelte +2 -2
- package/dist/components/ResizeBox.svelte.d.ts +1 -1
- package/dist/components/RetryTaskButton.svelte +2 -2
- package/dist/components/SafeDeleteConfirm.svelte +301 -0
- package/dist/components/SafeDeleteConfirm.svelte.d.ts +24 -0
- package/dist/components/SignaturePad.svelte +19 -3
- package/dist/components/SignaturePad.svelte.d.ts +3 -0
- package/dist/components/SliderCaptcha.svelte +448 -0
- package/dist/components/SliderCaptcha.svelte.d.ts +26 -0
- package/dist/components/TagsInput.svelte +10 -10
- package/dist/components/TagsInput.svelte.d.ts +10 -10
- package/dist/components/TaskCenter.svelte +450 -0
- package/dist/components/TaskCenter.svelte.d.ts +37 -0
- package/dist/components/TaskDetails.svelte +2 -2
- package/dist/components/TaskList.svelte +2 -2
- package/dist/components/TaskProgressBar.svelte +2 -2
- package/dist/components/TaskStatusBadge.svelte +2 -2
- package/dist/components/ThemedTitle.svelte +2 -2
- package/dist/components/Tour.svelte +9 -1
- package/dist/components/Tour.svelte.d.ts +2 -1
- package/dist/components/Transfer.svelte +11 -11
- package/dist/components/Transfer.svelte.d.ts +11 -11
- package/dist/components/TreeSelect.svelte +17 -17
- package/dist/components/TreeSelect.svelte.d.ts +17 -17
- package/dist/components/TreeTable.svelte.d.ts +1 -1
- package/dist/components/TrendIndicator.svelte +177 -0
- package/dist/components/TrendIndicator.svelte.d.ts +27 -0
- package/dist/components/UndoableNotification.svelte +2 -2
- package/dist/components/UpdatePasswordPage.svelte +2 -2
- package/dist/components/VirtualTreeSelect.svelte +431 -0
- package/dist/components/VirtualTreeSelect.svelte.d.ts +34 -0
- package/dist/components/buttons/CreateButton.svelte +2 -2
- package/dist/components/buttons/ExportButton.svelte +2 -2
- package/dist/components/buttons/ListButton.svelte +2 -2
- package/dist/components/buttons/RefreshButton.svelte +2 -2
- package/dist/components/buttons/SaveButton.svelte +2 -2
- package/dist/components/charts/GaugeChart.svelte +452 -57
- package/dist/components/charts/GaugeChart.svelte.d.ts +61 -10
- package/dist/components/content/AuditTimeline.svelte +125 -28
- package/dist/components/content/AuditTimeline.svelte.d.ts +30 -16
- package/dist/components/fields/JsonField.svelte +2 -2
- package/dist/components/fields/MultiSelectField.svelte +2 -2
- package/dist/components/fields/RelationField.svelte +2 -2
- package/dist/components/fields/RichTextField.svelte +2 -2
- package/dist/components/fields/SelectField.svelte +2 -2
- package/dist/components/list-state.svelte.d.ts +1 -1
- package/dist/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/components/ui/command/command-dialog.svelte.d.ts +1 -1
- package/dist/components/ui/command/index.d.ts +1 -1
- package/dist/components/ui/input/input.svelte.d.ts +1 -1
- package/dist/components/ui/switch/switch.svelte.d.ts +1 -1
- package/dist/components/useNetworkStatus.d.svelte.ts +1 -0
- package/dist/components/useNetworkStatus.svelte.d.ts +30 -0
- package/dist/components/useNetworkStatus.svelte.js +74 -0
- package/dist/design-system.d.ts +4 -4
- package/dist/index.d.ts +31 -5
- package/dist/index.js +23 -3
- package/dist/recipes.d.ts +91 -619
- package/package.json +30 -30
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
Activity,
|
|
5
|
+
Clock,
|
|
6
|
+
CheckCircle2,
|
|
7
|
+
AlertCircle,
|
|
8
|
+
XCircle,
|
|
9
|
+
Download,
|
|
10
|
+
RotateCw,
|
|
11
|
+
Trash2,
|
|
12
|
+
X,
|
|
13
|
+
Inbox,
|
|
14
|
+
} from '@lucide/svelte';
|
|
15
|
+
import * as Sheet from './ui/sheet/index.js';
|
|
16
|
+
import { Button } from './ui/button/index.js';
|
|
17
|
+
import { cn } from '../utils.js';
|
|
18
|
+
|
|
19
|
+
export type BackgroundTaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
20
|
+
|
|
21
|
+
export interface BackgroundTask {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
status: BackgroundTaskStatus;
|
|
26
|
+
progress?: number; // 0 - 100
|
|
27
|
+
processedCount?: number;
|
|
28
|
+
totalCount?: number;
|
|
29
|
+
createdAt: string | Date;
|
|
30
|
+
updatedAt?: string | Date;
|
|
31
|
+
estimatedSecondsRemaining?: number;
|
|
32
|
+
downloadUrl?: string;
|
|
33
|
+
downloadFileName?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TaskCenterProps {
|
|
38
|
+
open?: boolean;
|
|
39
|
+
tasks?: BackgroundTask[];
|
|
40
|
+
title?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
emptyText?: string;
|
|
43
|
+
showTrigger?: boolean;
|
|
44
|
+
triggerText?: string;
|
|
45
|
+
children?: Snippet;
|
|
46
|
+
onclose?: () => void;
|
|
47
|
+
ondownload?: (task: BackgroundTask) => void;
|
|
48
|
+
onretry?: (task: BackgroundTask) => void | Promise<void>;
|
|
49
|
+
oncancel?: (task: BackgroundTask) => void | Promise<void>;
|
|
50
|
+
onclearcompleted?: () => void | Promise<void>;
|
|
51
|
+
onrefresh?: () => void | Promise<void>;
|
|
52
|
+
class?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
open = $bindable(false),
|
|
57
|
+
tasks = [],
|
|
58
|
+
title = 'Task Center',
|
|
59
|
+
description = 'Track and manage asynchronous background exports and batch jobs',
|
|
60
|
+
emptyText = 'No background tasks',
|
|
61
|
+
showTrigger = false,
|
|
62
|
+
triggerText = 'Tasks',
|
|
63
|
+
children,
|
|
64
|
+
onclose,
|
|
65
|
+
ondownload,
|
|
66
|
+
onretry,
|
|
67
|
+
oncancel,
|
|
68
|
+
onclearcompleted,
|
|
69
|
+
onrefresh,
|
|
70
|
+
class: className,
|
|
71
|
+
}: TaskCenterProps = $props();
|
|
72
|
+
|
|
73
|
+
let activeTab = $state<'all' | 'running' | 'pending' | 'completed' | 'failed'>('all');
|
|
74
|
+
|
|
75
|
+
const runningCount = $derived(tasks.filter((t) => t.status === 'running').length);
|
|
76
|
+
const pendingCount = $derived(tasks.filter((t) => t.status === 'pending').length);
|
|
77
|
+
const completedCount = $derived(tasks.filter((t) => t.status === 'completed').length);
|
|
78
|
+
const failedCount = $derived(tasks.filter((t) => t.status === 'failed').length);
|
|
79
|
+
|
|
80
|
+
const filteredTasks = $derived.by(() => {
|
|
81
|
+
if (activeTab === 'all') return tasks;
|
|
82
|
+
if (activeTab === 'running') return tasks.filter((t) => t.status === 'running');
|
|
83
|
+
if (activeTab === 'pending') return tasks.filter((t) => t.status === 'pending');
|
|
84
|
+
if (activeTab === 'completed') return tasks.filter((t) => t.status === 'completed');
|
|
85
|
+
if (activeTab === 'failed') return tasks.filter((t) => t.status === 'failed' || t.status === 'cancelled');
|
|
86
|
+
return tasks;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
function formatTime(dateVal: string | Date): string {
|
|
90
|
+
const d = typeof dateVal === 'string' ? new Date(dateVal) : dateVal;
|
|
91
|
+
if (isNaN(d.getTime())) return String(dateVal);
|
|
92
|
+
return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function formatDuration(seconds: number | undefined): string {
|
|
96
|
+
if (seconds == null || seconds < 0) return '';
|
|
97
|
+
if (seconds < 60) return `${Math.round(seconds)}s`;
|
|
98
|
+
const mins = Math.floor(seconds / 60);
|
|
99
|
+
const secs = Math.round(seconds % 60);
|
|
100
|
+
return `${mins}m ${secs}s`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function handleDownload(task: BackgroundTask) {
|
|
104
|
+
if (ondownload) {
|
|
105
|
+
ondownload(task);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (task.downloadUrl && typeof window !== 'undefined') {
|
|
109
|
+
const a = document.createElement('a');
|
|
110
|
+
a.href = task.downloadUrl;
|
|
111
|
+
if (task.downloadFileName) {
|
|
112
|
+
a.download = task.downloadFileName;
|
|
113
|
+
}
|
|
114
|
+
a.target = '_blank';
|
|
115
|
+
document.body.appendChild(a);
|
|
116
|
+
a.click();
|
|
117
|
+
document.body.removeChild(a);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<div class={cn('inline-block', className)} data-svadmin-component="task-center">
|
|
123
|
+
{#if children}
|
|
124
|
+
<div
|
|
125
|
+
role="button"
|
|
126
|
+
tabindex="0"
|
|
127
|
+
onclick={() => (open = true)}
|
|
128
|
+
onkeydown={(e) => {
|
|
129
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
open = true;
|
|
132
|
+
}
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{@render children()}
|
|
136
|
+
</div>
|
|
137
|
+
{:else if showTrigger}
|
|
138
|
+
<Button
|
|
139
|
+
variant="outline"
|
|
140
|
+
size="sm"
|
|
141
|
+
class="relative flex items-center gap-1.5"
|
|
142
|
+
onclick={() => (open = true)}
|
|
143
|
+
aria-label="Open task center"
|
|
144
|
+
data-svadmin-action="open-task-center"
|
|
145
|
+
>
|
|
146
|
+
<Activity class={cn('h-4 w-4', runningCount > 0 ? 'text-primary animate-pulse' : 'text-muted-foreground')} />
|
|
147
|
+
<span>{triggerText}</span>
|
|
148
|
+
{#if runningCount > 0}
|
|
149
|
+
<span
|
|
150
|
+
class="ml-1 inline-flex items-center justify-center h-4 min-w-[1rem] px-1 text-[10px] font-semibold rounded-full bg-primary text-primary-foreground"
|
|
151
|
+
data-svadmin-counter="running-tasks"
|
|
152
|
+
>
|
|
153
|
+
{runningCount}
|
|
154
|
+
</span>
|
|
155
|
+
{/if}
|
|
156
|
+
</Button>
|
|
157
|
+
{/if}
|
|
158
|
+
|
|
159
|
+
<Sheet.Root bind:open onClose={() => { onclose?.(); }}>
|
|
160
|
+
<Sheet.Content class="w-full sm:max-w-lg flex flex-col p-0">
|
|
161
|
+
<!-- Header -->
|
|
162
|
+
<div class="px-6 py-4 border-b border-border flex items-center justify-between">
|
|
163
|
+
<div>
|
|
164
|
+
<h2 class="text-base font-semibold text-foreground flex items-center gap-2">
|
|
165
|
+
<Activity class="h-4 w-4 text-primary" />
|
|
166
|
+
{title}
|
|
167
|
+
</h2>
|
|
168
|
+
<p class="text-xs text-muted-foreground mt-0.5">{description}</p>
|
|
169
|
+
</div>
|
|
170
|
+
<div class="flex items-center gap-1">
|
|
171
|
+
{#if onrefresh}
|
|
172
|
+
<Button
|
|
173
|
+
variant="ghost"
|
|
174
|
+
size="icon"
|
|
175
|
+
class="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
176
|
+
onclick={() => onrefresh?.()}
|
|
177
|
+
aria-label="Refresh tasks"
|
|
178
|
+
data-svadmin-action="refresh-tasks"
|
|
179
|
+
>
|
|
180
|
+
<RotateCw class="h-4 w-4" />
|
|
181
|
+
</Button>
|
|
182
|
+
{/if}
|
|
183
|
+
<Button
|
|
184
|
+
variant="ghost"
|
|
185
|
+
size="icon"
|
|
186
|
+
class="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
187
|
+
onclick={() => {
|
|
188
|
+
open = false;
|
|
189
|
+
onclose?.();
|
|
190
|
+
}}
|
|
191
|
+
aria-label="Close task center"
|
|
192
|
+
data-svadmin-action="close-task-center"
|
|
193
|
+
>
|
|
194
|
+
<X class="h-4 w-4" />
|
|
195
|
+
</Button>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<!-- Filter Tabs -->
|
|
200
|
+
<div class="px-6 pt-3 pb-2 border-b border-border bg-muted/30 flex items-center justify-between">
|
|
201
|
+
<div class="flex items-center gap-1 overflow-x-auto text-xs" role="tablist">
|
|
202
|
+
<button
|
|
203
|
+
type="button"
|
|
204
|
+
role="tab"
|
|
205
|
+
aria-selected={activeTab === 'all'}
|
|
206
|
+
class={cn(
|
|
207
|
+
'px-2.5 py-1 rounded font-medium transition-colors cursor-pointer',
|
|
208
|
+
activeTab === 'all'
|
|
209
|
+
? 'bg-background text-foreground shadow-sm'
|
|
210
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
211
|
+
)}
|
|
212
|
+
onclick={() => (activeTab = 'all')}
|
|
213
|
+
data-svadmin-tab="all"
|
|
214
|
+
>
|
|
215
|
+
All ({tasks.length})
|
|
216
|
+
</button>
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
role="tab"
|
|
220
|
+
aria-selected={activeTab === 'running'}
|
|
221
|
+
class={cn(
|
|
222
|
+
'px-2.5 py-1 rounded font-medium transition-colors cursor-pointer flex items-center gap-1',
|
|
223
|
+
activeTab === 'running'
|
|
224
|
+
? 'bg-background text-foreground shadow-sm'
|
|
225
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
226
|
+
)}
|
|
227
|
+
onclick={() => (activeTab = 'running')}
|
|
228
|
+
data-svadmin-tab="running"
|
|
229
|
+
>
|
|
230
|
+
Running
|
|
231
|
+
{#if runningCount > 0}
|
|
232
|
+
<span class="inline-flex h-1.5 w-1.5 rounded-full bg-primary animate-pulse"></span>
|
|
233
|
+
<span class="text-[10px] bg-primary/10 text-primary px-1 rounded">{runningCount}</span>
|
|
234
|
+
{/if}
|
|
235
|
+
</button>
|
|
236
|
+
<button
|
|
237
|
+
type="button"
|
|
238
|
+
role="tab"
|
|
239
|
+
aria-selected={activeTab === 'pending'}
|
|
240
|
+
class={cn(
|
|
241
|
+
'px-2.5 py-1 rounded font-medium transition-colors cursor-pointer',
|
|
242
|
+
activeTab === 'pending'
|
|
243
|
+
? 'bg-background text-foreground shadow-sm'
|
|
244
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
245
|
+
)}
|
|
246
|
+
onclick={() => (activeTab = 'pending')}
|
|
247
|
+
data-svadmin-tab="pending"
|
|
248
|
+
>
|
|
249
|
+
Pending ({pendingCount})
|
|
250
|
+
</button>
|
|
251
|
+
<button
|
|
252
|
+
type="button"
|
|
253
|
+
role="tab"
|
|
254
|
+
aria-selected={activeTab === 'completed'}
|
|
255
|
+
class={cn(
|
|
256
|
+
'px-2.5 py-1 rounded font-medium transition-colors cursor-pointer',
|
|
257
|
+
activeTab === 'completed'
|
|
258
|
+
? 'bg-background text-foreground shadow-sm'
|
|
259
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
260
|
+
)}
|
|
261
|
+
onclick={() => (activeTab = 'completed')}
|
|
262
|
+
data-svadmin-tab="completed"
|
|
263
|
+
>
|
|
264
|
+
Completed ({completedCount})
|
|
265
|
+
</button>
|
|
266
|
+
<button
|
|
267
|
+
type="button"
|
|
268
|
+
role="tab"
|
|
269
|
+
aria-selected={activeTab === 'failed'}
|
|
270
|
+
class={cn(
|
|
271
|
+
'px-2.5 py-1 rounded font-medium transition-colors cursor-pointer',
|
|
272
|
+
activeTab === 'failed'
|
|
273
|
+
? 'bg-background text-foreground shadow-sm'
|
|
274
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
275
|
+
)}
|
|
276
|
+
onclick={() => (activeTab = 'failed')}
|
|
277
|
+
data-svadmin-tab="failed"
|
|
278
|
+
>
|
|
279
|
+
Failed ({failedCount})
|
|
280
|
+
</button>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
{#if onclearcompleted && completedCount > 0}
|
|
284
|
+
<Button
|
|
285
|
+
variant="ghost"
|
|
286
|
+
size="sm"
|
|
287
|
+
class="text-xs h-7 text-muted-foreground hover:text-destructive px-2"
|
|
288
|
+
onclick={() => onclearcompleted?.()}
|
|
289
|
+
data-svadmin-action="clear-completed"
|
|
290
|
+
>
|
|
291
|
+
<Trash2 class="h-3 w-3 mr-1" />
|
|
292
|
+
Clear
|
|
293
|
+
</Button>
|
|
294
|
+
{/if}
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
<!-- Task List Body -->
|
|
298
|
+
<div class="flex-1 overflow-y-auto px-6 py-4 space-y-3">
|
|
299
|
+
{#if filteredTasks.length === 0}
|
|
300
|
+
<div class="flex flex-col items-center justify-center py-16 text-center text-muted-foreground">
|
|
301
|
+
<Inbox class="h-10 w-10 stroke-1 text-muted-foreground/40 mb-3" />
|
|
302
|
+
<p class="text-sm">{emptyText}</p>
|
|
303
|
+
</div>
|
|
304
|
+
{:else}
|
|
305
|
+
{#each filteredTasks as task (task.id)}
|
|
306
|
+
<div
|
|
307
|
+
class={cn(
|
|
308
|
+
'p-3.5 rounded-lg border border-border bg-card transition-all',
|
|
309
|
+
task.status === 'running' && 'border-primary/40 shadow-sm',
|
|
310
|
+
task.status === 'failed' && 'border-destructive/30',
|
|
311
|
+
)}
|
|
312
|
+
data-svadmin-task-id={task.id}
|
|
313
|
+
data-svadmin-task-status={task.status}
|
|
314
|
+
>
|
|
315
|
+
<!-- Card Header -->
|
|
316
|
+
<div class="flex items-start justify-between gap-2">
|
|
317
|
+
<div class="min-w-0 flex-1">
|
|
318
|
+
<div class="flex items-center gap-2">
|
|
319
|
+
<span class="text-sm font-semibold text-foreground truncate">
|
|
320
|
+
{task.name}
|
|
321
|
+
</span>
|
|
322
|
+
<!-- Status Badge -->
|
|
323
|
+
{#if task.status === 'running'}
|
|
324
|
+
<span class="inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-full bg-primary/10 text-primary">
|
|
325
|
+
<RotateCw class="h-3 w-3 animate-spin" />
|
|
326
|
+
Running
|
|
327
|
+
</span>
|
|
328
|
+
{:else if task.status === 'pending'}
|
|
329
|
+
<span class="inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-full bg-muted text-muted-foreground">
|
|
330
|
+
<Clock class="h-3 w-3" />
|
|
331
|
+
Pending
|
|
332
|
+
</span>
|
|
333
|
+
{:else if task.status === 'completed'}
|
|
334
|
+
<span class="inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-full bg-success/15 text-success">
|
|
335
|
+
<CheckCircle2 class="h-3 w-3" />
|
|
336
|
+
Completed
|
|
337
|
+
</span>
|
|
338
|
+
{:else if task.status === 'failed'}
|
|
339
|
+
<span class="inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-full bg-destructive/15 text-destructive">
|
|
340
|
+
<AlertCircle class="h-3 w-3" />
|
|
341
|
+
Failed
|
|
342
|
+
</span>
|
|
343
|
+
{:else if task.status === 'cancelled'}
|
|
344
|
+
<span class="inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-full bg-muted text-muted-foreground">
|
|
345
|
+
<XCircle class="h-3 w-3" />
|
|
346
|
+
Cancelled
|
|
347
|
+
</span>
|
|
348
|
+
{/if}
|
|
349
|
+
</div>
|
|
350
|
+
{#if task.description}
|
|
351
|
+
<p class="text-xs text-muted-foreground mt-1 line-clamp-2">{task.description}</p>
|
|
352
|
+
{/if}
|
|
353
|
+
</div>
|
|
354
|
+
|
|
355
|
+
<span class="text-[11px] text-muted-foreground whitespace-nowrap">
|
|
356
|
+
{formatTime(task.createdAt)}
|
|
357
|
+
</span>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<!-- Progress Bar -->
|
|
361
|
+
{#if task.status === 'running' || task.status === 'pending'}
|
|
362
|
+
<div class="mt-3 space-y-1.5">
|
|
363
|
+
<div class="h-2 w-full rounded-full bg-muted overflow-hidden">
|
|
364
|
+
<div
|
|
365
|
+
class={cn(
|
|
366
|
+
'h-full bg-primary transition-all duration-300',
|
|
367
|
+
task.status === 'running' ? 'animate-pulse' : 'opacity-60',
|
|
368
|
+
)}
|
|
369
|
+
style="width: {Math.min(100, Math.max(0, task.progress ?? 0))}%"
|
|
370
|
+
role="progressbar"
|
|
371
|
+
aria-valuenow={task.progress ?? 0}
|
|
372
|
+
aria-valuemin="0"
|
|
373
|
+
aria-valuemax="100"
|
|
374
|
+
></div>
|
|
375
|
+
</div>
|
|
376
|
+
<div class="flex items-center justify-between text-xs text-muted-foreground">
|
|
377
|
+
<span>
|
|
378
|
+
{#if task.processedCount != null && task.totalCount != null}
|
|
379
|
+
{task.processedCount.toLocaleString()} / {task.totalCount.toLocaleString()}
|
|
380
|
+
{:else}
|
|
381
|
+
{task.progress ?? 0}%
|
|
382
|
+
{/if}
|
|
383
|
+
</span>
|
|
384
|
+
{#if task.estimatedSecondsRemaining != null && task.status === 'running'}
|
|
385
|
+
<span>~{formatDuration(task.estimatedSecondsRemaining)} remaining</span>
|
|
386
|
+
{/if}
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
{/if}
|
|
390
|
+
|
|
391
|
+
<!-- Error Box -->
|
|
392
|
+
{#if task.status === 'failed' && task.error}
|
|
393
|
+
<div class="mt-2.5 p-2 rounded bg-destructive/10 border border-destructive/20 text-xs text-destructive">
|
|
394
|
+
{task.error}
|
|
395
|
+
</div>
|
|
396
|
+
{/if}
|
|
397
|
+
|
|
398
|
+
<!-- Card Action Footer -->
|
|
399
|
+
<div class="mt-3 pt-2.5 border-t border-border/60 flex items-center justify-between text-xs">
|
|
400
|
+
<span class="text-muted-foreground text-[11px]">
|
|
401
|
+
ID: <span class="font-mono">{task.id}</span>
|
|
402
|
+
</span>
|
|
403
|
+
<div class="flex items-center gap-1">
|
|
404
|
+
{#if task.status === 'completed' && (task.downloadUrl || ondownload)}
|
|
405
|
+
<Button
|
|
406
|
+
variant="outline"
|
|
407
|
+
size="sm"
|
|
408
|
+
class="h-7 px-2 text-xs text-primary hover:text-primary-foreground hover:bg-primary"
|
|
409
|
+
onclick={() => handleDownload(task)}
|
|
410
|
+
data-svadmin-action="download-result"
|
|
411
|
+
>
|
|
412
|
+
<Download class="h-3 w-3 mr-1" />
|
|
413
|
+
Download
|
|
414
|
+
</Button>
|
|
415
|
+
{/if}
|
|
416
|
+
|
|
417
|
+
{#if (task.status === 'failed' || task.status === 'cancelled') && onretry}
|
|
418
|
+
<Button
|
|
419
|
+
variant="outline"
|
|
420
|
+
size="sm"
|
|
421
|
+
class="h-7 px-2 text-xs"
|
|
422
|
+
onclick={() => onretry?.(task)}
|
|
423
|
+
data-svadmin-action="retry-task"
|
|
424
|
+
>
|
|
425
|
+
<RotateCw class="h-3 w-3 mr-1" />
|
|
426
|
+
Retry
|
|
427
|
+
</Button>
|
|
428
|
+
{/if}
|
|
429
|
+
|
|
430
|
+
{#if (task.status === 'running' || task.status === 'pending') && oncancel}
|
|
431
|
+
<Button
|
|
432
|
+
variant="ghost"
|
|
433
|
+
size="sm"
|
|
434
|
+
class="h-7 px-2 text-xs text-muted-foreground hover:text-destructive"
|
|
435
|
+
onclick={() => oncancel?.(task)}
|
|
436
|
+
data-svadmin-action="cancel-task"
|
|
437
|
+
>
|
|
438
|
+
<XCircle class="h-3 w-3 mr-1" />
|
|
439
|
+
Cancel
|
|
440
|
+
</Button>
|
|
441
|
+
{/if}
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
{/each}
|
|
446
|
+
{/if}
|
|
447
|
+
</div>
|
|
448
|
+
</Sheet.Content>
|
|
449
|
+
</Sheet.Root>
|
|
450
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type BackgroundTaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
3
|
+
export interface BackgroundTask {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
status: BackgroundTaskStatus;
|
|
8
|
+
progress?: number;
|
|
9
|
+
processedCount?: number;
|
|
10
|
+
totalCount?: number;
|
|
11
|
+
createdAt: string | Date;
|
|
12
|
+
updatedAt?: string | Date;
|
|
13
|
+
estimatedSecondsRemaining?: number;
|
|
14
|
+
downloadUrl?: string;
|
|
15
|
+
downloadFileName?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TaskCenterProps {
|
|
19
|
+
open?: boolean;
|
|
20
|
+
tasks?: BackgroundTask[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
emptyText?: string;
|
|
24
|
+
showTrigger?: boolean;
|
|
25
|
+
triggerText?: string;
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
onclose?: () => void;
|
|
28
|
+
ondownload?: (task: BackgroundTask) => void;
|
|
29
|
+
onretry?: (task: BackgroundTask) => void | Promise<void>;
|
|
30
|
+
oncancel?: (task: BackgroundTask) => void | Promise<void>;
|
|
31
|
+
onclearcompleted?: () => void | Promise<void>;
|
|
32
|
+
onrefresh?: () => void | Promise<void>;
|
|
33
|
+
class?: string;
|
|
34
|
+
}
|
|
35
|
+
declare const TaskCenter: import("svelte").Component<TaskCenterProps, {}, "open">;
|
|
36
|
+
type TaskCenter = ReturnType<typeof TaskCenter>;
|
|
37
|
+
export default TaskCenter;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
title,
|
|
36
36
|
useProviderData = !task && !!taskId,
|
|
37
37
|
queryOptions,
|
|
38
|
-
}
|
|
38
|
+
}: {
|
|
39
39
|
task?: TaskRecord | undefined;
|
|
40
40
|
taskId?: string;
|
|
41
41
|
taskProvider?: TaskProvider<TaskRecord>;
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
refetchInterval?: number | false;
|
|
50
50
|
refetchIntervalInBackground?: boolean;
|
|
51
51
|
};
|
|
52
|
-
}
|
|
52
|
+
} = $props();
|
|
53
53
|
|
|
54
54
|
const canRead = $derived(useProviderData && !!taskId && !!taskProvider && queryOptions?.enabled !== false);
|
|
55
55
|
const query = useTask({
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
useProviderData = !tasks,
|
|
40
40
|
queryOptions,
|
|
41
41
|
onSelect,
|
|
42
|
-
}
|
|
42
|
+
}: {
|
|
43
43
|
tasks?: TaskRecord[];
|
|
44
44
|
taskProvider?: TaskProvider<TaskRecord>;
|
|
45
45
|
params?: Record<string, unknown>;
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
refetchIntervalInBackground?: boolean;
|
|
59
59
|
};
|
|
60
60
|
onSelect?: (task: TaskRecord) => void;
|
|
61
|
-
}
|
|
61
|
+
} = $props();
|
|
62
62
|
|
|
63
63
|
const hasReadCapability = $derived(typeof (dlq ? taskProvider?.listDlq : taskProvider?.list) === 'function');
|
|
64
64
|
const readUnavailable = $derived(useProviderData && !hasReadCapability);
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
value = 0,
|
|
6
6
|
label = 'Progress',
|
|
7
7
|
showLabel = true,
|
|
8
|
-
}
|
|
8
|
+
}: {
|
|
9
9
|
value?: number;
|
|
10
10
|
label?: string;
|
|
11
11
|
showLabel?: boolean;
|
|
12
|
-
}
|
|
12
|
+
} = $props();
|
|
13
13
|
|
|
14
14
|
const safeValue = $derived(Math.max(0, Math.min(100, Number(value ?? 0))));
|
|
15
15
|
</script>
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
status = 'pending',
|
|
12
12
|
showIcon = true,
|
|
13
13
|
class: className = '',
|
|
14
|
-
}
|
|
14
|
+
}: {
|
|
15
15
|
status?: string;
|
|
16
16
|
showIcon?: boolean;
|
|
17
17
|
class?: string;
|
|
18
|
-
}
|
|
18
|
+
} = $props();
|
|
19
19
|
|
|
20
20
|
const normalizedStatus = $derived(String(status || 'pending').toLowerCase());
|
|
21
21
|
const lifecycle = $derived(normalizeTaskStatus(normalizedStatus));
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
icon,
|
|
7
7
|
text,
|
|
8
8
|
wrapperStyles = '',
|
|
9
|
-
}
|
|
9
|
+
}: {
|
|
10
10
|
collapsed?: boolean;
|
|
11
11
|
icon?: string;
|
|
12
12
|
text?: string;
|
|
13
13
|
wrapperStyles?: string;
|
|
14
|
-
}
|
|
14
|
+
} = $props();
|
|
15
15
|
|
|
16
16
|
const adminOptions = getAdminOptions();
|
|
17
17
|
const titleText = $derived(text ?? adminOptions.title?.text ?? 'Admin');
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
onfinish?: () => void;
|
|
23
23
|
onclose?: () => void;
|
|
24
24
|
onstepchange?: (index: number) => void;
|
|
25
|
+
storageKey?: string;
|
|
25
26
|
class?: string;
|
|
26
27
|
children?: Snippet<[TourStep, number]>;
|
|
27
28
|
}
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
previousText = 'Back',
|
|
36
37
|
finishText = 'Done',
|
|
37
38
|
skipText = 'Skip',
|
|
39
|
+
storageKey,
|
|
38
40
|
onfinish,
|
|
39
41
|
onclose,
|
|
40
42
|
onstepchange,
|
|
@@ -76,6 +78,9 @@
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
function close(): void {
|
|
81
|
+
if (storageKey && typeof localStorage !== 'undefined') {
|
|
82
|
+
try { localStorage.setItem(storageKey, 'true'); } catch { /* ignore */ }
|
|
83
|
+
}
|
|
79
84
|
open = false;
|
|
80
85
|
onclose?.();
|
|
81
86
|
}
|
|
@@ -88,6 +93,9 @@
|
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
function finish(): void {
|
|
96
|
+
if (storageKey && typeof localStorage !== 'undefined') {
|
|
97
|
+
try { localStorage.setItem(storageKey, 'true'); } catch { /* ignore */ }
|
|
98
|
+
}
|
|
91
99
|
open = false;
|
|
92
100
|
onfinish?.();
|
|
93
101
|
}
|
|
@@ -147,7 +155,7 @@
|
|
|
147
155
|
</script>
|
|
148
156
|
|
|
149
157
|
{#if open}
|
|
150
|
-
<div data-targeted={rect ? 'true' : 'false'} class={cn('svadmin-tour', className)}>
|
|
158
|
+
<div data-svadmin-component="TourGuide" data-targeted={rect ? 'true' : 'false'} class={cn('svadmin-tour', className)}>
|
|
151
159
|
<button type="button" tabindex="-1" class="svadmin-tour__dismiss" aria-label={skipText} onclick={close}></button>
|
|
152
160
|
{#if rect}
|
|
153
161
|
<div
|
|
@@ -17,9 +17,10 @@ interface Props {
|
|
|
17
17
|
onfinish?: () => void;
|
|
18
18
|
onclose?: () => void;
|
|
19
19
|
onstepchange?: (index: number) => void;
|
|
20
|
+
storageKey?: string;
|
|
20
21
|
class?: string;
|
|
21
22
|
children?: Snippet<[TourStep, number]>;
|
|
22
23
|
}
|
|
23
|
-
declare const Tour: import("svelte").Component<Props, {}, "
|
|
24
|
+
declare const Tour: import("svelte").Component<Props, {}, "current" | "open">;
|
|
24
25
|
type Tour = ReturnType<typeof Tour>;
|
|
25
26
|
export default Tour;
|
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
const i18n = useTranslation();
|
|
20
20
|
|
|
21
21
|
interface Props {
|
|
22
|
-
id?: string;
|
|
23
|
-
labelledby?: string;
|
|
24
|
-
describedby?: string;
|
|
25
|
-
invalid?: boolean;
|
|
26
|
-
dataSource?: TransferItem[];
|
|
27
|
-
targetKeys?: (string | number)[];
|
|
28
|
-
titles?: [string, string];
|
|
29
|
-
searchable?: boolean;
|
|
30
|
-
disabled?: boolean;
|
|
31
|
-
class?: string;
|
|
22
|
+
id?: string | undefined;
|
|
23
|
+
labelledby?: string | undefined;
|
|
24
|
+
describedby?: string | undefined;
|
|
25
|
+
invalid?: boolean | undefined;
|
|
26
|
+
dataSource?: TransferItem[] | undefined;
|
|
27
|
+
targetKeys?: (string | number)[] | undefined;
|
|
28
|
+
titles?: [string, string] | undefined;
|
|
29
|
+
searchable?: boolean | undefined;
|
|
30
|
+
disabled?: boolean | undefined;
|
|
31
|
+
class?: string | undefined;
|
|
32
32
|
onchange?: (
|
|
33
33
|
nextTargetKeys: (string | number)[],
|
|
34
34
|
direction: 'left' | 'right',
|
|
35
35
|
moveKeys: (string | number)[]
|
|
36
36
|
) => void;
|
|
37
|
-
renderItem?: Snippet<[{ item: TransferItem; direction: 'left' | 'right' }]
|
|
37
|
+
renderItem?: Snippet<[{ item: TransferItem; direction: 'left' | 'right' }]> | undefined;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
let {
|