@svadmin/ui 0.122.0 → 0.126.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 +581 -4
- package/dist/app.theme.css +581 -4
- package/dist/components/AbacPolicyMatrix.svelte +356 -0
- package/dist/components/AbacPolicyMatrix.svelte.d.ts +30 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/ActionPalette.svelte +272 -0
- package/dist/components/ActionPalette.svelte.d.ts +23 -0
- package/dist/components/AdminCopilotWidget.svelte +316 -0
- package/dist/components/AdminCopilotWidget.svelte.d.ts +33 -0
- package/dist/components/AnnouncementBanner.svelte +12 -1
- package/dist/components/AnnouncementBanner.svelte.d.ts +4 -0
- package/dist/components/ApiPlayground.svelte +255 -0
- package/dist/components/ApiPlayground.svelte.d.ts +24 -0
- package/dist/components/ApiSettings.svelte +1 -1
- package/dist/components/AppearanceSettings.svelte +1 -1
- package/dist/components/ApprovalChainBuilder.svelte +262 -0
- package/dist/components/ApprovalChainBuilder.svelte.d.ts +20 -0
- package/dist/components/ApprovalTimeline.svelte +8 -1
- package/dist/components/AsyncExportModal.svelte +1 -1
- package/dist/components/AudioFeedbackProvider.svelte +1 -1
- package/dist/components/AuditLogDrawer.svelte +2 -2
- package/dist/components/AuditTrailInspector.svelte +448 -0
- package/dist/components/AuditTrailInspector.svelte.d.ts +44 -0
- package/dist/components/AutoTable.svelte +20 -1
- package/dist/components/AutoTable.svelte.d.ts +2 -0
- package/dist/components/BatchEditModal.svelte +266 -0
- package/dist/components/BatchEditModal.svelte.d.ts +27 -0
- package/dist/components/BillingInvoiceDrawer.svelte +206 -0
- package/dist/components/BillingInvoiceDrawer.svelte.d.ts +30 -0
- package/dist/components/ChartAnnotationOverlay.svelte +228 -0
- package/dist/components/ChartAnnotationOverlay.svelte.d.ts +21 -0
- package/dist/components/CheckCard.svelte +1 -1
- package/dist/components/ClusterTopologyGraph.svelte +317 -0
- package/dist/components/ClusterTopologyGraph.svelte.d.ts +31 -0
- package/dist/components/ColumnHeaderFilter.svelte +6 -6
- package/dist/components/ColumnMappingTable.svelte +174 -0
- package/dist/components/ColumnMappingTable.svelte.d.ts +23 -0
- package/dist/components/ConversionFunnel.svelte +1 -1
- package/dist/components/CursorListFooter.svelte +67 -0
- package/dist/components/CursorListFooter.svelte.d.ts +17 -0
- package/dist/components/DashboardGridLayout.svelte +309 -0
- package/dist/components/DashboardGridLayout.svelte.d.ts +30 -0
- package/dist/components/DashboardLayoutStorage.svelte +278 -0
- package/dist/components/DashboardLayoutStorage.svelte.d.ts +23 -0
- package/dist/components/DataFreshnessIndicator.svelte +149 -0
- package/dist/components/DataFreshnessIndicator.svelte.d.ts +20 -0
- package/dist/components/DataImportDropzone.svelte +215 -0
- package/dist/components/DataImportDropzone.svelte.d.ts +24 -0
- package/dist/components/DataLineageGraph.svelte +203 -0
- package/dist/components/DataLineageGraph.svelte.d.ts +26 -0
- package/dist/components/DataMaskPolicyEngine.svelte +291 -0
- package/dist/components/DataMaskPolicyEngine.svelte.d.ts +25 -0
- package/dist/components/DataScopeRuleEditor.svelte +142 -0
- package/dist/components/DataScopeRuleEditor.svelte.d.ts +19 -0
- package/dist/components/DataScreenContainer.svelte +160 -0
- package/dist/components/DataScreenContainer.svelte.d.ts +15 -0
- package/dist/components/DevTools.svelte +3 -3
- package/dist/components/DualApprovalGate.svelte +132 -65
- package/dist/components/DualApprovalGate.svelte.d.ts +20 -1
- package/dist/components/EditableTable.svelte +2 -2
- package/dist/components/ElectronicSealStamp.svelte +102 -0
- package/dist/components/ElectronicSealStamp.svelte.d.ts +14 -0
- package/dist/components/EnvVariableEditor.svelte +284 -0
- package/dist/components/EnvVariableEditor.svelte.d.ts +17 -0
- package/dist/components/ExcelImportWizard.svelte +2 -2
- package/dist/components/FeatureAnnouncementModal.svelte +173 -0
- package/dist/components/FeatureAnnouncementModal.svelte.d.ts +21 -0
- package/dist/components/FieldRenderer.svelte +1 -1
- package/dist/components/FilterTagBar.svelte +210 -0
- package/dist/components/FilterTagBar.svelte.d.ts +23 -0
- package/dist/components/FormulaField.svelte +149 -0
- package/dist/components/FormulaField.svelte.d.ts +18 -0
- package/dist/components/GeoScatterMap.svelte +225 -0
- package/dist/components/GeoScatterMap.svelte.d.ts +22 -0
- package/dist/components/HmacSignatureCalculator.svelte +199 -0
- package/dist/components/HmacSignatureCalculator.svelte.d.ts +10 -0
- package/dist/components/I18nLanguagePackEditor.svelte +208 -0
- package/dist/components/I18nLanguagePackEditor.svelte.d.ts +17 -0
- package/dist/components/ImportPreviewValidator.svelte +239 -0
- package/dist/components/ImportPreviewValidator.svelte.d.ts +26 -0
- package/dist/components/ImportWizard.svelte +2 -2
- package/dist/components/IncidentWarRoomDrawer.svelte +194 -0
- package/dist/components/IncidentWarRoomDrawer.svelte.d.ts +24 -0
- package/dist/components/InputGroup.svelte +133 -0
- package/dist/components/InputGroup.svelte.d.ts +16 -0
- package/dist/components/JsonSchemaForm.svelte +4 -4
- package/dist/components/LightFilter.svelte +2 -2
- package/dist/components/ListPagination.svelte +39 -3
- package/dist/components/LiveStreamLogViewer.svelte +185 -0
- package/dist/components/LiveStreamLogViewer.svelte.d.ts +21 -0
- package/dist/components/MasterSubTableDrawer.svelte +223 -0
- package/dist/components/MasterSubTableDrawer.svelte.d.ts +25 -0
- package/dist/components/MicroAppRouteSync.svelte +185 -0
- package/dist/components/MicroAppRouteSync.svelte.d.ts +12 -0
- package/dist/components/MicroAppSandbox.svelte +200 -0
- package/dist/components/MicroAppSandbox.svelte.d.ts +16 -0
- package/dist/components/MicroAppStateBusIndicator.svelte +159 -0
- package/dist/components/MicroAppStateBusIndicator.svelte.d.ts +12 -0
- package/dist/components/MockDataInterceptor.svelte +292 -0
- package/dist/components/MockDataInterceptor.svelte.d.ts +27 -0
- package/dist/components/OmnibarCommandPalette.svelte +320 -0
- package/dist/components/OmnibarCommandPalette.svelte.d.ts +27 -0
- package/dist/components/PageSkeleton.svelte +19 -5
- package/dist/components/PageSkeleton.svelte.d.ts +5 -3
- package/dist/components/PeriodComparisonCard.svelte +142 -0
- package/dist/components/PeriodComparisonCard.svelte.d.ts +16 -0
- package/dist/components/PermissionMatrix.svelte +1 -1
- package/dist/components/PermissionSimulator.svelte +319 -0
- package/dist/components/PermissionSimulator.svelte.d.ts +34 -0
- package/dist/components/PivotMatrix.svelte +271 -0
- package/dist/components/PivotMatrix.svelte.d.ts +32 -0
- package/dist/components/PlanUsageQuotaBar.svelte +154 -0
- package/dist/components/PlanUsageQuotaBar.svelte.d.ts +26 -0
- package/dist/components/Popconfirm.svelte +20 -8
- package/dist/components/Popconfirm.svelte.d.ts +3 -1
- package/dist/components/ProSkeleton.svelte +4 -0
- package/dist/components/ProSkeleton.svelte.d.ts +2 -0
- package/dist/components/QueryAiExplainer.svelte +148 -0
- package/dist/components/QueryAiExplainer.svelte.d.ts +16 -0
- package/dist/components/QueryBuilder.svelte +456 -0
- package/dist/components/QueryBuilder.svelte.d.ts +33 -0
- package/dist/components/Rate.svelte +19 -2
- package/dist/components/Result.svelte +36 -4
- package/dist/components/Result.svelte.d.ts +4 -2
- package/dist/components/RolePermissionComparator.svelte +273 -0
- package/dist/components/RolePermissionComparator.svelte.d.ts +28 -0
- package/dist/components/RuleExpressionBuilder.svelte +380 -0
- package/dist/components/RuleExpressionBuilder.svelte.d.ts +31 -0
- package/dist/components/ScheduledJobManager.svelte +225 -0
- package/dist/components/ScheduledJobManager.svelte.d.ts +23 -0
- package/dist/components/SchemaVisualModeler.svelte +2 -2
- package/dist/components/ScreenAntiLeakGuard.svelte +88 -0
- package/dist/components/ScreenAntiLeakGuard.svelte.d.ts +12 -0
- package/dist/components/SecureDataExporter.svelte +296 -0
- package/dist/components/SecureDataExporter.svelte.d.ts +29 -0
- package/dist/components/ServerStatusGrid.svelte +179 -0
- package/dist/components/ServerStatusGrid.svelte.d.ts +21 -0
- package/dist/components/SnapshotTimelineReplay.svelte +219 -0
- package/dist/components/SnapshotTimelineReplay.svelte.d.ts +19 -0
- package/dist/components/Spin.svelte +33 -11
- package/dist/components/Spin.svelte.d.ts +7 -4
- package/dist/components/SqlConsole.svelte +247 -0
- package/dist/components/SqlConsole.svelte.d.ts +20 -0
- package/dist/components/StepWizard.svelte +1 -1
- package/dist/components/Steps.svelte +44 -3
- package/dist/components/SystemCapacityForecastCard.svelte +132 -0
- package/dist/components/SystemCapacityForecastCard.svelte.d.ts +19 -0
- package/dist/components/SystemHealthCheckDashboard.svelte +306 -0
- package/dist/components/SystemHealthCheckDashboard.svelte.d.ts +24 -0
- package/dist/components/TableAggregationFooter.svelte +173 -0
- package/dist/components/TableAggregationFooter.svelte.d.ts +22 -0
- package/dist/components/TaskCenter.svelte +37 -29
- package/dist/components/TenantContextSwitcher.svelte +314 -0
- package/dist/components/TenantContextSwitcher.svelte.d.ts +35 -0
- package/dist/components/TenantQuotasMatrix.svelte +229 -0
- package/dist/components/TenantQuotasMatrix.svelte.d.ts +22 -0
- package/dist/components/ThemeSettingsDrawer.svelte +6 -14
- package/dist/components/ThreadedCommentDrawer.svelte +246 -0
- package/dist/components/ThreadedCommentDrawer.svelte.d.ts +26 -0
- package/dist/components/TierFeatureComparison.svelte +147 -0
- package/dist/components/TierFeatureComparison.svelte.d.ts +28 -0
- package/dist/components/Timeline.svelte +12 -3
- package/dist/components/Timeline.svelte.d.ts +2 -0
- package/dist/components/TreeTransferSelect.svelte +333 -0
- package/dist/components/TreeTransferSelect.svelte.d.ts +18 -0
- package/dist/components/VirtualCardGrid.svelte +180 -0
- package/dist/components/VirtualCardGrid.svelte.d.ts +65 -0
- package/dist/components/WebhookSimulator.svelte +263 -0
- package/dist/components/WebhookSimulator.svelte.d.ts +26 -0
- package/dist/components/WidgetContainer.svelte +204 -0
- package/dist/components/WidgetContainer.svelte.d.ts +31 -0
- package/dist/components/WorkflowExecutionTracker.svelte +131 -0
- package/dist/components/WorkflowExecutionTracker.svelte.d.ts +19 -0
- package/dist/components/WorkflowGraphDesigner.svelte +202 -0
- package/dist/components/WorkflowGraphDesigner.svelte.d.ts +24 -0
- package/dist/components/WorkflowNodeInspector.svelte +217 -0
- package/dist/components/WorkflowNodeInspector.svelte.d.ts +24 -0
- package/dist/components/WorkflowStepper.svelte +1 -1
- package/dist/components/list-i18n.d.ts +7 -0
- package/dist/components/list-i18n.js +14 -0
- package/dist/components/ui/badge/badge.svelte +3 -3
- package/dist/components/ui/button/button.svelte +3 -1
- package/dist/components/ui/button/button.svelte.d.ts +1 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/components/useDynamicLocale.d.svelte.ts +1 -0
- package/dist/components/useDynamicLocale.svelte.d.ts +10 -0
- package/dist/components/useDynamicLocale.svelte.js +40 -0
- package/dist/components/useFormulaEngine.d.svelte.ts +1 -0
- package/dist/components/useFormulaEngine.svelte.d.ts +9 -0
- package/dist/components/useFormulaEngine.svelte.js +209 -0
- package/dist/components/useMicroAppState.d.svelte.ts +1 -0
- package/dist/components/useMicroAppState.svelte.d.ts +17 -0
- package/dist/components/useMicroAppState.svelte.js +38 -0
- package/dist/components/useStorageCache.d.svelte.ts +1 -0
- package/dist/components/useStorageCache.svelte.d.ts +49 -0
- package/dist/components/useStorageCache.svelte.js +229 -0
- package/dist/components.css +5 -1
- package/dist/index.d.ts +75 -3
- package/dist/index.js +118 -2
- package/package.json +4 -4
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import * as Sheet from './ui/sheet/index.js';
|
|
16
16
|
import { Button } from './ui/button/index.js';
|
|
17
17
|
import { cn } from '../utils.js';
|
|
18
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
18
19
|
|
|
19
20
|
export type BackgroundTaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
20
21
|
|
|
@@ -52,14 +53,16 @@
|
|
|
52
53
|
class?: string;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
const i18n = useTranslation();
|
|
57
|
+
|
|
55
58
|
let {
|
|
56
59
|
open = $bindable(false),
|
|
57
60
|
tasks = [],
|
|
58
|
-
title
|
|
59
|
-
description
|
|
60
|
-
emptyText
|
|
61
|
+
title,
|
|
62
|
+
description,
|
|
63
|
+
emptyText,
|
|
61
64
|
showTrigger = false,
|
|
62
|
-
triggerText
|
|
65
|
+
triggerText,
|
|
63
66
|
children,
|
|
64
67
|
onclose,
|
|
65
68
|
ondownload,
|
|
@@ -70,6 +73,11 @@
|
|
|
70
73
|
class: className,
|
|
71
74
|
}: TaskCenterProps = $props();
|
|
72
75
|
|
|
76
|
+
const titleText = $derived(title ?? i18n.t('taskCenter.title'));
|
|
77
|
+
const descriptionText = $derived(description ?? i18n.t('taskCenter.description'));
|
|
78
|
+
const emptyTextValue = $derived(emptyText ?? i18n.t('taskCenter.empty'));
|
|
79
|
+
const triggerTextValue = $derived(triggerText ?? i18n.t('taskCenter.trigger'));
|
|
80
|
+
|
|
73
81
|
let activeTab = $state<'all' | 'running' | 'pending' | 'completed' | 'failed'>('all');
|
|
74
82
|
|
|
75
83
|
const runningCount = $derived(tasks.filter((t) => t.status === 'running').length);
|
|
@@ -94,10 +102,10 @@
|
|
|
94
102
|
|
|
95
103
|
function formatDuration(seconds: number | undefined): string {
|
|
96
104
|
if (seconds == null || seconds < 0) return '';
|
|
97
|
-
if (seconds < 60) return
|
|
105
|
+
if (seconds < 60) return i18n.t('taskCenter.seconds', { count: Math.round(seconds) });
|
|
98
106
|
const mins = Math.floor(seconds / 60);
|
|
99
107
|
const secs = Math.round(seconds % 60);
|
|
100
|
-
return
|
|
108
|
+
return i18n.t('taskCenter.minutes', { minutes: mins, seconds: secs });
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
function handleDownload(task: BackgroundTask) {
|
|
@@ -140,11 +148,11 @@
|
|
|
140
148
|
size="sm"
|
|
141
149
|
class="relative flex items-center gap-1.5"
|
|
142
150
|
onclick={() => (open = true)}
|
|
143
|
-
aria-label=
|
|
151
|
+
aria-label={i18n.t('taskCenter.open')}
|
|
144
152
|
data-svadmin-action="open-task-center"
|
|
145
153
|
>
|
|
146
154
|
<Activity class={cn('h-4 w-4', runningCount > 0 ? 'text-primary animate-pulse' : 'text-muted-foreground')} />
|
|
147
|
-
<span>{
|
|
155
|
+
<span>{triggerTextValue}</span>
|
|
148
156
|
{#if runningCount > 0}
|
|
149
157
|
<span
|
|
150
158
|
class="ml-1 inline-flex items-center justify-center h-4 min-w-[1rem] px-1 text-xs font-semibold rounded-full bg-primary text-primary-foreground"
|
|
@@ -163,9 +171,9 @@
|
|
|
163
171
|
<div>
|
|
164
172
|
<h2 class="text-base font-semibold text-foreground flex items-center gap-2">
|
|
165
173
|
<Activity class="h-4 w-4 text-primary" />
|
|
166
|
-
{
|
|
174
|
+
{titleText}
|
|
167
175
|
</h2>
|
|
168
|
-
<p class="text-xs text-muted-foreground mt-0.5">{
|
|
176
|
+
<p class="text-xs text-muted-foreground mt-0.5">{descriptionText}</p>
|
|
169
177
|
</div>
|
|
170
178
|
<div class="flex items-center gap-1">
|
|
171
179
|
{#if onrefresh}
|
|
@@ -174,7 +182,7 @@
|
|
|
174
182
|
size="icon"
|
|
175
183
|
class="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
176
184
|
onclick={() => onrefresh?.()}
|
|
177
|
-
aria-label=
|
|
185
|
+
aria-label={i18n.t('taskCenter.refresh')}
|
|
178
186
|
data-svadmin-action="refresh-tasks"
|
|
179
187
|
>
|
|
180
188
|
<RotateCw class="h-4 w-4" />
|
|
@@ -188,7 +196,7 @@
|
|
|
188
196
|
open = false;
|
|
189
197
|
onclose?.();
|
|
190
198
|
}}
|
|
191
|
-
aria-label=
|
|
199
|
+
aria-label={i18n.t('taskCenter.close')}
|
|
192
200
|
data-svadmin-action="close-task-center"
|
|
193
201
|
>
|
|
194
202
|
<X class="h-4 w-4" />
|
|
@@ -212,7 +220,7 @@
|
|
|
212
220
|
onclick={() => (activeTab = 'all')}
|
|
213
221
|
data-svadmin-tab="all"
|
|
214
222
|
>
|
|
215
|
-
|
|
223
|
+
{i18n.t('taskCenter.tab.all')} ({tasks.length})
|
|
216
224
|
</button>
|
|
217
225
|
<button
|
|
218
226
|
type="button"
|
|
@@ -227,7 +235,7 @@
|
|
|
227
235
|
onclick={() => (activeTab = 'running')}
|
|
228
236
|
data-svadmin-tab="running"
|
|
229
237
|
>
|
|
230
|
-
|
|
238
|
+
{i18n.t('taskCenter.tab.running')}
|
|
231
239
|
{#if runningCount > 0}
|
|
232
240
|
<span class="inline-flex h-1.5 w-1.5 rounded-full bg-primary animate-pulse"></span>
|
|
233
241
|
<span class="text-xs bg-primary/10 text-primary px-1 rounded">{runningCount}</span>
|
|
@@ -246,7 +254,7 @@
|
|
|
246
254
|
onclick={() => (activeTab = 'pending')}
|
|
247
255
|
data-svadmin-tab="pending"
|
|
248
256
|
>
|
|
249
|
-
|
|
257
|
+
{i18n.t('taskCenter.tab.pending')} ({pendingCount})
|
|
250
258
|
</button>
|
|
251
259
|
<button
|
|
252
260
|
type="button"
|
|
@@ -261,7 +269,7 @@
|
|
|
261
269
|
onclick={() => (activeTab = 'completed')}
|
|
262
270
|
data-svadmin-tab="completed"
|
|
263
271
|
>
|
|
264
|
-
|
|
272
|
+
{i18n.t('taskCenter.tab.completed')} ({completedCount})
|
|
265
273
|
</button>
|
|
266
274
|
<button
|
|
267
275
|
type="button"
|
|
@@ -276,7 +284,7 @@
|
|
|
276
284
|
onclick={() => (activeTab = 'failed')}
|
|
277
285
|
data-svadmin-tab="failed"
|
|
278
286
|
>
|
|
279
|
-
|
|
287
|
+
{i18n.t('taskCenter.tab.failed')} ({failedCount})
|
|
280
288
|
</button>
|
|
281
289
|
</div>
|
|
282
290
|
|
|
@@ -289,7 +297,7 @@
|
|
|
289
297
|
data-svadmin-action="clear-completed"
|
|
290
298
|
>
|
|
291
299
|
<Trash2 class="h-3 w-3 mr-1" />
|
|
292
|
-
|
|
300
|
+
{i18n.t('taskCenter.clear')}
|
|
293
301
|
</Button>
|
|
294
302
|
{/if}
|
|
295
303
|
</div>
|
|
@@ -299,7 +307,7 @@
|
|
|
299
307
|
{#if filteredTasks.length === 0}
|
|
300
308
|
<div class="flex flex-col items-center justify-center py-16 text-center text-muted-foreground">
|
|
301
309
|
<Inbox class="h-10 w-10 stroke-1 text-muted-foreground/40 mb-3" />
|
|
302
|
-
<p class="text-sm">{
|
|
310
|
+
<p class="text-sm">{emptyTextValue}</p>
|
|
303
311
|
</div>
|
|
304
312
|
{:else}
|
|
305
313
|
{#each filteredTasks as task (task.id)}
|
|
@@ -323,27 +331,27 @@
|
|
|
323
331
|
{#if task.status === 'running'}
|
|
324
332
|
<span class="inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-primary/10 text-primary">
|
|
325
333
|
<RotateCw class="h-3 w-3 animate-spin" />
|
|
326
|
-
|
|
334
|
+
{i18n.t('taskCenter.status.running')}
|
|
327
335
|
</span>
|
|
328
336
|
{:else if task.status === 'pending'}
|
|
329
337
|
<span class="inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-muted text-muted-foreground">
|
|
330
338
|
<Clock class="h-3 w-3" />
|
|
331
|
-
|
|
339
|
+
{i18n.t('taskCenter.status.pending')}
|
|
332
340
|
</span>
|
|
333
341
|
{:else if task.status === 'completed'}
|
|
334
342
|
<span class="inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-success/15 text-success">
|
|
335
343
|
<CheckCircle2 class="h-3 w-3" />
|
|
336
|
-
|
|
344
|
+
{i18n.t('taskCenter.status.completed')}
|
|
337
345
|
</span>
|
|
338
346
|
{:else if task.status === 'failed'}
|
|
339
347
|
<span class="inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-destructive/15 text-destructive">
|
|
340
348
|
<AlertCircle class="h-3 w-3" />
|
|
341
|
-
|
|
349
|
+
{i18n.t('taskCenter.status.failed')}
|
|
342
350
|
</span>
|
|
343
351
|
{:else if task.status === 'cancelled'}
|
|
344
352
|
<span class="inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-muted text-muted-foreground">
|
|
345
353
|
<XCircle class="h-3 w-3" />
|
|
346
|
-
|
|
354
|
+
{i18n.t('taskCenter.status.cancelled')}
|
|
347
355
|
</span>
|
|
348
356
|
{/if}
|
|
349
357
|
</div>
|
|
@@ -382,7 +390,7 @@
|
|
|
382
390
|
{/if}
|
|
383
391
|
</span>
|
|
384
392
|
{#if task.estimatedSecondsRemaining != null && task.status === 'running'}
|
|
385
|
-
<span
|
|
393
|
+
<span>{i18n.t('taskCenter.remaining', { duration: formatDuration(task.estimatedSecondsRemaining) })}</span>
|
|
386
394
|
{/if}
|
|
387
395
|
</div>
|
|
388
396
|
</div>
|
|
@@ -398,7 +406,7 @@
|
|
|
398
406
|
<!-- Card Action Footer -->
|
|
399
407
|
<div class="mt-3 pt-2.5 border-t border-border/60 flex items-center justify-between text-xs">
|
|
400
408
|
<span class="text-muted-foreground text-xs">
|
|
401
|
-
|
|
409
|
+
{i18n.t('taskCenter.id')}: <span class="font-mono">{task.id}</span>
|
|
402
410
|
</span>
|
|
403
411
|
<div class="flex items-center gap-1">
|
|
404
412
|
{#if task.status === 'completed' && (task.downloadUrl || ondownload)}
|
|
@@ -410,7 +418,7 @@
|
|
|
410
418
|
data-svadmin-action="download-result"
|
|
411
419
|
>
|
|
412
420
|
<Download class="h-3 w-3 mr-1" />
|
|
413
|
-
|
|
421
|
+
{i18n.t('taskCenter.download')}
|
|
414
422
|
</Button>
|
|
415
423
|
{/if}
|
|
416
424
|
|
|
@@ -423,7 +431,7 @@
|
|
|
423
431
|
data-svadmin-action="retry-task"
|
|
424
432
|
>
|
|
425
433
|
<RotateCw class="h-3 w-3 mr-1" />
|
|
426
|
-
|
|
434
|
+
{i18n.t('taskCenter.retry')}
|
|
427
435
|
</Button>
|
|
428
436
|
{/if}
|
|
429
437
|
|
|
@@ -436,7 +444,7 @@
|
|
|
436
444
|
data-svadmin-action="cancel-task"
|
|
437
445
|
>
|
|
438
446
|
<XCircle class="h-3 w-3 mr-1" />
|
|
439
|
-
|
|
447
|
+
{i18n.t('taskCenter.cancel')}
|
|
440
448
|
</Button>
|
|
441
449
|
{/if}
|
|
442
450
|
</div>
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Building2,
|
|
4
|
+
ChevronDown,
|
|
5
|
+
Check,
|
|
6
|
+
Search,
|
|
7
|
+
Clock,
|
|
8
|
+
Plus,
|
|
9
|
+
Users,
|
|
10
|
+
ArrowRightLeft,
|
|
11
|
+
Settings,
|
|
12
|
+
} from '@lucide/svelte';
|
|
13
|
+
import { cn } from '../utils.js';
|
|
14
|
+
|
|
15
|
+
export interface TenantRole {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
isPrimary?: boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TenantItem {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
code?: string | undefined;
|
|
25
|
+
type?: 'group' | 'subsidiary' | 'division' | 'store' | 'workspace' | undefined;
|
|
26
|
+
logo?: string | undefined;
|
|
27
|
+
tier?: 'free' | 'pro' | 'enterprise' | undefined;
|
|
28
|
+
roles?: (TenantRole | string)[] | undefined;
|
|
29
|
+
status?: 'active' | 'suspended' | 'trial' | undefined;
|
|
30
|
+
memberCount?: number | undefined;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
parentId?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TenantContextSwitcherProps {
|
|
36
|
+
currentTenantId?: string | undefined;
|
|
37
|
+
tenants?: TenantItem[] | undefined;
|
|
38
|
+
recentTenantIds?: string[] | undefined;
|
|
39
|
+
userRole?: string | undefined;
|
|
40
|
+
isSwitching?: boolean | undefined;
|
|
41
|
+
allowCreate?: boolean | undefined;
|
|
42
|
+
placeholder?: string | undefined;
|
|
43
|
+
searchPlaceholder?: string | undefined;
|
|
44
|
+
class?: string | undefined;
|
|
45
|
+
onTenantSelect?: ((tenant: TenantItem) => void | Promise<void>) | undefined;
|
|
46
|
+
onCreateTenant?: (() => void) | undefined;
|
|
47
|
+
onManageWorkspaces?: (() => void) | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let {
|
|
51
|
+
currentTenantId = $bindable('tenant-corp-01'),
|
|
52
|
+
tenants = [
|
|
53
|
+
{ id: 'tenant-corp-01', name: '星谷数智总集团', code: 'HQ-GLOBAL', type: 'group', tier: 'enterprise', memberCount: 1280, status: 'active' },
|
|
54
|
+
{ id: 'tenant-east-02', name: '华东大区创新科技中心', code: 'DIV-EAST', type: 'subsidiary', tier: 'enterprise', memberCount: 420, status: 'active' },
|
|
55
|
+
{ id: 'tenant-cloud-03', name: 'SupaCloud 云原生实验室', code: 'LAB-CLOUD', type: 'workspace', tier: 'pro', memberCount: 65, status: 'active' },
|
|
56
|
+
{ id: 'tenant-sandbox-04', name: '金融合规验收隔离沙箱', code: 'FIN-SANDBOX', type: 'subsidiary', tier: 'pro', memberCount: 18, status: 'trial' },
|
|
57
|
+
],
|
|
58
|
+
recentTenantIds = ['tenant-corp-01', 'tenant-east-02'],
|
|
59
|
+
userRole = '全局系统主管',
|
|
60
|
+
isSwitching = false,
|
|
61
|
+
allowCreate = true,
|
|
62
|
+
placeholder = '选择工作区/租户',
|
|
63
|
+
searchPlaceholder = '搜索租户名称或编号...',
|
|
64
|
+
class: className = '',
|
|
65
|
+
onTenantSelect,
|
|
66
|
+
onCreateTenant,
|
|
67
|
+
onManageWorkspaces,
|
|
68
|
+
}: TenantContextSwitcherProps = $props();
|
|
69
|
+
|
|
70
|
+
let isOpen = $state(false);
|
|
71
|
+
let searchQuery = $state('');
|
|
72
|
+
|
|
73
|
+
let currentTenant = $derived(
|
|
74
|
+
tenants.find((t) => t.id === currentTenantId) ?? tenants[0]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
let filteredTenants = $derived(
|
|
78
|
+
tenants.filter((t) => {
|
|
79
|
+
if (!searchQuery.trim()) return true;
|
|
80
|
+
const q = searchQuery.toLowerCase();
|
|
81
|
+
return t.name.toLowerCase().includes(q) || (t.code && t.code.toLowerCase().includes(q));
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
let recentTenants = $derived(
|
|
86
|
+
recentTenantIds
|
|
87
|
+
.map((id) => tenants.find((t) => t.id === id))
|
|
88
|
+
.filter((t): t is TenantItem => Boolean(t))
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
function handleSelect(tenant: TenantItem) {
|
|
92
|
+
if (tenant.status === 'suspended') return;
|
|
93
|
+
currentTenantId = tenant.id;
|
|
94
|
+
isOpen = false;
|
|
95
|
+
onTenantSelect?.(tenant);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getTypeBadge(type: TenantItem['type']) {
|
|
99
|
+
switch (type) {
|
|
100
|
+
case 'group':
|
|
101
|
+
return { label: '集团总部', class: 'bg-primary/10 text-primary border-primary/20' };
|
|
102
|
+
case 'subsidiary':
|
|
103
|
+
return { label: '子公司', class: 'bg-info/10 text-info border-info/20' };
|
|
104
|
+
case 'division':
|
|
105
|
+
return { label: '事业部', class: 'bg-warning/10 text-warning border-warning/20' };
|
|
106
|
+
case 'store':
|
|
107
|
+
return { label: '门店/网点', class: 'bg-secondary text-secondary-foreground border-border' };
|
|
108
|
+
default:
|
|
109
|
+
return { label: '工作区', class: 'bg-muted text-muted-foreground border-border' };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getTierBadge(tier: TenantItem['tier']) {
|
|
114
|
+
switch (tier) {
|
|
115
|
+
case 'enterprise':
|
|
116
|
+
return { label: '旗舰版', class: 'bg-primary/10 text-primary border-primary/20' };
|
|
117
|
+
case 'pro':
|
|
118
|
+
return { label: '专业版', class: 'bg-success/10 text-success border-success/20' };
|
|
119
|
+
default:
|
|
120
|
+
return { label: '基础版', class: 'bg-muted text-muted-foreground border-border' };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<div
|
|
126
|
+
class={cn('relative inline-block text-left', className)}
|
|
127
|
+
data-svadmin-component="tenant-context-switcher"
|
|
128
|
+
>
|
|
129
|
+
<!-- 切换触发器按钮 -->
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
class="flex items-center gap-2.5 px-3 py-1.5 rounded-lg border border-border bg-card hover:bg-muted/50 text-foreground transition-all duration-150 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
133
|
+
aria-expanded={isOpen}
|
|
134
|
+
aria-haspopup="listbox"
|
|
135
|
+
onclick={() => (isOpen = !isOpen)}
|
|
136
|
+
>
|
|
137
|
+
<div class="flex items-center justify-center w-7 h-7 rounded-md bg-primary/10 text-primary font-semibold text-xs border border-primary/20">
|
|
138
|
+
{#if currentTenant?.logo}
|
|
139
|
+
<img src={currentTenant.logo} alt={currentTenant.name} class="w-full h-full rounded-md object-cover" />
|
|
140
|
+
{:else}
|
|
141
|
+
<Building2 class="w-4 h-4" />
|
|
142
|
+
{/if}
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="flex flex-col text-left">
|
|
146
|
+
<div class="flex items-center gap-1.5">
|
|
147
|
+
<span class="font-medium text-sm leading-tight tracking-tight text-foreground line-clamp-1 max-w-[160px]">
|
|
148
|
+
{currentTenant?.name ?? placeholder}
|
|
149
|
+
</span>
|
|
150
|
+
{#if currentTenant?.tier}
|
|
151
|
+
{@const tier = getTierBadge(currentTenant.tier)}
|
|
152
|
+
<span class={cn('text-[10px] font-medium px-1.5 py-0.2 rounded border leading-none', tier.class)}>
|
|
153
|
+
{tier.label}
|
|
154
|
+
</span>
|
|
155
|
+
{/if}
|
|
156
|
+
</div>
|
|
157
|
+
<span class="text-[11px] text-muted-foreground leading-tight">
|
|
158
|
+
{currentTenant?.code ?? userRole}
|
|
159
|
+
</span>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<div class="ml-1 text-muted-foreground">
|
|
163
|
+
{#if isSwitching}
|
|
164
|
+
<ArrowRightLeft class="w-3.5 h-3.5 animate-spin text-primary" />
|
|
165
|
+
{:else}
|
|
166
|
+
<ChevronDown class={cn('w-3.5 h-3.5 transition-transform duration-200', isOpen && 'rotate-180')} />
|
|
167
|
+
{/if}
|
|
168
|
+
</div>
|
|
169
|
+
</button>
|
|
170
|
+
|
|
171
|
+
<!-- 浮层下拉面板 -->
|
|
172
|
+
{#if isOpen}
|
|
173
|
+
<div
|
|
174
|
+
class="fixed inset-0 z-40"
|
|
175
|
+
onclick={() => (isOpen = false)}
|
|
176
|
+
aria-hidden="true"
|
|
177
|
+
></div>
|
|
178
|
+
|
|
179
|
+
<div
|
|
180
|
+
class="absolute left-0 mt-1.5 w-80 rounded-xl border border-border bg-card text-foreground shadow-xl z-50 overflow-hidden flex flex-col animate-in fade-in-0 zoom-in-95 duration-150"
|
|
181
|
+
role="listbox"
|
|
182
|
+
>
|
|
183
|
+
<!-- 搜索栏 -->
|
|
184
|
+
<div class="p-2.5 border-b border-border bg-muted/20">
|
|
185
|
+
<div class="relative flex items-center">
|
|
186
|
+
<Search class="absolute left-2.5 w-3.5 h-3.5 text-muted-foreground pointer-events-none" />
|
|
187
|
+
<input
|
|
188
|
+
type="text"
|
|
189
|
+
bind:value={searchQuery}
|
|
190
|
+
placeholder={searchPlaceholder}
|
|
191
|
+
class="w-full pl-8 pr-3 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<!-- 最近访问 -->
|
|
197
|
+
{#if recentTenants.length > 0 && !searchQuery}
|
|
198
|
+
<div class="px-3 pt-2 pb-1 border-b border-border/50">
|
|
199
|
+
<div class="flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground mb-1.5">
|
|
200
|
+
<Clock class="w-3 h-3" />
|
|
201
|
+
<span>最近访问</span>
|
|
202
|
+
</div>
|
|
203
|
+
<div class="flex flex-wrap gap-1 mb-1">
|
|
204
|
+
{#each recentTenants as recent (recent.id)}
|
|
205
|
+
<button
|
|
206
|
+
type="button"
|
|
207
|
+
class={cn(
|
|
208
|
+
'text-xs px-2 py-1 rounded-md border text-left transition-colors flex items-center gap-1.5',
|
|
209
|
+
recent.id === currentTenantId
|
|
210
|
+
? 'border-primary/40 bg-primary/10 text-primary font-medium'
|
|
211
|
+
: 'border-border bg-muted/30 text-foreground hover:bg-muted'
|
|
212
|
+
)}
|
|
213
|
+
onclick={() => handleSelect(recent)}
|
|
214
|
+
>
|
|
215
|
+
<span class="truncate max-w-[100px]">{recent.name}</span>
|
|
216
|
+
{#if recent.id === currentTenantId}
|
|
217
|
+
<Check class="w-3 h-3 text-primary" />
|
|
218
|
+
{/if}
|
|
219
|
+
</button>
|
|
220
|
+
{/each}
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
{/if}
|
|
224
|
+
|
|
225
|
+
<!-- 租户列表 -->
|
|
226
|
+
<div class="max-h-60 overflow-y-auto p-1.5 divide-y divide-border/30">
|
|
227
|
+
{#if filteredTenants.length === 0}
|
|
228
|
+
<div class="py-6 text-center text-xs text-muted-foreground">
|
|
229
|
+
未检索到匹配的租户或工作区
|
|
230
|
+
</div>
|
|
231
|
+
{:else}
|
|
232
|
+
{#each filteredTenants as tenant (tenant.id)}
|
|
233
|
+
{@const isSelected = tenant.id === currentTenantId}
|
|
234
|
+
{@const typeBadge = getTypeBadge(tenant.type)}
|
|
235
|
+
{@const isSuspended = tenant.status === 'suspended'}
|
|
236
|
+
<button
|
|
237
|
+
type="button"
|
|
238
|
+
class={cn(
|
|
239
|
+
'w-full flex items-center justify-between p-2 rounded-lg text-left transition-colors',
|
|
240
|
+
isSelected ? 'bg-primary/10 text-primary' : 'hover:bg-muted/60 text-foreground',
|
|
241
|
+
isSuspended && 'opacity-60 cursor-not-allowed'
|
|
242
|
+
)}
|
|
243
|
+
disabled={isSuspended}
|
|
244
|
+
onclick={() => handleSelect(tenant)}
|
|
245
|
+
>
|
|
246
|
+
<div class="flex items-center gap-2.5 min-w-0">
|
|
247
|
+
<div class="flex items-center justify-center w-7 h-7 rounded-md bg-muted text-muted-foreground border border-border shrink-0">
|
|
248
|
+
<Building2 class="w-3.5 h-3.5" />
|
|
249
|
+
</div>
|
|
250
|
+
<div class="flex flex-col min-w-0">
|
|
251
|
+
<div class="flex items-center gap-1.5">
|
|
252
|
+
<span class={cn('text-xs font-medium truncate', isSelected ? 'text-primary' : 'text-foreground')}>
|
|
253
|
+
{tenant.name}
|
|
254
|
+
</span>
|
|
255
|
+
<span class={cn('text-[9px] px-1 py-0.2 rounded border leading-none shrink-0', typeBadge.class)}>
|
|
256
|
+
{typeBadge.label}
|
|
257
|
+
</span>
|
|
258
|
+
</div>
|
|
259
|
+
<div class="flex items-center gap-2 text-[10px] text-muted-foreground mt-0.5">
|
|
260
|
+
{#if tenant.code}
|
|
261
|
+
<span>{tenant.code}</span>
|
|
262
|
+
{/if}
|
|
263
|
+
{#if tenant.memberCount}
|
|
264
|
+
<span class="flex items-center gap-0.5">
|
|
265
|
+
<Users class="w-2.5 h-2.5" />
|
|
266
|
+
{tenant.memberCount} 成员
|
|
267
|
+
</span>
|
|
268
|
+
{/if}
|
|
269
|
+
{#if isSuspended}
|
|
270
|
+
<span class="text-destructive font-medium">已停用</span>
|
|
271
|
+
{/if}
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
{#if isSelected}
|
|
277
|
+
<Check class="w-4 h-4 text-primary shrink-0 ml-2" />
|
|
278
|
+
{/if}
|
|
279
|
+
</button>
|
|
280
|
+
{/each}
|
|
281
|
+
{/if}
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<!-- 底部操作区 -->
|
|
285
|
+
<div class="p-1.5 border-t border-border bg-muted/30 flex items-center justify-between gap-1 text-xs">
|
|
286
|
+
{#if allowCreate}
|
|
287
|
+
<button
|
|
288
|
+
type="button"
|
|
289
|
+
class="flex items-center gap-1 px-2.5 py-1 rounded-md text-foreground hover:bg-muted font-medium transition-colors"
|
|
290
|
+
onclick={() => {
|
|
291
|
+
isOpen = false;
|
|
292
|
+
onCreateTenant?.();
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
<Plus class="w-3.5 h-3.5 text-primary" />
|
|
296
|
+
<span>创建新租户</span>
|
|
297
|
+
</button>
|
|
298
|
+
{/if}
|
|
299
|
+
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
class="flex items-center gap-1 px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors ml-auto"
|
|
303
|
+
onclick={() => {
|
|
304
|
+
isOpen = false;
|
|
305
|
+
onManageWorkspaces?.();
|
|
306
|
+
}}
|
|
307
|
+
>
|
|
308
|
+
<Settings class="w-3 h-3" />
|
|
309
|
+
<span>组织管理</span>
|
|
310
|
+
</button>
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
{/if}
|
|
314
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface TenantRole {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
isPrimary?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface TenantItem {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
code?: string | undefined;
|
|
10
|
+
type?: 'group' | 'subsidiary' | 'division' | 'store' | 'workspace' | undefined;
|
|
11
|
+
logo?: string | undefined;
|
|
12
|
+
tier?: 'free' | 'pro' | 'enterprise' | undefined;
|
|
13
|
+
roles?: (TenantRole | string)[] | undefined;
|
|
14
|
+
status?: 'active' | 'suspended' | 'trial' | undefined;
|
|
15
|
+
memberCount?: number | undefined;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
parentId?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface TenantContextSwitcherProps {
|
|
20
|
+
currentTenantId?: string | undefined;
|
|
21
|
+
tenants?: TenantItem[] | undefined;
|
|
22
|
+
recentTenantIds?: string[] | undefined;
|
|
23
|
+
userRole?: string | undefined;
|
|
24
|
+
isSwitching?: boolean | undefined;
|
|
25
|
+
allowCreate?: boolean | undefined;
|
|
26
|
+
placeholder?: string | undefined;
|
|
27
|
+
searchPlaceholder?: string | undefined;
|
|
28
|
+
class?: string | undefined;
|
|
29
|
+
onTenantSelect?: ((tenant: TenantItem) => void | Promise<void>) | undefined;
|
|
30
|
+
onCreateTenant?: (() => void) | undefined;
|
|
31
|
+
onManageWorkspaces?: (() => void) | undefined;
|
|
32
|
+
}
|
|
33
|
+
declare const TenantContextSwitcher: import("svelte").Component<TenantContextSwitcherProps, {}, "currentTenantId">;
|
|
34
|
+
type TenantContextSwitcher = ReturnType<typeof TenantContextSwitcher>;
|
|
35
|
+
export default TenantContextSwitcher;
|