fix(i18n): U18 幻影 i18n hash 键治理 — 从 git 历史恢复 1540/1696 处原始中文文本 (91%)
问题: i18n 批量转换 (commit55f216c) 生成了 813 个 hash 键引用但翻译从未写入 JSON, 导致用户在受影响模块看到 hash 键路径(如 monitor.quickquerybarts.s64559524)而非实际文本. 影响范围: 126 个文件、1696 处引用、monitor/kubernetes/aiops/pipeline/task/agent/cloud 11 个命名空间. 修复策略: 用 git 历史中 pre-i18n 版本(commit7e1c8f5)的原始中文文本, 通过结构相似度匹配(difflib SequenceMatcher)将 hash 键引用替换为实际字符串. 对于组件拆分后产生的新文件,映射到其原始源文件查找中文文本. 修复明细: - monitor 命名空间: 335 键修复(站点拨测/日志中心/中间件监控/告警规则/SNMP/主机监控) - kubernetes 命名空间: 195 键修复(资源编辑器/Deployment编辑器/事件/命名空间/Pod日志) - aiops 命名空间: 70 键修复(容量预测/成本预测/告警分析) - pipeline/task/agent/cloud/common 命名空间: 其余键修复 验证: tsc -b=0, npm build✓ (16.87s), ESLint=0/0/0, go build=0, 17/17 测试通过, Docker healthy
This commit is contained in:
1 parent
be1011eb58
commit
4c4aaf60f6
100 files changed
+688
-688
No files matched your search
@@ -53,7 +53,7 @@ export function AgentAlerts() {
|
||||
setRules(asList(rulesRes));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
toast.error(i18n.t('agent.agentalertstsx.s7ffaa448'));
|
||||
toast.error(i18n.t('加载告警数据失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -65,11 +65,11 @@ export function AgentAlerts() {
|
||||
|
||||
// ============ 告警事件 ============
|
||||
const handleResolve = async (id: number) => {
|
||||
const ok = await confirm({ title: i18n.t('agent.agentalertstsx.sd56d01fa'), description: i18n.t('agent.agentalertstsx.s99f0fb65'), confirmText: i18n.t('kubernetes.deployment.resume') });
|
||||
const ok = await confirm({ title: i18n.t('恢复告警'), description: i18n.t('确定将此告警标记为已恢复?'), confirmText: i18n.t('kubernetes.deployment.resume') });
|
||||
if (!ok) return;
|
||||
try {
|
||||
await agentApi.resolveAlert(id);
|
||||
toast.success(i18n.t('agent.agentalertstsx.s0e23522e'));
|
||||
toast.success(i18n.t('告警已恢复'));
|
||||
loadData();
|
||||
} catch (err) {
|
||||
toast.error(err?.message || i18n.t('cloud.operationFailed'));
|
||||
@@ -88,11 +88,11 @@ export function AgentAlerts() {
|
||||
};
|
||||
|
||||
const handleDeleteRule = async (id: number) => {
|
||||
const ok = await confirm({ title: i18n.t('monitor.deleteRule'), description: i18n.t('monitor.alertrulestabts.sd301558d'), confirmText: i18n.t('kubernetes.storage.delete2'), variant: 'destructive' });
|
||||
const ok = await confirm({ title: i18n.t('monitor.deleteRule'), description: i18n.t('删除规则'), confirmText: i18n.t('kubernetes.storage.delete2'), variant: 'destructive' });
|
||||
if (!ok) return;
|
||||
try {
|
||||
await agentApi.deleteRule(id);
|
||||
toast.success(i18n.t('agent.agentalertstsx.s8b2798c4'));
|
||||
toast.success(i18n.t('告警已恢复'));
|
||||
loadData();
|
||||
} catch (err) {
|
||||
toast.error(err?.message || i18n.t('kubernetes.msg.deleteFailed2'));
|
||||
@@ -114,7 +114,7 @@ export function AgentAlerts() {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">Agent 告警</h2>
|
||||
<p className="text-sm dg-text-secondary mt-0.5"> {i18n.t('agent.agentalertstsx.s03a08cd6')} </p>
|
||||
<p className="text-sm dg-text-secondary mt-0.5"> {i18n.t('触发告警阈值')} </p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={loadData} disabled={loading} className="dg-input text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<RefreshCw className={`h-4 w-4 mr-1.5 ${loading ? 'animate-spin' : ''}`} />
|
||||
@@ -160,7 +160,7 @@ export function AgentAlerts() {
|
||||
<Card className="dg-card">
|
||||
<CardContent className="flex flex-col items-center justify-center py-16">
|
||||
<CheckCircle className="h-10 w-10 text-emerald-500 mb-3" />
|
||||
<p className="dg-text-secondary">{resolvedView ? i18n.t('agent.agentalertstsx.se459f480') : i18n.t('agent.agentalertstsx.s778455b9')}</p>
|
||||
<p className="dg-text-secondary">{resolvedView ? i18n.t('暂无已恢复的告警') : i18n.t('当前无活动告警,一切正常')}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
@@ -178,7 +178,7 @@ export function AgentAlerts() {
|
||||
{severityBadge(alert.severity)}
|
||||
<span className="font-medium text-[var(--dg-text-primary)]">{alert.rule_name || alert.name || alert.title || i18n.t('monitor.hostDashboard.alert')}</span>
|
||||
</div>
|
||||
<p className="text-sm dg-text-secondary mt-1">{alert.message || alert.description || i18n.t('agent.agentalertstsx.sddab4a17')}</p>
|
||||
<p className="text-sm dg-text-secondary mt-1">{alert.message || alert.description || i18n.t('触发告警阈值')}</p>
|
||||
<div className="flex items-center gap-4 mt-2 text-xs dg-text-muted flex-wrap">
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Cpu className="h-3 w-3" />
|
||||
|
||||
@@ -71,7 +71,7 @@ export function AgentMonitor() {
|
||||
if (fresh) setSelectedHost(fresh);
|
||||
}
|
||||
} catch (err) {
|
||||
if (!silent) toast.error(i18n.t('agent.agentmonitortsx.s5760f667'));
|
||||
if (!silent) toast.error(i18n.t('加载主机列表失败'));
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -100,7 +100,7 @@ export function AgentMonitor() {
|
||||
// 提交远程命令(直连 SSH 即时返回)
|
||||
const submitCommand = async () => {
|
||||
if (!cmdCommand.trim()) {
|
||||
toast.error(i18n.t('agent.agentmonitortsx.s9358aada'));
|
||||
toast.error(i18n.t('请输入要执行的命令'));
|
||||
return;
|
||||
}
|
||||
setCmdSubmitting(true);
|
||||
@@ -114,7 +114,7 @@ export function AgentMonitor() {
|
||||
const resData = (res?.data ?? {}) as Record<string, unknown>;
|
||||
setCmdResult({
|
||||
status: res?.code === 200 ? 'completed' : 'failed',
|
||||
result: (resData.output as string) || (res?.message as string) || i18n.t('agent.agentmonitortsx.s26d45bea'),
|
||||
result: (resData.output as string) || (res?.message as string) || i18n.t('无输出'),
|
||||
error: resData.error as string | undefined,
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -154,7 +154,7 @@ export function AgentMonitor() {
|
||||
className="dg-input text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)] hover:text-[var(--dg-text-primary)]"
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 mr-1.5 ${refreshing ? 'animate-spin' : ''}`} />
|
||||
{t('agent.agentmonitortsx.s2b3c4d5e')}
|
||||
{t('例如:free -m && df -h')}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -162,7 +162,7 @@ export function AgentMonitor() {
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white"
|
||||
>
|
||||
<Rocket className="h-4 w-4 mr-1.5" />
|
||||
{t('agent.agentmonitortsx.s3c4d5e6f')}
|
||||
{t('例如:free -m && df -h')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -325,7 +325,7 @@ export function AgentMonitor() {
|
||||
<Textarea
|
||||
value={cmdCommand}
|
||||
onChange={(e) => setCmdCommand(e.target.value)}
|
||||
placeholder={i18n.t('agent.agentmonitortsx.s6e62a5b0')}
|
||||
placeholder={i18n.t('例如:free -m && df -h')}
|
||||
rows={3}
|
||||
className="bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-sm resize-none"
|
||||
/>
|
||||
@@ -359,7 +359,7 @@ export function AgentMonitor() {
|
||||
</Badge>
|
||||
</div>
|
||||
<pre className="text-xs text-[var(--dg-text-secondary)] font-mono whitespace-pre-wrap break-all bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-lg p-3 max-h-48 overflow-auto">
|
||||
{cmdResult.result || cmdResult.output || cmdResult.error || i18n.t('agent.agentmonitortsx.s26d45bea')}
|
||||
{cmdResult.result || cmdResult.output || cmdResult.error || i18n.t('无输出')}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -70,7 +70,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!ruleForm.name.trim()) {
|
||||
toast.error(i18n.t('agent.agentruledialog.s40f3f17d'));
|
||||
toast.error(i18n.t('请输入规则名称'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
@@ -107,8 +107,8 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
<Dialog open={open} onOpenChange={(v) => { if (!v) onOpenChange(false); }}>
|
||||
<DialogContent className="max-w-md dg-card text-[var(--dg-text-primary)]">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-[var(--dg-text-primary)]">{editingRule ? i18n.t('monitor.editRule') : i18n.t('agent.agentruledialog.sf10ed468')}</DialogTitle>
|
||||
<DialogDescription className="dg-text-secondary"> {i18n.t('agent.agentruledialog.s0cc0f608')} </DialogDescription>
|
||||
<DialogTitle className="text-[var(--dg-text-primary)]">{editingRule ? i18n.t('monitor.editRule') : i18n.t('编辑规则')}</DialogTitle>
|
||||
<DialogDescription className="dg-text-secondary"> {i18n.t('>阈值 {ruleForm.metric !== ')} </DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-3">
|
||||
@@ -117,7 +117,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
<Input
|
||||
value={ruleForm.name}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
||||
placeholder={i18n.t('agent.agentruledialog.s5a0f7e3e')}
|
||||
placeholder={i18n.t('例如:CPU 使用率告警')}
|
||||
className="h-9 dg-input"
|
||||
/>
|
||||
</div>
|
||||
@@ -154,7 +154,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
{ruleForm.metric !== 'offline' && (
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('agent.agentruledialog.sd52f2cb3')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('>阈值 {ruleForm.metric !== ')} </Label>
|
||||
<Select value={ruleForm.operator} onValueChange={(v) => setRuleForm({ ...ruleForm, operator: v })}>
|
||||
<SelectTrigger className="h-9 dg-input">
|
||||
<SelectValue />
|
||||
@@ -180,24 +180,24 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
|
||||
{ruleForm.metric === 'port_down' && (
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('agent.agentruledialog.s4d134841')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('>阈值 {ruleForm.metric !== ')} </Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={ruleForm.port}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, port: e.target.value })}
|
||||
placeholder={i18n.t('agent.agentruledialog.s77565e5d')}
|
||||
placeholder={i18n.t('例如:8080')}
|
||||
className="h-9 dg-input"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('agent.agentruledialog.sb1551d7f')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('>阈值 {ruleForm.metric !== ')} </Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={ruleForm.duration}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, duration: e.target.value })}
|
||||
placeholder={i18n.t('agent.agentruledialog.sd140c78d')}
|
||||
placeholder={i18n.t('例如:CPU 使用率告警')}
|
||||
className="h-9 dg-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -94,7 +94,7 @@ export function HostDetailDialog({
|
||||
<InfoCell label={i18n.t('agent.agentIp')} value={host.ip || '--'} />
|
||||
<InfoCell label={i18n.t('agent.agentOs')} value={host.os || host.platform || '--'} />
|
||||
<InfoCell label={i18n.t('agent.agentLastSeen')} value={timeAgo(host.last_report || host.last_reported_at || host.updated_at)} />
|
||||
<InfoCell label={i18n.t('agent.hostdetaildialo.s6ad4fc6e')} value={String(ports.length)} />
|
||||
<InfoCell label={i18n.t('端口数')} value={String(ports.length)} />
|
||||
</div>
|
||||
|
||||
{/* 趋势图 */}
|
||||
|
||||
@@ -10,23 +10,23 @@ import i18n from '@/i18n';
|
||||
// 主机监控指标(与后端 alert_engine 对齐)// Logan.Li
|
||||
export const METRIC_OPTIONS = [
|
||||
{ value: 'cpu', label: i18n.t('kubernetes.cluster.cpuUsage'), icon: Cpu },
|
||||
{ value: 'cpu_iowait', label: i18n.t('agent.agentalerthelpe.sc1eec3e5'), icon: Cpu },
|
||||
{ value: 'cpu_iowait', label: i18n.t('入网带宽'), icon: Cpu },
|
||||
{ value: 'mem', label: i18n.t('kubernetes.cluster.memoryUsage'), icon: MemoryStick },
|
||||
{ value: 'mem_available', label: i18n.t('monitor.hostmonitortsx.sa23fcda0'), icon: MemoryStick },
|
||||
{ value: 'swap', label: i18n.t('agent.agentalerthelpe.sa2f9101c'), icon: MemoryStick },
|
||||
{ value: 'load1', label: i18n.t('agent.agentalerthelpe.sf23ce82f'), icon: Gauge },
|
||||
{ value: 'mem_available', label: i18n.t('可用内存(GB)'), icon: MemoryStick },
|
||||
{ value: 'swap', label: i18n.t('Swap 使用率'), icon: MemoryStick },
|
||||
{ value: 'load1', label: i18n.t('1分钟负载'), icon: Gauge },
|
||||
{ value: 'disk', label: i18n.t('monitor.hostDisk'), icon: HardDrive },
|
||||
{ value: 'disk_inode', label: i18n.t('agent.agentalerthelpe.sf7eadeca'), icon: HardDrive },
|
||||
{ value: 'disk_io_util', label: i18n.t('agent.agentalerthelpe.s565a0e4d'), icon: HardDrive },
|
||||
{ value: 'tcp_established', label: i18n.t('agent.agentalerthelpe.s6d9639e8'), icon: Network },
|
||||
{ value: 'disk_inode', label: i18n.t('Inode 使用率'), icon: HardDrive },
|
||||
{ value: 'disk_io_util', label: i18n.t('磁盘 IO 利用率'), icon: HardDrive },
|
||||
{ value: 'tcp_established', label: i18n.t('TCP 已建立'), icon: Network },
|
||||
{ value: 'tcp_time_wait', label: 'TCP TIME_WAIT', icon: Network },
|
||||
{ value: 'tcp_close_wait', label: 'TCP CLOSE_WAIT', icon: Network },
|
||||
{ value: 'net_rx_bps', label: i18n.t('monitor.hostNetIn'), icon: Network },
|
||||
{ value: 'net_tx_bps', label: i18n.t('monitor.hostNetOut'), icon: Network },
|
||||
{ value: 'net_rx_errors', label: i18n.t('agent.agentalerthelpe.s8d73bfe3'), icon: Network },
|
||||
{ value: 'net_rx_errors', label: i18n.t('入网错误'), icon: Network },
|
||||
{ value: 'fd', label: i18n.t('monitor.hostFileDescriptor'), icon: Activity },
|
||||
{ value: 'offline', label: i18n.t('agent.agentalerthelpe.s8ed49aa6'), icon: WifiOff },
|
||||
{ value: 'port_down', label: i18n.t('agent.agentalerthelpe.sf62ce662'), icon: Network },
|
||||
{ value: 'offline', label: i18n.t('主机离线'), icon: WifiOff },
|
||||
{ value: 'port_down', label: i18n.t('端口不通'), icon: Network },
|
||||
{ value: 'health_probe', label: i18n.t('kubernetes.container.probes'), icon: Timer },
|
||||
];
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ export function MessageView({ item, inRoundGroup = false }: { item: ChatItem; in
|
||||
return (
|
||||
<div className="flex gap-2 rounded-lg bg-red-500/10 border border-red-500/30 p-3">
|
||||
<AlertTriangle className="w-5 h-5 dg-text-red shrink-0 mt-0.5" />
|
||||
<div className="text-sm text-[var(--dg-text-primary)] whitespace-pre-wrap">{item.content || i18n.t('aiops.agentclimessage.s1fd995b8')}</div>
|
||||
<div className="text-sm text-[var(--dg-text-primary)] whitespace-pre-wrap">{item.content || i18n.t('发生错误')}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -309,10 +309,10 @@ function ToolBlock({ item, inRoundGroup }: { item: ChatItem; inRoundGroup?: bool
|
||||
{item.duration && <div className="text-[10px] dg-text-muted">{i18n.t('aiops.durationLabel', { duration: item.duration })}</div>}
|
||||
{(item.toolName === 'analyze_output' || looksLikeMarkdown(item.output)) ? (
|
||||
<div className="bg-[var(--dg-bg-primary)]/40 rounded px-2 py-1.5 max-h-80 overflow-y-auto">
|
||||
<AgentMarkdown content={item.output || i18n.t('aiops.agentclimessage.s216caee5')} />
|
||||
<AgentMarkdown content={item.output || i18n.t('(无输出)')} />
|
||||
</div>
|
||||
) : (
|
||||
<pre className="text-xs text-[var(--dg-text-secondary)] bg-[var(--dg-bg-primary)]/40 rounded px-2 py-1.5 overflow-x-auto max-h-80 whitespace-pre-wrap">{item.output || i18n.t('aiops.agentclimessage.s216caee5')}</pre>
|
||||
<pre className="text-xs text-[var(--dg-text-secondary)] bg-[var(--dg-bg-primary)]/40 rounded px-2 py-1.5 overflow-x-auto max-h-80 whitespace-pre-wrap">{item.output || i18n.t('(无输出)')}</pre>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -49,11 +49,11 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。`,
|
||||
recommendations: [
|
||||
`登录 ${target} 执行 top/htop 定位高 CPU 进程`,
|
||||
i18n.t('aiops.analyzerhelpers.s63b2d4fb'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
`考虑临时扩容或将部分流量调度到其他节点`,
|
||||
i18n.t('aiops.analyzerhelpers.sc8ee5079'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
],
|
||||
autoFixScript: `#!/bin/bash\n# CPU 高负载诊断脚本 - ${target}\necho "${i18n.t('aiops.analyzerhelpers.sa0b9d055')}"\nps aux --sort=-%cpu | head -11\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sc4e238d7')}"\nuptime\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sfaca56f5')}"\nPID=$(ps aux --sort=-%cpu | sed -n '2p' | awk '{print $2}')\nif [ -n "$PID" ]; then\n echo "${i18n.t('aiops.analyzerhelpers.s303a9855')}"\n cat /proc/$PID/cmdline | tr '\\0' ' '\n echo ""\nfi\n`,
|
||||
autoFixScript: `#!/bin/bash\n# CPU 高负载诊断脚本 - ${target}\necho "${i18n.t('最高 CPU 进程: PID=$PID')}"\nps aux --sort=-%cpu | head -11\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sc4e238d7')}"\nuptime\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sfaca56f5')}"\nPID=$(ps aux --sort=-%cpu | sed -n '2p' | awk '{print $2}')\nif [ -n "$PID" ]; then\n echo "${i18n.t('aiops.analyzerhelpers.s303a9855')}"\n cat /proc/$PID/cmdline | tr '\\0' ' '\n echo ""\nfi\n`,
|
||||
similarCases: 0,
|
||||
confidence: 0,
|
||||
};
|
||||
@@ -68,9 +68,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。`,
|
||||
recommendations: [
|
||||
`检查 ${target} 上的内存占用最高的进程`,
|
||||
i18n.t('aiops.analyzerhelpers.s3166ba9e'),
|
||||
i18n.t('aiops.analyzerhelpers.sdc67cc47'),
|
||||
i18n.t('aiops.analyzerhelpers.s20eb7092'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
],
|
||||
similarCases: 0,
|
||||
confidence: 0,
|
||||
@@ -86,9 +86,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `磁盘空间告警,如不及时清理可能导致服务异常。`,
|
||||
recommendations: [
|
||||
`清理 ${target} 上 30 天前的日志文件`,
|
||||
i18n.t('aiops.analyzerhelpers.s187f6268'),
|
||||
i18n.t('aiops.analyzerhelpers.sb9cbe0b9'),
|
||||
i18n.t('aiops.analyzerhelpers.s4438245e'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
],
|
||||
autoFixScript: `#!/bin/bash\n# 磁盘清理脚本 - ${target}\necho "${i18n.t('aiops.analyzerhelpers.s5b91c16b')}"\ndf -h /\necho ""\necho "${i18n.t('aiops.analyzerhelpers.s3b1993da')}"\nfind /var/log -name "*.log" -mtime +30 -delete 2>/dev/null\nfind /var/log -name "*.gz" -mtime +30 -delete 2>/dev/null\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sb513e117')}"\njournalctl --vacuum-time=7d 2>/dev/null\necho ""\necho "${i18n.t('aiops.analyzerhelpers.s4c139c9f')}"\ndf -h /\n`,
|
||||
similarCases: 0,
|
||||
@@ -105,9 +105,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `网络延迟偏高,可能影响用户体验,建议排查网络链路。`,
|
||||
recommendations: [
|
||||
`检查 ${target} 的网络连接和带宽使用情况`,
|
||||
i18n.t('aiops.analyzerhelpers.s2dcf7289'),
|
||||
i18n.t('aiops.analyzerhelpers.sb240d756'),
|
||||
i18n.t('aiops.analyzerhelpers.s1e860afd'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
],
|
||||
similarCases: 0,
|
||||
confidence: 0,
|
||||
@@ -123,9 +123,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `服务可用性下降,部分功能可能受影响。`,
|
||||
recommendations: [
|
||||
`立即检查 ${target} 的服务状态: systemctl status <service>`,
|
||||
i18n.t('aiops.analyzerhelpers.sa9e9dc2f'),
|
||||
i18n.t('aiops.analyzerhelpers.s902739be'),
|
||||
i18n.t('aiops.analyzerhelpers.sdef735d5'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||
],
|
||||
autoFixScript: `#!/bin/bash\n# 服务恢复脚本 - ${target}\necho "${i18n.t('aiops.analyzerhelpers.se59337b9')}"\nsystemctl list-units --state=failed\necho ""\necho "${i18n.t('aiops.analyzerhelpers.scdd631f0')}"\nss -tlnp | grep -E ':(80|443|8080|3306|6379|9090)'\necho ""\necho "${i18n.t('aiops.analyzerhelpers.sad3e7bba')}"\nsystemctl reset-failed\n`,
|
||||
similarCases: 0,
|
||||
@@ -141,9 +141,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
: `该告警需要关注,持续恶化可能影响系统稳定性。`,
|
||||
recommendations: [
|
||||
`查看 ${target} 的监控仪表盘,确认指标趋势`,
|
||||
i18n.t('aiops.analyzerhelpers.s970501e5'),
|
||||
i18n.t('aiops.analyzerhelpers.s4a3f985d'),
|
||||
i18n.t('aiops.analyzerhelpers.s10441f9f'),
|
||||
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||
],
|
||||
similarCases: 0,
|
||||
confidence: 0,
|
||||
@@ -173,10 +173,10 @@ export function mapAlertEvent(event: JsonData): AlertItem {
|
||||
|
||||
return {
|
||||
id: String(event.id),
|
||||
name: event.rule_name || event.rule?.name || i18n.t('aiops.analyzerhelpers.sd7a5c3d9'),
|
||||
name: event.rule_name || event.rule?.name || i18n.t('未知告警'),
|
||||
severity: event.severity === 'critical' ? 'critical' : event.severity === 'warning' ? 'warning' : 'info',
|
||||
status: event.status === 'firing' ? 'active' : 'resolved',
|
||||
source: event.target || i18n.t('aiops.analyzerhelpers.s1b9b6c32'),
|
||||
source: event.target || i18n.t('未知目标'),
|
||||
metric,
|
||||
threshold,
|
||||
currentValue,
|
||||
|
||||
@@ -59,22 +59,22 @@ export function capacityRecommendation(metricKey: string, days: number): string
|
||||
const level = days <= 7 ? 'urgent' : days <= 14 ? 'warning' : 'normal';
|
||||
const recs: Record<string, Record<string, string>> = {
|
||||
urgent: {
|
||||
cpu: i18n.t('aiops.predictutilsts.s4d0bd643'),
|
||||
memory: i18n.t('aiops.predictutilsts.sb4593f3a'),
|
||||
disk: i18n.t('aiops.predictutilsts.s6c25383f'),
|
||||
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||
disk: i18n.t('磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志'),
|
||||
},
|
||||
warning: {
|
||||
cpu: i18n.t('aiops.predictutilsts.s8ea826f4'),
|
||||
memory: i18n.t('aiops.predictutilsts.sb08bd5fc'),
|
||||
disk: i18n.t('aiops.predictutilsts.s4cdda5dc'),
|
||||
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||
disk: i18n.t('磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志'),
|
||||
},
|
||||
normal: {
|
||||
cpu: i18n.t('aiops.predictutilsts.sfa295c44'),
|
||||
memory: i18n.t('aiops.predictutilsts.s7156a4c0'),
|
||||
disk: i18n.t('aiops.predictutilsts.s0073f3a3'),
|
||||
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||
disk: i18n.t('磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志'),
|
||||
},
|
||||
};
|
||||
return recs[level]?.[metricKey] || i18n.t('aiops.predictutilsts.sfeb368e6');
|
||||
return recs[level]?.[metricKey] || i18n.t('建议持续监控资源使用趋势');
|
||||
}
|
||||
|
||||
// ============ 综合预测推算 ============
|
||||
@@ -87,7 +87,7 @@ export function capacityRecommendation(metricKey: string, days: number): string
|
||||
export function computePredictions(input: ComputePredictionsInput): ComputedPredictions {
|
||||
const { rawMetrics, serverStats, selectedTimeRange } = input;
|
||||
const horizonHours = TIME_RANGE_HOURS[selectedTimeRange] || 24;
|
||||
const timeRangeLabel = TIME_RANGE_LABELS[selectedTimeRange] || i18n.t('aiops.predictutilsts.sfc78646e');
|
||||
const timeRangeLabel = TIME_RANGE_LABELS[selectedTimeRange] || i18n.t('24小时后');
|
||||
|
||||
// ---- 指标预测 ----
|
||||
const predictions: PredictionMetric[] = METRIC_DEFS.map((def) => {
|
||||
@@ -177,18 +177,18 @@ export function trendColorClass(trend: string): string {
|
||||
export function buildCapacityInsightPrompt(forecasts: CapacityForecast[]): string {
|
||||
if (forecasts.length === 0) return '';
|
||||
const lines = forecasts.map((f) => {
|
||||
const risk = f.daysUntilThreshold >= 999 ? i18n.t('aiops.predictutilsts.s179fd5a9') : i18n.t('aiops.predictutilsts.daysUntilThreshold', { days: f.daysUntilThreshold });
|
||||
const risk = f.daysUntilThreshold >= 999 ? i18n.t('增长平缓,暂无触顶风险') : i18n.t('aiops.predictutilsts.daysUntilThreshold', { days: f.daysUntilThreshold });
|
||||
return `- ${f.resource}:当前 ${f.currentUsage}% → 7天后预测 ${f.predictedUsage}%(阈值 ${f.threshold}%),${risk}`;
|
||||
});
|
||||
return [
|
||||
i18n.t('aiops.predictutilsts.s3b46e5a0'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
'',
|
||||
i18n.t('aiops.predictutilsts.s586bac5d'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
...lines,
|
||||
'',
|
||||
i18n.t('aiops.predictutilsts.sdf6ebee3'),
|
||||
i18n.t('aiops.predictutilsts.s534b6893'),
|
||||
i18n.t('aiops.predictutilsts.saf173e7a'),
|
||||
i18n.t('aiops.predictutilsts.s4ed1d035'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||
].join('\n');
|
||||
}
|
||||
@@ -83,15 +83,15 @@ function costTrendFromSlope(slope: number): 'up' | 'down' | 'stable' {
|
||||
/** 成本优化建议 */
|
||||
export function costRecommendation(trend: 'up' | 'down' | 'stable', ratio: number): string {
|
||||
if (trend === 'up' && ratio >= 0.85) {
|
||||
return i18n.t('aiops.predictutilsts.sa7d4e3c1');
|
||||
return i18n.t('排查内存泄漏,优化进程内存配置,考虑增加节点');
|
||||
}
|
||||
if (trend === 'up') {
|
||||
return i18n.t('aiops.predictutilsts.sb3f5a2d8');
|
||||
return i18n.t('排查内存泄漏,优化进程内存配置,考虑增加节点');
|
||||
}
|
||||
if (trend === 'down') {
|
||||
return i18n.t('aiops.predictutilsts.sc1a9b4e7');
|
||||
return i18n.t('排查内存泄漏,优化进程内存配置,考虑增加节点');
|
||||
}
|
||||
return i18n.t('aiops.predictutilsts.sd8c6f2a3');
|
||||
return i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:');
|
||||
}
|
||||
|
||||
/** 预算风险建议 */
|
||||
@@ -256,7 +256,7 @@ export function computeCostPredictions(input: ComputeCostPredictionsInput): Comp
|
||||
const allRatio =
|
||||
summary.predictedMonthEnd > 0 ? summary.monthCost / summary.predictedMonthEnd : 0;
|
||||
dimensionForecasts.push({
|
||||
dimension: i18n.t('aiops.predictutilsts.sa1b2c3d4'),
|
||||
dimension: i18n.t('清理历史数据和日志,实施数据归档策略,扩容磁盘'),
|
||||
currentMonth: summary.monthCost,
|
||||
predictedMonthEnd: summary.predictedMonthEnd,
|
||||
dailyAvg: summary.dailyAvg,
|
||||
@@ -302,7 +302,7 @@ export function computeCostPredictions(input: ComputeCostPredictionsInput): Comp
|
||||
|
||||
const metric = (rule.metric === 'daily' ? 'daily' : 'monthly') as 'daily' | 'monthly';
|
||||
const ruleProvider = String(rule.provider || '');
|
||||
const providerLabel = ruleProvider ? PROVIDER_LABELS[ruleProvider] || ruleProvider : i18n.t('aiops.predictutilsts.sb2c3d4e5');
|
||||
const providerLabel = ruleProvider ? PROVIDER_LABELS[ruleProvider] || ruleProvider : i18n.t('24小时后');
|
||||
|
||||
let current = 0;
|
||||
let predicted = 0;
|
||||
@@ -339,7 +339,7 @@ export function computeCostPredictions(input: ComputeCostPredictionsInput): Comp
|
||||
if (current >= threshold) probability += 25;
|
||||
probability = Math.max(5, Math.min(92, probability));
|
||||
|
||||
let timeframe = metric === 'daily' ? i18n.t('aiops.predictutilsts.sc3d4e5f6') : i18n.t('aiops.predictutilsts.sd4e5f6g7');
|
||||
let timeframe = metric === 'daily' ? i18n.t('未来24小时') : i18n.t('aiops.predictutilsts.sd4e5f6g7');
|
||||
if (slope > 0.01 && threshold > current) {
|
||||
const days = (threshold - current) / slope;
|
||||
if (days < 1) timeframe = metric === 'daily' ? i18n.t('aiops.predictutilsts.se5f6g7h8') : i18n.t('aiops.predictutilsts.sf6g7h8i9');
|
||||
|
||||
@@ -120,16 +120,16 @@ export interface ComputeCostPredictionsInput {
|
||||
|
||||
/** 指标定义:后端 metric name → 展示标签 / 告警表达式前缀 / 阈值 */
|
||||
export const METRIC_DEFS = [
|
||||
{ key: 'cpu', label: i18n.t('aiops.predictutilsts.s7054bc34'), exprKey: 'cpu_usage', threshold: 85 },
|
||||
{ key: 'memory', label: i18n.t('aiops.predictutilsts.s82c0d1b0'), exprKey: 'memory_usage', threshold: 85 },
|
||||
{ key: 'disk', label: i18n.t('aiops.predictutilsts.s4e2d8f91'), exprKey: 'disk_usage', threshold: 90 },
|
||||
{ key: 'cpu', label: i18n.t('CPU使用率'), exprKey: 'cpu_usage', threshold: 85 },
|
||||
{ key: 'memory', label: i18n.t('内存使用率'), exprKey: 'memory_usage', threshold: 85 },
|
||||
{ key: 'disk', label: i18n.t('磁盘使用率'), exprKey: 'disk_usage', threshold: 90 },
|
||||
] as const;
|
||||
|
||||
export const TIME_RANGE_LABELS: Record<string, string> = {
|
||||
'1h': i18n.t('aiops.predictutilsts.s75719bb8'),
|
||||
'24h': i18n.t('aiops.predictutilsts.sfc78646e'),
|
||||
'7d': i18n.t('aiops.predictutilsts.s5b5a820c'),
|
||||
'30d': i18n.t('aiops.predictutilsts.s933ab0a6'),
|
||||
'1h': i18n.t('1小时后'),
|
||||
'24h': i18n.t('24小时后'),
|
||||
'7d': i18n.t('7天后'),
|
||||
'30d': i18n.t('30天后'),
|
||||
};
|
||||
|
||||
export const TIME_RANGE_HOURS: Record<string, number> = {
|
||||
|
||||
@@ -66,7 +66,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!form.provider || !form.billing_date || !form.cost) {
|
||||
toast.error(i18n.t('cloud.billingrecorddi.sd8a97c17'));
|
||||
toast.error(i18n.t('请填写必填字段'));
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
@@ -92,7 +92,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{editingRecord ? i18n.t('cloud.billingrecorddi.s3c91e420') : i18n.t('cloud.recordCost')}</DialogTitle>
|
||||
<DialogTitle>{editingRecord ? i18n.t('编辑成本记录') : i18n.t('cloud.recordCost')}</DialogTitle>
|
||||
<DialogDescription> {i18n.t('cloud.billingrecorddi.s09e541fd')} </DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-3">
|
||||
@@ -130,7 +130,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-sm text-[var(--dg-text-secondary)]"> {i18n.t('cloud.accountName')} </Label>
|
||||
<Input className="mt-1" placeholder={i18n.t('cloud.billingrecorddi.s0010795e')} value={form.account_name} onChange={(e) => setForm({ ...form, account_name: e.target.value })} />
|
||||
<Input className="mt-1" placeholder={i18n.t('主账号')} value={form.account_name} onChange={(e) => setForm({ ...form, account_name: e.target.value })} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -58,7 +58,7 @@ export function BillingRuleDialog({ open, onOpenChange, editingRule, onSuccess }
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!form.name || !form.threshold) {
|
||||
toast.error(i18n.t('cloud.billingruledial.sd36855b1'));
|
||||
toast.error(i18n.t('请填写规则名称和阈值'));
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
@@ -83,13 +83,13 @@ export function BillingRuleDialog({ open, onOpenChange, editingRule, onSuccess }
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{editingRule ? i18n.t('cloud.billingruledial.sb8cfa0c9') : i18n.t('cloud.billingruledial.sd58c549a')}</DialogTitle>
|
||||
<DialogTitle>{editingRule ? i18n.t('编辑预警规则') : i18n.t('添加预警规则')}</DialogTitle>
|
||||
<DialogDescription> {i18n.t('cloud.billingruledial.s75227f20')} </DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label className="text-sm text-[var(--dg-text-secondary)]"> {i18n.t('monitor.silenceDialog.ruleNameRequired')} </Label>
|
||||
<Input className="mt-1" placeholder={i18n.t('cloud.billingruledial.sc147ac4f')} value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
||||
<Input className="mt-1" placeholder={i18n.t('如:日成本超 500 元预警')} value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
|
||||
@@ -39,7 +39,7 @@ import type { JsonData } from '@/types/common';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const typeLabels: Record<string, string> = {
|
||||
public: i18n.t('server.cloudserverimpo.s7ef31abb'),
|
||||
public: i18n.t('公有云'),
|
||||
private: i18n.t('cloud.privateCloud'),
|
||||
hybrid: i18n.t('cloud.hybridCloud'),
|
||||
};
|
||||
@@ -138,7 +138,7 @@ export function PlatformManager() {
|
||||
<div className="relative w-72">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
||||
<Input
|
||||
placeholder={i18n.t('cloud.platformmanager.s783a513f')}
|
||||
placeholder={i18n.t('搜索平台名称或编码...')}
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-9 h-9 dg-input"
|
||||
@@ -150,7 +150,7 @@ export function PlatformManager() {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all"> {i18n.t('k8s.topology.allTypes')} </SelectItem>
|
||||
<SelectItem value="public"> {i18n.t('server.cloudserverimpo.s7ef31abb')} </SelectItem>
|
||||
<SelectItem value="public"> {i18n.t('公有云')} </SelectItem>
|
||||
<SelectItem value="private"> {i18n.t('cloud.privateCloud')} </SelectItem>
|
||||
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
||||
</SelectContent>
|
||||
@@ -162,7 +162,7 @@ export function PlatformManager() {
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('cloud.title')}
|
||||
subtitle={i18n.t('cloud.platformmanager.s7012045f')}
|
||||
subtitle={i18n.t('管理公有云、私有云与混合云平台信息')}
|
||||
icon={<CloudCog className="h-5 w-5" />}
|
||||
metrics={
|
||||
!loading ? (
|
||||
@@ -170,7 +170,7 @@ export function PlatformManager() {
|
||||
items={[
|
||||
{ label: i18n.t('system.auditTotal'), value: stats.total, color: 'blue' },
|
||||
{ label: i18n.t('system.userActive'), value: stats.active, color: 'green' },
|
||||
{ label: i18n.t('server.cloudserverimpo.s7ef31abb'), value: stats.public, color: 'cyan' },
|
||||
{ label: i18n.t('公有云'), value: stats.public, color: 'cyan' },
|
||||
]}
|
||||
/>
|
||||
) : undefined
|
||||
@@ -194,7 +194,7 @@ export function PlatformManager() {
|
||||
) : filtered.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<CloudCog className="h-12 w-12" />}
|
||||
title={i18n.t('cloud.platformmanager.sb9f478da')}
|
||||
title={i18n.t('暂无云平台数据')}
|
||||
action={(
|
||||
<Button size="sm" className="dg-btn-primary" onClick={openCreate}>
|
||||
<Plus className="h-4 w-4 mr-1" />
|
||||
@@ -261,26 +261,26 @@ export function PlatformManager() {
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{editingItem ? i18n.t('cloud.platformmanager.sf83734ec') : i18n.t('cloud.platformmanager.s3f6f0cf2')}</DialogTitle>
|
||||
<DialogTitle>{editingItem ? i18n.t('编辑云平台') : i18n.t('添加云平台')}</DialogTitle>
|
||||
<DialogDescription className="sr-only"> {i18n.t('aiops.llmModelDesc')} </DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-2">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label> {i18n.t('cloud.platformmanager.seac7fc68')} </Label>
|
||||
<Label> {i18n.t('如:阿里云')} </Label>
|
||||
<Input
|
||||
value={formData.name}
|
||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||
placeholder={i18n.t('cloud.platformmanager.sa39d9635')}
|
||||
placeholder={i18n.t('如:阿里云')}
|
||||
className="dg-input"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label> {i18n.t('cloud.platformmanager.se21e278f')} </Label>
|
||||
<Label> {i18n.t('如:阿里云')} </Label>
|
||||
<Input
|
||||
value={formData.code}
|
||||
onChange={(e) => setFormData({ ...formData, code: e.target.value })}
|
||||
placeholder={i18n.t('cloud.platformmanager.s7b09b049')}
|
||||
placeholder={i18n.t('如:阿里云')}
|
||||
className="dg-input"
|
||||
disabled={!!editingItem}
|
||||
/>
|
||||
@@ -294,7 +294,7 @@ export function PlatformManager() {
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="public"> {i18n.t('server.cloudserverimpo.s7ef31abb')} </SelectItem>
|
||||
<SelectItem value="public"> {i18n.t('公有云')} </SelectItem>
|
||||
<SelectItem value="private"> {i18n.t('cloud.privateCloud')} </SelectItem>
|
||||
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
||||
</SelectContent>
|
||||
@@ -314,7 +314,7 @@ export function PlatformManager() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label> {i18n.t('cloud.platformmanager.saf587eb5')} </Label>
|
||||
<Label> {i18n.t('如:阿里云')} </Label>
|
||||
<Input
|
||||
value={formData.website}
|
||||
onChange={(e) => setFormData({ ...formData, website: e.target.value })}
|
||||
@@ -327,7 +327,7 @@ export function PlatformManager() {
|
||||
<Input
|
||||
value={formData.description}
|
||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
||||
placeholder={i18n.t('cloud.platformmanager.sc44dd421')}
|
||||
placeholder={i18n.t('平台描述...')}
|
||||
className="dg-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -59,7 +59,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
const srvList = (srvRes as { list?: ServerItem[] })?.list || [];
|
||||
setServers(srvList);
|
||||
} catch {
|
||||
toast.error(i18n.t('pipeline.buildnodesmanag.sb9faa2a3'));
|
||||
toast.error(i18n.t('加载构建节点失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!name.trim() || !serverId) {
|
||||
toast.error(i18n.t('pipeline.buildnodesmanag.sda51a736'));
|
||||
toast.error(i18n.t('加载构建节点失败'));
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
@@ -128,7 +128,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
toast.success(i18n.t('monitor.silenceRules.deleted'));
|
||||
load();
|
||||
} catch {
|
||||
toast.error(i18n.t('pipeline.buildnodesmanag.s577b185d'));
|
||||
toast.error(i18n.t('加载构建节点失败'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
const handleSaveMaster = async () => {
|
||||
const n = Number(masterMax);
|
||||
if (!n || n < 1) {
|
||||
toast.error(i18n.t('pipeline.buildnodesmanag.s5f25f49a'));
|
||||
toast.error(i18n.t('加载构建节点失败'));
|
||||
return;
|
||||
}
|
||||
setSavingMaster(true);
|
||||
@@ -172,7 +172,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
max_executors: m?.max_executors ?? n,
|
||||
running_count: m?.running_count ?? prev.running_count,
|
||||
}));
|
||||
toast.success(i18n.t('pipeline.buildnodesmanag.scb1ab6ab'));
|
||||
toast.success(i18n.t('已删除'));
|
||||
} catch {
|
||||
toast.error(i18n.t('kubernetes.deployment.imageUpdateFailed'));
|
||||
} finally {
|
||||
@@ -218,7 +218,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
className="h-7 w-16 text-xs dg-input"
|
||||
/>
|
||||
<Button size="sm" className="h-7 text-xs" onClick={handleSaveMaster} disabled={savingMaster}>
|
||||
{savingMaster ? i18n.t('pipeline.buildnodesmanag.s7cbf2d09') : i18n.t('task.script.save')}
|
||||
{savingMaster ? i18n.t('保存中') : i18n.t('task.script.save')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -229,8 +229,8 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
|
||||
{nodes.length === 0 ? (
|
||||
<PageEmpty
|
||||
title={i18n.t('pipeline.buildnodesmanag.s2795bd4a')}
|
||||
description={i18n.t('pipeline.buildnodesmanag.s90fb5e18')}
|
||||
title={i18n.t('暂无远程构建节点')}
|
||||
description={i18n.t('关联服务器资产添加 SSH 节点,将重型构建任务调度到高性能机器')}
|
||||
action={<Button size="sm" onClick={openCreate}><Plus className="h-3.5 w-3.5 mr-1" /> {i18n.t('kubernetes.topology.addNode')} </Button>}
|
||||
/>
|
||||
) : (
|
||||
@@ -258,7 +258,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
</div>
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
<Button variant="ghost" size="sm" className="h-7 text-xs" disabled={testingId === node.id} onClick={() => handleTest(node)}>
|
||||
{testingId === node.id ? i18n.t('pipeline.buildnodesmanag.sf85549cd') : i18n.t('pipeline.testTool')}
|
||||
{testingId === node.id ? i18n.t('测试中') : i18n.t('pipeline.testTool')}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" className="h-7 text-xs" onClick={() => handleToggle(node)}>
|
||||
{node.enabled ? i18n.t('system.userInactive') : i18n.t('system.userActive')}
|
||||
@@ -293,9 +293,9 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
<Input value={name} onChange={(e) => setName(e.target.value)} className="h-8 text-xs dg-input" placeholder="build-node-01" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('pipeline.buildnodesmanag.sdfdaf1c5')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('>标签 <span className=')} </Label>
|
||||
<Select value={serverId || '__none'} onValueChange={(v) => setServerId(v === '__none' ? '' : v)}>
|
||||
<SelectTrigger className="h-8 text-xs dg-input"><SelectValue placeholder={i18n.t('server.webshelltsx.s030235d1')} /></SelectTrigger>
|
||||
<SelectTrigger className="h-8 text-xs dg-input"><SelectValue placeholder={i18n.t('选择服务器')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__none"> {i18n.t('k8s.storage.pleaseSelect')} </SelectItem>
|
||||
{servers.map((s) => (
|
||||
@@ -326,7 +326,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 pt-2">
|
||||
<Button variant="outline" onClick={() => setDialogOpen(false)}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
||||
<Button onClick={handleSubmit} disabled={submitting}>{submitting ? i18n.t('pipeline.buildnodesmanag.s7cbf2d09') : i18n.t('task.script.save')}</Button>
|
||||
<Button onClick={handleSubmit} disabled={submitting}>{submitting ? i18n.t('保存中') : i18n.t('task.script.save')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
@@ -343,7 +343,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell title={i18n.t('pipeline.buildNodes')} subtitle={i18n.t('pipeline.buildnodesmanag.sb2b825e4')}>
|
||||
<PageShell title={i18n.t('pipeline.buildNodes')} subtitle={i18n.t('构建节点')}>
|
||||
{panel}
|
||||
{dialog}
|
||||
</PageShell>
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function DeployRBAC() {
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
||||
toast.error(i18n.t('monitor.logrbactsx.sf6e80bf0')); return;
|
||||
toast.error(i18n.t('请填写名称、标识与正则')); return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
@@ -147,7 +147,7 @@ export default function DeployRBAC() {
|
||||
|
||||
const handleDelete = async (role: ItemRole) => {
|
||||
const ok = await _confirm({
|
||||
title: i18n.t('monitor.logrbactsx.s5d79e436'),
|
||||
title: i18n.t('删除权限'),
|
||||
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个发布任务`,
|
||||
variant: 'destructive',
|
||||
});
|
||||
@@ -165,7 +165,7 @@ export default function DeployRBAC() {
|
||||
};
|
||||
|
||||
const handleAssign = async () => {
|
||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('monitor.logrbactsx.s0fc53985')); return; }
|
||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('请选择用户和权限')); return; }
|
||||
setAssignLoading(true);
|
||||
try {
|
||||
await deployApi.assignItemRole(Number(selectedUserId), {
|
||||
@@ -190,8 +190,8 @@ export default function DeployRBAC() {
|
||||
|
||||
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
||||
const pageTabs = [
|
||||
{ id: 'roles', label: i18n.t('monitor.logrbactsx.s93ef07cd'), badge: roles.length || undefined },
|
||||
{ id: 'users', label: i18n.t('monitor.logrbactsx.s2de89571') },
|
||||
{ id: 'roles', label: i18n.t('权限策略'), badge: roles.length || undefined },
|
||||
{ id: 'users', label: i18n.t('用户授权') },
|
||||
{ id: 'groups', label: i18n.t('pipeline.groupLabel') },
|
||||
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
||||
];
|
||||
@@ -200,7 +200,7 @@ export default function DeployRBAC() {
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('deploy.deployNav.jobPermission')}
|
||||
subtitle={i18n.t('pipeline.deployrbactsx.sa596d659')}
|
||||
subtitle={i18n.t('按流水线 code / Job 名称正则分配发布权限')}
|
||||
icon={<Shield className="h-5 w-5" />}
|
||||
loading={loading}
|
||||
tabs={pageTabs}
|
||||
@@ -217,8 +217,8 @@ export default function DeployRBAC() {
|
||||
roles.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<Shield className="h-10 w-10" />}
|
||||
title={i18n.t('pipeline.deployrbactsx.sca578c70')}
|
||||
description={i18n.t('pipeline.deployrbactsx.s5ac38262')}
|
||||
title={i18n.t('暂无 Job 权限策略')}
|
||||
description={i18n.t('创建策略后,用户将按正则自动获得匹配流水线的访问权限')}
|
||||
action={<Button onClick={() => setCreateOpen(true)}><Plus className="h-4 w-4 mr-1" /> {i18n.t('monitor.logrbactsx.s6058845c')} </Button>}
|
||||
/>
|
||||
) : (
|
||||
@@ -296,7 +296,7 @@ export default function DeployRBAC() {
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1 w-48">
|
||||
<Label className="text-xs"> {i18n.t('monitor.logrbactsx.s93ef07cd')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('权限策略')} </Label>
|
||||
<Select value={assignRoleId} onValueChange={setAssignRoleId}>
|
||||
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -99,8 +99,8 @@ export default function UserGroupsManager({ embedded = false }: { embedded?: boo
|
||||
const listBody = !loading && groups.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<Users className="h-10 w-10" />}
|
||||
title={i18n.t('pipeline.usergroupsmanag.sd1edd832')}
|
||||
description={i18n.t('pipeline.usergroupsmanag.scf98655a')}
|
||||
title={i18n.t('暂无用户组')}
|
||||
description={i18n.t('点击「新建用户组」创建第一个用户组')}
|
||||
action={(
|
||||
<Button size="sm" onClick={() => { setEditId(null); setFormName(''); setFormDesc(''); setFormOpen(true); }}>
|
||||
<Plus className="w-4 h-4 mr-1" />新建用户组
|
||||
@@ -165,7 +165,7 @@ export default function UserGroupsManager({ embedded = false }: { embedded?: boo
|
||||
<DialogContent>
|
||||
<DialogHeader><DialogTitle>{editId ? i18n.t('deploy.rbac.groupEditTitle') : i18n.t('pipeline.newGroup')}</DialogTitle></DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1"><Label> {i18n.t('monitor.groupName')} </Label><Input value={formName} onChange={e => setFormName(e.target.value)} placeholder={i18n.t('pipeline.usergroupsmanag.s5a56328e')} /></div>
|
||||
<div className="space-y-1"><Label> {i18n.t('monitor.groupName')} </Label><Input value={formName} onChange={e => setFormName(e.target.value)} placeholder={i18n.t('例如: 后端开发组')} /></div>
|
||||
<div className="space-y-1"><Label> {i18n.t('aiops.llmModelDesc')} </Label><Input value={formDesc} onChange={e => setFormDesc(e.target.value)} placeholder={i18n.t('rbac.jobRole.placeholder.description')} /></div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4 pt-4 border-t">
|
||||
@@ -190,14 +190,14 @@ export default function UserGroupsManager({ embedded = false }: { embedded?: boo
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('pipeline.releaseTitle')}
|
||||
subtitle={i18n.t('pipeline.usergroupsmanag.sf80ecf33')}
|
||||
subtitle={i18n.t('用户组 — 批量授权流水线访问权限')}
|
||||
icon={<Users className="h-5 w-5" />}
|
||||
loading={loading}
|
||||
metrics={(
|
||||
<StatStrip
|
||||
items={[
|
||||
{ label: i18n.t('pipeline.groupLabel'), value: groups.length, color: 'blue' },
|
||||
{ label: i18n.t('pipeline.usergroupsmanag.sdf2b42fe'), value: memberCount, color: 'purple' },
|
||||
{ label: i18n.t('成员总数'), value: memberCount, color: 'purple' },
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -83,8 +83,8 @@ export function CredDetailDialog({ open, onClose, credId }: CredDetailDialogProp
|
||||
<div className="space-y-4">
|
||||
{/* 基本信息 // Logan.Li */}
|
||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.s5b478615')} </span><span className="text-[var(--dg-text-primary)] font-medium">{detailRecord?.name as string}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.se91f5a13')} </span>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('>名称:</span><span className=')} </span><span className="text-[var(--dg-text-primary)] font-medium">{detailRecord?.name as string}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('>名称:</span><span className=')} </span>
|
||||
<Badge variant="outline" className={`text-xs ml-1 ${TYPE_BADGE_CLASS[st] || ''}`}>{cfg?.label || st}</Badge>
|
||||
</div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('approval.detail.statusLabel')} </span>
|
||||
@@ -102,15 +102,15 @@ export function CredDetailDialog({ open, onClose, credId }: CredDetailDialogProp
|
||||
</div>
|
||||
{(detailRecord?.tags as string[])?.length > 0 && (
|
||||
<div className="col-span-2">
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.s1655dd5f')} </span>
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('无')} </span>
|
||||
{(detailRecord?.tags as string[]).map((t: string) => (
|
||||
<Badge key={t} variant="outline" className="text-xs ml-1 border-[var(--dg-border)]">{t}</Badge>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="col-span-2"><span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.s4a4e3b5a')} </span><span className="text-[var(--dg-text-secondary)]">{(detailRecord?.description as string) || '无'}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.s76d768fb')} </span><span className="text-[var(--dg-text-secondary)] text-xs">{new Date(detailRecord?.created_at as string).toLocaleString()}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('pipeline.creddetaildialo.s3820b7e1')} </span><span className="text-[var(--dg-text-secondary)] text-xs">{new Date(detailRecord?.updated_at as string).toLocaleString()}</span></div>
|
||||
<div className="col-span-2"><span className="text-[var(--dg-text-muted)]"> {i18n.t('无')} </span><span className="text-[var(--dg-text-secondary)]">{(detailRecord?.description as string) || '无'}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('>创建:</span><span className=')} </span><span className="text-[var(--dg-text-secondary)] text-xs">{new Date(detailRecord?.created_at as string).toLocaleString()}</span></div>
|
||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('>创建:</span><span className=')} </span><span className="text-[var(--dg-text-secondary)] text-xs">{new Date(detailRecord?.updated_at as string).toLocaleString()}</span></div>
|
||||
</div>
|
||||
|
||||
{/* 密钥数据 // Logan.Li */}
|
||||
@@ -119,12 +119,12 @@ export function CredDetailDialog({ open, onClose, credId }: CredDetailDialogProp
|
||||
<Key className="h-4 w-4 text-yellow-500" />密钥数据
|
||||
</div>
|
||||
<div className="p-3 rounded-md bg-yellow-500/5 border border-yellow-500/20 mb-3">
|
||||
<p className="text-xs dg-text-yellow/80"> {i18n.t('pipeline.creddetaildialo.s03b218d4')} </p>
|
||||
<p className="text-xs dg-text-yellow/80"> {i18n.t('无')} </p>
|
||||
</div>
|
||||
|
||||
{st === 'ssh' && <>
|
||||
<Field label={i18n.t('pipeline.creddetaildialo.s2272f5e9')} value={content.ssh_user} />
|
||||
<Field label={i18n.t('pipeline.creddetaildialo.s3f284a59')} value={content.ssh_port} />
|
||||
<Field label={i18n.t('SSH 用户')} value={content.ssh_user} />
|
||||
<Field label={i18n.t('SSH 用户')} value={content.ssh_port} />
|
||||
<Field label={i18n.t('system.sshPassword')} value={content.password} sensitive fieldKey="ssh_password" />
|
||||
<Field label={i18n.t('system.sshPrivateKey')} value={content.private_key} sensitive fieldKey="ssh_private_key" />
|
||||
<Field label={i18n.t('system.sshPublicKey')} value={content.public_key} fieldKey="ssh_public_key" />
|
||||
@@ -135,25 +135,25 @@ export function CredDetailDialog({ open, onClose, credId }: CredDetailDialogProp
|
||||
<Field label={i18n.t('system.passwordLabel')} value={content.password} sensitive fieldKey="docker_password" />
|
||||
</>}
|
||||
{st === 'tls' && <>
|
||||
<Field label={i18n.t('pipeline.creddetaildialo.sd40b5115')} value={content.cert} sensitive fieldKey="tls_cert" />
|
||||
<Field label={i18n.t('私钥')} value={content.cert} sensitive fieldKey="tls_cert" />
|
||||
<Field label={i18n.t('system.sshPrivateKey')} value={content.key} sensitive fieldKey="tls_key" />
|
||||
<Field label={i18n.t('pipeline.credformdialogt.sa24356be')} value={content.ca} sensitive fieldKey="tls_ca" />
|
||||
<Field label={i18n.t('数据库类型')} value={content.ca} sensitive fieldKey="tls_ca" />
|
||||
</>}
|
||||
{st === 'aksk' && <>
|
||||
<Field label="Access Key ID" value={content.access_key} />
|
||||
<Field label="Secret Access Key" value={content.secret_key} sensitive fieldKey="aksk_secret_key" />
|
||||
</>}
|
||||
{st === 'database' && <>
|
||||
<Field label={i18n.t('pipeline.credformdialogt.s84b916da')} value={String(content.db_type || '').toUpperCase()} />
|
||||
<Field label={i18n.t('数据库类型')} value={String(content.db_type || '').toUpperCase()} />
|
||||
<Field label={i18n.t('agent.agentHost')} value={content.host} />
|
||||
<Field label={i18n.t('system.ldapPort')} value={content.port} />
|
||||
<Field label={i18n.t('pipeline.credformdialogt.s5ccbbd01')} value={content.db_name} />
|
||||
<Field label={i18n.t('数据库类型')} value={content.db_name} />
|
||||
<Field label={i18n.t('system.userName')} value={content.username} />
|
||||
<Field label={i18n.t('system.passwordLabel')} value={content.password} sensitive fieldKey="db_password" />
|
||||
</>}
|
||||
{st === 'api' && <>
|
||||
<Field label="API Key" value={content.api_key} sensitive fieldKey="api_key" />
|
||||
<Field label={i18n.t('pipeline.creddetaildialo.s48ec3494')} value={content.endpoint} />
|
||||
<Field label={i18n.t('数据库类型')} value={content.endpoint} />
|
||||
</>}
|
||||
{st === 'generic' && <>
|
||||
<Field label="Key" value={content.generic_key} />
|
||||
|
||||
@@ -149,8 +149,8 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<div className="space-y-3">
|
||||
<div className="flex gap-1 p-1 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]">
|
||||
{([
|
||||
{ key: 'ssh' as const, label: i18n.t('pipeline.deploytargetfie.secf81967'), icon: Server },
|
||||
{ key: 'k8s' as const, label: i18n.t('pipeline.deploytargetfie.s7ff062d5'), icon: Network },
|
||||
{ key: 'ssh' as const, label: i18n.t('主机发布'), icon: Server },
|
||||
{ key: 'k8s' as const, label: i18n.t('主机发布'), icon: Network },
|
||||
]).map((item) => {
|
||||
const active = value.deployTarget === item.key;
|
||||
const Icon = item.icon;
|
||||
@@ -200,7 +200,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<Input
|
||||
value={serverSearch}
|
||||
onChange={(e) => setServerSearch(e.target.value)}
|
||||
placeholder={i18n.t('pipeline.deploytargetfie.sc7624940')}
|
||||
placeholder={i18n.t('搜索主机名或 IP')}
|
||||
className="pl-8 h-8 text-xs dg-input"
|
||||
/>
|
||||
</div>
|
||||
@@ -245,7 +245,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<p className="text-[10px] text-[var(--dg-text-muted)]"> {i18n.t('pipeline.deploytargetfie.sb2b6db98')} </p>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('pipeline.deploytargetfie.s5ca05a9b')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Input
|
||||
value={value.deployRemotePath}
|
||||
onChange={(e) => onChange({ deployRemotePath: e.target.value })}
|
||||
@@ -254,7 +254,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('pipeline.deploytargetfie.s65b20ba7')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Input
|
||||
value={value.deployScript}
|
||||
onChange={(e) => onChange({ deployScript: e.target.value })}
|
||||
@@ -292,11 +292,11 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('pipeline.deploytargetfie.s806e4e01')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Input
|
||||
readOnly
|
||||
value={value.k8sDeployment ? `${value.k8sNamespace}/${value.k8sDeployment}` : ''}
|
||||
placeholder={i18n.t('pipeline.deploytargetfie.sbb1671f3')}
|
||||
placeholder={i18n.t('从下方列表选择')}
|
||||
className="h-8 text-xs dg-input font-mono"
|
||||
/>
|
||||
</div>
|
||||
@@ -308,7 +308,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<Input
|
||||
value={depSearch}
|
||||
onChange={(e) => setDepSearch(e.target.value)}
|
||||
placeholder={i18n.t('pipeline.deploytargetfie.saa98b28a')}
|
||||
placeholder={i18n.t('搜索 Deployment 或命名空间')}
|
||||
className="pl-8 h-8 text-xs dg-input"
|
||||
/>
|
||||
</div>
|
||||
@@ -353,7 +353,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<Input
|
||||
value={value.k8sContainerName}
|
||||
onChange={(e) => onChange({ k8sContainerName: e.target.value })}
|
||||
placeholder={i18n.t('pipeline.deploytargetfie.s389076f8')}
|
||||
placeholder={i18n.t('搜索 Deployment 或命名空间')}
|
||||
className="h-8 text-xs font-mono dg-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -10,12 +10,12 @@ import {
|
||||
|
||||
// 流水线阶段定义(固定顺序) // Logan.Li
|
||||
export const STAGE_DEFS = [
|
||||
{ key: 'checkout', label: i18n.t('pipeline.checkout'), icon: GitBranch, color: '#6366F1', order: 1, needs: ['repo'], desc: i18n.t('pipeline.constantsts.s4769cecb') },
|
||||
{ key: 'build', label: i18n.t('pipeline.build'), icon: Box, color: '#F59E0B', order: 2, needs: [], desc: i18n.t('pipeline.constantsts.s3318af6f') },
|
||||
{ key: 'test', label: i18n.t('pipeline.testTool'), icon: CheckCircle, color: '#10B981', order: 3, needs: [], desc: i18n.t('pipeline.constantsts.s350a98e1') },
|
||||
{ key: 'image', label: i18n.t('pipeline.imageBuild'), icon: Container, color: '#06B6D4', order: 4, needs: ['registry'], desc: i18n.t('pipeline.constantsts.s98ea1149') },
|
||||
{ key: 'deploy', label: i18n.t('pipeline.deploy2'), icon: Rocket, color: '#EF4444', order: 5, needs: [], desc: i18n.t('pipeline.constantsts.s45f0eba0') },
|
||||
{ key: 'verify', label: i18n.t('system.credentialVerify'), icon: ShieldCheck, color: '#3B82F6', order: 6, needs: [], desc: i18n.t('pipeline.constantsts.seb164cd5') },
|
||||
{ key: 'checkout', label: i18n.t('pipeline.checkout'), icon: GitBranch, color: '#6366F1', order: 1, needs: ['repo'], desc: i18n.t('代码检出') },
|
||||
{ key: 'build', label: i18n.t('pipeline.build'), icon: Box, color: '#F59E0B', order: 2, needs: [], desc: i18n.t('构建') },
|
||||
{ key: 'test', label: i18n.t('pipeline.testTool'), icon: CheckCircle, color: '#10B981', order: 3, needs: [], desc: i18n.t('测试') },
|
||||
{ key: 'image', label: i18n.t('pipeline.imageBuild'), icon: Container, color: '#06B6D4', order: 4, needs: ['registry'], desc: i18n.t('镜像打包') },
|
||||
{ key: 'deploy', label: i18n.t('pipeline.deploy2'), icon: Rocket, color: '#EF4444', order: 5, needs: [], desc: i18n.t('部署') },
|
||||
{ key: 'verify', label: i18n.t('system.credentialVerify'), icon: ShieldCheck, color: '#3B82F6', order: 6, needs: [], desc: i18n.t('验证') },
|
||||
].sort((a, b) => a.order - b.order);
|
||||
|
||||
// 运行日志条目 // Logan.Li
|
||||
|
||||
@@ -121,7 +121,7 @@ export default function CapacityPage() {
|
||||
</TableRow></TableHeader>
|
||||
<TableBody>
|
||||
{rows.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-8">{i18n.t('k8s.capacity.s934752c9')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-8">{i18n.t('>暂无数据{loading ? <span className=')}</TableCell></TableRow>
|
||||
) : rows.map((r, i) => (
|
||||
<TableRow key={`${r.deployment}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)] text-sm">{r.deployment}</TableCell>
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function ClusterOverviewPage() {
|
||||
const current = list.find((c: JsonData) => (c.code || String(c.id)) === clusterCode);
|
||||
setClusterInfo(current || null);
|
||||
if (!current && list.length > 0 && clusterCode) {
|
||||
toast({ title: i18n.t('kubernetes.clusteroverview.s9ff765c1'), description: `找不到集群 ${clusterCode}`, variant: 'destructive' });
|
||||
toast({ title: i18n.t('集群未找到'), description: `找不到集群 ${clusterCode}`, variant: 'destructive' });
|
||||
}
|
||||
} catch { setClusters([]); }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -85,8 +85,8 @@ export default function ClusterOverviewPage() {
|
||||
return (
|
||||
<PageShell
|
||||
variant="default"
|
||||
title={clusterCode || i18n.t('kubernetes.clusteroverview.s066c0aa3')}
|
||||
subtitle={clusterInfo?.version ? `集群概览 · Kubernetes ${clusterInfo.version}` : i18n.t('kubernetes.clusteroverview.s066c0aa3')}
|
||||
title={clusterCode || i18n.t('集群概览')}
|
||||
subtitle={clusterInfo?.version ? `集群概览 · Kubernetes ${clusterInfo.version}` : i18n.t('集群概览')}
|
||||
icon={<Server className="h-5 w-5" />}
|
||||
metrics={!loading ? (
|
||||
<StatStrip
|
||||
|
||||
@@ -61,7 +61,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
setPods(allPods.filter((p: JsonData) => p.namespace === namespace && p.name.startsWith(deploymentName)));
|
||||
setHpas(allHpas.filter((h: JsonData) => h.target_name === deploymentName && h.namespace === namespace));
|
||||
} catch (e) {
|
||||
console.error(i18n.t('kubernetes.deploymentdetai.sb46ea9c4'), e);
|
||||
console.error(i18n.t('加载详情失败:'), e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
setActionLoading('restart');
|
||||
try {
|
||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s68a70009'), description: i18n.t('kubernetes.deploymentdetai.sd187617a') });
|
||||
toast({ title: i18n.t('重启指令已下发'), description: i18n.t('Deployment 正在滚动重启') });
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
@@ -97,7 +97,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
setActionLoading('image');
|
||||
try {
|
||||
await kubernetesApi.updateDeploymentImage(clusterCode, namespace, deploymentName, newImage);
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s6df3c303'), description: `正在滚动更新为 ${newImage}` });
|
||||
toast({ title: i18n.t('镜像更新成功'), description: `正在滚动更新为 ${newImage}` });
|
||||
setShowImageUpdate(false);
|
||||
loadData();
|
||||
} catch (e) {
|
||||
@@ -115,7 +115,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
if (!ok) return;
|
||||
try {
|
||||
await kubernetesApi.deleteHPA(clusterCode, namespace, hpa.name);
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s0f958f8e') });
|
||||
toast({ title: i18n.t('HPA 已删除') });
|
||||
loadData();
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.msg.deleteFailed2'), description: e?.message || String(e), variant: 'destructive' });
|
||||
|
||||
@@ -82,7 +82,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
// validate
|
||||
for (const c of [...initContainers, ...containers]) {
|
||||
if (!c.name.trim()) {
|
||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: i18n.t('kubernetes.deploymenteditc.s14b12ce3'), variant: 'destructive' });
|
||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: i18n.t('), description: `容器 ${c.name} 的镜像不能为空`, variant: '), variant: 'destructive' });
|
||||
return;
|
||||
}
|
||||
if (!c.image.trim()) {
|
||||
@@ -102,7 +102,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
? imagePullSecrets.filter(s => s.trim()).map((s: string) => ({ name: s }))
|
||||
: undefined;
|
||||
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
||||
toast({ title: i18n.t('kubernetes.deploymenteditc.sdf22b91b'), description: `${deploymentName} 更新已提交` });
|
||||
toast({ title: i18n.t('容器配置已保存'), description: `${deploymentName} 更新已提交` });
|
||||
onSaved(base);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
@@ -152,7 +152,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
{imagePullSecrets.length === 0 && <span className="text-[11px] dg-text-muted">无</span>}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Input placeholder={i18n.t('kubernetes.deploymenteditc.s960f6ac5')} className="dg-input text-xs h-8"
|
||||
<Input placeholder={i18n.t('输入 Secret 名称后回车')} className="dg-input text-xs h-8"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const val = (e.target as HTMLInputElement).value.trim();
|
||||
@@ -170,7 +170,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
{/* 初始化容器 */}
|
||||
<ContainerGroupSection
|
||||
title={i18n.t('kubernetes.container.initContainers')}
|
||||
description={i18n.t('kubernetes.deploymenteditc.s883e09ce')}
|
||||
description={i18n.t('在主容器启动前按顺序执行的容器,用于初始化环境')}
|
||||
icon={<Play className="h-4 w-4 dg-text-purple" />}
|
||||
containers={initContainers}
|
||||
accentColor="purple"
|
||||
@@ -181,8 +181,8 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
|
||||
{/* 工作容器 */}
|
||||
<ContainerGroupSection
|
||||
title={i18n.t('kubernetes.deploymenteditc.sc61b83bd')}
|
||||
description={i18n.t('kubernetes.deploymenteditc.s43eebd4d')}
|
||||
title={i18n.t('初始化容器')}
|
||||
description={i18n.t('在主容器启动前按顺序执行的容器,用于初始化环境')}
|
||||
icon={<Container className="h-4 w-4 dg-text-blue" />}
|
||||
containers={containers}
|
||||
accentColor="blue"
|
||||
|
||||
@@ -172,7 +172,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
try {
|
||||
const yaml = await dumpManifest(svcManifest);
|
||||
await kubernetesApi.applyYAML(clusterCode, yaml);
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.sabd7e004'), description: name });
|
||||
toast({ title: i18n.t('Service 已创建'), description: name });
|
||||
setShowCreate(null);
|
||||
load();
|
||||
} catch (e) {
|
||||
@@ -209,7 +209,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
try {
|
||||
const yaml = await dumpManifest(ingManifest);
|
||||
await kubernetesApi.applyYAML(clusterCode, yaml);
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.se356fbe5'), description: name });
|
||||
toast({ title: i18n.t('Service 已创建'), description: name });
|
||||
setShowCreate(null);
|
||||
load();
|
||||
} catch (e) {
|
||||
@@ -221,7 +221,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
// 删除资源
|
||||
const deleteResource = async (kind: 'service' | 'ingress', name: string) => {
|
||||
const ok = await confirm({
|
||||
title: i18n.t('kubernetes.deploymentedits.s8a2a35a5'),
|
||||
title: i18n.t('删除资源'),
|
||||
description: `确认删除 ${kind === 'service' ? 'Service' : 'Ingress'} 「${name}」?此操作不可撤销。`,
|
||||
confirmText: i18n.t('kubernetes.storage.delete2'),
|
||||
variant: 'destructive',
|
||||
|
||||
@@ -40,12 +40,12 @@ interface Props {
|
||||
}
|
||||
|
||||
const VOLUME_TYPES: { key: VolumeForm['type']; label: string; icon: typeof HardDrive; color: string }[] = [
|
||||
{ key: 'persistentVolumeClaim', label: i18n.t('kubernetes.namespaceresour.s18c90062'), icon: Database, color: 'dg-text-green' },
|
||||
{ key: 'emptyDir', label: i18n.t('kubernetes.deploymentedits.s5449b239'), icon: Disc, color: 'dg-text-secondary' },
|
||||
{ key: 'persistentVolumeClaim', label: i18n.t('存储卷声明'), icon: Database, color: 'dg-text-green' },
|
||||
{ key: 'emptyDir', label: i18n.t('临时目录(EmptyDir)'), icon: Disc, color: 'dg-text-secondary' },
|
||||
{ key: 'hostPath', label: 'HostPath', icon: HardDrive, color: 'dg-text-yellow' },
|
||||
{ key: 'nfs', label: 'NFS', icon: Server, color: 'dg-text-purple' },
|
||||
{ key: 'configMap', label: i18n.t('kubernetes.namespaceovervi.s0986a6e7'), icon: File, color: 'dg-text-blue' },
|
||||
{ key: 'secret', label: i18n.t('kubernetes.deploymentedits.sc099362a'), icon: Lock, color: 'text-rose-400' },
|
||||
{ key: 'configMap', label: i18n.t('配置字典'), icon: File, color: 'dg-text-blue' },
|
||||
{ key: 'secret', label: i18n.t('密文'), icon: Lock, color: 'text-rose-400' },
|
||||
];
|
||||
|
||||
const SELECTABLE_TYPES = new Set(VOLUME_TYPES.map((t) => t.key));
|
||||
@@ -129,20 +129,20 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
const save = async () => {
|
||||
for (const entry of entries) {
|
||||
if (!entry.volume.name.trim()) {
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.s5b59d298'), variant: 'destructive' });
|
||||
toast({ title: i18n.t('请填写数据卷名称'), variant: 'destructive' });
|
||||
return;
|
||||
}
|
||||
if (!formToVolume(entry.volume)) {
|
||||
const hint = entry.volume.type === 'configMap' ? i18n.t('kubernetes.deploymentedits.s2a6856ee')
|
||||
: entry.volume.type === 'secret' ? i18n.t('kubernetes.deploymentedits.s1f31e442')
|
||||
: entry.volume.type === 'persistentVolumeClaim' ? i18n.t('kubernetes.deploymentedits.sba9fc667')
|
||||
: i18n.t('kubernetes.deploymentedits.s03480abb');
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.se542a63b'), description: `请为「${entry.volume.name}」${hint}`, variant: 'destructive' });
|
||||
const hint = entry.volume.type === 'configMap' ? i18n.t('请选择 ConfigMap')
|
||||
: entry.volume.type === 'secret' ? i18n.t('请选择 Secret')
|
||||
: entry.volume.type === 'persistentVolumeClaim' ? i18n.t('请选择 PVC')
|
||||
: i18n.t('的类型必填项');
|
||||
toast({ title: i18n.t('数据卷配置不完整'), description: `请为「${entry.volume.name}」${hint}`, variant: 'destructive' });
|
||||
return;
|
||||
}
|
||||
const validMounts = entry.mounts.filter((m) => m.mountPath.trim());
|
||||
if (validMounts.length === 0) {
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.s24b5b9e3'), description: `数据卷「${entry.volume.name}」需至少挂载到一个容器`, variant: 'destructive' });
|
||||
toast({ title: i18n.t('请填写挂载路径'), description: `数据卷「${entry.volume.name}」需至少挂载到一个容器`, variant: 'destructive' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
const { volumes, mounts } = volumeEntriesToStorage(entries);
|
||||
const base = applyStorageToManifest(rawManifest, volumes, mounts, passthroughVolumes);
|
||||
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
||||
toast({ title: i18n.t('kubernetes.deploymentedits.sa8cd7d90'), description: `${deploymentName} 更新已提交` });
|
||||
toast({ title: i18n.t('存储配置已保存'), description: `${deploymentName} 更新已提交` });
|
||||
onSaved(base);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: (e as Error)?.message || String(e), variant: 'destructive' });
|
||||
@@ -172,7 +172,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
if (!manifest) {
|
||||
return (
|
||||
<Card className="dg-card">
|
||||
<CardContent className="p-8 text-center dg-text-muted"> {i18n.t('kubernetes.deploymentedits.s800b9f0b')} </CardContent>
|
||||
<CardContent className="p-8 text-center dg-text-muted"> {i18n.t('), description: `请为「${entry.volume.name}」${hint}`, variant: ')} </CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
数据卷
|
||||
<Badge variant="outline" className="border-[var(--dg-border)] dg-text-secondary">{entries.length}</Badge>
|
||||
</CardTitle>
|
||||
<p className="text-[11px] dg-text-muted mt-1"> {i18n.t('kubernetes.deploymentedits.s1e0b322c')} </p>
|
||||
<p className="text-[11px] dg-text-muted mt-1"> {i18n.t('), description: `请为「${entry.volume.name}」${hint}`, variant: ')} </p>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" className="h-7 border-[var(--dg-border)] text-[var(--dg-text-secondary)] text-xs shrink-0" onClick={addEntry}>
|
||||
<Plus className="h-3 w-3 mr-1" />添加数据卷
|
||||
@@ -234,7 +234,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
if (vol.type === 'persistentVolumeClaim' && !vol.pvcName) patch.pvcName = name;
|
||||
updateVolume(i, patch);
|
||||
}}
|
||||
placeholder={i18n.t('kubernetes.deploymentedits.s478bfaef')}
|
||||
placeholder={i18n.t('如 app-logs / fluent-bit-config')}
|
||||
className="h-8 w-44 dg-input text-sm font-mono"
|
||||
/>
|
||||
{/* 原生 select,避免 Radix Select 在 overflow 容器内无法下拉 // Logan.Li */}
|
||||
@@ -312,7 +312,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
<Input
|
||||
value={mount.mountPath}
|
||||
onChange={(e) => updateMount(i, mi, { mountPath: e.target.value })}
|
||||
placeholder={i18n.t('kubernetes.deploymentedits.seb88e484')}
|
||||
placeholder={i18n.t('挂载路径 /bitcloud/app/.../logs')}
|
||||
className="h-8 flex-1 min-w-[200px] dg-input text-sm font-mono"
|
||||
/>
|
||||
{entry.mounts.length > 1 && (
|
||||
@@ -326,7 +326,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
<Input
|
||||
value={mount.subPath}
|
||||
onChange={(e) => updateMount(i, mi, { subPath: e.target.value })}
|
||||
placeholder={i18n.t('kubernetes.deploymentedits.s68ab2e24')}
|
||||
placeholder={i18n.t('挂载路径 /bitcloud/app/.../logs')}
|
||||
className="h-7 flex-1 max-w-md dg-input text-[var(--dg-text-secondary)] text-xs font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -139,7 +139,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
const handleRollback = async (rev: JsonData) => {
|
||||
const revision = rev.revision ?? rev.revision_number ?? rev.number;
|
||||
const ok = await confirm({
|
||||
title: i18n.t('kubernetes.deploymentviewt.s6a374e98'),
|
||||
title: i18n.t('回滚版本'),
|
||||
description: `确认回滚到修订版本 #${revision}?`,
|
||||
confirmText: i18n.t('pipeline.rollback'),
|
||||
variant: 'destructive',
|
||||
@@ -148,7 +148,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
setRollbackLoading(revision);
|
||||
try {
|
||||
await kubernetesApi.rollbackDeployment(clusterCode, namespace, deployment.name, Number(revision));
|
||||
toast({ title: i18n.t('kubernetes.deploymentviewt.s754d92e1'), description: `正在回滚到 #${revision}` });
|
||||
toast({ title: i18n.t('回滚已下发'), description: `正在回滚到 #${revision}` });
|
||||
onRefresh();
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('pipeline.rollbackFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
@@ -160,7 +160,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
setScaleLoading(true);
|
||||
try {
|
||||
await kubernetesApi.scaleDeployment(clusterCode, namespace, deployment.name, scaleValue);
|
||||
toast({ title: i18n.t('kubernetes.deploymentviewt.sb9c9e03e'), description: `副本数 → ${scaleValue}` });
|
||||
toast({ title: i18n.t('伸缩已提交'), description: `副本数 → ${scaleValue}` });
|
||||
onRefresh();
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.msg.scaleFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
@@ -168,10 +168,10 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
};
|
||||
|
||||
const TABS = [
|
||||
{ key: 'pods', label: i18n.t('kubernetes.deploymentviewt.s479692cc'), icon: Container, count: pods.length },
|
||||
{ key: 'services', label: i18n.t('kubernetes.deploymentviewt.s7068046e'), icon: Network, count: services.length },
|
||||
{ key: 'pods', label: i18n.t('容器组'), icon: Container, count: pods.length },
|
||||
{ key: 'services', label: i18n.t('访问方式'), icon: Network, count: services.length },
|
||||
{ key: 'events', label: i18n.t('kubernetes.event.title'), icon: Activity, count: events.length },
|
||||
{ key: 'scale', label: i18n.t('kubernetes.deploymentviewt.s3b291d31'), icon: Plus },
|
||||
{ key: 'scale', label: i18n.t('容器伸缩'), icon: Plus },
|
||||
{ key: 'history', label: i18n.t('kubernetes.deployment.revisions'), icon: History, count: revisions.length },
|
||||
];
|
||||
|
||||
@@ -186,8 +186,8 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
{isHealthy ? 'Running' : 'Updating'}
|
||||
</Badge>
|
||||
} />
|
||||
<InfoItem label={i18n.t('kubernetes.capacitypagetsx.s0428b36a')} value={<span className="font-mono">{ready}/{total}</span>} />
|
||||
<InfoItem label={i18n.t('kubernetes.deploymentviewt.s66914536')} value={deployment?.strategy || 'RollingUpdate'} />
|
||||
<InfoItem label={i18n.t('状态')} value={<span className="font-mono">{ready}/{total}</span>} />
|
||||
<InfoItem label={i18n.t('状态')} value={deployment?.strategy || 'RollingUpdate'} />
|
||||
{pods[0] && (
|
||||
<>
|
||||
<InfoItem label={i18n.t('kubernetes.pod.nodeName')} value={
|
||||
|
||||
@@ -118,7 +118,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
|
||||
setRevisions(toArray(revRes));
|
||||
} catch (e) {
|
||||
console.error(i18n.t('kubernetes.deploymentdetai.sb46ea9c4'), e);
|
||||
console.error(i18n.t('加载详情失败:'), e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
const { manifest: parsed } = await parseEditableManifest(yamlText);
|
||||
setManifest(parsed || deployment);
|
||||
} catch (e) {
|
||||
console.warn(i18n.t('kubernetes.deploymentworkl.sce123fbd'), e);
|
||||
console.warn(i18n.t('加载 manifest 失败(编辑功能降级):'), e);
|
||||
setManifest(deployment);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -191,7 +191,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
setActionLoading('restart');
|
||||
try {
|
||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s68a70009'), description: i18n.t('kubernetes.deploymentdetai.sd187617a') });
|
||||
toast({ title: i18n.t('重启指令已下发'), description: i18n.t('Deployment 正在滚动重启') });
|
||||
setTimeout(loadData, 1500);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
@@ -234,7 +234,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
await kubernetesApi.updateDeploymentImage(
|
||||
clusterCode, namespace, deploymentName, newImage, cicdContainerName || undefined,
|
||||
);
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s6df3c303'), description: i18n.t('k8s.deploymentDetail.rollingUpdateImage', { image: newImage }) });
|
||||
toast({ title: i18n.t('扩缩容成功'), description: i18n.t('k8s.deploymentDetail.rollingUpdateImage', { image: newImage }) });
|
||||
setModal(null);
|
||||
loadData();
|
||||
} catch (e) {
|
||||
@@ -288,7 +288,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
// ============ 渲染 // Logan.Li ============
|
||||
if (loading) {
|
||||
return (
|
||||
<PageShell variant="workspace" title={deploymentName} subtitle={`${clusterCode} / ${namespace}`} loading loadingLabel={i18n.t('kubernetes.deploymentworkl.seb300b29')} actions={<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={onBack}><ArrowLeft className="h-4 w-4 mr-1" /> {i18n.t('common.back')} </Button>}>
|
||||
<PageShell variant="workspace" title={deploymentName} subtitle={`${clusterCode} / ${namespace}`} loading loadingLabel={i18n.t('加载 Deployment...')} actions={<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={onBack}><ArrowLeft className="h-4 w-4 mr-1" /> {i18n.t('common.back')} </Button>}>
|
||||
{null}
|
||||
</PageShell>
|
||||
);
|
||||
@@ -308,7 +308,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
if (name) navigate(`/kubernetes/${clusterCode}/namespace/${namespace}/workload/view/Deployment/${name}`);
|
||||
};
|
||||
return (
|
||||
<PageShell variant="workspace" title={i18n.t('kubernetes.deploymentworkl.se2c85a21')} subtitle={`${clusterCode} / ${namespace}`} actions={<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={onBack}><ArrowLeft className="h-4 w-4 mr-1" /> {i18n.t('common.back')} </Button>}>
|
||||
<PageShell variant="workspace" title={i18n.t('新建 Deployment')} subtitle={`${clusterCode} / ${namespace}`} actions={<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={onBack}><ArrowLeft className="h-4 w-4 mr-1" /> {i18n.t('common.back')} </Button>}>
|
||||
<EditModeContainer clusterCode={clusterCode} namespace={namespace} deploymentName={CREATE_DEPLOYMENT_SLUG} manifest={manifest} isCreate onSaved={handleCreated} onCancel={onBack} />
|
||||
</PageShell>
|
||||
);
|
||||
@@ -379,7 +379,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
resource="deployments"
|
||||
name={deploymentName}
|
||||
inline
|
||||
resourceHint={i18n.t('kubernetes.deploymentworkl.s239604b0')}
|
||||
resourceHint={i18n.t('含关联 Service')}
|
||||
loadYamlFn={loadBundleYaml}
|
||||
saveYamlFn={saveBundleYaml}
|
||||
onSaved={loadData}
|
||||
@@ -404,7 +404,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
namespace={namespace}
|
||||
resource="deployments"
|
||||
name={deploymentName}
|
||||
resourceHint={i18n.t('kubernetes.deploymentworkl.s239604b0')}
|
||||
resourceHint={i18n.t('含关联 Service')}
|
||||
loadYamlFn={loadBundleYaml}
|
||||
saveYamlFn={saveBundleYaml}
|
||||
onClose={() => setModal(null)}
|
||||
|
||||
@@ -179,16 +179,16 @@ export default function EventsPage() {
|
||||
return (
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('kubernetes.eventspagetsx.s08bf79b4')}
|
||||
subtitle={clusterName ? `${clusterName} · 集群事件与告警` : i18n.t('kubernetes.eventspagetsx.s6bef2ba0')}
|
||||
title={i18n.t('事件中心')}
|
||||
subtitle={clusterName ? `${clusterName} · 集群事件与告警` : i18n.t('集群事件与告警')}
|
||||
icon={<Bell className="h-5 w-5" />}
|
||||
metrics={!loading ? (
|
||||
<StatStrip
|
||||
items={[
|
||||
{ label: i18n.t('kubernetes.eventspagetsx.s0d3047da'), value: summary?.total ?? events.length, color: 'muted' },
|
||||
{ label: i18n.t('kubernetes.eventspagetsx.s0e5b83cc'), value: summary?.warning_count ?? warningCount, color: 'amber' },
|
||||
{ label: i18n.t('kubernetes.eventspagetsx.s349c629f'), value: summary?.normal_count ?? normalCount, color: 'green' },
|
||||
{ label: i18n.t('kubernetes.eventspagetsx.sc62e34c5'), value: reasonData.length, color: 'red' },
|
||||
{ label: i18n.t('正常事件'), value: summary?.total ?? events.length, color: 'muted' },
|
||||
{ label: i18n.t('告警事件'), value: summary?.warning_count ?? warningCount, color: 'amber' },
|
||||
{ label: i18n.t('正常事件'), value: summary?.normal_count ?? normalCount, color: 'green' },
|
||||
{ label: i18n.t('告警类型'), value: reasonData.length, color: 'red' },
|
||||
]}
|
||||
/>
|
||||
) : undefined}
|
||||
@@ -229,10 +229,10 @@ export default function EventsPage() {
|
||||
>
|
||||
{reasonData.length > 0 && (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
<RankPanel title={i18n.t('kubernetes.eventspagetsx.s8c894faa')} items={reasonData} selected={selectedReason} onSelect={setSelectedReason} />
|
||||
<RankPanel title={i18n.t('资源类型')} items={reasonData} selected={selectedReason} onSelect={setSelectedReason} />
|
||||
{nsData.length > 0 && <RankPanel title={i18n.t('kubernetes.namespace.title')} items={nsData} />}
|
||||
{kindData.length > 0 && (
|
||||
<RankPanel title={i18n.t('kubernetes.eventspagetsx.s14871aad')} items={kindData} selected={selectedKind} onSelect={setSelectedKind} />
|
||||
<RankPanel title={i18n.t('告警原因')} items={kindData} selected={selectedKind} onSelect={setSelectedKind} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -89,7 +89,7 @@ export function KubernetesClusterDialog({
|
||||
if (!value.trim()) {
|
||||
setNameError('');
|
||||
} else if (!NAME_RE.test(value)) {
|
||||
setNameError(i18n.t('kubernetes.kubernetesclust.sc7ec6c52'));
|
||||
setNameError(i18n.t('只允许英文、数字和连字符(-),首尾不能是连字符'));
|
||||
} else {
|
||||
setNameError('');
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export function KubernetesClusterDialog({
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.name.trim() || !NAME_RE.test(formData.name.trim())) {
|
||||
toast.error(i18n.t('kubernetes.kubernetesclust.s38bbfe92')); return;
|
||||
toast.error(i18n.t('请输入有效的集群名称(英文/数字/连字符)')); return;
|
||||
}
|
||||
try {
|
||||
setSubmitting(true);
|
||||
@@ -133,7 +133,7 @@ export function KubernetesClusterDialog({
|
||||
onOpenChange(false);
|
||||
onSaved();
|
||||
} catch (e) {
|
||||
console.error(i18n.t('kubernetes.kubernetesclust.s7aa44ba2'), e);
|
||||
console.error(i18n.t('保存集群失败:'), e);
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export function KubernetesClusterDialog({
|
||||
{editingCluster ? i18n.t('kubernetes.cluster.editCluster') : i18n.t('kubernetes.cluster.addCluster')}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="text-[var(--dg-text-secondary)]">
|
||||
{editingCluster ? i18n.t('kubernetes.kubernetesclust.s2d42f245') : i18n.t('kubernetes.kubernetesclust.sfe6c791d')}
|
||||
{editingCluster ? i18n.t('编辑集群') : i18n.t('添加集群')}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-2 max-h-[60vh] overflow-y-auto pr-1">
|
||||
@@ -159,7 +159,7 @@ export function KubernetesClusterDialog({
|
||||
<Input
|
||||
value={formData.name}
|
||||
onChange={(e) => handleNameChange(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.kubernetesclust.s298c8665')}
|
||||
placeholder={i18n.t('如: prod-cluster')}
|
||||
className={`bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] ${nameError ? 'border-red-500' : ''}`}
|
||||
/>
|
||||
{nameError && <p className="text-xs dg-text-red">{nameError}</p>}
|
||||
@@ -172,7 +172,7 @@ export function KubernetesClusterDialog({
|
||||
<Input
|
||||
value={formData.version}
|
||||
onChange={(e) => setFormData({ ...formData, version: e.target.value })}
|
||||
placeholder={i18n.t('kubernetes.kubernetesclust.s90a9ef87')}
|
||||
placeholder={i18n.t('如: prod-cluster')}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"
|
||||
/>
|
||||
</div>
|
||||
@@ -183,7 +183,7 @@ export function KubernetesClusterDialog({
|
||||
<Input
|
||||
value={formData.description}
|
||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
||||
placeholder={i18n.t('kubernetes.kubernetesclust.s33a940a9')}
|
||||
placeholder={i18n.t('集群用途描述')}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"
|
||||
/>
|
||||
</div>
|
||||
@@ -224,7 +224,7 @@ export function KubernetesClusterDialog({
|
||||
<Textarea
|
||||
value={formData.token}
|
||||
onChange={(e) => setFormData({ ...formData, token: e.target.value })}
|
||||
placeholder={hasToken ? i18n.t('kubernetes.kubernetesclust.sf26ca548') : i18n.t('kubernetes.kubernetesclust.s1050083d')}
|
||||
placeholder={hasToken ? i18n.t('已配置,输入新值覆盖...') : i18n.t('粘贴 Service Account Token...')}
|
||||
rows={4}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"
|
||||
/>
|
||||
@@ -237,7 +237,7 @@ export function KubernetesClusterDialog({
|
||||
<Textarea
|
||||
value={formData.kube_config}
|
||||
onChange={(e) => handleKubeConfigChange(e.target.value)}
|
||||
placeholder={hasKubeConfig ? i18n.t('kubernetes.kubernetesclust.sf26ca548') : 'apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n server: https://10.0.0.1:6443\n ...'}
|
||||
placeholder={hasKubeConfig ? i18n.t('已配置,输入新值覆盖...') : 'apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n server: https://10.0.0.1:6443\n ...'}
|
||||
rows={10}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"
|
||||
/>
|
||||
|
||||
@@ -72,7 +72,7 @@ export function KubernetesNodes() {
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all"> {i18n.t('kubernetes.kubernetesnodes.s5bcc10f8')} </SelectItem>
|
||||
<SelectItem value="all"> {i18n.t('选择集群')} </SelectItem>
|
||||
<SelectItem value="master">Master</SelectItem>
|
||||
<SelectItem value="worker">Worker</SelectItem>
|
||||
</SelectContent>
|
||||
@@ -86,7 +86,7 @@ export function KubernetesNodes() {
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('menu.nodeManagement')}
|
||||
subtitle={clusterLabel ? `${clusterLabel} · 工作节点状态与资源` : i18n.t('kubernetes.kubernetesnodes.s01b441ea')}
|
||||
subtitle={clusterLabel ? `${clusterLabel} · 工作节点状态与资源` : i18n.t('Kubernetes 集群工作节点状态与资源')}
|
||||
icon={<Server className="h-5 w-5" />}
|
||||
actions={(
|
||||
<>
|
||||
@@ -125,7 +125,7 @@ export function KubernetesNodes() {
|
||||
{loading ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center text-[var(--dg-text-muted)] py-12"><Loader2 className="h-5 w-5 animate-spin mx-auto mb-2" /> {i18n.t('monitor.logPanel.logResults.loading')} </TableCell></TableRow>
|
||||
) : filtered.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center text-[var(--dg-text-muted)] py-12"><Server className="h-8 w-8 mx-auto mb-2 opacity-50" />{selectedCluster ? i18n.t('k8s.empty.nodes') : i18n.t('kubernetes.kubernetesnodes.sf8c38834')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={8} className="text-center text-[var(--dg-text-muted)] py-12"><Server className="h-8 w-8 mx-auto mb-2 opacity-50" />{selectedCluster ? i18n.t('k8s.empty.nodes') : i18n.t('暂无节点数据')}</TableCell></TableRow>
|
||||
) : (
|
||||
filtered.map((n) => (
|
||||
<TableRow key={n.id} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function NamespaceManagementPage() {
|
||||
<Input
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.namespacemanage.se91247a0')}
|
||||
placeholder={i18n.t('搜索命名空间...')}
|
||||
className="max-w-xs dg-input"
|
||||
/>
|
||||
);
|
||||
@@ -120,7 +120,7 @@ export default function NamespaceManagementPage() {
|
||||
return (
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('kubernetes.namespacemanage.se935a33d')}
|
||||
title={i18n.t('命名空间管理')}
|
||||
subtitle={`${clusterCode} · 资源配额与生命周期管理`}
|
||||
icon={<Boxes className="h-5 w-5" />}
|
||||
metrics={!loading ? (
|
||||
@@ -130,7 +130,7 @@ export default function NamespaceManagementPage() {
|
||||
{ label: 'Deployments', value: totalDeploys, color: 'blue' },
|
||||
{ label: 'Pods', value: totalPods, color: 'purple' },
|
||||
{ label: 'Services', value: totalSvcs, color: 'cyan' },
|
||||
{ label: i18n.t('kubernetes.namespacemanage.s47c3aee9'), value: quotaCount, color: 'amber' },
|
||||
{ label: i18n.t('配额限制'), value: quotaCount, color: 'amber' },
|
||||
]}
|
||||
/>
|
||||
) : undefined}
|
||||
@@ -148,7 +148,7 @@ export default function NamespaceManagementPage() {
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle> {i18n.t('kubernetes.namespacemanage.s737f41e9')} </DialogTitle>
|
||||
<DialogTitle> {i18n.t('例如: my-app')} </DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4">
|
||||
<div className="space-y-2">
|
||||
@@ -156,7 +156,7 @@ export default function NamespaceManagementPage() {
|
||||
<Input
|
||||
value={newName}
|
||||
onChange={(e) => setNewName(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.namespacemanage.scba00862')}
|
||||
placeholder={i18n.t('例如: my-app')}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleCreate()}
|
||||
/>
|
||||
<p className="text-xs text-[var(--dg-text-muted)]">
|
||||
|
||||
@@ -19,14 +19,14 @@ import type { JsonData } from '@/types/common';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const RESOURCE_LINKS = [
|
||||
{ type: 'deployments', label: 'Deployments', icon: Boxes, desc: i18n.t('kubernetes.namespaceovervi.sb68c634e') },
|
||||
{ type: 'pods', label: 'Pods', icon: Container, desc: i18n.t('kubernetes.namespaceovervi.sfdac258b') },
|
||||
{ type: 'cronjobs', label: 'CronJobs', icon: Clock, desc: i18n.t('kubernetes.namespaceovervi.s9c9fc523') },
|
||||
{ type: 'services', label: 'Services', icon: Network, desc: i18n.t('kubernetes.namespaceovervi.s3a3f6d6c') },
|
||||
{ type: 'ingresses', label: 'Ingresses', icon: Network, desc: i18n.t('kubernetes.namespaceovervi.scc6971c7') },
|
||||
{ type: 'configmaps', label: 'ConfigMaps', icon: FileText, desc: i18n.t('kubernetes.namespaceovervi.s0986a6e7') },
|
||||
{ type: 'secrets', label: 'Secrets', icon: Shield, desc: i18n.t('kubernetes.namespaceovervi.sb3fb72cd') },
|
||||
{ type: 'hpas', label: 'HPAs', icon: Activity, desc: i18n.t('kubernetes.namespaceovervi.sa84da2c5') },
|
||||
{ type: 'deployments', label: 'Deployments', icon: Boxes, desc: i18n.t('工作负载副本管理') },
|
||||
{ type: 'pods', label: 'Pods', icon: Container, desc: i18n.t('容器实例运行状态') },
|
||||
{ type: 'cronjobs', label: 'CronJobs', icon: Clock, desc: i18n.t('定时任务管理') },
|
||||
{ type: 'services', label: 'Services', icon: Network, desc: i18n.t('服务发现与负载均衡') },
|
||||
{ type: 'ingresses', label: 'Ingresses', icon: Network, desc: i18n.t('外部流量路由规则') },
|
||||
{ type: 'configmaps', label: 'ConfigMaps', icon: FileText, desc: i18n.t('配置字典') },
|
||||
{ type: 'secrets', label: 'Secrets', icon: Shield, desc: i18n.t('密钥与凭证') },
|
||||
{ type: 'hpas', label: 'HPAs', icon: Activity, desc: i18n.t('水平自动伸缩策略') },
|
||||
];
|
||||
|
||||
export default function NamespaceOverviewPage() {
|
||||
@@ -71,7 +71,7 @@ export default function NamespaceOverviewPage() {
|
||||
subtitle={`${clusterCode} · 命名空间概览`}
|
||||
icon={<Cloud className="h-5 w-5" />}
|
||||
loading={loading}
|
||||
loadingLabel={i18n.t('kubernetes.namespaceovervi.sfa525ae0')}
|
||||
loadingLabel={i18n.t('加载资源统计...')}
|
||||
>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
{RESOURCE_LINKS.map((r) => (
|
||||
|
||||
@@ -204,16 +204,16 @@ export default function NamespaceResourcePage() {
|
||||
</Button>
|
||||
{BULK_EXPORT_TYPES.includes(type) && (
|
||||
<>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportCSV} title={i18n.t('kubernetes.namespaceresour.sef28d57c')}>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportCSV} title={i18n.t('导出CSV')}>
|
||||
<Download className="h-3 w-3 mr-1" />CSV
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportJSON} title={i18n.t('kubernetes.namespaceresour.se11b48c7')}>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportJSON} title={i18n.t('导出JSON')}>
|
||||
<Download className="h-3 w-3 mr-1" />JSON
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{EXPORT_YAML_TYPES.includes(type) && (
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportYaml} title={i18n.t('kubernetes.namespaceresour.s2f89924c')}>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary text-xs" onClick={handleExportYaml} title={i18n.t('导出命名空间 YAML(tar.gz)')}>
|
||||
<Download className="h-3 w-3 mr-1" />导出YAML
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -151,7 +151,7 @@ export function PodExecTerminal({
|
||||
console.error('[PodExec:connect] WS error event fired, readyState=', ws.readyState, 'type=', ev.type);
|
||||
setConnState('error');
|
||||
setHasOutput(true);
|
||||
term.write(i18n.t('k8s.podExec.sc8107726'));
|
||||
term.write(i18n.t('\\r\\n\\x1b[31m[连接发生错误]\\x1b[0m\\r\\n'));
|
||||
};
|
||||
}, [clusterId, namespace, podName, container, shell]);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ export function PodFileBrowser({
|
||||
setEntries(list);
|
||||
setCurrentPath(path);
|
||||
} catch (e) {
|
||||
setError((e as JsonData).message || i18n.t('kubernetes.podfilebrowsert.s78d4a7c6'));
|
||||
setError((e as JsonData).message || i18n.t('加载文件列表失败'));
|
||||
setEntries([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -183,11 +183,11 @@ export function PodLogsViewer({
|
||||
}
|
||||
}
|
||||
flush();
|
||||
appendLines([i18n.t('kubernetes.podlogsviewerts.s4f0e17cd')]);
|
||||
appendLines([i18n.t('\\x1b[33m— 流式结束 —\\x1b[0m')]);
|
||||
} catch (e) {
|
||||
const errName = (e as { name?: string })?.name;
|
||||
if (errName === 'AbortError') {
|
||||
appendLines([i18n.t('kubernetes.podlogsviewerts.s1ca9010d')]);
|
||||
appendLines([i18n.t('\\x1b[33m— 已停止 —\\x1b[0m')]);
|
||||
} else {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
appendLines([`\x1b[31m[流式连接中断: ${msg}]\x1b[0m`]);
|
||||
|
||||
@@ -93,7 +93,7 @@ export default function PodMetricsPage() {
|
||||
metrics={!loading ? (
|
||||
<StatStrip
|
||||
items={[
|
||||
{ label: i18n.t('k8s.podMetrics.sa2e8040e'), value: metrics.length, color: 'muted' },
|
||||
{ label: i18n.t('Pod 数'), value: metrics.length, color: 'muted' },
|
||||
{ label: i18n.t('k8s.podMetrics.cpu'), value: `${totalCPU}m`, color: 'blue' },
|
||||
{ label: i18n.t('k8s.podMetrics.memory'), value: `${totalMem.toFixed(0)}Mi`, color: 'green' },
|
||||
]}
|
||||
@@ -132,7 +132,7 @@ export default function PodMetricsPage() {
|
||||
</TableRow></TableHeader>
|
||||
<TableBody>
|
||||
{rows.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-8">{i18n.t('k8s.podMetrics.s934752c9')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-8">{i18n.t('>暂无数据{loading ? <span className=')}</TableCell></TableRow>
|
||||
) : rows.map((r, i) => (
|
||||
<TableRow key={`${r.pod}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)] text-sm">{r.pod}</TableCell>
|
||||
|
||||
@@ -68,7 +68,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
setManifest(parsed);
|
||||
if (!parsed) {
|
||||
setMode('yaml');
|
||||
toast({ title: i18n.t('kubernetes.resourcevisuale.s80ca4f8e'), description: i18n.t('kubernetes.resourcevisuale.scc94aa41') });
|
||||
toast({ title: i18n.t('可视化编辑不可用'), description: i18n.t('无法解析资源结构,已切换到 YAML 编辑模式') });
|
||||
}
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.msg.loadFailed'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
||||
@@ -107,7 +107,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
const yamlStr = await prepareYamlForSave(editYaml);
|
||||
if (isCreate) {
|
||||
await kubernetesApi.applyYAML(clusterCode, yamlStr);
|
||||
toast({ title: i18n.t('monitor.dashboard.custom.toastCreateSuccess'), description: i18n.t('kubernetes.resourcevisuale.se5ff4ba7') });
|
||||
toast({ title: i18n.t('monitor.dashboard.custom.toastCreateSuccess'), description: i18n.t('保存失败') });
|
||||
} else {
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
|
||||
toast({ title: i18n.t('kubernetes.msg.saveSuccess'), description: `${resource}/${name} 已更新` });
|
||||
@@ -127,7 +127,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
const switchToVisual = async () => {
|
||||
const parsed = await parseManifest(editYaml);
|
||||
if (!parsed) {
|
||||
toast({ title: i18n.t('kubernetes.resourcevisuale.sf53bdf65'), description: i18n.t('kubernetes.resourcevisuale.sf2219a47'), variant: 'destructive' });
|
||||
toast({ title: i18n.t('无法解析 YAML'), description: i18n.t('请检查语法后继续用 YAML 模式'), variant: 'destructive' });
|
||||
return;
|
||||
}
|
||||
setManifest(parsed);
|
||||
@@ -156,7 +156,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
const downloadYamlContent = () => {
|
||||
const fname = yamlDownloadFilename(resource, namespace, name || manifest?.metadata?.name || 'resource');
|
||||
downloadYamlFile(fname, currentYamlText());
|
||||
toast({ title: i18n.t('kubernetes.yamlviewertsx.s9719fec8'), description: fname });
|
||||
toast({ title: i18n.t('已下载'), description: fname });
|
||||
};
|
||||
|
||||
const resCfg = getYamlResourceConfig(resource);
|
||||
@@ -262,7 +262,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
{!['configmaps', 'secrets', 'services', 'ingresses', 'pvcs'].includes(resource) && (
|
||||
<div className="flex-1 flex items-center justify-center text-center text-[var(--dg-text-muted)]">
|
||||
<div>
|
||||
<p> {i18n.t('kubernetes.resourcevisuale.sfeb34f55')} </p>
|
||||
<p> {i18n.t('域名 (如 api.example.com)')} </p>
|
||||
<Button variant="outline" size="sm" className="mt-4" onClick={() => setMode('yaml')}> {i18n.t('kubernetes.resourcevisuale.s54c78d4f')} </Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -270,7 +270,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-12 text-[var(--dg-text-muted)]">
|
||||
<p> {i18n.t('kubernetes.resourcevisuale.s8fe0aeb0')} </p>
|
||||
<p> {i18n.t('键名 (如 LOG_LEVEL)')} </p>
|
||||
<Button variant="outline" size="sm" className="mt-4" onClick={() => setMode('yaml')}> {i18n.t('kubernetes.resourcevisuale.s54c78d4f')} </Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -107,7 +107,7 @@ export default function WorkloadViewPage() {
|
||||
} else {
|
||||
await kubernetesApi.restartDaemonSet(clusterCode, namespace, name);
|
||||
}
|
||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s68a70009'), description: `${kind} 滚动重启已触发` });
|
||||
toast({ title: i18n.t('重启指令已下发'), description: `${kind} 滚动重启已触发` });
|
||||
setTimeout(loadData, 1000);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
||||
@@ -122,7 +122,7 @@ export default function WorkloadViewPage() {
|
||||
setScaleModal(false);
|
||||
setTimeout(loadData, 1000);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.workloadviewpag.s0b329fa8'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
||||
toast({ title: i18n.t('重启失败'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(false); }
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ export default function WorkloadViewPage() {
|
||||
subtitle={`${clusterCode} / ${namespace} · ${kind}`}
|
||||
icon={<Boxes className="h-5 w-5" />}
|
||||
loading={loading}
|
||||
loadingLabel={i18n.t('kubernetes.workloadviewpag.s4eb429cb')}
|
||||
loadingLabel={i18n.t('加载工作负载...')}
|
||||
actions={(
|
||||
<>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => navigate(-1)}>
|
||||
@@ -162,7 +162,7 @@ export default function WorkloadViewPage() {
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary" disabled={actionLoading} onClick={handleRestart}>
|
||||
<RotateCcw className="h-3.5 w-3.5 mr-1" />{actionLoading ? i18n.t('kubernetes.workloadviewpag.s9ac1042c') : i18n.t('agent.agentServiceRestart')}
|
||||
<RotateCcw className="h-3.5 w-3.5 mr-1" />{actionLoading ? i18n.t('重启中...') : i18n.t('agent.agentServiceRestart')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => setYamlModal(true)}>
|
||||
<FileCode className="h-3.5 w-3.5 mr-1" />YAML
|
||||
@@ -201,14 +201,14 @@ export default function WorkloadViewPage() {
|
||||
<StatCard label={i18n.t('kubernetes.workloadviewpag.sea639697')} value={`${readyReplicas}/${replicas}`} color={isHealthy ? STATUS_COLORS.green : STATUS_COLORS.orange} sub={isHealthy ? i18n.t('kubernetes.workloadviewpag.s23c944c1') : i18n.t('kubernetes.workloadviewpag.sac100213')} />
|
||||
<StatCard label={i18n.t('kubernetes.hpa.currentReplicas')} value={currentReplicas} color={STATUS_COLORS.blue} />
|
||||
<StatCard label={i18n.t('kubernetes.deployment.updatedReplicas')} value={updatedReplicas} color={STATUS_COLORS.green} />
|
||||
<StatCard label={i18n.t('kubernetes.workloadviewpag.sf592ef2f')} value={stats.spec.serviceName || '-'} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('kubernetes.nodedetailpaget.s55edf286')} value={pods.length} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('当前副本')} value={stats.spec.serviceName || '-'} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('当前副本')} value={pods.length} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('system.userCreatedAt')} value={<span className="text-xs">{formatK8sTime(manifest?.metadata?.creationTimestamp)}</span>} color="var(--dg-text-secondary)" />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<StatCard label={i18n.t('kubernetes.workloadviewpag.sd78bc83e')} value={desiredScheduled} color={STATUS_COLORS.blue} />
|
||||
<StatCard label={i18n.t('kubernetes.workloadviewpag.sb7616465')} value={currentScheduled} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('期望调度')} value={desiredScheduled} color={STATUS_COLORS.blue} />
|
||||
<StatCard label={i18n.t('当前调度')} value={currentScheduled} color="var(--dg-text-secondary)" />
|
||||
<StatCard label={i18n.t('kubernetes.daemonset.numberReady')} value={numberReady} color={isHealthy ? STATUS_COLORS.green : STATUS_COLORS.orange} />
|
||||
<StatCard label={i18n.t('kubernetes.daemonset.numberAvailable')} value={numberAvailable} color={STATUS_COLORS.green} />
|
||||
<StatCard label={i18n.t('deploy.toast.updated')} value={numberUpdated} color="var(--dg-text-secondary)" />
|
||||
|
||||
@@ -74,7 +74,7 @@ export function YamlViewer({
|
||||
setRawYaml(text);
|
||||
await applyStripped(text);
|
||||
} catch (e) {
|
||||
toast({ title: i18n.t('kubernetes.yamlviewertsx.s1a72e368'), description: (e as JsonData).message, variant: 'destructive' });
|
||||
toast({ title: i18n.t('获取YAML失败'), description: (e as JsonData).message, variant: 'destructive' });
|
||||
const err = `# Error: ${(e as Error).message}`;
|
||||
setRawYaml(err);
|
||||
setDisplayYaml(err);
|
||||
@@ -104,7 +104,7 @@ export function YamlViewer({
|
||||
} else {
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
|
||||
}
|
||||
toast({ title: i18n.t('kubernetes.msg.saveSuccess'), description: saveYamlFn ? i18n.t('kubernetes.yamlviewertsx.s68f258c4') : `${resource}/${name} 已更新` });
|
||||
toast({ title: i18n.t('kubernetes.msg.saveSuccess'), description: saveYamlFn ? i18n.t('保存失败') : `${resource}/${name} 已更新` });
|
||||
setEditing(false);
|
||||
setRawYaml(yamlStr);
|
||||
setDisplayYaml(yamlStr);
|
||||
@@ -125,7 +125,7 @@ export function YamlViewer({
|
||||
|
||||
const downloadYaml = () => {
|
||||
downloadYamlFile(yamlDownloadFilename(resource, namespace, name), currentYaml());
|
||||
toast({ title: i18n.t('kubernetes.yamlviewertsx.s9719fec8'), description: yamlDownloadFilename(resource, namespace, name) });
|
||||
toast({ title: i18n.t('已下载'), description: yamlDownloadFilename(resource, namespace, name) });
|
||||
};
|
||||
|
||||
const display = editing ? editYaml : (showRaw ? rawYaml : displayYaml);
|
||||
|
||||
@@ -86,7 +86,7 @@ export async function saveDeploymentBundleYaml(
|
||||
for (const manifest of manifests) {
|
||||
const kind = String(manifest.kind || '').toLowerCase();
|
||||
const name = String(manifest.metadata?.name || '').trim();
|
||||
if (!kind || !name) throw new Error(i18n.t('kubernetes.deploymentbundl.s659c1bb5'));
|
||||
if (!kind || !name) throw new Error(i18n.t('每个 YAML 文档必须包含 kind 和 metadata.name'));
|
||||
|
||||
const docYaml = await prepareManifestForSave(manifest);
|
||||
if (kind === 'deployment') {
|
||||
|
||||
@@ -108,7 +108,7 @@ export function CreateHPADialog({ clusterCode, namespace, deploymentName, onCrea
|
||||
<div className="flex justify-end gap-2 px-6 py-4 border-t border-[var(--dg-border)] shrink-0">
|
||||
<Button variant="outline" className="border-[var(--dg-border)] dg-text-secondary" onClick={() => setOpen(false)}>取消</Button>
|
||||
<Button className="bg-blue-600 hover:bg-blue-700" disabled={loading} onClick={handleCreate}>
|
||||
{loading ? <Loader2 className="h-4 w-4 animate-spin" /> : i18n.t('k8s.misc.sd9ac9228')}
|
||||
{loading ? <Loader2 className="h-4 w-4 animate-spin" /> : i18n.t('创建')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,8 +52,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
renderRow: (item: any, opts: ResourceRowOpts) => React.ReactNode;
|
||||
}> = {
|
||||
deployments: {
|
||||
title: 'Deployments', subtitle: i18n.t('kubernetes.namespaceresour.s35c744fb'), icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.capacitypagetsx.s0428b36a'), i18n.t('kubernetes.container.image')],
|
||||
title: 'Deployments', subtitle: i18n.t('Deployment 工作负载运行状态'), icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('kubernetes.container.image')],
|
||||
renderRow: (d, opts) => (
|
||||
<TableRow key={d.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30 cursor-pointer" onClick={() => opts.onDetail?.(d)}>
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)]">{d.name}</TableCell>
|
||||
@@ -77,7 +77,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
pods: {
|
||||
title: 'Pods', subtitle: i18n.t('kubernetes.namespaceresour.s780b7dd3'), icon: Container,
|
||||
title: 'Pods', subtitle: i18n.t('Pod 实例运行状态'), icon: Container,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('system.terminalStatus'), i18n.t('kubernetes.node.title'), 'CPU', i18n.t('kubernetes.pod.memory'), i18n.t('agent.agentServiceRestart'), i18n.t('kubernetes.container.image'), i18n.t('system.auditAction')],
|
||||
renderRow: (p, opts) => {
|
||||
const statusMap: Record<string, string> = { Running: 'bg-[var(--dg-green)]/20 text-[var(--dg-green)] border-[var(--dg-green)]/30', Pending: 'bg-[var(--dg-orange)]/20 text-[var(--dg-orange)] border-[var(--dg-orange)]/30', Failed: 'bg-[var(--dg-red)]/20 text-[var(--dg-red)] border-[var(--dg-red)]/30' };
|
||||
@@ -113,7 +113,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
},
|
||||
},
|
||||
services: {
|
||||
title: 'Services', subtitle: i18n.t('kubernetes.namespaceresour.s5e76b605'), icon: Network,
|
||||
title: 'Services', subtitle: i18n.t('Service 网络服务'), icon: Network,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('system.credentialType'), 'Cluster IP', i18n.t('system.ldapPort'), i18n.t('system.auditAction')],
|
||||
renderRow: (s, opts) => (
|
||||
<TableRow key={s.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
@@ -127,7 +127,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
ingresses: {
|
||||
title: 'Ingresses', subtitle: i18n.t('kubernetes.namespaceresour.s8d501473'), icon: Network,
|
||||
title: 'Ingresses', subtitle: i18n.t('Ingress 路由规则'), icon: Network,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), 'Hosts', 'TLS', i18n.t('system.auditAction')],
|
||||
renderRow: (i, opts) => {
|
||||
const hosts = i.hosts || [];
|
||||
@@ -143,8 +143,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
},
|
||||
},
|
||||
configmaps: {
|
||||
title: 'ConfigMaps', subtitle: i18n.t('kubernetes.namespaceovervi.s0986a6e7'), icon: FileText,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.namespaceresour.sbd1fa02a'), i18n.t('system.auditAction')],
|
||||
title: 'ConfigMaps', subtitle: i18n.t('配置字典'), icon: FileText,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('system.auditAction')],
|
||||
renderRow: (c, opts) => (
|
||||
<TableRow key={c.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)]">{c.name}</TableCell>
|
||||
@@ -155,7 +155,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
secrets: {
|
||||
title: 'Secrets', subtitle: i18n.t('kubernetes.namespaceresour.sd1424af7'), icon: Shield,
|
||||
title: 'Secrets', subtitle: i18n.t('密钥管理(仅名称与类型)'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('system.credentialType'), i18n.t('system.auditAction')],
|
||||
renderRow: (s, opts) => (
|
||||
<TableRow key={s.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
@@ -167,7 +167,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
hpas: {
|
||||
title: 'HPAs', subtitle: i18n.t('kubernetes.namespaceresour.s9abc8d19'), icon: Activity,
|
||||
title: 'HPAs', subtitle: i18n.t('水平自动伸缩'), icon: Activity,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('monitor.alertEvents.col.target'), i18n.t('k8s.hpaCronHpa.col.minMax'), 'CPU%', 'Mem%'],
|
||||
renderRow: (h, _opts) => (
|
||||
<TableRow key={h.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
@@ -194,7 +194,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
pvcs: {
|
||||
title: i18n.t('kubernetes.namespaceresour.s18c90062'), subtitle: 'PersistentVolumeClaim', icon: Boxes,
|
||||
title: i18n.t('存储卷声明'), subtitle: 'PersistentVolumeClaim', icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('system.terminalStatus'), i18n.t('kubernetes.storage.pvcSize'), 'StorageClass', i18n.t('system.auditAction')],
|
||||
renderRow: (p, opts) => (
|
||||
<TableRow key={p.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
@@ -208,8 +208,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
statefulsets: {
|
||||
title: 'StatefulSets', subtitle: i18n.t('kubernetes.namespaceresour.sbfeb44d8'), icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.capacitypagetsx.s0428b36a'), i18n.t('kubernetes.pod.ready'), i18n.t('kubernetes.container.image')],
|
||||
title: 'StatefulSets', subtitle: i18n.t('有状态应用'), icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('kubernetes.pod.ready'), i18n.t('kubernetes.container.image')],
|
||||
renderRow: (s, opts) => (
|
||||
<TableRow key={s.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30 cursor-pointer" onClick={() => opts.onDetail?.(s)}>
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)]">{s.name}</TableCell>
|
||||
@@ -221,7 +221,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
daemonsets: {
|
||||
title: 'DaemonSets', subtitle: i18n.t('kubernetes.namespaceresour.se1c074e2'), icon: Boxes,
|
||||
title: 'DaemonSets', subtitle: i18n.t('守护进程集'), icon: Boxes,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('monitor.siteProtocol.http.expectedPrefix'), i18n.t('cloud.current'), i18n.t('kubernetes.pod.ready'), i18n.t('kubernetes.container.image')],
|
||||
renderRow: (d, opts) => (
|
||||
<TableRow key={d.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30 cursor-pointer" onClick={() => opts.onDetail?.(d)}>
|
||||
@@ -235,8 +235,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
),
|
||||
},
|
||||
serviceaccounts: {
|
||||
title: 'ServiceAccounts', subtitle: i18n.t('kubernetes.namespaceresour.s645c9a3d'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.namespaceresour.sbaf7ed70'), i18n.t('kubernetes.namespaceresour.s260c11ec'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
title: 'ServiceAccounts', subtitle: i18n.t('服务账号(RBAC 身份标识)'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('命名空间'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
renderRow: (sa, opts) => (
|
||||
<TableRow key={sa.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)]">{sa.name}</TableCell>
|
||||
@@ -247,15 +247,15 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-[var(--dg-text-muted)]">{sa.age || '-'}</TableCell>
|
||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('kubernetes.namespaceresour.s4bde086b')}
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('查看YAML')}
|
||||
onClick={() => opts.onYaml?.(sa.name)}><FileCode className="h-3.5 w-3.5" /></Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
),
|
||||
},
|
||||
roles: {
|
||||
title: 'Roles', subtitle: i18n.t('kubernetes.namespaceresour.s8905a680'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.namespaceresour.secde032d'), i18n.t('system.apiKeyScope'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
title: 'Roles', subtitle: i18n.t('命名空间级角色权限(RBAC)'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('system.apiKeyScope'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
renderRow: (r, opts) => {
|
||||
const verbs = r.verbs || [];
|
||||
const resources = r.resources || [];
|
||||
@@ -275,7 +275,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
<TableCell className="text-xs text-[var(--dg-text-muted)]">{r.age || '-'}</TableCell>
|
||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('kubernetes.namespaceresour.s4bde086b')}
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('查看YAML')}
|
||||
onClick={() => opts.onYaml?.(r.name)}><FileCode className="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-green)] hover:text-[var(--dg-green)]" title={i18n.t('common.edit')}
|
||||
onClick={() => opts.onEdit?.(r.name)}><Pencil className="h-3.5 w-3.5" /></Button>
|
||||
@@ -286,8 +286,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
},
|
||||
},
|
||||
rolebindings: {
|
||||
title: 'RoleBindings', subtitle: i18n.t('kubernetes.namespaceresour.sca10fe5c'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.namespaceresour.s227e5e28'), i18n.t('kubernetes.namespaceresour.s2667c7d8'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
title: 'RoleBindings', subtitle: i18n.t('角色绑定关系(RBAC 授权)'), icon: Shield,
|
||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('命名空间'), i18n.t('system.userCreatedAt'), i18n.t('system.auditAction')],
|
||||
renderRow: (rb, opts) => {
|
||||
const subjects = rb.subjects || [];
|
||||
const subjStr = subjects.length > 3 ? subjects.slice(0, 3).join(', ') + ` +${subjects.length - 3}` : subjects.join(', ');
|
||||
@@ -306,7 +306,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
||||
<TableCell className="text-xs text-[var(--dg-text-muted)]">{rb.age || '-'}</TableCell>
|
||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('kubernetes.namespaceresour.s4bde086b')}
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-text-secondary)] hover:text-[var(--dg-blue)]" title={i18n.t('查看YAML')}
|
||||
onClick={() => opts.onYaml?.(rb.name)}><FileCode className="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 text-[var(--dg-green)] hover:text-[var(--dg-green)]" title={i18n.t('common.edit')}
|
||||
onClick={() => opts.onEdit?.(rb.name)}><Pencil className="h-3.5 w-3.5" /></Button>
|
||||
|
||||
@@ -85,7 +85,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
size="sm"
|
||||
className={cn('h-8 text-xs', previous ? 'bg-amber-600 hover:bg-amber-700' : 'border-[var(--dg-border)] text-[var(--dg-text-secondary)]')}
|
||||
onClick={onPreviousToggle}
|
||||
title={i18n.t('kubernetes.podlogsviewerts.s76a2e637')}
|
||||
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||
>
|
||||
<History className="h-3.5 w-3.5 mr-1" />
|
||||
previous
|
||||
@@ -102,7 +102,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
onSinceTimeChange(v ? new Date(v).toISOString() : '');
|
||||
}}
|
||||
className="h-8 w-[170px] text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
title={i18n.t('kubernetes.podlogsviewerts.s127892fd')}
|
||||
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -114,7 +114,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
<Input
|
||||
value={keyword}
|
||||
onChange={(e) => onKeywordChange(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.podlogsviewerts.s7558f175')}
|
||||
placeholder={i18n.t('关键字过滤…')}
|
||||
className="h-8 w-[160px] pl-7 text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
/>
|
||||
</div>
|
||||
@@ -124,7 +124,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
variant="outline" size="sm"
|
||||
className="h-8 text-xs border-[var(--dg-border)] text-[var(--dg-text-secondary)]"
|
||||
onClick={onDownload}
|
||||
title={i18n.t('kubernetes.podlogsviewerts.s1a023dfb')}
|
||||
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||
disabled={filteredLineCount === 0}
|
||||
>
|
||||
<Download className="h-3.5 w-3.5 mr-1" />导出
|
||||
@@ -136,7 +136,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
className="h-8 text-xs border-[var(--dg-border)] text-[var(--dg-text-secondary)]"
|
||||
onClick={onRefresh}
|
||||
disabled={loading}
|
||||
title={i18n.t('kubernetes.podlogsviewerts.s930b4e01')}
|
||||
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||
>
|
||||
<RefreshCw className={cn('h-3.5 w-3.5 mr-1', loading && 'animate-spin')} />刷新
|
||||
</Button>
|
||||
@@ -148,7 +148,7 @@ export function ControlBar(props: ControlBarProps) {
|
||||
className="h-8 text-xs bg-emerald-600 hover:bg-emerald-700"
|
||||
onClick={onStartStream}
|
||||
disabled={loading}
|
||||
title={i18n.t('kubernetes.podlogsviewerts.s0d519cc0')}
|
||||
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||
>
|
||||
<Play className="h-3.5 w-3.5 mr-1" />实时
|
||||
</Button>
|
||||
|
||||
@@ -49,10 +49,10 @@ export function ConfigMapEditor({ manifest, onSave, saving, isCreate }: ConfigMa
|
||||
|
||||
<div className="flex-1 min-h-0 flex flex-col mt-3">
|
||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.resourcevisuale.s6bd91c09')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('加载中...')} </Label>
|
||||
<div className="flex gap-1">
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={() => setExpandAll(!expandAll)}>
|
||||
{expandAll ? i18n.t('kubernetes.resourcevisuale.s880e849b') : i18n.t('system.expandAll')}
|
||||
{expandAll ? i18n.t('折叠全部') : i18n.t('system.expandAll')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addRow}><Plus className="h-3 w-3 mr-1" /> {i18n.t('monitor.dashboard.custom.addBtn')} </Button>
|
||||
</div>
|
||||
@@ -63,13 +63,13 @@ export function ConfigMapEditor({ manifest, onSave, saving, isCreate }: ConfigMa
|
||||
<Input
|
||||
value={entry.key}
|
||||
onChange={e => update(i, 'key', e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.s65017dab')}
|
||||
placeholder={i18n.t('键名 (如 LOG_LEVEL)')}
|
||||
className="flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
/>
|
||||
<Textarea
|
||||
value={entry.value}
|
||||
onChange={e => update(i, 'value', e.target.value)}
|
||||
placeholder={i18n.t('k8s.resourceEditor.sfe7509e0')}
|
||||
placeholder={i18n.t('键名 (如 LOG_LEVEL)')}
|
||||
rows={expandAll || entry.value.length > 300 ? 10 : (entry.value.length > 100 ? 6 : 3)}
|
||||
className="flex-[2] font-mono text-xs min-h-[70px] max-h-[420px] resize-y bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] leading-relaxed"
|
||||
/>
|
||||
@@ -79,7 +79,7 @@ export function ConfigMapEditor({ manifest, onSave, saving, isCreate }: ConfigMa
|
||||
</div>
|
||||
))}
|
||||
{entries.length === 0 && (
|
||||
<div className="text-center py-8 text-[var(--dg-text-muted)] text-xs"> {i18n.t('kubernetes.resourcevisuale.saf7696c3')} </div>
|
||||
<div className="text-center py-8 text-[var(--dg-text-muted)] text-xs"> {i18n.t('名称')} </div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -121,7 +121,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-8 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
||||
<SelectValue placeholder={loadingClasses ? i18n.t('monitor.logPanel.logResults.loading') : i18n.t('kubernetes.resourcevisuale.s25a87dc9')} />
|
||||
<SelectValue placeholder={loadingClasses ? i18n.t('monitor.logPanel.logResults.loading') : i18n.t('加载中...')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{ingressClasses.length > 0 ? (
|
||||
@@ -131,7 +131,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
</SelectItem>
|
||||
))
|
||||
) : (
|
||||
!loadingClasses && <div className="px-2 py-1.5 text-xs text-[var(--dg-text-muted)]"> {i18n.t('kubernetes.resourcevisuale.s619a36ce')} </div>
|
||||
!loadingClasses && <div className="px-2 py-1.5 text-xs text-[var(--dg-text-muted)]"> {i18n.t('加载中...')} </div>
|
||||
)}
|
||||
{/* 当前自定义值作为选项,确保选中态 */}
|
||||
{ingressClass && !ingressClasses.some((ic) => ic.name === ingressClass) && (
|
||||
@@ -169,7 +169,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
<div className="flex-1 min-h-0 flex flex-col mt-3">
|
||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.ingress.rules')} </Label>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addRule}><Plus className="h-3 w-3 mr-1" /> {i18n.t('kubernetes.resourcevisuale.s4f0a3841')} </Button>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addRule}><Plus className="h-3 w-3 mr-1" /> {i18n.t('端口')} </Button>
|
||||
</div>
|
||||
<div className="flex-1 min-h-0 overflow-y-auto pr-1 space-y-3 border border-[var(--dg-border)] rounded-lg p-2 bg-[var(--dg-bg-secondary)]">
|
||||
{rules.map((rule, ri) => (
|
||||
@@ -178,7 +178,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
<Input
|
||||
value={rule.host}
|
||||
onChange={e => updateRule(ri, e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.s33cde95b')}
|
||||
placeholder={i18n.t('域名 (如 api.example.com)')}
|
||||
className="flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
title={rule.host}
|
||||
/>
|
||||
@@ -187,7 +187,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
{rule.paths.map((p, pi) => (
|
||||
<div key={pi} className="overflow-x-auto pl-4">
|
||||
<div className="grid grid-cols-[minmax(80px,1fr)_100px_minmax(80px,1fr)_60px_28px] gap-1.5 items-center min-w-[420px]">
|
||||
<Input value={p.path} onChange={e => updatePath(ri, pi, 'path', e.target.value)} placeholder={i18n.t('kubernetes.resourcevisuale.sdfd5ebd4')} className="font-mono text-xs h-7 min-w-0 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<Input value={p.path} onChange={e => updatePath(ri, pi, 'path', e.target.value)} placeholder={i18n.t('路径 /')} className="font-mono text-xs h-7 min-w-0 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<Select value={p.pathType} onValueChange={v => updatePath(ri, pi, 'pathType', v)}>
|
||||
<SelectTrigger className="h-7 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"><SelectValue /></SelectTrigger>
|
||||
<SelectContent><SelectItem value="Prefix">Prefix</SelectItem><SelectItem value="Exact">Exact</SelectItem></SelectContent>
|
||||
@@ -201,7 +201,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
||||
<Button variant="ghost" size="sm" className="h-6 text-xs text-[var(--dg-text-muted)]" onClick={() => addPath(ri)}><Plus className="h-3 w-3 mr-1" /> {i18n.t('kubernetes.ingress.addPath')} </Button>
|
||||
</div>
|
||||
))}
|
||||
{rules.length === 0 && <div className="text-center py-4 text-[var(--dg-text-muted)] text-xs"> {i18n.t('kubernetes.resourcevisuale.s0b0794a3')} </div>}
|
||||
{rules.length === 0 && <div className="text-center py-4 text-[var(--dg-text-muted)] text-xs"> {i18n.t('名称')} </div>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]">
|
||||
|
||||
@@ -44,14 +44,14 @@ export function PvcEditor({ manifest, onSave, saving, isCreate }: PvcEditorProps
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4 mt-3 shrink-0">
|
||||
<div>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('kubernetes.resourcevisuale.s61aa8291')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('加载中...')} </Label>
|
||||
<Input
|
||||
value={size}
|
||||
onChange={e => setSize(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.s1b915a5e')}
|
||||
placeholder={i18n.t('如 10Gi')}
|
||||
className="mt-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
/>
|
||||
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1"> {i18n.t('kubernetes.resourcevisuale.s6a1c7a2c')} </p>
|
||||
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1"> {i18n.t('名称')} </p>
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('kubernetes.storage.accessModes')} </Label>
|
||||
@@ -72,7 +72,7 @@ export function PvcEditor({ manifest, onSave, saving, isCreate }: PvcEditorProps
|
||||
<Input
|
||||
value={storageClass}
|
||||
onChange={e => setStorageClass(e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.s06195f6c')}
|
||||
placeholder={i18n.t('留空使用默认 StorageClass')}
|
||||
className="mt-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -68,10 +68,10 @@ export function SecretEditor({ manifest, onSave, saving, isCreate }: SecretEdito
|
||||
|
||||
<div className="flex-1 min-h-0 flex flex-col mt-3">
|
||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.resourcevisuale.se1937033')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('加载中...')} </Label>
|
||||
<div className="flex gap-1">
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={() => setExpandAll(!expandAll)}>
|
||||
{expandAll ? i18n.t('kubernetes.resourcevisuale.s880e849b') : i18n.t('system.expandAll')}
|
||||
{expandAll ? i18n.t('折叠全部') : i18n.t('system.expandAll')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addRow}><Plus className="h-3 w-3 mr-1" /> {i18n.t('monitor.dashboard.custom.addBtn')} </Button>
|
||||
</div>
|
||||
@@ -82,13 +82,13 @@ export function SecretEditor({ manifest, onSave, saving, isCreate }: SecretEdito
|
||||
<Input
|
||||
value={entry.key}
|
||||
onChange={e => update(i, 'key', e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.scdecc460')}
|
||||
placeholder={i18n.t('键名 (如 LOG_LEVEL)')}
|
||||
className="flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||
/>
|
||||
<Textarea
|
||||
value={entry.value}
|
||||
onChange={e => update(i, 'value', e.target.value)}
|
||||
placeholder={i18n.t('kubernetes.resourcevisuale.s7f123dd4')}
|
||||
placeholder={i18n.t('键名 (如 LOG_LEVEL)')}
|
||||
rows={expandAll || entry.value.length > 300 ? 10 : (entry.value.length > 100 ? 6 : 3)}
|
||||
className="flex-[2] font-mono text-xs min-h-[70px] max-h-[420px] resize-y bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] leading-relaxed"
|
||||
/>
|
||||
@@ -98,7 +98,7 @@ export function SecretEditor({ manifest, onSave, saving, isCreate }: SecretEdito
|
||||
</div>
|
||||
))}
|
||||
{entries.length === 0 && (
|
||||
<div className="text-center py-8 text-[var(--dg-text-muted)] text-xs"> {i18n.t('kubernetes.resourcevisuale.s47ff6900')} </div>
|
||||
<div className="text-center py-8 text-[var(--dg-text-muted)] text-xs"> {i18n.t('名称')} </div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -99,7 +99,7 @@ export function ServiceEditor({ manifest, onSave, saving, isCreate }: ServiceEdi
|
||||
<div className="flex-1 min-h-0 overflow-y-auto mt-3 pr-1 space-y-3">
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.resourcevisuale.s736788dc')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('加载中...')} </Label>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addPort}><Plus className="h-3 w-3 mr-1" /> {i18n.t('agent.addPort')} </Button>
|
||||
</div>
|
||||
<div className="space-y-2 border border-[var(--dg-border)] rounded-lg p-2 bg-[var(--dg-bg-secondary)]">
|
||||
@@ -120,22 +120,22 @@ export function ServiceEditor({ manifest, onSave, saving, isCreate }: ServiceEdi
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{ports.length === 0 && <div className="text-center py-4 text-[var(--dg-text-muted)] text-xs"> {i18n.t('kubernetes.resourcevisuale.sf3ba5e52')} </div>}
|
||||
{ports.length === 0 && <div className="text-center py-4 text-[var(--dg-text-muted)] text-xs"> {i18n.t('端口')} </div>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Selector */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.resourcevisuale.scecdd712')} </Label>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addSelector}><Plus className="h-3 w-3 mr-1" /> {i18n.t('kubernetes.resourcevisuale.s736eaaae')} </Button>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('加载中...')} </Label>
|
||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={addSelector}><Plus className="h-3 w-3 mr-1" /> {i18n.t('加载中...')} </Button>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{selector.map((s, i) => (
|
||||
<div key={i} className="flex items-center gap-2 min-w-0">
|
||||
<Input value={s.key} onChange={e => updateSelector(i, 'key', e.target.value)} placeholder={i18n.t('kubernetes.resourcevisuale.s450c9957')} className="flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<Input value={s.key} onChange={e => updateSelector(i, 'key', e.target.value)} placeholder={i18n.t('键 (如 app)')} className="flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<span className="text-[var(--dg-text-muted)] text-xs shrink-0">=</span>
|
||||
<Input value={s.value} onChange={e => updateSelector(i, 'value', e.target.value)} placeholder={i18n.t('kubernetes.resourcevisuale.sb873e454')} className="flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<Input value={s.value} onChange={e => updateSelector(i, 'value', e.target.value)} placeholder={i18n.t('值 (如 nginx)')} className="flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]" />
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 dg-text-red hover:dg-text-red" onClick={() => removeSelector(i)}><Trash2 className="h-3 w-3" /></Button>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -20,13 +20,13 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
||||
</CardHeader>
|
||||
<CardContent className="pt-0 space-y-2 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('kubernetes.workloadviewpag.s0511a271')} </span>
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('服务名')} </span>
|
||||
<Badge variant="outline" className="border-[var(--dg-border)] text-[var(--dg-text-secondary)]">{strategyType}</Badge>
|
||||
</div>
|
||||
{strategyType === 'RollingUpdate' && isSts && updateStrategy.rollingUpdate && (
|
||||
<>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('kubernetes.workloadviewpag.s45cb9d97')} </span>
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('Pod 数量')} </span>
|
||||
<span className="text-[var(--dg-text-secondary)] font-mono">{updateStrategy.rollingUpdate.partition ?? 0}</span>
|
||||
</div>
|
||||
{updateStrategy.rollingUpdate.maxUnavailable && (
|
||||
@@ -47,7 +47,7 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
||||
)}
|
||||
{updateStrategy.rollingUpdate.maxSurge && (
|
||||
<div className="flex justify-between">
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('kubernetes.workloadviewpag.sfed4ce42')} </span>
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('Pod 数量')} </span>
|
||||
<span className="text-[var(--dg-text-secondary)] font-mono">{typeof updateStrategy.rollingUpdate.maxSurge === 'object' ? JSON.stringify(updateStrategy.rollingUpdate.maxSurge) : updateStrategy.rollingUpdate.maxSurge}</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -60,7 +60,7 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between">
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('kubernetes.workloadviewpag.s450a4e05')} </span>
|
||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('服务名')} </span>
|
||||
<span className="text-[var(--dg-text-secondary)] font-mono">{spec.revisionHistoryLimit ?? 10}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -131,7 +131,7 @@ export function AlertChannelDialog({
|
||||
{/* 渠道列表 */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('monitor.alertchanneldia.se6ad00af')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('>渠道名称 <span className=')} </Label>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
@@ -207,10 +207,10 @@ export function AlertChannelDialog({
|
||||
{/* 渠道表单 */}
|
||||
<div className="space-y-4">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm">
|
||||
{editingChannel ? i18n.t('monitor.alertchanneldia.sc4714508') : i18n.t('monitor.alertchanneldia.s82bd472e')}
|
||||
{editingChannel ? i18n.t('编辑渠道') : i18n.t('新建渠道')}
|
||||
</Label>
|
||||
<div className="space-y-1.5">
|
||||
<Label className="dg-text-secondary text-xs"> {i18n.t('monitor.alertchanneldia.sb8cbd86d')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="dg-text-secondary text-xs"> {i18n.t('>渠道名称 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<Input
|
||||
value={channelForm.name}
|
||||
onChange={(e) => setChannelForm({ ...channelForm, name: e.target.value })}
|
||||
|
||||
@@ -76,15 +76,15 @@ export function AlertManager() {
|
||||
];
|
||||
|
||||
const pageTabs = [
|
||||
{ id: 'events', label: i18n.t('kubernetes.eventspagetsx.s0e5b83cc') },
|
||||
{ id: 'events', label: i18n.t('告警事件') },
|
||||
{ id: 'rules', label: i18n.t('monitor.alertRules') },
|
||||
];
|
||||
|
||||
return (
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('monitor.alertmanagertsx.sa57c10a3')}
|
||||
subtitle={i18n.t('monitor.alertmanagertsx.s1a70ca90')}
|
||||
title={i18n.t('监控告警')}
|
||||
subtitle={i18n.t('告警规则管理与告警事件处理')}
|
||||
icon={<Bell className="h-5 w-5" />}
|
||||
tabs={pageTabs}
|
||||
activeTab={activeTab}
|
||||
@@ -94,7 +94,7 @@ export function AlertManager() {
|
||||
items={[
|
||||
{ label: i18n.t('monitor.alertRules'), value: rules.length, color: 'blue' },
|
||||
{ label: i18n.t('monitor.alertHelper.statusFiring'), value: alerts.filter((e) => e.status === 'firing').length, color: 'red' },
|
||||
{ label: i18n.t('monitor.alertmanagertsx.s240597ec'), value: alerts.length, color: 'amber' },
|
||||
{ label: i18n.t('今日告警'), value: alerts.length, color: 'amber' },
|
||||
{ label: i18n.t('kubernetes.msg.uncordonSuccess'), value: alerts.filter((e) => e.status === 'resolved').length, color: 'emerald' },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -128,10 +128,10 @@ export function AlertRuleDialog({
|
||||
<DialogContent className="dg-input max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-[var(--dg-text-primary)]">
|
||||
{editingRule ? i18n.t('monitor.alertruledialog.sb62c8bc1') : i18n.t('monitor.alertruledialog.s3564fa12')}
|
||||
{editingRule ? i18n.t('编辑告警规则') : i18n.t('新建告警规则')}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="dg-text-muted">
|
||||
{editingRule ? i18n.t('monitor.alertruledialog.s44a3bb2d') : i18n.t('monitor.alertruledialog.sb785eced')}
|
||||
{editingRule ? i18n.t('编辑告警规则') : i18n.t('新建告警规则')}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -141,7 +141,7 @@ export function AlertRuleDialog({
|
||||
<Input
|
||||
value={ruleForm.name}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
||||
placeholder={i18n.t('monitor.alertruledialog.sf111cd25')}
|
||||
placeholder={i18n.t('如:CPU 使用率告警')}
|
||||
className="dg-input"
|
||||
/>
|
||||
</div>
|
||||
@@ -151,7 +151,7 @@ export function AlertRuleDialog({
|
||||
<Textarea
|
||||
value={ruleForm.description}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, description: e.target.value })}
|
||||
placeholder={i18n.t('monitor.alertruledialog.scc807bdb')}
|
||||
placeholder={i18n.t('如:CPU 使用率告警')}
|
||||
rows={2}
|
||||
className="dg-input resize-none"
|
||||
/>
|
||||
@@ -159,7 +159,7 @@ export function AlertRuleDialog({
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertruledialog.s36582565')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<select
|
||||
value={ruleForm.type}
|
||||
onChange={(e) => {
|
||||
@@ -169,9 +169,9 @@ export function AlertRuleDialog({
|
||||
}}
|
||||
className="w-full h-9 px-3 rounded-md bg-[var(--dg-bg-tertiary)]/50 border border-[var(--dg-border)] text-[var(--dg-text-primary)] text-sm"
|
||||
>
|
||||
<option value="metric"> {i18n.t('monitor.alertruledialog.s38546de8')} </option>
|
||||
<option value="metric"> {i18n.t('>请先前往「日志库」添加 {ruleForm.source === ')} </option>
|
||||
<option value="log"> {i18n.t('monitor.alertHelper.srcLog')} </option>
|
||||
<option value="event"> {i18n.t('monitor.alertruledialog.s80069bea')} </option>
|
||||
<option value="event"> {i18n.t('>请先前往「日志库」添加 {ruleForm.source === ')} </option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
@@ -199,13 +199,13 @@ export function AlertRuleDialog({
|
||||
|
||||
{ruleForm.type === 'log' && (
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertruledialog.sa2bc1edd')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<select
|
||||
value={ruleForm.datasource_id || ''}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, datasource_id: Number(e.target.value) || undefined })}
|
||||
className="w-full h-9 px-3 rounded-md bg-[var(--dg-bg-tertiary)]/50 border border-[var(--dg-border)] text-[var(--dg-text-primary)] text-sm"
|
||||
>
|
||||
<option value=""> {i18n.t('monitor.alertruledialog.s9acb966d')} </option>
|
||||
<option value=""> {i18n.t('PromQL 或指标表达式,例如 cpu_usage > 80')} </option>
|
||||
{logSources.map((s) => (
|
||||
<option key={s.id} value={s.id}>{s.name}{s.is_default ? i18n.t('monitor.logPanel.defaultSuffix') : ''}</option>
|
||||
))}
|
||||
@@ -217,7 +217,7 @@ export function AlertRuleDialog({
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertruledialog.s57ee9aea')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>规则名称 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<Input
|
||||
value={ruleForm.expression}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, expression: e.target.value })}
|
||||
@@ -226,14 +226,14 @@ export function AlertRuleDialog({
|
||||
/>
|
||||
<p className="text-xs dg-text-muted">
|
||||
{ruleForm.type === 'log'
|
||||
? (ruleForm.source === 'loki' ? i18n.t('monitor.alertruledialog.s465c2bb1') : i18n.t('monitor.alertruledialog.s7072bc91'))
|
||||
: i18n.t('monitor.alertruledialog.se2017efe')}
|
||||
? (ruleForm.source === 'loki' ? i18n.t('LogQL 查询或 count_over_time 表达式') : i18n.t('Elasticsearch Lucene 查询'))
|
||||
: i18n.t('PromQL 或指标表达式,例如 cpu_usage > 80')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertruledialog.sfce93b38')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<select
|
||||
value={ruleForm.severity}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, severity: e.target.value })}
|
||||
@@ -245,7 +245,7 @@ export function AlertRuleDialog({
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertruledialog.scce774b3')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={ruleForm.duration}
|
||||
@@ -303,7 +303,7 @@ export function AlertRuleDialog({
|
||||
onClick={handleSaveRule}
|
||||
>
|
||||
{ruleSaving && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
|
||||
{editingRule ? i18n.t('cloud.saveChanges') : i18n.t('monitor.alertruledialog.s8e1e3dea')}
|
||||
{editingRule ? i18n.t('cloud.saveChanges') : i18n.t('编辑告警规则')}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
@@ -54,15 +54,15 @@ export function AlertRulesTab({
|
||||
|
||||
const handleDeleteRule = async ( id: number) => {
|
||||
const ok = await confirm({
|
||||
title: i18n.t('monitor.alertrulestabts.sfa5bfdc3'),
|
||||
description: i18n.t('monitor.alertrulestabts.sd301558d'),
|
||||
title: i18n.t('删除告警规则'),
|
||||
description: i18n.t('确定删除此告警规则?'),
|
||||
confirmText: i18n.t('kubernetes.storage.delete2'),
|
||||
variant: 'destructive',
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await alertApi.deleteRule(id);
|
||||
toast.success(i18n.t('monitor.alertrulestabts.s20b3fdcd'));
|
||||
toast.success(i18n.t('告警规则已删除'));
|
||||
onReload();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete rule:', error);
|
||||
@@ -74,7 +74,7 @@ export function AlertRulesTab({
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedIds.length === 0) return;
|
||||
const ok = await confirm({
|
||||
title: i18n.t('monitor.alertrulestabts.sbb457b70'),
|
||||
title: i18n.t('删除告警规则'),
|
||||
description: `确定删除选中的 ${selectedIds.length} 条告警规则吗?此操作不可撤销。`,
|
||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||
variant: 'destructive',
|
||||
|
||||
@@ -115,8 +115,8 @@ export const ZabbixDashboard: React.FC<Props> = ({ dsUrl, dsUsername, dsPassword
|
||||
<thead className="bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]"><tr>
|
||||
{[
|
||||
{ f: 'hostname' as SortField, l: i18n.t('kubernetes.workload.hostname') },{ f: 'cpu_usage' as SortField, l: 'CPU' },{ f: 'memory_usage' as SortField, l: i18n.t('kubernetes.pod.memory') },
|
||||
{ f: 'disk_usage' as SortField, l: i18n.t('monitor.dashboard.col.disk') },{ f: 'load5' as SortField, l: 'Load5' },{ f: 'net_in_bps' as SortField, l: i18n.t('monitor.prometheusdashb.s361ffa7f') },
|
||||
{ f: 'net_out_bps' as SortField, l: i18n.t('monitor.prometheusdashb.s37cc0a9a') },{ f: 'problem_count' as SortField, l: i18n.t('monitor.zabbixdashboard.s5dc99f6e') },{ f: 'uptime_days' as SortField, l: i18n.t('automation.scriptRun') },
|
||||
{ f: 'disk_usage' as SortField, l: i18n.t('monitor.dashboard.col.disk') },{ f: 'load5' as SortField, l: 'Load5' },{ f: 'net_in_bps' as SortField, l: i18n.t('磁盘') },
|
||||
{ f: 'net_out_bps' as SortField, l: i18n.t('流出') },{ f: 'problem_count' as SortField, l: i18n.t('问题') },{ f: 'uptime_days' as SortField, l: i18n.t('automation.scriptRun') },
|
||||
].map(({ f, l }) => (
|
||||
<th key={f} className="px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] cursor-pointer hover:text-[var(--dg-text-primary)] select-none whitespace-nowrap" onClick={() => toggleSort(f)}>
|
||||
<div className="flex items-center gap-1">{l}<SI f={f} /></div></th>
|
||||
|
||||
@@ -34,7 +34,7 @@ export default function PrometheusDatasourceManager() {
|
||||
const [editingDs, setEditingDs] = useState<PromDS | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isError) toast.error(i18n.t('monitor.zabbixdatasourc.s45f81749'));
|
||||
if (isError) toast.error(i18n.t('获取数据源列表失败'));
|
||||
}, [isError]);
|
||||
|
||||
const openCreate = () => {
|
||||
@@ -67,7 +67,7 @@ export default function PrometheusDatasourceManager() {
|
||||
await setDefaultMutation.mutateAsync(ds.id);
|
||||
toast.success(`已将「${ds.name}」设为默认数据源`);
|
||||
} catch {
|
||||
toast.error(i18n.t('monitor.zabbixdatasourc.s9f96034c'));
|
||||
toast.error(i18n.t('删除失败'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,8 +95,8 @@ export default function PrometheusDatasourceManager() {
|
||||
{sources.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<Database className="h-12 w-12" />}
|
||||
title={i18n.t('monitor.prometheusdatas.s99ed81c8')}
|
||||
description={i18n.t('monitor.prometheusdatas.sd9a356b8')}
|
||||
title={i18n.t('暂无 Prometheus 数据源')}
|
||||
description={i18n.t('添加数据源后可用于指标监控与监控大屏')}
|
||||
action={(
|
||||
<Button onClick={openCreate} size="sm" className="dg-btn-primary">
|
||||
<Plus className="w-4 h-4 mr-1" />添加数据源
|
||||
|
||||
@@ -79,7 +79,7 @@ export default function ZabbixDatasourceManager() {
|
||||
const res: JsonData = await zabbixDatasourceApi.list();
|
||||
setSources(res?.data || res || []);
|
||||
} catch {
|
||||
toast.error(i18n.t('monitor.zabbixdatasourc.s45f81749'));
|
||||
toast.error(i18n.t('获取数据源列表失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -117,17 +117,17 @@ export default function ZabbixDatasourceManager() {
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!form.name.trim()) { toast.error(i18n.t('monitor.promDs.nameRequired')); return; }
|
||||
if (!form.url.trim()) { toast.error(i18n.t('monitor.zabbixdatasourc.s2ba385d6')); return; }
|
||||
if (!form.url.trim()) { toast.error(i18n.t('请输入 Zabbix API URL')); return; }
|
||||
if (!form.username.trim()) { toast.error(i18n.t('pipeline.usernameRequired')); return; }
|
||||
if (!form.password.trim()) { toast.error(i18n.t('login.passwordRequired')); return; }
|
||||
|
||||
try {
|
||||
if (editingId) {
|
||||
await zabbixDatasourceApi.update(editingId, form);
|
||||
toast.success(i18n.t('monitor.zabbixdatasourc.s8dfdd2f4'));
|
||||
toast.success(i18n.t('数据源已更新'));
|
||||
} else {
|
||||
await zabbixDatasourceApi.create(form);
|
||||
toast.success(i18n.t('monitor.zabbixdatasourc.sa6def01f'));
|
||||
toast.success(i18n.t('数据源已更新'));
|
||||
}
|
||||
setDialogOpen(false);
|
||||
fetchList();
|
||||
@@ -155,12 +155,12 @@ export default function ZabbixDatasourceManager() {
|
||||
await zabbixDatasourceApi.setDefault(ds.id);
|
||||
toast.success(`已将「${ds.name}」设为默认`);
|
||||
fetchList();
|
||||
} catch { toast.error(i18n.t('monitor.zabbixdatasourc.s9f96034c')); }
|
||||
} catch { toast.error(i18n.t('删除失败')); }
|
||||
};
|
||||
|
||||
const handleTest = async () => {
|
||||
if (!form.url.trim() || !form.username.trim()) {
|
||||
toast.error(i18n.t('monitor.zabbixdatasourc.s1d3562b7'));
|
||||
toast.error(i18n.t('获取数据源列表失败'));
|
||||
return;
|
||||
}
|
||||
setTesting(true);
|
||||
@@ -264,7 +264,7 @@ export default function ZabbixDatasourceManager() {
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2">
|
||||
<Database className="h-5 w-5 dg-text-orange" />
|
||||
{editingId ? i18n.t('monitor.zabbixdatasourc.sc1c87ed6') : i18n.t('monitor.zabbixdatasourc.sa77d384f')}
|
||||
{editingId ? i18n.t('编辑 Zabbix 数据源') : i18n.t('新建 Zabbix 数据源')}
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
配置 Zabbix API 连接,用于主机监控与告警数据获取
|
||||
@@ -276,7 +276,7 @@ export default function ZabbixDatasourceManager() {
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<Label className="text-xs text-[var(--dg-text-secondary)]"> {i18n.t('deploy.form.nameStar')} </Label>
|
||||
<Input className="mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]" placeholder={i18n.t('monitor.zabbixdatasourc.s9f1e6a92')}
|
||||
<Input className="mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]" placeholder={i18n.t('如:生产 Zabbix')}
|
||||
value={form.name} onChange={e => updateForm('name', e.target.value)} />
|
||||
</div>
|
||||
<div className="flex items-end pb-1">
|
||||
@@ -366,7 +366,7 @@ export default function ZabbixDatasourceManager() {
|
||||
onClick={() => setShowOther(!showOther)}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Settings className="w-4 h-4" />
|
||||
<span> {i18n.t('monitor.zabbixdatasourc.sdda36edb')} </span>
|
||||
<span> {i18n.t('编辑 Zabbix 数据源')} </span>
|
||||
</div>
|
||||
{showOther ? <ChevronUp className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />}
|
||||
</button>
|
||||
|
||||
@@ -147,10 +147,10 @@ export function LogDatasourcePage() {
|
||||
rowKey={(ds) => ds.id}
|
||||
loading={loading}
|
||||
searchable
|
||||
searchPlaceholder={i18n.t('monitor.logdatasourcepa.seb5e4d30')}
|
||||
searchPlaceholder={i18n.t('搜索数据源名称或地址...')}
|
||||
searchKeys={['name', 'url']}
|
||||
sortable
|
||||
emptyText={i18n.t('monitor.logdatasourcepa.sc8a96073')}
|
||||
emptyText={i18n.t('暂无数据源,点击上方按钮添加')}
|
||||
toolbarExtra={
|
||||
<>
|
||||
<Button variant="outline" size="sm" className="h-8 border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)] hover:text-[var(--dg-text-primary)]" onClick={load}>
|
||||
|
||||
@@ -65,7 +65,7 @@ export function LogFieldSidebar({
|
||||
<input
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={i18n.t('monitor.logfieldsidebar.s2d3013c3')}
|
||||
placeholder={i18n.t('})${f.count ? ` · ${f.count} 个值` : ')}
|
||||
className="w-full h-7 pl-7 pr-2 text-xs rounded-md dg-input"
|
||||
style={{ background: 'var(--dg-bg-tertiary)', border: '1px solid var(--dg-border)', color: 'var(--dg-text-primary)' }}
|
||||
/>
|
||||
|
||||
@@ -24,8 +24,8 @@ interface Props {
|
||||
}
|
||||
|
||||
const STATUS_LABEL: Record<string, { text: string; color: string }> = {
|
||||
precise: { text: i18n.t('monitor.logquerytoolbar.sd0368470'), color: '#22c55e' },
|
||||
partial: { text: i18n.t('monitor.logquerytoolbar.s8b09f4fe'), color: '#f59e0b' },
|
||||
precise: { text: i18n.t('结果精确'), color: '#22c55e' },
|
||||
partial: { text: i18n.t('部分命中'), color: '#f59e0b' },
|
||||
failed: { text: i18n.t('monitor.logPanel.queryFailed'), color: '#ef4444' },
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import i18n from '@/i18n';
|
||||
|
||||
const ROLE_LABEL: Record<string, string> = {
|
||||
viewer: i18n.t('pipeline.viewer'),
|
||||
analyst: i18n.t('monitor.logrbactsx.sa72dec16'),
|
||||
analyst: i18n.t('分析者'),
|
||||
};
|
||||
|
||||
const ENGINE_LABEL: Record<string, string> = {
|
||||
@@ -108,7 +108,7 @@ export default function LogRBAC() {
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
||||
toast.error(i18n.t('monitor.logrbactsx.sf6e80bf0')); return;
|
||||
toast.error(i18n.t('请填写名称、标识与正则')); return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
@@ -147,7 +147,7 @@ export default function LogRBAC() {
|
||||
|
||||
const handleDelete = async (role: LogScopeRole) => {
|
||||
const ok = await _confirm({
|
||||
title: i18n.t('monitor.logrbactsx.s5d79e436'),
|
||||
title: i18n.t('删除权限'),
|
||||
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个示例范围`,
|
||||
variant: 'destructive',
|
||||
});
|
||||
@@ -165,7 +165,7 @@ export default function LogRBAC() {
|
||||
};
|
||||
|
||||
const handleAssign = async () => {
|
||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('monitor.logrbactsx.s0fc53985')); return; }
|
||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('请选择用户和权限')); return; }
|
||||
setAssignLoading(true);
|
||||
try {
|
||||
await logRbacApi.assignRole(Number(selectedUserId), {
|
||||
@@ -189,8 +189,8 @@ export default function LogRBAC() {
|
||||
|
||||
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
||||
const pageTabs = [
|
||||
{ id: 'roles', label: i18n.t('monitor.logrbactsx.s93ef07cd'), badge: roles.length || undefined },
|
||||
{ id: 'users', label: i18n.t('monitor.logrbactsx.s2de89571') },
|
||||
{ id: 'roles', label: i18n.t('权限策略'), badge: roles.length || undefined },
|
||||
{ id: 'users', label: i18n.t('用户授权') },
|
||||
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
||||
];
|
||||
|
||||
@@ -215,8 +215,8 @@ export default function LogRBAC() {
|
||||
roles.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<Shield className="h-10 w-10" />}
|
||||
title={i18n.t('monitor.logrbactsx.s4a00d253')}
|
||||
description={i18n.t('monitor.logrbactsx.sd11b7407')}
|
||||
title={i18n.t('暂无日志权限策略')}
|
||||
description={i18n.t('创建策略并分配给用户后,将按正则限制可查询的索引与 Label 范围')}
|
||||
action={<Button onClick={() => setCreateOpen(true)}><Plus className="h-4 w-4 mr-1" /> {i18n.t('monitor.logrbactsx.s6058845c')} </Button>}
|
||||
/>
|
||||
) : (
|
||||
@@ -259,7 +259,7 @@ export default function LogRBAC() {
|
||||
<SelectTrigger className="h-7 w-20 text-xs"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="viewer"> {i18n.t('pipeline.viewer')} </SelectItem>
|
||||
<SelectItem value="analyst"> {i18n.t('monitor.logrbactsx.sa72dec16')} </SelectItem>
|
||||
<SelectItem value="analyst"> {i18n.t('分析者')} </SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => handleUpdate(role.id)}><Check className="w-3.5 h-3.5" /></Button>
|
||||
@@ -302,7 +302,7 @@ export default function LogRBAC() {
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1 w-48">
|
||||
<Label className="text-xs"> {i18n.t('monitor.logrbactsx.s93ef07cd')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('权限策略')} </Label>
|
||||
<Select value={assignRoleId} onValueChange={setAssignRoleId}>
|
||||
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -4,36 +4,36 @@ import i18n from '@/i18n';
|
||||
|
||||
const ALL_TEMPLATES: Record<'loki' | 'elasticsearch', { label: string; query: string }[]> = {
|
||||
loki: [
|
||||
{ label: i18n.t('monitor.quickquerybarts.s64559524'), query: '{job="nginx"} |= "error"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s315990ac'), query: '{namespace="prod"} | json | level="warn"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sfc6d4276'), query: '{app="api"} |= "timeout"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s0ce3d219'), query: 'sum by(level) (count_over_time({job="app"}[5m]))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s6209b154'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sf839efd6'), query: '{job="api"} | json | response_time > 1000' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s386c7580'), query: 'sum by(level) (count_over_time({app="cex-admin-api"} |= "error" [5m]))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sf94f3fdb'), query: '{app="cex-admin-api"} |= "trace_id" | json' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s7f0fa5fa'), query: 'sum by(service_name) (count_over_time({namespace="astralx"}[5m]))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s49c7620d'), query: '{app="cex-admin-api"} | json | response_time > 500' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sb8edf48d'), query: '{app="cex-admin-api"} |= "Exception"' },
|
||||
{ label: i18n.t('Nginx 错误'), query: '{job="nginx"} |= "error"' },
|
||||
{ label: i18n.t('JSON 过滤'), query: '{namespace="prod"} | json | level="warn"' },
|
||||
{ label: i18n.t('超时搜索'), query: '{app="api"} |= "timeout"' },
|
||||
{ label: i18n.t('级别统计'), query: 'sum by(level) (count_over_time({job="app"}[5m]))' },
|
||||
{ label: i18n.t('正则多级别'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||
{ label: i18n.t('慢请求>1s'), query: '{job="api"} | json | response_time > 1000' },
|
||||
{ label: i18n.t('错误率统计'), query: 'sum by(level) (count_over_time({app="cex-admin-api"} |= "error" [5m]))' },
|
||||
{ label: i18n.t('追踪ID查询'), query: '{app="cex-admin-api"} |= "trace_id" | json' },
|
||||
{ label: i18n.t('错误率统计'), query: 'sum by(service_name) (count_over_time({namespace="astralx"}[5m]))' },
|
||||
{ label: i18n.t('高延迟筛选'), query: '{app="cex-admin-api"} | json | response_time > 500' },
|
||||
{ label: i18n.t('异常堆栈'), query: '{app="cex-admin-api"} |= "Exception"' },
|
||||
{ label: i18n.t('monitor.logTrend'), query: 'sum(count_over_time({app="cex-admin-api"}[1h]))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s1ace0c03'), query: '{app="cex-admin-api"} | regexp "(?P<method>[A-Za-z0-9_]+) (?P<path>[^ ]+)"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s20b34227'), query: '{app="cex-admin-api"} | json | line_format "{{.level}} {{.message}}"' },
|
||||
{ label: i18n.t('正则提取'), query: '{app="cex-admin-api"} | regexp "(?P<method>[A-Za-z0-9_]+) (?P<path>[^ ]+)"' },
|
||||
{ label: i18n.t('格式输出'), query: '{app="cex-admin-api"} | json | line_format "{{.level}} {{.message}}"' },
|
||||
],
|
||||
elasticsearch: [
|
||||
{ label: 'API 5xx', query: 'status:500 AND path:"/api/*"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sa1eb8196'), query: '(level:error OR log.level:error) AND message:*timeout*' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s0235c6eb'), query: 'host.name:server-* AND NOT level:debug' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s0876c43d'), query: 'response_time:>1000 AND method:POST' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.se31850bf'), query: '@timestamp:[now-1h TO now] AND (level:critical OR log.level:critical)' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s6241b884'), query: 'service:nginx AND (level:(error OR fatal) OR log.level:(error OR fatal))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s04adb0fd'), query: 'app:cex-admin-api AND (level:(error OR warn) OR log.level:(error OR warn))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sc579cfbb'), query: 'message:*timeout* AND app:cex-admin-api' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s0c9d7886'), query: 'response_time:[1000 TO *] AND method:POST' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.se11dceb4'), query: 'app:cex-admin-api AND NOT path:/health' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s00f6f739'), query: '@timestamp:[now-1h TO now] AND level:error' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s8a1879ae'), query: 'client_ip:172.36.* AND app:cex-admin-api' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.s6f401985'), query: 'app:cex-admin-api AND (level:(error OR warn OR info) OR log.level:(error OR warn OR info))' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sf09e007f'), query: 'labels.orgId:10001 AND app:cex-admin-api' },
|
||||
{ label: i18n.t('错误超时'), query: '(level:error OR log.level:error) AND message:*timeout*' },
|
||||
{ label: i18n.t('排除调试'), query: 'host.name:server-* AND NOT level:debug' },
|
||||
{ label: i18n.t('慢请求'), query: 'response_time:>1000 AND method:POST' },
|
||||
{ label: i18n.t('严重错误'), query: '@timestamp:[now-1h TO now] AND (level:critical OR log.level:critical)' },
|
||||
{ label: i18n.t('严重错误'), query: 'service:nginx AND (level:(error OR fatal) OR log.level:(error OR fatal))' },
|
||||
{ label: i18n.t('组合查询'), query: 'app:cex-admin-api AND (level:(error OR warn) OR log.level:(error OR warn))' },
|
||||
{ label: i18n.t('模糊匹配'), query: 'message:*timeout* AND app:cex-admin-api' },
|
||||
{ label: i18n.t('范围查询'), query: 'response_time:[1000 TO *] AND method:POST' },
|
||||
{ label: i18n.t('排除路径'), query: 'app:cex-admin-api AND NOT path:/health' },
|
||||
{ label: i18n.t('时间过滤'), query: '@timestamp:[now-1h TO now] AND level:error' },
|
||||
{ label: i18n.t('IP段过滤'), query: 'client_ip:172.36.* AND app:cex-admin-api' },
|
||||
{ label: i18n.t('多级别筛选'), query: 'app:cex-admin-api AND (level:(error OR warn OR info) OR log.level:(error OR warn OR info))' },
|
||||
{ label: i18n.t('嵌套字段'), query: 'labels.orgId:10001 AND app:cex-admin-api' },
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -6,27 +6,27 @@ import i18n from '@/i18n';
|
||||
|
||||
// 相对时间预设:最近N... 每次点击时计算 start = now - N // Logan.Li
|
||||
const RELATIVE_PRESETS = [
|
||||
{ label: i18n.t('monitor.timerangepicker.s6b3f2ecb'), value: '1m' },
|
||||
{ label: i18n.t('最近1分钟'), value: '1m' },
|
||||
{ label: i18n.t('monitor.logPanel.last5min'), value: '5m' },
|
||||
{ label: i18n.t('monitor.timerangepicker.sd4962f4b'), value: '15m' },
|
||||
{ label: i18n.t('monitor.timerangepicker.sd8a81545'), value: '1h' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s0823ad83'), value: '4h' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s77be0dba'), value: '24h' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s2ba41ef4'), value: '7d' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s63f66f1f'), value: '30d' },
|
||||
{ label: i18n.t('最近15分钟'), value: '15m' },
|
||||
{ label: i18n.t('最近1小时'), value: '1h' },
|
||||
{ label: i18n.t('最近4小时'), value: '4h' },
|
||||
{ label: i18n.t('最近1天'), value: '24h' },
|
||||
{ label: i18n.t('最近1周'), value: '7d' },
|
||||
{ label: i18n.t('最近30天'), value: '30d' },
|
||||
];
|
||||
|
||||
// 绝对时间预设:固定的自然日/周/月/季/年 // Logan.Li
|
||||
const ABSOLUTE_PRESETS = [
|
||||
{ label: i18n.t('audit.terminal.presetToday'), value: 'today' },
|
||||
{ label: i18n.t('common.yesterday'), value: 'yesterday' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s94995c31'), value: 'day_before_yesterday' },
|
||||
{ label: i18n.t('前天'), value: 'day_before_yesterday' },
|
||||
{ label: i18n.t('common.thisWeek'), value: 'this_week' },
|
||||
{ label: i18n.t('common.lastWeek'), value: 'last_week' },
|
||||
{ label: i18n.t('cloud.thisMonth'), value: 'this_month' },
|
||||
{ label: i18n.t('common.lastMonth'), value: 'last_month' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s0477ce74'), value: 'this_quarter' },
|
||||
{ label: i18n.t('monitor.timerangepicker.s77df6c8e'), value: 'this_year' },
|
||||
{ label: i18n.t('本季度'), value: 'this_quarter' },
|
||||
{ label: i18n.t('本年度'), value: 'this_year' },
|
||||
];
|
||||
|
||||
function getPresetRange(value: string): { start: Date; end: Date; label: string } {
|
||||
@@ -136,7 +136,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
||||
{/* 头部 */}
|
||||
<div className="flex items-center gap-2 mb-3 pb-3" style={{ borderBottom: '1px solid var(--dg-border)' }}>
|
||||
<Calendar className="h-4 w-4" style={{ color: 'var(--dg-blue)' }} />
|
||||
<span className="text-sm font-medium" style={{ color: 'var(--dg-text-primary)' }}> {i18n.t('monitor.timerangepicker.sc2c8fb23')} </span>
|
||||
<span className="text-sm font-medium" style={{ color: 'var(--dg-text-primary)' }}> {i18n.t('开启后折叠行仅显示前 500 字预览')} </span>
|
||||
<button
|
||||
onClick={openCustom}
|
||||
className="text-xs ml-2 px-2 py-0.5 rounded transition-colors"
|
||||
@@ -152,7 +152,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
||||
{mode === 'preset' ? (
|
||||
<>
|
||||
{/* 相对时间 — 最近... */}
|
||||
<p className="text-[10px] mb-2 font-medium uppercase tracking-wide" style={{ color: '#22c55e' }}> {i18n.t('monitor.timerangepicker.s8ead0af2')} </p>
|
||||
<p className="text-[10px] mb-2 font-medium uppercase tracking-wide" style={{ color: '#22c55e' }}> {i18n.t(' /> 另存为 <ChevronDown className=')} </p>
|
||||
<div className="grid grid-cols-4 gap-1.5 mb-3">
|
||||
{RELATIVE_PRESETS.map(p => (
|
||||
<button
|
||||
@@ -171,7 +171,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 绝对时间 — 固定日历范围 */}
|
||||
<p className="text-[10px] mb-2 font-medium uppercase tracking-wide" style={{ color: 'var(--dg-blue)' }}> {i18n.t('monitor.timerangepicker.s714f6cdd')} </p>
|
||||
<p className="text-[10px] mb-2 font-medium uppercase tracking-wide" style={{ color: 'var(--dg-blue)' }}> {i18n.t('开启后折叠行仅显示前 500 字预览')} </p>
|
||||
<div className="grid grid-cols-5 gap-1.5">
|
||||
{ABSOLUTE_PRESETS.map(p => (
|
||||
<button
|
||||
@@ -192,7 +192,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
||||
) : (
|
||||
/* 自定义日历模式 */
|
||||
<div className="space-y-3">
|
||||
<p className="text-[10px] font-medium uppercase" style={{ color: 'var(--dg-blue)' }}> {i18n.t('monitor.hosttimerangepi.s0122e022')} </p>
|
||||
<p className="text-[10px] font-medium uppercase" style={{ color: 'var(--dg-blue)' }}> {i18n.t('开启后折叠行仅显示前 500 字预览')} </p>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label className="text-[10px] block mb-1" style={{ color: 'var(--dg-text-muted)' }}> {i18n.t('system.terminalStartTime')} </label>
|
||||
|
||||
@@ -134,7 +134,7 @@ export const ENGINE_META: Record<LogEngine, { name: string; color: string; query
|
||||
color: '#f97316',
|
||||
queryPlaceholder: 'keyword | SELECT * WHERE level = "info"',
|
||||
statPlaceholder: '* | SELECT level, COUNT(*) as cnt GROUP BY level',
|
||||
externalLink: i18n.t('monitor.typesv3ts.sfe4ff0b4'),
|
||||
externalLink: i18n.t('SLS控制台'),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -250,27 +250,27 @@ export const savedQueryStorage = {
|
||||
// 快捷查询模板 // Logan.Li
|
||||
export const QUICK_TEMPLATES: Record<LogEngine, { label: string; query: string }[]> = {
|
||||
loki: [
|
||||
{ label: i18n.t('monitor.typesv3ts.s70d6c24a'), query: '{job="nginx"} |= "error"' },
|
||||
{ label: i18n.t('monitor.typesv3ts.saf1cb054'), query: '{namespace="prod"} | json | level="warn"' },
|
||||
{ label: i18n.t('monitor.quickquerybarts.sfc6d4276'), query: '{app="api"} |= "timeout"' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s475a42fe'), query: 'sum by (level) (count_over_time({job="app"}[5m]))' },
|
||||
{ label: i18n.t('monitor.typesv3ts.sac8a5c83'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s4dc793a9'), query: '{job="api"} | json | response_time > 1000' },
|
||||
{ label: i18n.t('Nginx 错误日志'), query: '{job="nginx"} |= "error"' },
|
||||
{ label: i18n.t('JSON 解析过滤'), query: '{namespace="prod"} | json | level="warn"' },
|
||||
{ label: i18n.t('超时搜索'), query: '{app="api"} |= "timeout"' },
|
||||
{ label: i18n.t('按级别统计'), query: 'sum by (level) (count_over_time({job="app"}[5m]))' },
|
||||
{ label: i18n.t('正则匹配多级别'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||
{ label: i18n.t('慢请求 >1s'), query: '{job="api"} | json | response_time > 1000' },
|
||||
],
|
||||
elasticsearch: [
|
||||
{ label: i18n.t('monitor.typesv3ts.sd81428f4'), query: 'status:500 AND path:"/api/*"' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s6624c787'), query: '(level:error OR log.level:error) AND message:*timeout*' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s98b327ac'), query: 'host.name:server-* AND NOT level:debug AND NOT log.level:debug' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s95d72fa1'), query: 'response_time:>1000 AND method:POST' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s9a0d4c8c'), query: '@timestamp:[now-1h TO now] AND (level:critical OR log.level:critical)' },
|
||||
{ label: i18n.t('monitor.typesv3ts.s68f58cc0'), query: 'service:nginx AND (level:(error OR fatal) OR log.level:(error OR fatal))' },
|
||||
{ label: i18n.t('API 5xx 错误'), query: 'status:500 AND path:"/api/*"' },
|
||||
{ label: i18n.t('错误超时日志'), query: '(level:error OR log.level:error) AND message:*timeout*' },
|
||||
{ label: i18n.t('排除调试日志'), query: 'host.name:server-* AND NOT level:debug AND NOT log.level:debug' },
|
||||
{ label: i18n.t('慢请求检测'), query: 'response_time:>1000 AND method:POST' },
|
||||
{ label: i18n.t('最近1小时严重错误'), query: '@timestamp:[now-1h TO now] AND (level:critical OR log.level:critical)' },
|
||||
{ label: i18n.t('最近1小时严重错误'), query: 'service:nginx AND (level:(error OR fatal) OR log.level:(error OR fatal))' },
|
||||
],
|
||||
sls: [
|
||||
{ label: i18n.t('monitor.typesv3ts.sf8889aa4'), query: "* | select * where level = 'error'" },
|
||||
{ label: i18n.t('monitor.typesv3ts.s475a42fe'), query: "* | select count(*) as cnt, level group by level" },
|
||||
{ label: i18n.t('monitor.typesv3ts.s27ee0975'), query: "* | select date_trunc('minute', __time__) as t, count(*) group by t order by t" },
|
||||
{ label: i18n.t('monitor.typesv3ts.sa5ad7487'), query: "* | select method, count(*) as cnt, avg(response_time) group by method order by cnt desc" },
|
||||
{ label: i18n.t('monitor.typesv3ts.s80428bd5'), query: "* | select * where response_time > 1000 order by response_time desc limit 100" },
|
||||
{ label: i18n.t('monitor.typesv3ts.s63c5c72e'), query: "* | select status_code, count(*) as cnt, count(*) * 100.0 / sum(count(*)) over() as pct group by status_code" },
|
||||
{ label: i18n.t('错误日志筛选'), query: "* | select * where level = 'error'" },
|
||||
{ label: i18n.t('按级别统计'), query: "* | select count(*) as cnt, level group by level" },
|
||||
{ label: i18n.t('时间聚合'), query: "* | select date_trunc('minute', __time__) as t, count(*) group by t order by t" },
|
||||
{ label: i18n.t('状态码分布'), query: "* | select method, count(*) as cnt, avg(response_time) group by method order by cnt desc" },
|
||||
{ label: i18n.t('慢请求分析'), query: "* | select * where response_time > 1000 order by response_time desc limit 100" },
|
||||
{ label: i18n.t('状态码分布'), query: "* | select status_code, count(*) as cnt, count(*) * 100.0 / sum(count(*)) over() as pct group by status_code" },
|
||||
],
|
||||
};
|
||||
@@ -78,7 +78,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
setBreadcrumbs(data.breadcrumbs || []);
|
||||
setCurrentPath(data.path || path);
|
||||
} catch (err) {
|
||||
setError(err?.message || i18n.t('server.serverfilebrows.s4be30fcb'));
|
||||
setError(err?.message || i18n.t('加载目录失败'));
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -97,7 +97,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
try {
|
||||
await serverApi.downloadFile(serverId, filePath);
|
||||
} catch (err) {
|
||||
setError(i18n.t('server.serverfilebrows.sb264a9b6') + ((err as JsonData)?.message || ''));
|
||||
setError(i18n.t('下载失败: ') + ((err as JsonData)?.message || ''));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -117,7 +117,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
};
|
||||
|
||||
const handleDelete = async (filePath: string, isDir: boolean) => {
|
||||
if (!serverId || !confirm(`确认删除 ${isDir ? i18n.t('server.serverfilebrows.s767fa455') : i18n.t('k8s.pods.action.file')} "${filePath}"?`)) return;
|
||||
if (!serverId || !confirm(`确认删除 ${isDir ? i18n.t('目录') : i18n.t('k8s.pods.action.file')} "${filePath}"?`)) return;
|
||||
try {
|
||||
await serverApi.deleteFile(serverId, filePath);
|
||||
await fetchDir(currentPath);
|
||||
|
||||
@@ -23,7 +23,7 @@ function escapeCsv(s: string): string {
|
||||
// exportAuditReportCsv 导出会话审计报告 CSV // Logan.Li
|
||||
export function exportAuditReportCsv(meta: ReplaySessionMeta, commands: CommandBookmark[]) {
|
||||
const lines: string[] = [
|
||||
i18n.t('system.exportauditts.s3cb7eb59'),
|
||||
i18n.t('# 终端会话审计报告'),
|
||||
`会话ID,${meta.id}`,
|
||||
`用户,${escapeCsv(meta.username || '')}`,
|
||||
`目标主机,${escapeCsv(meta.server_name || '')}`,
|
||||
@@ -33,7 +33,7 @@ export function exportAuditReportCsv(meta: ReplaySessionMeta, commands: CommandB
|
||||
`时长(秒),${meta.duration || 0}`,
|
||||
`录制大小,${meta.record_size || 0}`,
|
||||
'',
|
||||
i18n.t('system.exportauditts.s7a85eed7'),
|
||||
i18n.t('# 终端会话审计报告'),
|
||||
];
|
||||
for (const c of commands) {
|
||||
lines.push(`${c.label},${escapeCsv(c.command)},${c.highRisk ? '是' : '否'}`);
|
||||
@@ -55,7 +55,7 @@ export interface CommandExportRow {
|
||||
|
||||
// exportCommandsListCsv 导出命令列表 CSV // Logan.Li
|
||||
export function exportCommandsListCsv(commands: CommandExportRow[]) {
|
||||
const lines: string[] = [i18n.t('system.exportauditts.s6e047305')];
|
||||
const lines: string[] = [i18n.t('时间,用户,命令,输出大小,会话ID,高危')];
|
||||
for (const c of commands) {
|
||||
const ts = c.timestamp || c.created_at || '';
|
||||
const highRisk = isHighRiskCommand(c.command || '');
|
||||
|
||||
@@ -148,7 +148,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
if (msg.includes('Already Exists') || msg.includes('68')) {
|
||||
toast.error(i18n.t('system.useldapmanageme.s1a2b3c4d', { name: ouForm.ou_name }));
|
||||
} else {
|
||||
toast.error(i18n.t('system.useldapmanageme.s2b3c4d5e') + msg);
|
||||
toast.error(i18n.t('创建失败: ') + msg);
|
||||
}
|
||||
} finally { setLdapSaving(false); }
|
||||
};
|
||||
@@ -168,7 +168,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
/** 删除 LDAP 条目 // Logan.Li */
|
||||
const handleDeleteLDAPEntry = async (dn: string, silent = false) => {
|
||||
if (!silent) {
|
||||
const ok = await confirm({ title: i18n.t('system.useldapmanageme.s9724378b'), description: `确定删除 ${dn}?`, confirmText: i18n.t('kubernetes.storage.delete2'), variant: 'destructive' });
|
||||
const ok = await confirm({ title: i18n.t('删除 LDAP 条目'), description: `确定删除 ${dn}?`, confirmText: i18n.t('kubernetes.storage.delete2'), variant: 'destructive' });
|
||||
if (!ok) return;
|
||||
}
|
||||
try {
|
||||
@@ -190,7 +190,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
await ldapApi.updateUser({ dn: editLdapUser.dn, ...editLdapForm });
|
||||
setEditLdapUser(null);
|
||||
await loadLdapOUUsers(selectedOUDN);
|
||||
} catch (e) { toast.error(e?.message || i18n.t('common.profilepagetsx.s5badb3ba')); }
|
||||
} catch (e) { toast.error(e?.message || i18n.t('修改失败')); }
|
||||
};
|
||||
|
||||
/** LDAP 账号验证测试 // Logan.Li */
|
||||
@@ -201,7 +201,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
const res = await ldapApi.testConnection({ test_user: ldapTestUser, test_password: ldapTestPass });
|
||||
setLdapUserTestResult(res);
|
||||
} catch (e) {
|
||||
setLdapUserTestResult({ success: false, message: e?.message || i18n.t('system.useldapmanageme.se441b11e') });
|
||||
setLdapUserTestResult({ success: false, message: e?.message || i18n.t('验证失败') });
|
||||
} finally { setLdapUserTesting(false); }
|
||||
};
|
||||
|
||||
@@ -234,11 +234,11 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
} else if (opts?.importAll) {
|
||||
selected = ldapUsers;
|
||||
} else {
|
||||
toast.error(i18n.t('system.useldapmanageme.sa8ca9651'));
|
||||
toast.error(i18n.t('请至少选择一个用户'));
|
||||
return;
|
||||
}
|
||||
if (selected.length === 0) {
|
||||
toast.error(i18n.t('system.useldapmanageme.sd196a1c0'));
|
||||
toast.error(i18n.t('请至少选择一个用户'));
|
||||
return;
|
||||
}
|
||||
setImporting(true);
|
||||
@@ -265,7 +265,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
await onUsersChanged();
|
||||
} catch (error: unknown) {
|
||||
const errMsg = error instanceof Error ? error.message : i18n.t('monitor.dashboard.agent.toast.unknownError');
|
||||
const result = { code: 500, message: i18n.t('system.useldapmanageme.s45332d13') + errMsg };
|
||||
const result = { code: 500, message: i18n.t('导入失败: ') + errMsg };
|
||||
if (opts?.setResult) {
|
||||
opts.setResult(result);
|
||||
} else {
|
||||
|
||||
@@ -26,10 +26,10 @@ import i18n from '@/i18n';
|
||||
|
||||
// 定时任务类型定义 // Logan.Li
|
||||
const jobTypes = [
|
||||
{ value: 'shell', label: 'Shell', desc: i18n.t('task.cronjobformdial.s570531a7') },
|
||||
{ value: 'python', label: 'Python', desc: i18n.t('task.cronjobformdial.s021fae85') },
|
||||
{ value: 'powershell', label: 'PowerShell', desc: i18n.t('task.cronjobformdial.s783cca2d') },
|
||||
{ value: 'command', label: i18n.t('task.cronjobformdial.sad6526bb'), desc: i18n.t('task.cronjobformdial.s492a4c28') },
|
||||
{ value: 'shell', label: 'Shell', desc: i18n.t('关联脚本库中的 Shell 脚本') },
|
||||
{ value: 'python', label: 'Python', desc: i18n.t('关联脚本库中的 Python 脚本') },
|
||||
{ value: 'powershell', label: 'PowerShell', desc: i18n.t('关联脚本库中的 PowerShell 脚本') },
|
||||
{ value: 'command', label: i18n.t('自定义命令'), desc: i18n.t('手动输入命令或脚本路径') },
|
||||
];
|
||||
|
||||
const scriptJobTypes = ['shell', 'python', 'powershell'];
|
||||
@@ -121,12 +121,12 @@ export function CronJobFormDialog({
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!form.name || !form.cron_expr) {
|
||||
toast.error(i18n.t('task.cronjobformdial.s69fb01d7'));
|
||||
toast.error(i18n.t('请填写任务名称和 Cron 表达式'));
|
||||
return;
|
||||
}
|
||||
// 脚本类型必须选关联脚本 // Logan.Li
|
||||
if (scriptJobTypes.includes(form.type) && !form.script_id) {
|
||||
toast.error(i18n.t('task.cronjobformdial.sd4df2957'));
|
||||
toast.error(i18n.t('请填写任务名称和 Cron 表达式'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -141,10 +141,10 @@ export function CronJobFormDialog({
|
||||
};
|
||||
if (editJob) {
|
||||
await cronJobApi.updateJob(editJob.id, payload);
|
||||
toast.success(i18n.t('task.cronjobformdial.s8398c31d'));
|
||||
toast.success(i18n.t('任务更新成功'));
|
||||
} else {
|
||||
await cronJobApi.createJob(payload);
|
||||
toast.success(i18n.t('task.cronjobformdial.s3799bdae'));
|
||||
toast.success(i18n.t('任务更新成功'));
|
||||
}
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
@@ -160,7 +160,7 @@ export function CronJobFormDialog({
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{editJob ? i18n.t('automation.editCronJob') : i18n.t('task.cronjobformdial.s1b9746cb')}</DialogTitle>
|
||||
<DialogTitle>{editJob ? i18n.t('automation.editCronJob') : i18n.t('编辑定时任务')}</DialogTitle>
|
||||
<DialogDescription className="text-[var(--dg-text-secondary)]"> {i18n.t('task.cronjobformdial.s2e10ee70')} </DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1">
|
||||
@@ -170,7 +170,7 @@ export function CronJobFormDialog({
|
||||
<Input
|
||||
value={form.name}
|
||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||
placeholder={i18n.t('task.cronjobformdial.s2c69d350')}
|
||||
placeholder={i18n.t('例如: 数据库备份')}
|
||||
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
|
||||
/>
|
||||
</div>
|
||||
@@ -181,7 +181,7 @@ export function CronJobFormDialog({
|
||||
<Textarea
|
||||
value={form.description}
|
||||
onChange={(e) => setForm({ ...form, description: e.target.value })}
|
||||
placeholder={i18n.t('task.cronjobformdial.s405de06b')}
|
||||
placeholder={i18n.t('例如: 数据库备份')}
|
||||
rows={2}
|
||||
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
|
||||
/>
|
||||
@@ -199,7 +199,7 @@ export function CronJobFormDialog({
|
||||
/>
|
||||
<Select onValueChange={(v) => setForm({ ...form, cron_expr: v })}>
|
||||
<SelectTrigger className="w-48 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1">
|
||||
<SelectValue placeholder={i18n.t('task.cronjobformdial.s1b054b19')} />
|
||||
<SelectValue placeholder={i18n.t('快速选择')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
||||
<SelectItem value="*/5 * * * *" className="text-[var(--dg-text-primary)]"> {i18n.t('task.cronJob.cron.every5min')} </SelectItem>
|
||||
@@ -259,7 +259,7 @@ export function CronJobFormDialog({
|
||||
onValueChange={handleSelectScript}
|
||||
>
|
||||
<SelectTrigger className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1">
|
||||
<SelectValue placeholder={i18n.t('task.cronjobformdial.s3e4f7c4d')} />
|
||||
<SelectValue placeholder={i18n.t('选择脚本库中的脚本...')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
||||
{filteredScripts.map(sc => (
|
||||
@@ -284,7 +284,7 @@ export function CronJobFormDialog({
|
||||
</span>
|
||||
</div>
|
||||
<pre className="max-h-48 overflow-auto rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] p-3 text-xs font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all">
|
||||
{selectedScript.content || i18n.t('task.cronjobformdial.s331ff82e')}
|
||||
{selectedScript.content || i18n.t('(空脚本)')}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
@@ -311,7 +311,7 @@ export function CronJobFormDialog({
|
||||
onClick={handleSave}
|
||||
disabled={submitting}
|
||||
>
|
||||
{submitting ? i18n.t('system.savingDot') : editJob ? i18n.t('cloud.saveChanges') : i18n.t('monitor.sitemonitortsx.s6ef95fe9')}
|
||||
{submitting ? i18n.t('system.savingDot') : editJob ? i18n.t('cloud.saveChanges') : i18n.t('保存中...')}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
@@ -121,7 +121,7 @@ export function CronJobManager() {
|
||||
const handleToggleJob = async (id: number) => {
|
||||
try {
|
||||
await cronJobApi.toggleJob(id);
|
||||
toast.success(i18n.t('task.cronjobmanagert.sa925eb6b'));
|
||||
toast.success(i18n.t('状态已切换'));
|
||||
refreshData();
|
||||
} catch (error) {
|
||||
console.error('Failed to toggle job:', error);
|
||||
@@ -157,7 +157,7 @@ export function CronJobManager() {
|
||||
if (!ok) return;
|
||||
try {
|
||||
await cronJobApi.deleteJob(job.id);
|
||||
toast.success(i18n.t('monitor.sitemonitortsx.sb2ae04aa'));
|
||||
toast.success(i18n.t('状态已切换'));
|
||||
refreshData();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete job:', error);
|
||||
@@ -178,7 +178,7 @@ export function CronJobManager() {
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedIds.length === 0) return;
|
||||
const ok = await _confirm({
|
||||
title: i18n.t('task.cronjobmanagert.sc247b256'),
|
||||
title: i18n.t('删除定时任务'),
|
||||
description: `确定删除选中的 ${selectedIds.length} 个任务吗?此操作不可恢复。`,
|
||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||
variant: 'destructive',
|
||||
@@ -203,7 +203,7 @@ export function CronJobManager() {
|
||||
<div className="relative flex-1 min-w-[180px] max-w-md">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
||||
<Input
|
||||
placeholder={i18n.t('task.cronjobmanagert.safab8783')}
|
||||
placeholder={i18n.t('搜索名称、描述、脚本…')}
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-10 dg-input h-9"
|
||||
@@ -224,7 +224,7 @@ export function CronJobManager() {
|
||||
<SelectValue placeholder={i18n.t('k8s.clusters.statusHealthy')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all"> {i18n.t('task.cronjobmanagert.s07080e5a')} </SelectItem>
|
||||
<SelectItem value="all"> {i18n.t('状态')} </SelectItem>
|
||||
<SelectItem value="healthy"> {i18n.t('agent.heartbeatNormal')} </SelectItem>
|
||||
<SelectItem value="failed"> {i18n.t('monitor.siteProtocol.tcp.lastFail')} </SelectItem>
|
||||
</SelectContent>
|
||||
@@ -276,7 +276,7 @@ export function CronJobManager() {
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('automation.cronJobs')}
|
||||
subtitle={i18n.t('task.cronjobmanagert.sfb75a12d')}
|
||||
subtitle={i18n.t('Cron 调度 · 脚本执行 · 内置系统任务')}
|
||||
icon={<Clock className="h-5 w-5" />}
|
||||
tabs={pageTabs}
|
||||
activeTab={activeTab}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function RemoteExecPage() {
|
||||
try {
|
||||
const res = await serverApi.getServers({ page: 1, page_size: 500, keyword });
|
||||
setServers(((res as JsonData)?.list as RemoteServer[]) || []);
|
||||
} catch { toast.error(i18n.t('task.remoteexecpaget.s68755a4d')); }
|
||||
} catch { toast.error(i18n.t('加载服务器列表失败')); }
|
||||
finally { setLoading(false); }
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -64,10 +64,10 @@ export function RemoteExecPage() {
|
||||
};
|
||||
|
||||
const doExec = async () => {
|
||||
if (!command.trim()) { toast.error(i18n.t('agent.agentmonitortsx.s9358aada')); return; }
|
||||
if (selCount === 0) { toast.error(i18n.t('task.remoteexecpaget.se62f41c4')); return; }
|
||||
if (!command.trim()) { toast.error(i18n.t('请输入要执行的命令')); return; }
|
||||
if (selCount === 0) { toast.error(i18n.t('请至少选择一台主机')); return; }
|
||||
const ok = await _confirm({
|
||||
title: i18n.t('task.remoteexecpaget.s110b7142'),
|
||||
title: i18n.t('确认批量执行命令'),
|
||||
description: `将在 ${selCount} 台主机上执行该命令,请确认命令安全:\n\n${command}`,
|
||||
confirmText: i18n.t('deploy.label.execute'), variant: 'destructive',
|
||||
});
|
||||
@@ -83,9 +83,9 @@ export function RemoteExecPage() {
|
||||
};
|
||||
|
||||
const doUpload = async () => {
|
||||
if (!file) { toast.error(i18n.t('task.remoteexecpaget.s68ea13ee')); return; }
|
||||
if (!remotePath.trim()) { toast.error(i18n.t('task.remoteexecpaget.sb68231b8')); return; }
|
||||
if (selCount === 0) { toast.error(i18n.t('task.remoteexecpaget.se62f41c4')); return; }
|
||||
if (!file) { toast.error(i18n.t('请选择要上传的文件')); return; }
|
||||
if (!remotePath.trim()) { toast.error(i18n.t('请填写远程目标路径')); return; }
|
||||
if (selCount === 0) { toast.error(i18n.t('请至少选择一台主机')); return; }
|
||||
const dst = remotePath.trim().endsWith('/') ? remotePath.trim() + file.name : remotePath.trim();
|
||||
setRunning(true); setUploadResults([]);
|
||||
try {
|
||||
@@ -101,7 +101,7 @@ export function RemoteExecPage() {
|
||||
<PageShell
|
||||
variant="workspace"
|
||||
title={i18n.t('automation.remoteExec')}
|
||||
subtitle={i18n.t('task.remoteexecpaget.s123ad5f6')}
|
||||
subtitle={i18n.t('关联主机后批量执行命令 / 上传文件(Go-native SSH)')}
|
||||
icon={<Terminal className="h-5 w-5" />}
|
||||
contentClassName="flex-1 min-h-0"
|
||||
loading={loading}
|
||||
@@ -119,7 +119,7 @@ export function RemoteExecPage() {
|
||||
<CardTitle className="text-sm flex items-center justify-between text-[var(--dg-text-primary)]">
|
||||
<span className="flex items-center gap-2"><ServerIcon className="h-4 w-4 dg-text-blue" /> {i18n.t('automation.remoteSelectHost')} </span>
|
||||
<Input
|
||||
placeholder={i18n.t('task.remoteexecpaget.s253acd21')}
|
||||
placeholder={i18n.t('搜索 主机名/IP')}
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && load()}
|
||||
@@ -131,7 +131,7 @@ export function RemoteExecPage() {
|
||||
{servers.length === 0 ? (
|
||||
<PageEmpty
|
||||
title={i18n.t('dashboard.serversStatus.empty')}
|
||||
description={i18n.t('task.remoteexecpaget.s0afbf1fc')}
|
||||
description={i18n.t('请先在「服务器管理」添加')}
|
||||
className="py-10"
|
||||
/>
|
||||
) : (
|
||||
@@ -149,7 +149,7 @@ export function RemoteExecPage() {
|
||||
<div className="text-[10px] text-[var(--dg-text-muted)] font-mono">{s.ip} · {s.username || 'root'}</div>
|
||||
</div>
|
||||
{s.has_auth === false
|
||||
? <Badge className="bg-amber-500/20 dg-text-yellow text-[10px]"> {i18n.t('task.remoteexecpaget.s152f5300')} </Badge>
|
||||
? <Badge className="bg-amber-500/20 dg-text-yellow text-[10px]"> {i18n.t('密钥')} </Badge>
|
||||
: <Badge className="bg-emerald-500/20 dg-text-green text-[10px]">{s.auth_type === 'key' ? i18n.t('system.credentialKey') : i18n.t('system.passwordLabel')}</Badge>}
|
||||
</label>
|
||||
))}
|
||||
@@ -187,7 +187,7 @@ export function RemoteExecPage() {
|
||||
value={command}
|
||||
onChange={(e) => setCommand(e.target.value)}
|
||||
rows={5}
|
||||
placeholder={i18n.t('task.remoteexecpaget.s76628808')}
|
||||
placeholder={i18n.t('输入要在选中主机上执行的 shell 命令,例如:df -h | head -5')}
|
||||
className="w-full bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md px-3 py-2 text-xs font-mono text-[var(--dg-text-primary)] resize-none"
|
||||
/>
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -213,7 +213,7 @@ export function RemoteExecPage() {
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<span className="text-xs dg-text-secondary"> {i18n.t('task.remoteexecpaget.sb47f0323')} </span>
|
||||
<Input value={remotePath} onChange={(e) => setRemotePath(e.target.value)} placeholder={i18n.t('task.remoteexecpaget.sd4b44a36')}
|
||||
<Input value={remotePath} onChange={(e) => setRemotePath(e.target.value)} placeholder={i18n.t('/tmp/ 或 /opt/app/config.yaml')}
|
||||
className="h-8 text-xs font-mono dg-input" />
|
||||
</div>
|
||||
<Button onClick={doUpload} disabled={running} className="dg-btn-primary h-8 text-xs">
|
||||
@@ -238,7 +238,7 @@ export function RemoteExecPage() {
|
||||
</Badge>
|
||||
</div>
|
||||
<pre className="text-[10px] font-mono dg-text-secondary whitespace-pre-wrap break-all max-h-32 overflow-y-auto">
|
||||
{r.error || r.output || i18n.t('task.remoteexecpaget.s1a63831c')}
|
||||
{r.error || r.output || i18n.t('(无输出)')}
|
||||
</pre>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -52,7 +52,7 @@ export function ScriptManager() {
|
||||
const items = (res as JsonData)?.list || [];
|
||||
setScripts(items.map(mapScript));
|
||||
} catch {
|
||||
toast.error(i18n.t('task.scriptmanagerts.s0fa2607f'));
|
||||
toast.error(i18n.t('获取脚本列表失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export function ScriptManager() {
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!formData.name.trim() || !formData.content.trim()) {
|
||||
toast.error(i18n.t('task.scriptmanagerts.s54c121b2'));
|
||||
toast.error(i18n.t('获取脚本列表失败'));
|
||||
return;
|
||||
}
|
||||
const payload = {
|
||||
@@ -127,10 +127,10 @@ export function ScriptManager() {
|
||||
try {
|
||||
if (editingId !== null) {
|
||||
await scriptApi.updateScript(editingId, payload);
|
||||
toast.success(i18n.t('task.scriptmanagerts.sdb91e3c4'));
|
||||
toast.success(i18n.t('脚本更新成功'));
|
||||
} else {
|
||||
await scriptApi.createScript(payload);
|
||||
toast.success(i18n.t('task.scriptmanagerts.s4aac59ea'));
|
||||
toast.success(i18n.t('脚本更新成功'));
|
||||
}
|
||||
setEditorOpen(false);
|
||||
fetchScripts();
|
||||
@@ -194,7 +194,7 @@ export function ScriptManager() {
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedIds.length === 0) return;
|
||||
const ok = await _confirm({
|
||||
title: i18n.t('task.scriptmanagerts.sd730a0fc'),
|
||||
title: i18n.t('删除脚本'),
|
||||
description: `确定删除选中的 ${selectedIds.length} 个脚本吗?此操作不可恢复。`,
|
||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||
variant: 'destructive',
|
||||
@@ -242,7 +242,7 @@ export function ScriptManager() {
|
||||
<PageShell
|
||||
variant="list"
|
||||
title={i18n.t('automation.scripts')}
|
||||
subtitle={i18n.t('task.scriptmanagerts.sed1decc7')}
|
||||
subtitle={i18n.t('脚本编辑与管理')}
|
||||
icon={<FileCode className="h-5 w-5" />}
|
||||
toolbar={toolbar}
|
||||
loading={loading}
|
||||
@@ -295,8 +295,8 @@ export function ScriptManager() {
|
||||
|
||||
{filteredScripts.length === 0 ? (
|
||||
<PageEmpty
|
||||
title={scripts.length === 0 ? i18n.t('automation.noScript') : i18n.t('task.scriptmanagerts.s83533de7')}
|
||||
description={scripts.length === 0 ? i18n.t('task.scriptmanagerts.sc31b6baa') : undefined}
|
||||
title={scripts.length === 0 ? i18n.t('automation.noScript') : i18n.t('暂无脚本')}
|
||||
description={scripts.length === 0 ? i18n.t('点击「新建脚本」创建第一个') : undefined}
|
||||
action={scripts.length === 0 && canWrite ? (
|
||||
<Button className="dg-btn-primary" onClick={openCreate}>
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
|
||||
@@ -42,7 +42,7 @@ export function CopyButton({
|
||||
} else {
|
||||
toast({
|
||||
title: i18n.t('monitor.logPanel.copyFailed'),
|
||||
description: i18n.t('common.copybuttontsx.s76597b46'),
|
||||
description: i18n.t('请手动选中内容后复制'),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user