@svadmin/ui 0.129.0 → 0.131.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 +403 -0
- package/dist/app.theme.css +403 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AccessRevocationMatrix.svelte +425 -0
- package/dist/components/AccessRevocationMatrix.svelte.d.ts +27 -0
- package/dist/components/AudioVisualInspector.svelte +458 -0
- package/dist/components/AudioVisualInspector.svelte.d.ts +53 -0
- package/dist/components/AuditSnapshotCapture.svelte +328 -0
- package/dist/components/AuditSnapshotCapture.svelte.d.ts +28 -0
- package/dist/components/CannedResponsePicker.svelte +257 -0
- package/dist/components/CannedResponsePicker.svelte.d.ts +22 -0
- package/dist/components/ContentModerationCenter.svelte +166 -0
- package/dist/components/ContentModerationCenter.svelte.d.ts +11 -0
- package/dist/components/ContractClauseDiffViewer.svelte +566 -0
- package/dist/components/ContractClauseDiffViewer.svelte.d.ts +53 -0
- package/dist/components/DataImportPipeline.svelte +577 -0
- package/dist/components/DataImportPipeline.svelte.d.ts +35 -0
- package/dist/components/DataRetentionPolicyEditor.svelte +455 -0
- package/dist/components/DataRetentionPolicyEditor.svelte.d.ts +10 -0
- package/dist/components/ElectronicSealInspector.svelte +450 -0
- package/dist/components/ElectronicSealInspector.svelte.d.ts +72 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte +405 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte.d.ts +39 -0
- package/dist/components/FeatureFlagStudio.svelte +583 -0
- package/dist/components/FeatureFlagStudio.svelte.d.ts +12 -0
- package/dist/components/FieldMappingBuilder.svelte +393 -0
- package/dist/components/FieldMappingBuilder.svelte.d.ts +39 -0
- package/dist/components/GatewayRouteEditor.svelte +493 -0
- package/dist/components/GatewayRouteEditor.svelte.d.ts +34 -0
- package/dist/components/HotkeysHelpModal.svelte +286 -0
- package/dist/components/HotkeysHelpModal.svelte.d.ts +21 -0
- package/dist/components/I18nStudio.svelte +635 -0
- package/dist/components/I18nStudio.svelte.d.ts +23 -0
- package/dist/components/IpAccessRuleEditor.svelte +290 -0
- package/dist/components/IpAccessRuleEditor.svelte.d.ts +19 -0
- package/dist/components/IpWhitelistDrawer.svelte +94 -0
- package/dist/components/IpWhitelistDrawer.svelte.d.ts +10 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte +357 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte.d.ts +64 -0
- package/dist/components/MediaGallery.svelte +575 -0
- package/dist/components/MediaGallery.svelte.d.ts +34 -0
- package/dist/components/NotificationCenter.svelte +20 -1
- package/dist/components/NotificationCenter.svelte.d.ts +2 -0
- package/dist/components/NotificationDrawer.svelte +242 -0
- package/dist/components/NotificationDrawer.svelte.d.ts +40 -0
- package/dist/components/PrintDocument.svelte +95 -0
- package/dist/components/PrintDocument.svelte.d.ts +10 -0
- package/dist/components/PrintPreviewModal.svelte +52 -0
- package/dist/components/PrintPreviewModal.svelte.d.ts +11 -0
- package/dist/components/PrintTemplateDesigner.svelte +280 -0
- package/dist/components/PrintTemplateDesigner.svelte.d.ts +11 -0
- package/dist/components/RateLimitPolicyPanel.svelte +369 -0
- package/dist/components/RateLimitPolicyPanel.svelte.d.ts +29 -0
- package/dist/components/ResizableSplitter.svelte +246 -0
- package/dist/components/ResizableSplitter.svelte.d.ts +18 -0
- package/dist/components/SensitiveWordAuditor.svelte +368 -0
- package/dist/components/SensitiveWordAuditor.svelte.d.ts +9 -0
- package/dist/components/ServiceDeskTicketCard.svelte +297 -0
- package/dist/components/ServiceDeskTicketCard.svelte.d.ts +52 -0
- package/dist/components/ShiftScheduler.svelte +490 -0
- package/dist/components/ShiftScheduler.svelte.d.ts +50 -0
- package/dist/components/SslCertificateMonitorCard.svelte +309 -0
- package/dist/components/SslCertificateMonitorCard.svelte.d.ts +30 -0
- package/dist/components/SsoConnectionStudio.svelte +784 -0
- package/dist/components/SsoConnectionStudio.svelte.d.ts +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte.d.ts +8 -0
- package/dist/components/StepUpAuthModal.svelte +448 -0
- package/dist/components/StepUpAuthModal.svelte.d.ts +26 -0
- package/dist/components/TrafficTopologyInspector.svelte +361 -0
- package/dist/components/TrafficTopologyInspector.svelte.d.ts +43 -0
- package/dist/components/ip-access-rules.d.ts +24 -0
- package/dist/components/ip-access-rules.js +110 -0
- package/dist/components/moderation-utils.d.ts +45 -0
- package/dist/components/moderation-utils.js +74 -0
- package/dist/components/print-document.d.ts +3 -0
- package/dist/components/print-document.js +65 -0
- package/dist/components/print-utils.d.ts +44 -0
- package/dist/components/print-utils.js +68 -0
- package/dist/components/retention-utils.d.ts +31 -0
- package/dist/components/retention-utils.js +38 -0
- package/dist/components/sso-connection-presets.d.ts +2 -0
- package/dist/components/sso-connection-presets.js +59 -0
- package/dist/components/ui/sheet/sheet.svelte +3 -1
- package/dist/components/ui/sheet/sheet.svelte.d.ts +1 -0
- package/dist/components/useFeatureFlag.d.svelte.ts +1 -0
- package/dist/components/useFeatureFlag.svelte.d.ts +45 -0
- package/dist/components/useFeatureFlag.svelte.js +94 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +53 -0
- package/package.json +5 -4
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
RetentionAction,
|
|
5
|
+
RetentionPolicy,
|
|
6
|
+
} from './retention-utils.js';
|
|
7
|
+
import {
|
|
8
|
+
calculateRetentionMetrics,
|
|
9
|
+
detectPolicyConflicts,
|
|
10
|
+
} from './retention-utils.js';
|
|
11
|
+
|
|
12
|
+
export interface DataRetentionPolicyEditorProps {
|
|
13
|
+
policies?: RetentionPolicy[];
|
|
14
|
+
class?: string;
|
|
15
|
+
onSave?: (policies: RetentionPolicy[]) => void;
|
|
16
|
+
onRunManualArchive?: (policy: RetentionPolicy) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
policies: initialPolicies = [],
|
|
21
|
+
class: className = '',
|
|
22
|
+
onSave,
|
|
23
|
+
onRunManualArchive,
|
|
24
|
+
}: DataRetentionPolicyEditorProps = $props();
|
|
25
|
+
|
|
26
|
+
// Internal reactive policies
|
|
27
|
+
let policyList = $state<RetentionPolicy[]>(untrack(() => initialPolicies.map(policy => ({ ...policy }))));
|
|
28
|
+
|
|
29
|
+
const metrics = $derived(calculateRetentionMetrics(policyList));
|
|
30
|
+
const conflicts = $derived(detectPolicyConflicts(policyList));
|
|
31
|
+
|
|
32
|
+
// Edit / Add Modal state
|
|
33
|
+
let isEditing = $state(false);
|
|
34
|
+
let editId = $state('');
|
|
35
|
+
let editName = $state('');
|
|
36
|
+
let editResource = $state('audit_logs');
|
|
37
|
+
let editDays = $state<number | undefined>(180);
|
|
38
|
+
let editAction = $state<RetentionAction>('archive_cold_storage');
|
|
39
|
+
let editTargetStorage = $state('');
|
|
40
|
+
let editCondition = $state('');
|
|
41
|
+
let validationError = $state('');
|
|
42
|
+
|
|
43
|
+
// Search & Filter
|
|
44
|
+
let searchQuery = $state('');
|
|
45
|
+
let filterAction = $state<'ALL' | RetentionAction>('ALL');
|
|
46
|
+
|
|
47
|
+
const filteredPolicies = $derived.by(() => {
|
|
48
|
+
return policyList.filter((p) => {
|
|
49
|
+
if (filterAction !== 'ALL' && p.action !== filterAction) return false;
|
|
50
|
+
if (searchQuery.trim()) {
|
|
51
|
+
const q = searchQuery.toLowerCase();
|
|
52
|
+
const matchesName = p.name.toLowerCase().includes(q);
|
|
53
|
+
const matchesResource = p.resource.toLowerCase().includes(q);
|
|
54
|
+
if (!matchesName && !matchesResource) return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
function openCreateModal() {
|
|
61
|
+
editId = `ret-${Date.now()}`;
|
|
62
|
+
editName = '';
|
|
63
|
+
editResource = '';
|
|
64
|
+
editDays = 180;
|
|
65
|
+
editAction = 'archive_cold_storage';
|
|
66
|
+
editTargetStorage = '';
|
|
67
|
+
editCondition = '';
|
|
68
|
+
validationError = '';
|
|
69
|
+
isEditing = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function openEditModal(p: RetentionPolicy) {
|
|
73
|
+
editId = p.id;
|
|
74
|
+
editName = p.name;
|
|
75
|
+
editResource = p.resource;
|
|
76
|
+
editDays = p.retentionDays;
|
|
77
|
+
editAction = p.action;
|
|
78
|
+
editTargetStorage = p.targetStorage || '';
|
|
79
|
+
editCondition = p.filterCondition || '';
|
|
80
|
+
validationError = '';
|
|
81
|
+
isEditing = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function savePolicy() {
|
|
85
|
+
validationError = '';
|
|
86
|
+
if (!editName.trim() || !editResource.trim()) {
|
|
87
|
+
validationError = '规则名称和目标数据资源不能为空';
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof editDays !== 'number' || !Number.isSafeInteger(editDays) || editDays < 1) {
|
|
91
|
+
validationError = '保留期限必须为正整数天数';
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const requiresStorage = editAction === 'archive_cold_storage' || editAction === 'mask_and_archive';
|
|
95
|
+
if (requiresStorage && !editTargetStorage.trim()) {
|
|
96
|
+
validationError = '归档动作必须填写目标存储路径';
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const existingIndex = policyList.findIndex(p => p.id === editId);
|
|
100
|
+
const previous = policyList[existingIndex];
|
|
101
|
+
const item: RetentionPolicy = {
|
|
102
|
+
...previous,
|
|
103
|
+
id: editId,
|
|
104
|
+
name: editName.trim(),
|
|
105
|
+
resource: editResource.trim(),
|
|
106
|
+
retentionDays: editDays,
|
|
107
|
+
action: editAction,
|
|
108
|
+
status: previous?.status ?? 'draft',
|
|
109
|
+
estimatedRows: previous?.estimatedRows ?? 0,
|
|
110
|
+
estimatedStorageMb: previous?.estimatedStorageMb ?? 0,
|
|
111
|
+
};
|
|
112
|
+
delete item.targetStorage;
|
|
113
|
+
delete item.filterCondition;
|
|
114
|
+
if (requiresStorage) item.targetStorage = editTargetStorage.trim();
|
|
115
|
+
if (editCondition.trim()) item.filterCondition = editCondition.trim();
|
|
116
|
+
|
|
117
|
+
if (existingIndex >= 0) {
|
|
118
|
+
policyList[existingIndex] = item;
|
|
119
|
+
} else {
|
|
120
|
+
policyList = [...policyList, item];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
onSave?.($state.snapshot(policyList));
|
|
124
|
+
isEditing = false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function toggleStatus(policy: RetentionPolicy) {
|
|
128
|
+
policy.status = policy.status === 'active' ? 'paused' : 'active';
|
|
129
|
+
onSave?.($state.snapshot(policyList));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function deletePolicy(id: string) {
|
|
133
|
+
policyList = policyList.filter(p => p.id !== id);
|
|
134
|
+
onSave?.($state.snapshot(policyList));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function handleTriggerManual(p: RetentionPolicy) {
|
|
138
|
+
onRunManualArchive?.(p);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getActionBadge(act: RetentionAction) {
|
|
142
|
+
switch (act) {
|
|
143
|
+
case 'hard_delete':
|
|
144
|
+
return 'bg-destructive/15 text-destructive border-destructive/25';
|
|
145
|
+
case 'archive_cold_storage':
|
|
146
|
+
return 'bg-primary/15 text-primary border-primary/25';
|
|
147
|
+
case 'mask_and_archive':
|
|
148
|
+
return 'bg-warning/15 text-warning dark:text-warning border-warning/25';
|
|
149
|
+
case 'soft_delete':
|
|
150
|
+
return 'bg-muted text-muted-foreground border-border';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getActionLabel(act: RetentionAction) {
|
|
155
|
+
switch (act) {
|
|
156
|
+
case 'hard_delete':
|
|
157
|
+
return '物理销毁 (Hard Delete)';
|
|
158
|
+
case 'archive_cold_storage':
|
|
159
|
+
return '冷存储归档 (Glacier/S3)';
|
|
160
|
+
case 'mask_and_archive':
|
|
161
|
+
return '脱敏后归档 (Mask & Archive)';
|
|
162
|
+
case 'soft_delete':
|
|
163
|
+
return '软删除标记 (Soft Delete)';
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<div
|
|
169
|
+
class="w-full flex flex-col gap-6 p-6 bg-background text-foreground rounded-xl border border-border shadow-sm {className}"
|
|
170
|
+
data-svadmin-component="DataRetentionPolicyEditor"
|
|
171
|
+
data-svadmin-resource="data_retention_policies"
|
|
172
|
+
>
|
|
173
|
+
<!-- Header -->
|
|
174
|
+
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-border">
|
|
175
|
+
<div class="flex flex-col gap-1">
|
|
176
|
+
<div class="flex items-center gap-2">
|
|
177
|
+
<h2 class="text-xl font-bold tracking-tight text-foreground">数据生命周期与合规归档中心 (Retention Studio)</h2>
|
|
178
|
+
<span class="text-xs px-2 py-0.5 rounded-full font-medium bg-primary/10 text-primary border border-primary/20">
|
|
179
|
+
GDPR & 等保 2.0 合规
|
|
180
|
+
</span>
|
|
181
|
+
</div>
|
|
182
|
+
<p class="text-sm text-muted-foreground">
|
|
183
|
+
配置资源数据留存期限(Retention Policy),支持自动下沉至冷存储、定期物理安全擦除与合规审计报表生成。
|
|
184
|
+
</p>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div class="flex items-center gap-2">
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
onclick={openCreateModal}
|
|
191
|
+
class="inline-flex items-center justify-center text-xs font-semibold px-4 py-2 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm"
|
|
192
|
+
>
|
|
193
|
+
<svg class="w-3.5 h-3.5 mr-1.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
194
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
|
195
|
+
</svg>
|
|
196
|
+
新建留存规则
|
|
197
|
+
</button>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<!-- Conflict Warnings Banner -->
|
|
202
|
+
{#if conflicts.length > 0}
|
|
203
|
+
<div class="p-3.5 rounded-lg bg-warning/10 border border-warning/30 flex flex-col gap-1 text-xs text-warning dark:text-warning">
|
|
204
|
+
<span class="font-bold flex items-center gap-1.5">
|
|
205
|
+
⚠️ 检测到规则重叠与潜在冲突提示:
|
|
206
|
+
</span>
|
|
207
|
+
{#each conflicts as warn, i (i)}
|
|
208
|
+
<p class="text-[11px] leading-relaxed pl-4">• {warn}</p>
|
|
209
|
+
{/each}
|
|
210
|
+
</div>
|
|
211
|
+
{/if}
|
|
212
|
+
|
|
213
|
+
<!-- Metrics Strip -->
|
|
214
|
+
<div class="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
|
215
|
+
<div class="p-3 rounded-lg bg-card border border-border flex flex-col gap-1">
|
|
216
|
+
<span class="text-xs text-muted-foreground">活跃生命周期策略</span>
|
|
217
|
+
<span class="text-xl font-bold text-foreground">
|
|
218
|
+
{metrics.activePolicies} <span class="text-xs text-muted-foreground font-normal">/ {metrics.totalPolicies} 条</span>
|
|
219
|
+
</span>
|
|
220
|
+
</div>
|
|
221
|
+
<div class="p-3 rounded-lg bg-card border border-border flex flex-col gap-1">
|
|
222
|
+
<span class="text-xs text-muted-foreground">月度预估受影响数据</span>
|
|
223
|
+
<span class="text-xl font-bold text-primary font-mono">
|
|
224
|
+
{(metrics.totalEstimatedRows / 10000).toFixed(1)} 万行
|
|
225
|
+
</span>
|
|
226
|
+
</div>
|
|
227
|
+
<div class="p-3 rounded-lg bg-card border border-border flex flex-col gap-1">
|
|
228
|
+
<span class="text-xs text-muted-foreground">预计释放线上存储</span>
|
|
229
|
+
<span class="text-xl font-bold text-success dark:text-success font-mono">
|
|
230
|
+
{metrics.totalEstimatedStorageGb} GB
|
|
231
|
+
</span>
|
|
232
|
+
</div>
|
|
233
|
+
<div class="p-3 rounded-lg bg-card border border-border flex flex-col gap-1">
|
|
234
|
+
<span class="text-xs text-muted-foreground">转存入冷存储体量</span>
|
|
235
|
+
<span class="text-xl font-bold text-foreground font-mono">
|
|
236
|
+
{metrics.archivedToColdStorageGb} GB
|
|
237
|
+
</span>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<!-- Filters & Search -->
|
|
242
|
+
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3 text-xs">
|
|
243
|
+
<div class="relative flex-1 max-w-sm">
|
|
244
|
+
<input
|
|
245
|
+
type="text"
|
|
246
|
+
bind:value={searchQuery}
|
|
247
|
+
placeholder="搜索策略名称、对应数据资源..."
|
|
248
|
+
class="w-full px-3 py-2 pl-8 rounded-lg border border-border bg-card text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
249
|
+
/>
|
|
250
|
+
<svg class="w-3.5 h-3.5 absolute left-2.5 top-2.5 text-muted-foreground" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
251
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
252
|
+
</svg>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<div class="flex items-center gap-2">
|
|
256
|
+
<select
|
|
257
|
+
bind:value={filterAction}
|
|
258
|
+
class="px-2.5 py-2 rounded-lg border border-border bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
259
|
+
>
|
|
260
|
+
<option value="ALL">全部处置策略</option>
|
|
261
|
+
<option value="archive_cold_storage">冷存储归档</option>
|
|
262
|
+
<option value="hard_delete">物理安全销毁</option>
|
|
263
|
+
<option value="mask_and_archive">脱敏后归档</option>
|
|
264
|
+
<option value="soft_delete">软删除标记</option>
|
|
265
|
+
</select>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<!-- Policies Table -->
|
|
270
|
+
<div class="rounded-xl border border-border bg-card overflow-hidden text-xs">
|
|
271
|
+
<table class="w-full border-collapse">
|
|
272
|
+
<thead>
|
|
273
|
+
<tr class="bg-muted/40 border-b border-border text-muted-foreground font-semibold">
|
|
274
|
+
<th class="p-3 text-left">策略名称 / 资源</th>
|
|
275
|
+
<th class="p-3 text-center">留存期限</th>
|
|
276
|
+
<th class="p-3 text-left">到期处置动作</th>
|
|
277
|
+
<th class="p-3 text-left">归档存储 / 过滤条件</th>
|
|
278
|
+
<th class="p-3 text-right">预估数据量</th>
|
|
279
|
+
<th class="p-3 text-center">状态</th>
|
|
280
|
+
<th class="p-3 text-right">操作</th>
|
|
281
|
+
</tr>
|
|
282
|
+
</thead>
|
|
283
|
+
<tbody>
|
|
284
|
+
{#if filteredPolicies.length === 0}
|
|
285
|
+
<tr>
|
|
286
|
+
<td colspan="7" class="p-8 text-center text-muted-foreground">没有找到匹配的数据生命周期策略</td>
|
|
287
|
+
</tr>
|
|
288
|
+
{:else}
|
|
289
|
+
{#each filteredPolicies as item (item.id)}
|
|
290
|
+
<tr class="border-b border-border/60 hover:bg-muted/20 transition-colors">
|
|
291
|
+
<td class="p-3">
|
|
292
|
+
<div class="flex flex-col gap-0.5">
|
|
293
|
+
<span class="font-semibold text-foreground">{item.name}</span>
|
|
294
|
+
<span class="text-[11px] font-mono text-muted-foreground">Resource: {item.resource}</span>
|
|
295
|
+
</div>
|
|
296
|
+
</td>
|
|
297
|
+
<td class="p-3 text-center font-mono font-bold text-foreground">
|
|
298
|
+
{item.retentionDays} 天
|
|
299
|
+
</td>
|
|
300
|
+
<td class="p-3">
|
|
301
|
+
<span class="px-2 py-0.5 rounded-full text-[11px] font-medium border {getActionBadge(item.action)}">
|
|
302
|
+
{getActionLabel(item.action)}
|
|
303
|
+
</span>
|
|
304
|
+
</td>
|
|
305
|
+
<td class="p-3">
|
|
306
|
+
<div class="flex flex-col gap-0.5 max-w-xs font-mono text-[10px] text-muted-foreground">
|
|
307
|
+
{#if item.targetStorage}
|
|
308
|
+
<span class="truncate">存储: {item.targetStorage}</span>
|
|
309
|
+
{/if}
|
|
310
|
+
{#if item.filterCondition}
|
|
311
|
+
<span class="truncate">过滤: {item.filterCondition}</span>
|
|
312
|
+
{/if}
|
|
313
|
+
</div>
|
|
314
|
+
</td>
|
|
315
|
+
<td class="p-3 text-right font-mono">
|
|
316
|
+
<div class="flex flex-col items-end">
|
|
317
|
+
<span class="text-foreground">{item.estimatedRows.toLocaleString()} 行</span>
|
|
318
|
+
<span class="text-[10px] text-muted-foreground">约 {(item.estimatedStorageMb / 1024).toFixed(2)} GB</span>
|
|
319
|
+
</div>
|
|
320
|
+
</td>
|
|
321
|
+
<td class="p-3 text-center">
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
onclick={() => toggleStatus(item)}
|
|
325
|
+
class="text-[11px] px-2 py-0.5 rounded font-medium transition-colors {item.status === 'active' ? 'bg-success/15 text-success dark:text-success' : 'bg-muted text-muted-foreground'}"
|
|
326
|
+
>
|
|
327
|
+
{item.status === 'active' ? '已生效' : item.status === 'draft' ? '草稿' : '已暂停'}
|
|
328
|
+
</button>
|
|
329
|
+
</td>
|
|
330
|
+
<td class="p-3 text-right">
|
|
331
|
+
<div class="flex items-center justify-end gap-1.5">
|
|
332
|
+
<button
|
|
333
|
+
type="button"
|
|
334
|
+
onclick={() => handleTriggerManual(item)}
|
|
335
|
+
class="px-2 py-1 rounded border border-border bg-muted/40 hover:bg-muted text-foreground transition-colors"
|
|
336
|
+
>
|
|
337
|
+
测试执行
|
|
338
|
+
</button>
|
|
339
|
+
<button
|
|
340
|
+
type="button"
|
|
341
|
+
onclick={() => openEditModal(item)}
|
|
342
|
+
class="px-2 py-1 rounded text-primary hover:bg-primary/10 transition-colors"
|
|
343
|
+
>
|
|
344
|
+
编辑
|
|
345
|
+
</button>
|
|
346
|
+
<button
|
|
347
|
+
type="button"
|
|
348
|
+
onclick={() => deletePolicy(item.id)}
|
|
349
|
+
class="px-2 py-1 rounded text-destructive hover:bg-destructive/10 transition-colors"
|
|
350
|
+
>
|
|
351
|
+
删除
|
|
352
|
+
</button>
|
|
353
|
+
</div>
|
|
354
|
+
</td>
|
|
355
|
+
</tr>
|
|
356
|
+
{/each}
|
|
357
|
+
{/if}
|
|
358
|
+
</tbody>
|
|
359
|
+
</table>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
<!-- Create / Edit Modal -->
|
|
363
|
+
{#if isEditing}
|
|
364
|
+
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
|
365
|
+
<div class="w-full max-w-md rounded-xl bg-card border border-border p-6 shadow-xl flex flex-col gap-4 text-foreground text-xs">
|
|
366
|
+
<div class="flex items-center justify-between pb-2 border-b border-border">
|
|
367
|
+
<h3 class="font-bold text-sm text-foreground">
|
|
368
|
+
{editId.startsWith('ret-') && editName === '' ? '新建数据生命周期规则' : '编辑数据生命周期规则'}
|
|
369
|
+
</h3>
|
|
370
|
+
<button type="button" onclick={() => (isEditing = false)} class="text-muted-foreground hover:text-foreground">✕</button>
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
<div class="flex flex-col gap-3">
|
|
374
|
+
<div class="flex flex-col gap-1">
|
|
375
|
+
<label for="policy-name-input" class="font-semibold text-foreground">规则名称</label>
|
|
376
|
+
<input
|
|
377
|
+
id="policy-name-input"
|
|
378
|
+
type="text"
|
|
379
|
+
bind:value={editName}
|
|
380
|
+
placeholder="例如:系统操作日志定期冷存储归档"
|
|
381
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground"
|
|
382
|
+
/>
|
|
383
|
+
</div>
|
|
384
|
+
|
|
385
|
+
<div class="grid grid-cols-2 gap-2">
|
|
386
|
+
<div class="flex flex-col gap-1">
|
|
387
|
+
<label for="policy-resource-input" class="font-semibold text-foreground">目标数据资源 (Resource)</label>
|
|
388
|
+
<input
|
|
389
|
+
id="policy-resource-input"
|
|
390
|
+
type="text"
|
|
391
|
+
bind:value={editResource}
|
|
392
|
+
placeholder="audit_logs"
|
|
393
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground font-mono"
|
|
394
|
+
/>
|
|
395
|
+
</div>
|
|
396
|
+
<div class="flex flex-col gap-1">
|
|
397
|
+
<label for="policy-days-input" class="font-semibold text-foreground">保留期限 (天数)</label>
|
|
398
|
+
<input
|
|
399
|
+
id="policy-days-input"
|
|
400
|
+
type="number"
|
|
401
|
+
bind:value={editDays}
|
|
402
|
+
min="1"
|
|
403
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground font-mono"
|
|
404
|
+
/>
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
|
|
408
|
+
<div class="flex flex-col gap-1">
|
|
409
|
+
<label for="policy-action-select" class="font-semibold text-foreground">到期处置动作</label>
|
|
410
|
+
<select
|
|
411
|
+
id="policy-action-select"
|
|
412
|
+
bind:value={editAction}
|
|
413
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground"
|
|
414
|
+
>
|
|
415
|
+
<option value="archive_cold_storage">冷存储归档 (转存至 S3 Glacier / OSS 冷存)</option>
|
|
416
|
+
<option value="hard_delete">物理安全擦除 (不可恢复的物理销毁)</option>
|
|
417
|
+
<option value="mask_and_archive">脱敏后归档 (擦除敏感信息保留统计属性)</option>
|
|
418
|
+
<option value="soft_delete">软删除标记 (保留数据记录打上 deleted 标记)</option>
|
|
419
|
+
</select>
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
{#if editAction === 'archive_cold_storage' || editAction === 'mask_and_archive'}
|
|
423
|
+
<div class="flex flex-col gap-1">
|
|
424
|
+
<label for="policy-storage-input" class="font-semibold text-foreground">归档目标存储路径</label>
|
|
425
|
+
<input
|
|
426
|
+
id="policy-storage-input"
|
|
427
|
+
type="text"
|
|
428
|
+
bind:value={editTargetStorage}
|
|
429
|
+
placeholder="s3://corp-compliance-vault/archive/"
|
|
430
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground font-mono"
|
|
431
|
+
/>
|
|
432
|
+
</div>
|
|
433
|
+
{/if}
|
|
434
|
+
|
|
435
|
+
<div class="flex flex-col gap-1">
|
|
436
|
+
<label for="policy-filter-input" class="font-semibold text-foreground">条件过滤器 (可选 SQL/DSL 表达式)</label>
|
|
437
|
+
<input
|
|
438
|
+
id="policy-filter-input"
|
|
439
|
+
type="text"
|
|
440
|
+
bind:value={editCondition}
|
|
441
|
+
placeholder="event_level != 'CRITICAL'"
|
|
442
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground font-mono"
|
|
443
|
+
/>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
|
|
447
|
+
{#if validationError}<p role="alert" class="text-destructive">{validationError}</p>{/if}
|
|
448
|
+
<div class="flex items-center justify-end gap-2 pt-3 border-t border-border">
|
|
449
|
+
<button type="button" onclick={() => (isEditing = false)} class="px-3 py-1.5 rounded border border-border bg-card">取消</button>
|
|
450
|
+
<button type="button" onclick={savePolicy} class="px-3 py-1.5 rounded bg-primary text-primary-foreground font-semibold">保存规则</button>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
453
|
+
</div>
|
|
454
|
+
{/if}
|
|
455
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RetentionPolicy } from './retention-utils.js';
|
|
2
|
+
export interface DataRetentionPolicyEditorProps {
|
|
3
|
+
policies?: RetentionPolicy[];
|
|
4
|
+
class?: string;
|
|
5
|
+
onSave?: (policies: RetentionPolicy[]) => void;
|
|
6
|
+
onRunManualArchive?: (policy: RetentionPolicy) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const DataRetentionPolicyEditor: import("svelte").Component<DataRetentionPolicyEditorProps, {}, "">;
|
|
9
|
+
type DataRetentionPolicyEditor = ReturnType<typeof DataRetentionPolicyEditor>;
|
|
10
|
+
export default DataRetentionPolicyEditor;
|