@svadmin/ui 0.121.0 → 0.125.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 +757 -7
- package/dist/app.theme.css +757 -7
- 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 +325 -0
- package/dist/components/AnnouncementBanner.svelte.d.ts +49 -0
- package/dist/components/ApiPlayground.svelte +255 -0
- package/dist/components/ApiPlayground.svelte.d.ts +24 -0
- 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 +551 -0
- package/dist/components/AsyncExportModal.svelte.d.ts +50 -0
- package/dist/components/AudioFeedbackProvider.svelte +131 -0
- package/dist/components/AudioFeedbackProvider.svelte.d.ts +11 -0
- package/dist/components/AuditLogViewer.svelte +1 -1
- package/dist/components/AuditTrailInspector.svelte +448 -0
- package/dist/components/AuditTrailInspector.svelte.d.ts +44 -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/CanvasAnnotation.svelte +1 -1
- package/dist/components/ChartAnnotationOverlay.svelte +228 -0
- package/dist/components/ChartAnnotationOverlay.svelte.d.ts +21 -0
- package/dist/components/ClusterTopologyGraph.svelte +317 -0
- package/dist/components/ClusterTopologyGraph.svelte.d.ts +31 -0
- package/dist/components/ColumnFilterBuilder.svelte +135 -0
- package/dist/components/ColumnFilterBuilder.svelte.d.ts +20 -0
- package/dist/components/ColumnMappingTable.svelte +174 -0
- package/dist/components/ColumnMappingTable.svelte.d.ts +23 -0
- package/dist/components/ColumnSettings.svelte +1 -1
- package/dist/components/ColumnVisibilityDrawer.svelte +541 -0
- package/dist/components/ColumnVisibilityDrawer.svelte.d.ts +16 -0
- package/dist/components/ConcurrentConflictModal.svelte +7 -7
- package/dist/components/ConversionFunnel.svelte +154 -0
- package/dist/components/ConversionFunnel.svelte.d.ts +22 -0
- package/dist/components/CronExpressionBuilder.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/DecisionTable.svelte +1 -1
- package/dist/components/DevTools.svelte +4 -4
- package/dist/components/DraggableRowTable.svelte +1 -1
- package/dist/components/DualApprovalGate.svelte +485 -0
- package/dist/components/DualApprovalGate.svelte.d.ts +58 -0
- package/dist/components/EditableTable.svelte +1 -1
- 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/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/GlobalShortcuts.svelte +1 -1
- 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/ImageCropper.svelte +1 -1
- package/dist/components/ImportPreviewValidator.svelte +239 -0
- package/dist/components/ImportPreviewValidator.svelte.d.ts +26 -0
- package/dist/components/ImportWizard.svelte +1 -1
- package/dist/components/IncidentWarRoomDrawer.svelte +194 -0
- package/dist/components/IncidentWarRoomDrawer.svelte.d.ts +24 -0
- package/dist/components/JsonSchemaForm.svelte +5 -5
- package/dist/components/JsonViewer.svelte +11 -11
- package/dist/components/KeyboardShortcutsModal.svelte +362 -0
- package/dist/components/KeyboardShortcutsModal.svelte.d.ts +22 -0
- package/dist/components/KpiCard.svelte +5 -5
- 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/MasterDetailView.svelte +1 -1
- package/dist/components/MasterSubTableDrawer.svelte +223 -0
- package/dist/components/MasterSubTableDrawer.svelte.d.ts +25 -0
- package/dist/components/MetricGrid.svelte +2 -2
- package/dist/components/MicroAppBridge.svelte +59 -0
- package/dist/components/MicroAppBridge.svelte.d.ts +11 -0
- package/dist/components/MockDataInterceptor.svelte +292 -0
- package/dist/components/MockDataInterceptor.svelte.d.ts +27 -0
- package/dist/components/OfflineSyncBanner.svelte +1 -1
- package/dist/components/OmnibarCommandPalette.svelte +320 -0
- package/dist/components/OmnibarCommandPalette.svelte.d.ts +27 -0
- package/dist/components/OrgChart.svelte +1 -1
- package/dist/components/OrgTreePicker.svelte +1 -1
- package/dist/components/OtpInput.svelte +5 -5
- package/dist/components/PageSkeleton.svelte +19 -5
- package/dist/components/PageSkeleton.svelte.d.ts +5 -3
- package/dist/components/PdfDocumentViewer.svelte +2 -2
- package/dist/components/PeriodComparisonCard.svelte +142 -0
- package/dist/components/PeriodComparisonCard.svelte.d.ts +16 -0
- package/dist/components/PermissionSimulator.svelte +319 -0
- package/dist/components/PermissionSimulator.svelte.d.ts +34 -0
- package/dist/components/PivotDrilldownModal.svelte +6 -6
- package/dist/components/PivotMatrix.svelte +271 -0
- package/dist/components/PivotMatrix.svelte.d.ts +32 -0
- package/dist/components/PivotTable.svelte +1 -1
- 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/PricingCard.svelte +1 -1
- package/dist/components/PricingTable.svelte +1 -1
- package/dist/components/PrintableBill.svelte +2 -2
- package/dist/components/PrintableReportLayout.svelte +259 -0
- package/dist/components/PrintableReportLayout.svelte.d.ts +32 -0
- package/dist/components/ProSkeleton.svelte +10 -6
- 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/ResultPage.svelte +2 -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/SafeDeleteConfirm.svelte +5 -5
- package/dist/components/SankeyChart.svelte +111 -0
- package/dist/components/SankeyChart.svelte.d.ts +22 -0
- package/dist/components/ScheduledJobManager.svelte +225 -0
- package/dist/components/ScheduledJobManager.svelte.d.ts +23 -0
- package/dist/components/SchemaVisualModeler.svelte +336 -0
- package/dist/components/SchemaVisualModeler.svelte.d.ts +17 -0
- 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/SensitiveDataMask.svelte +81 -22
- package/dist/components/SensitiveDataMask.svelte.d.ts +15 -10
- package/dist/components/ServerStatusGrid.svelte +179 -0
- package/dist/components/ServerStatusGrid.svelte.d.ts +21 -0
- package/dist/components/SessionTimeoutGuard.svelte +154 -0
- package/dist/components/SessionTimeoutGuard.svelte.d.ts +25 -0
- package/dist/components/SignaturePad.svelte +1 -1
- package/dist/components/SliderCaptcha.svelte +1 -1
- package/dist/components/SnapshotTimelineReplay.svelte +219 -0
- package/dist/components/SnapshotTimelineReplay.svelte.d.ts +19 -0
- package/dist/components/SplitPaneLayout.svelte +1 -1
- package/dist/components/SpreadsheetView.svelte +1 -1
- package/dist/components/SqlConsole.svelte +247 -0
- package/dist/components/SqlConsole.svelte.d.ts +20 -0
- package/dist/components/StepForm.svelte +1 -1
- package/dist/components/StepWizard.svelte +513 -0
- package/dist/components/StepWizard.svelte.d.ts +49 -0
- 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/TableClipboardManager.svelte +307 -0
- package/dist/components/TableClipboardManager.svelte.d.ts +13 -0
- package/dist/components/TaskCenter.svelte +46 -38
- 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/TextDiffViewer.svelte +613 -0
- package/dist/components/TextDiffViewer.svelte.d.ts +39 -0
- 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/TreeTransfer.svelte +1 -1
- package/dist/components/TreeTransferSelect.svelte +333 -0
- package/dist/components/TreeTransferSelect.svelte.d.ts +18 -0
- package/dist/components/UnsavedChangesGuard.svelte +5 -5
- package/dist/components/UsageCard.svelte +1 -1
- package/dist/components/VersionDiffViewer.svelte +1 -1
- package/dist/components/VirtualCardGrid.svelte +180 -0
- package/dist/components/VirtualCardGrid.svelte.d.ts +65 -0
- package/dist/components/VirtualTable.svelte +1 -1
- package/dist/components/VirtualTreeSelect.svelte +1 -1
- 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/WorkflowDesigner.svelte +3 -3
- 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/WorkflowProcessCard.svelte +1 -1
- package/dist/components/WorkflowStepper.svelte +250 -0
- package/dist/components/WorkflowStepper.svelte.d.ts +27 -0
- package/dist/components/charts/GaugeChart.svelte +1 -1
- package/dist/components/list-i18n.d.ts +7 -0
- package/dist/components/list-i18n.js +14 -0
- 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/useAudioAlert.d.svelte.ts +1 -0
- package/dist/components/useAudioAlert.svelte.d.ts +13 -0
- package/dist/components/useAudioAlert.svelte.js +90 -0
- 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/useHotkeys.d.svelte.ts +1 -0
- package/dist/components/useHotkeys.svelte.d.ts +44 -0
- package/dist/components/useHotkeys.svelte.js +190 -0
- package/dist/components/useMicroAppEvent.d.svelte.ts +1 -0
- package/dist/components/useMicroAppEvent.svelte.d.ts +16 -0
- package/dist/components/useMicroAppEvent.svelte.js +61 -0
- package/dist/components/usePrintExport.d.svelte.ts +1 -0
- package/dist/components/usePrintExport.svelte.d.ts +11 -0
- package/dist/components/usePrintExport.svelte.js +45 -0
- package/dist/components/useSessionTimeout.d.svelte.ts +1 -0
- package/dist/components/useSessionTimeout.svelte.d.ts +28 -0
- package/dist/components/useSessionTimeout.svelte.js +182 -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/useTableClipboard.d.svelte.ts +1 -0
- package/dist/components/useTableClipboard.svelte.d.ts +28 -0
- package/dist/components/useTableClipboard.svelte.js +116 -0
- package/dist/components.css +1 -1
- package/dist/index.d.ts +96 -11
- package/dist/index.js +146 -1
- package/package.json +4 -4
|
@@ -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;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
PieChart,
|
|
5
|
+
AlertTriangle,
|
|
6
|
+
Zap,
|
|
7
|
+
HardDrive,
|
|
8
|
+
Users,
|
|
9
|
+
Cpu,
|
|
10
|
+
ArrowUpRight,
|
|
11
|
+
} from '@lucide/svelte';
|
|
12
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
13
|
+
import { cn } from '../utils.js';
|
|
14
|
+
import { Button } from './ui/button/index.js';
|
|
15
|
+
|
|
16
|
+
export interface TenantQuotaItem {
|
|
17
|
+
id: string;
|
|
18
|
+
resourceName: string;
|
|
19
|
+
used: number;
|
|
20
|
+
limit: number;
|
|
21
|
+
unit?: string | undefined;
|
|
22
|
+
icon?: 'api' | 'storage' | 'seats' | 'compute' | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TenantQuotasMatrixProps {
|
|
26
|
+
tenantName?: string | undefined;
|
|
27
|
+
planName?: string | undefined;
|
|
28
|
+
quotas?: TenantQuotaItem[] | undefined;
|
|
29
|
+
title?: string | undefined;
|
|
30
|
+
class?: string | undefined;
|
|
31
|
+
onUpgradePlan?: (() => void) | undefined;
|
|
32
|
+
onRequestQuotaIncrease?: ((quota: TenantQuotaItem) => void) | undefined;
|
|
33
|
+
children?: Snippet | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
tenantName = 'Acme Global Group',
|
|
38
|
+
planName = 'Enterprise Pro',
|
|
39
|
+
quotas = [
|
|
40
|
+
{ id: 'api_calls', resourceName: '每月 API 调用次数', used: 980000, limit: 1000000, unit: '次', icon: 'api' },
|
|
41
|
+
{ id: 'cloud_storage', resourceName: '分布式对象存储容量', used: 485, limit: 500, unit: 'GB', icon: 'storage' },
|
|
42
|
+
{ id: 'team_seats', resourceName: '企业已分配席位', used: 48, limit: 50, unit: '人', icon: 'seats' },
|
|
43
|
+
{ id: 'gpu_compute', resourceName: 'AI 算力点数消耗', used: 12000, limit: 12000, unit: '点', icon: 'compute' },
|
|
44
|
+
],
|
|
45
|
+
title,
|
|
46
|
+
class: className = '',
|
|
47
|
+
onUpgradePlan,
|
|
48
|
+
onRequestQuotaIncrease,
|
|
49
|
+
children,
|
|
50
|
+
}: TenantQuotasMatrixProps = $props();
|
|
51
|
+
|
|
52
|
+
const i18n = useTranslation();
|
|
53
|
+
const chinese = $derived(i18n.locale.startsWith('zh'));
|
|
54
|
+
|
|
55
|
+
let exhaustedModalQuota = $state<TenantQuotaItem | null>(null);
|
|
56
|
+
|
|
57
|
+
const enrichedQuotas = $derived(
|
|
58
|
+
quotas.map((q) => {
|
|
59
|
+
const percentage = Math.min(100, Math.round((q.used / Math.max(1, q.limit)) * 100));
|
|
60
|
+
const isExhausted = q.used >= q.limit;
|
|
61
|
+
const isNearLimit = percentage >= 80 && !isExhausted;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
...q,
|
|
65
|
+
percentage,
|
|
66
|
+
isExhausted,
|
|
67
|
+
isNearLimit,
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const resolvedTitle = $derived(title ?? (chinese ? '多租户配额与资源熔断看板' : 'Tenant Resource Quotas Matrix'));
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div
|
|
77
|
+
data-svadmin-component="TenantQuotasMatrix"
|
|
78
|
+
class={cn(
|
|
79
|
+
'w-full rounded-2xl border border-border bg-card text-card-foreground shadow-xs p-6 space-y-4 flex flex-col text-xs',
|
|
80
|
+
className,
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
<!-- Header Bar -->
|
|
84
|
+
<div class="flex items-center justify-between border-b border-border/70 pb-4">
|
|
85
|
+
<div class="flex items-center gap-2.5">
|
|
86
|
+
<div class="flex h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary border border-primary/20">
|
|
87
|
+
<PieChart class="h-5 w-5" />
|
|
88
|
+
</div>
|
|
89
|
+
<div>
|
|
90
|
+
<h3 class="text-base font-semibold text-foreground">{resolvedTitle}</h3>
|
|
91
|
+
<p class="text-xs text-muted-foreground">{tenantName} · {planName}</p>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{#if onUpgradePlan}
|
|
96
|
+
<Button size="sm" onclick={onUpgradePlan} class="gap-1 text-xs font-semibold">
|
|
97
|
+
<span>{chinese ? '升级租户套餐' : 'Upgrade Plan'}</span>
|
|
98
|
+
<ArrowUpRight class="h-3.5 w-3.5" />
|
|
99
|
+
</Button>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<!-- Quota Gauges Grid -->
|
|
104
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
105
|
+
{#each enrichedQuotas as quota (quota.id)}
|
|
106
|
+
<div
|
|
107
|
+
class={cn(
|
|
108
|
+
'relative flex flex-col justify-between p-4 rounded-xl border transition-all bg-card shadow-2xs space-y-3',
|
|
109
|
+
quota.isExhausted
|
|
110
|
+
? 'border-destructive/60 ring-2 ring-destructive/20 bg-destructive/5'
|
|
111
|
+
: quota.isNearLimit
|
|
112
|
+
? 'border-warning/60 bg-warning/5'
|
|
113
|
+
: 'border-border/80',
|
|
114
|
+
)}
|
|
115
|
+
>
|
|
116
|
+
<div class="flex items-start justify-between">
|
|
117
|
+
<div class="flex items-center gap-2">
|
|
118
|
+
{#if quota.icon === 'api'}
|
|
119
|
+
<Zap class="h-4 w-4 text-primary" />
|
|
120
|
+
{:else if quota.icon === 'storage'}
|
|
121
|
+
<HardDrive class="h-4 w-4 text-info" />
|
|
122
|
+
{:else if quota.icon === 'seats'}
|
|
123
|
+
<Users class="h-4 w-4 text-success" />
|
|
124
|
+
{:else}
|
|
125
|
+
<Cpu class="h-4 w-4 text-warning" />
|
|
126
|
+
{/if}
|
|
127
|
+
<span class="font-bold text-xs text-foreground truncate max-w-28">{quota.resourceName}</span>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{#if quota.isExhausted}
|
|
131
|
+
<span class="rounded bg-destructive/15 px-1.5 py-0.2 text-[9px] font-bold text-destructive uppercase">
|
|
132
|
+
100% 熔断
|
|
133
|
+
</span>
|
|
134
|
+
{:else if quota.isNearLimit}
|
|
135
|
+
<span class="rounded bg-warning/15 px-1.5 py-0.2 text-[9px] font-bold text-warning uppercase">
|
|
136
|
+
{quota.percentage}% 告警
|
|
137
|
+
</span>
|
|
138
|
+
{:else}
|
|
139
|
+
<span class="font-mono text-[11px] text-muted-foreground font-semibold">
|
|
140
|
+
{quota.percentage}%
|
|
141
|
+
</span>
|
|
142
|
+
{/if}
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<!-- Numbers Row -->
|
|
146
|
+
<div class="flex items-baseline justify-between font-mono text-xs">
|
|
147
|
+
<span class="font-bold text-foreground text-sm">
|
|
148
|
+
{quota.used.toLocaleString()} <span class="text-[11px] text-muted-foreground font-normal">{quota.unit ?? ''}</span>
|
|
149
|
+
</span>
|
|
150
|
+
<span class="text-muted-foreground text-[11px]">
|
|
151
|
+
/ {quota.limit.toLocaleString()} {quota.unit ?? ''}
|
|
152
|
+
</span>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<!-- Progress Bar -->
|
|
156
|
+
<div class="h-2 w-full rounded-full bg-muted overflow-hidden">
|
|
157
|
+
<div
|
|
158
|
+
class={cn(
|
|
159
|
+
'h-full rounded-full transition-all duration-300',
|
|
160
|
+
quota.isExhausted ? 'bg-destructive' : quota.isNearLimit ? 'bg-warning' : 'bg-primary',
|
|
161
|
+
)}
|
|
162
|
+
style="width: {quota.percentage}%;"
|
|
163
|
+
></div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
{#if quota.isExhausted && onRequestQuotaIncrease}
|
|
167
|
+
<button
|
|
168
|
+
type="button"
|
|
169
|
+
onclick={() => (exhaustedModalQuota = quota)}
|
|
170
|
+
class="w-full text-center text-[11px] font-bold text-destructive hover:underline pt-1"
|
|
171
|
+
>
|
|
172
|
+
{chinese ? '⚠️ 配额已用尽,申请临时提额' : 'Request Quota Increase'}
|
|
173
|
+
</button>
|
|
174
|
+
{/if}
|
|
175
|
+
</div>
|
|
176
|
+
{/each}
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
{#if children}
|
|
180
|
+
<div class="pt-2">
|
|
181
|
+
{@render children()}
|
|
182
|
+
</div>
|
|
183
|
+
{/if}
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<!-- Exhausted Warning Dialog -->
|
|
187
|
+
{#if exhaustedModalQuota}
|
|
188
|
+
<div
|
|
189
|
+
role="dialog"
|
|
190
|
+
aria-modal="true"
|
|
191
|
+
aria-label="Quota Exhausted"
|
|
192
|
+
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm"
|
|
193
|
+
>
|
|
194
|
+
<div class="w-full max-w-md rounded-2xl border border-destructive/40 bg-card p-6 shadow-2xl text-xs space-y-3">
|
|
195
|
+
<div class="flex items-start gap-3">
|
|
196
|
+
<div class="flex h-10 w-10 items-center justify-center rounded-xl bg-destructive/15 text-destructive border border-destructive/20 shrink-0">
|
|
197
|
+
<AlertTriangle class="h-5 w-5" />
|
|
198
|
+
</div>
|
|
199
|
+
<div class="flex-1">
|
|
200
|
+
<h4 class="text-sm font-bold text-foreground">
|
|
201
|
+
{chinese ? '当前租户资源配额已耗尽' : 'Resource Quota Exhausted'}
|
|
202
|
+
</h4>
|
|
203
|
+
<p class="text-[11px] text-muted-foreground mt-1 leading-relaxed">
|
|
204
|
+
{chinese
|
|
205
|
+
? `租户已达到 [${exhaustedModalQuota.resourceName}] 上限 (${exhaustedModalQuota.limit.toLocaleString()} ${exhaustedModalQuota.unit ?? ''})。继续执行操作可能被服务端拒绝。`
|
|
206
|
+
: `Quota for ${exhaustedModalQuota.resourceName} has reached 100%.`}
|
|
207
|
+
</p>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div class="flex justify-end gap-2 pt-3 border-t border-border/70">
|
|
212
|
+
<Button variant="ghost" size="sm" onclick={() => (exhaustedModalQuota = null)}>
|
|
213
|
+
{chinese ? '关闭' : 'Dismiss'}
|
|
214
|
+
</Button>
|
|
215
|
+
{#if onRequestQuotaIncrease}
|
|
216
|
+
<Button
|
|
217
|
+
size="sm"
|
|
218
|
+
onclick={() => {
|
|
219
|
+
if (exhaustedModalQuota) onRequestQuotaIncrease(exhaustedModalQuota);
|
|
220
|
+
exhaustedModalQuota = null;
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
{chinese ? '提交提额工单' : 'Submit Request'}
|
|
224
|
+
</Button>
|
|
225
|
+
{/if}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface TenantQuotaItem {
|
|
3
|
+
id: string;
|
|
4
|
+
resourceName: string;
|
|
5
|
+
used: number;
|
|
6
|
+
limit: number;
|
|
7
|
+
unit?: string | undefined;
|
|
8
|
+
icon?: 'api' | 'storage' | 'seats' | 'compute' | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface TenantQuotasMatrixProps {
|
|
11
|
+
tenantName?: string | undefined;
|
|
12
|
+
planName?: string | undefined;
|
|
13
|
+
quotas?: TenantQuotaItem[] | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
class?: string | undefined;
|
|
16
|
+
onUpgradePlan?: (() => void) | undefined;
|
|
17
|
+
onRequestQuotaIncrease?: ((quota: TenantQuotaItem) => void) | undefined;
|
|
18
|
+
children?: Snippet | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare const TenantQuotasMatrix: import("svelte").Component<TenantQuotasMatrixProps, {}, "">;
|
|
21
|
+
type TenantQuotasMatrix = ReturnType<typeof TenantQuotasMatrix>;
|
|
22
|
+
export default TenantQuotasMatrix;
|