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));
|
setRules(asList(rulesRes));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
toast.error(i18n.t('agent.agentalertstsx.s7ffaa448'));
|
toast.error(i18n.t('加载告警数据失败'));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ export function AgentAlerts() {
|
|||||||
|
|
||||||
// ============ 告警事件 ============
|
// ============ 告警事件 ============
|
||||||
const handleResolve = async (id: number) => {
|
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;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await agentApi.resolveAlert(id);
|
await agentApi.resolveAlert(id);
|
||||||
toast.success(i18n.t('agent.agentalertstsx.s0e23522e'));
|
toast.success(i18n.t('告警已恢复'));
|
||||||
loadData();
|
loadData();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(err?.message || i18n.t('cloud.operationFailed'));
|
toast.error(err?.message || i18n.t('cloud.operationFailed'));
|
||||||
@@ -88,11 +88,11 @@ export function AgentAlerts() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteRule = async (id: number) => {
|
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;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await agentApi.deleteRule(id);
|
await agentApi.deleteRule(id);
|
||||||
toast.success(i18n.t('agent.agentalertstsx.s8b2798c4'));
|
toast.success(i18n.t('告警已恢复'));
|
||||||
loadData();
|
loadData();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(err?.message || i18n.t('kubernetes.msg.deleteFailed2'));
|
toast.error(err?.message || i18n.t('kubernetes.msg.deleteFailed2'));
|
||||||
@@ -114,7 +114,7 @@ export function AgentAlerts() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">Agent 告警</h2>
|
<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>
|
</div>
|
||||||
<Button variant="outline" size="sm" onClick={loadData} disabled={loading} className="dg-input text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)]">
|
<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' : ''}`} />
|
<RefreshCw className={`h-4 w-4 mr-1.5 ${loading ? 'animate-spin' : ''}`} />
|
||||||
@@ -160,7 +160,7 @@ export function AgentAlerts() {
|
|||||||
<Card className="dg-card">
|
<Card className="dg-card">
|
||||||
<CardContent className="flex flex-col items-center justify-center py-16">
|
<CardContent className="flex flex-col items-center justify-center py-16">
|
||||||
<CheckCircle className="h-10 w-10 text-emerald-500 mb-3" />
|
<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>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
@@ -178,7 +178,7 @@ export function AgentAlerts() {
|
|||||||
{severityBadge(alert.severity)}
|
{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>
|
<span className="font-medium text-[var(--dg-text-primary)]">{alert.rule_name || alert.name || alert.title || i18n.t('monitor.hostDashboard.alert')}</span>
|
||||||
</div>
|
</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">
|
<div className="flex items-center gap-4 mt-2 text-xs dg-text-muted flex-wrap">
|
||||||
<span className="inline-flex items-center gap-1">
|
<span className="inline-flex items-center gap-1">
|
||||||
<Cpu className="h-3 w-3" />
|
<Cpu className="h-3 w-3" />
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export function AgentMonitor() {
|
|||||||
if (fresh) setSelectedHost(fresh);
|
if (fresh) setSelectedHost(fresh);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!silent) toast.error(i18n.t('agent.agentmonitortsx.s5760f667'));
|
if (!silent) toast.error(i18n.t('加载主机列表失败'));
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -100,7 +100,7 @@ export function AgentMonitor() {
|
|||||||
// 提交远程命令(直连 SSH 即时返回)
|
// 提交远程命令(直连 SSH 即时返回)
|
||||||
const submitCommand = async () => {
|
const submitCommand = async () => {
|
||||||
if (!cmdCommand.trim()) {
|
if (!cmdCommand.trim()) {
|
||||||
toast.error(i18n.t('agent.agentmonitortsx.s9358aada'));
|
toast.error(i18n.t('请输入要执行的命令'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCmdSubmitting(true);
|
setCmdSubmitting(true);
|
||||||
@@ -114,7 +114,7 @@ export function AgentMonitor() {
|
|||||||
const resData = (res?.data ?? {}) as Record<string, unknown>;
|
const resData = (res?.data ?? {}) as Record<string, unknown>;
|
||||||
setCmdResult({
|
setCmdResult({
|
||||||
status: res?.code === 200 ? 'completed' : 'failed',
|
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,
|
error: resData.error as string | undefined,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} 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)]"
|
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' : ''}`} />
|
<RefreshCw className={`h-4 w-4 mr-1.5 ${refreshing ? 'animate-spin' : ''}`} />
|
||||||
{t('agent.agentmonitortsx.s2b3c4d5e')}
|
{t('例如:free -m && df -h')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -162,7 +162,7 @@ export function AgentMonitor() {
|
|||||||
className="bg-blue-600 hover:bg-blue-700 text-white"
|
className="bg-blue-600 hover:bg-blue-700 text-white"
|
||||||
>
|
>
|
||||||
<Rocket className="h-4 w-4 mr-1.5" />
|
<Rocket className="h-4 w-4 mr-1.5" />
|
||||||
{t('agent.agentmonitortsx.s3c4d5e6f')}
|
{t('例如:free -m && df -h')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -325,7 +325,7 @@ export function AgentMonitor() {
|
|||||||
<Textarea
|
<Textarea
|
||||||
value={cmdCommand}
|
value={cmdCommand}
|
||||||
onChange={(e) => setCmdCommand(e.target.value)}
|
onChange={(e) => setCmdCommand(e.target.value)}
|
||||||
placeholder={i18n.t('agent.agentmonitortsx.s6e62a5b0')}
|
placeholder={i18n.t('例如:free -m && df -h')}
|
||||||
rows={3}
|
rows={3}
|
||||||
className="bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-sm resize-none"
|
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>
|
</Badge>
|
||||||
</div>
|
</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">
|
<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>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!ruleForm.name.trim()) {
|
if (!ruleForm.name.trim()) {
|
||||||
toast.error(i18n.t('agent.agentruledialog.s40f3f17d'));
|
toast.error(i18n.t('请输入规则名称'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
@@ -107,8 +107,8 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
|||||||
<Dialog open={open} onOpenChange={(v) => { if (!v) onOpenChange(false); }}>
|
<Dialog open={open} onOpenChange={(v) => { if (!v) onOpenChange(false); }}>
|
||||||
<DialogContent className="max-w-md dg-card text-[var(--dg-text-primary)]">
|
<DialogContent className="max-w-md dg-card text-[var(--dg-text-primary)]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-[var(--dg-text-primary)]">{editingRule ? i18n.t('monitor.editRule') : i18n.t('agent.agentruledialog.sf10ed468')}</DialogTitle>
|
<DialogTitle className="text-[var(--dg-text-primary)]">{editingRule ? i18n.t('monitor.editRule') : i18n.t('编辑规则')}</DialogTitle>
|
||||||
<DialogDescription className="dg-text-secondary"> {i18n.t('agent.agentruledialog.s0cc0f608')} </DialogDescription>
|
<DialogDescription className="dg-text-secondary"> {i18n.t('>阈值 {ruleForm.metric !== ')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
@@ -117,7 +117,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
|||||||
<Input
|
<Input
|
||||||
value={ruleForm.name}
|
value={ruleForm.name}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
||||||
placeholder={i18n.t('agent.agentruledialog.s5a0f7e3e')}
|
placeholder={i18n.t('例如:CPU 使用率告警')}
|
||||||
className="h-9 dg-input"
|
className="h-9 dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +154,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
|||||||
{ruleForm.metric !== 'offline' && (
|
{ruleForm.metric !== 'offline' && (
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div className="space-y-1.5">
|
<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 })}>
|
<Select value={ruleForm.operator} onValueChange={(v) => setRuleForm({ ...ruleForm, operator: v })}>
|
||||||
<SelectTrigger className="h-9 dg-input">
|
<SelectTrigger className="h-9 dg-input">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
@@ -180,24 +180,24 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
|||||||
|
|
||||||
{ruleForm.metric === 'port_down' && (
|
{ruleForm.metric === 'port_down' && (
|
||||||
<div className="space-y-1.5">
|
<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
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
value={ruleForm.port}
|
value={ruleForm.port}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, port: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, port: e.target.value })}
|
||||||
placeholder={i18n.t('agent.agentruledialog.s77565e5d')}
|
placeholder={i18n.t('例如:8080')}
|
||||||
className="h-9 dg-input"
|
className="h-9 dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
<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
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
value={ruleForm.duration}
|
value={ruleForm.duration}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, duration: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, duration: e.target.value })}
|
||||||
placeholder={i18n.t('agent.agentruledialog.sd140c78d')}
|
placeholder={i18n.t('例如:CPU 使用率告警')}
|
||||||
className="h-9 dg-input"
|
className="h-9 dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export function HostDetailDialog({
|
|||||||
<InfoCell label={i18n.t('agent.agentIp')} value={host.ip || '--'} />
|
<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.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.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>
|
</div>
|
||||||
|
|
||||||
{/* 趋势图 */}
|
{/* 趋势图 */}
|
||||||
|
|||||||
@@ -10,23 +10,23 @@ import i18n from '@/i18n';
|
|||||||
// 主机监控指标(与后端 alert_engine 对齐)// Logan.Li
|
// 主机监控指标(与后端 alert_engine 对齐)// Logan.Li
|
||||||
export const METRIC_OPTIONS = [
|
export const METRIC_OPTIONS = [
|
||||||
{ value: 'cpu', label: i18n.t('kubernetes.cluster.cpuUsage'), icon: Cpu },
|
{ 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', label: i18n.t('kubernetes.cluster.memoryUsage'), icon: MemoryStick },
|
||||||
{ value: 'mem_available', label: i18n.t('monitor.hostmonitortsx.sa23fcda0'), icon: MemoryStick },
|
{ value: 'mem_available', label: i18n.t('可用内存(GB)'), icon: MemoryStick },
|
||||||
{ value: 'swap', label: i18n.t('agent.agentalerthelpe.sa2f9101c'), icon: MemoryStick },
|
{ value: 'swap', label: i18n.t('Swap 使用率'), icon: MemoryStick },
|
||||||
{ value: 'load1', label: i18n.t('agent.agentalerthelpe.sf23ce82f'), icon: Gauge },
|
{ value: 'load1', label: i18n.t('1分钟负载'), icon: Gauge },
|
||||||
{ value: 'disk', label: i18n.t('monitor.hostDisk'), icon: HardDrive },
|
{ value: 'disk', label: i18n.t('monitor.hostDisk'), icon: HardDrive },
|
||||||
{ value: 'disk_inode', label: i18n.t('agent.agentalerthelpe.sf7eadeca'), icon: HardDrive },
|
{ value: 'disk_inode', label: i18n.t('Inode 使用率'), icon: HardDrive },
|
||||||
{ value: 'disk_io_util', label: i18n.t('agent.agentalerthelpe.s565a0e4d'), icon: HardDrive },
|
{ value: 'disk_io_util', label: i18n.t('磁盘 IO 利用率'), icon: HardDrive },
|
||||||
{ value: 'tcp_established', label: i18n.t('agent.agentalerthelpe.s6d9639e8'), icon: Network },
|
{ value: 'tcp_established', label: i18n.t('TCP 已建立'), icon: Network },
|
||||||
{ value: 'tcp_time_wait', label: 'TCP TIME_WAIT', icon: Network },
|
{ value: 'tcp_time_wait', label: 'TCP TIME_WAIT', icon: Network },
|
||||||
{ value: 'tcp_close_wait', label: 'TCP CLOSE_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_rx_bps', label: i18n.t('monitor.hostNetIn'), icon: Network },
|
||||||
{ value: 'net_tx_bps', label: i18n.t('monitor.hostNetOut'), 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: 'fd', label: i18n.t('monitor.hostFileDescriptor'), icon: Activity },
|
||||||
{ value: 'offline', label: i18n.t('agent.agentalerthelpe.s8ed49aa6'), icon: WifiOff },
|
{ value: 'offline', label: i18n.t('主机离线'), icon: WifiOff },
|
||||||
{ value: 'port_down', label: i18n.t('agent.agentalerthelpe.sf62ce662'), icon: Network },
|
{ value: 'port_down', label: i18n.t('端口不通'), icon: Network },
|
||||||
{ value: 'health_probe', label: i18n.t('kubernetes.container.probes'), icon: Timer },
|
{ 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 (
|
return (
|
||||||
<div className="flex gap-2 rounded-lg bg-red-500/10 border border-red-500/30 p-3">
|
<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" />
|
<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>
|
</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.duration && <div className="text-[10px] dg-text-muted">{i18n.t('aiops.durationLabel', { duration: item.duration })}</div>}
|
||||||
{(item.toolName === 'analyze_output' || looksLikeMarkdown(item.output)) ? (
|
{(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">
|
<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>
|
</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 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。`,
|
: `CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`登录 ${target} 执行 top/htop 定位高 CPU 进程`,
|
`登录 ${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,
|
similarCases: 0,
|
||||||
confidence: 0,
|
confidence: 0,
|
||||||
};
|
};
|
||||||
@@ -68,9 +68,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
|||||||
: `内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。`,
|
: `内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`检查 ${target} 上的内存占用最高的进程`,
|
`检查 ${target} 上的内存占用最高的进程`,
|
||||||
i18n.t('aiops.analyzerhelpers.s3166ba9e'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.sdc67cc47'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.s20eb7092'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
],
|
],
|
||||||
similarCases: 0,
|
similarCases: 0,
|
||||||
confidence: 0,
|
confidence: 0,
|
||||||
@@ -86,9 +86,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
|||||||
: `磁盘空间告警,如不及时清理可能导致服务异常。`,
|
: `磁盘空间告警,如不及时清理可能导致服务异常。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`清理 ${target} 上 30 天前的日志文件`,
|
`清理 ${target} 上 30 天前的日志文件`,
|
||||||
i18n.t('aiops.analyzerhelpers.s187f6268'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.sb9cbe0b9'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.s4438245e'),
|
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`,
|
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,
|
similarCases: 0,
|
||||||
@@ -105,9 +105,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
|||||||
: `网络延迟偏高,可能影响用户体验,建议排查网络链路。`,
|
: `网络延迟偏高,可能影响用户体验,建议排查网络链路。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`检查 ${target} 的网络连接和带宽使用情况`,
|
`检查 ${target} 的网络连接和带宽使用情况`,
|
||||||
i18n.t('aiops.analyzerhelpers.s2dcf7289'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.sb240d756'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.s1e860afd'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
],
|
],
|
||||||
similarCases: 0,
|
similarCases: 0,
|
||||||
confidence: 0,
|
confidence: 0,
|
||||||
@@ -123,9 +123,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
|||||||
: `服务可用性下降,部分功能可能受影响。`,
|
: `服务可用性下降,部分功能可能受影响。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`立即检查 ${target} 的服务状态: systemctl status <service>`,
|
`立即检查 ${target} 的服务状态: systemctl status <service>`,
|
||||||
i18n.t('aiops.analyzerhelpers.sa9e9dc2f'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.s902739be'),
|
i18n.t('检查是否有异常定时任务或批处理任务在运行'),
|
||||||
i18n.t('aiops.analyzerhelpers.sdef735d5'),
|
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`,
|
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,
|
similarCases: 0,
|
||||||
@@ -141,9 +141,9 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
|||||||
: `该告警需要关注,持续恶化可能影响系统稳定性。`,
|
: `该告警需要关注,持续恶化可能影响系统稳定性。`,
|
||||||
recommendations: [
|
recommendations: [
|
||||||
`查看 ${target} 的监控仪表盘,确认指标趋势`,
|
`查看 ${target} 的监控仪表盘,确认指标趋势`,
|
||||||
i18n.t('aiops.analyzerhelpers.s970501e5'),
|
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||||
i18n.t('aiops.analyzerhelpers.s4a3f985d'),
|
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||||
i18n.t('aiops.analyzerhelpers.s10441f9f'),
|
i18n.t('检查对应时间段的系统日志和应用日志'),
|
||||||
],
|
],
|
||||||
similarCases: 0,
|
similarCases: 0,
|
||||||
confidence: 0,
|
confidence: 0,
|
||||||
@@ -173,10 +173,10 @@ export function mapAlertEvent(event: JsonData): AlertItem {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: String(event.id),
|
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',
|
severity: event.severity === 'critical' ? 'critical' : event.severity === 'warning' ? 'warning' : 'info',
|
||||||
status: event.status === 'firing' ? 'active' : 'resolved',
|
status: event.status === 'firing' ? 'active' : 'resolved',
|
||||||
source: event.target || i18n.t('aiops.analyzerhelpers.s1b9b6c32'),
|
source: event.target || i18n.t('未知目标'),
|
||||||
metric,
|
metric,
|
||||||
threshold,
|
threshold,
|
||||||
currentValue,
|
currentValue,
|
||||||
|
|||||||
@@ -59,22 +59,22 @@ export function capacityRecommendation(metricKey: string, days: number): string
|
|||||||
const level = days <= 7 ? 'urgent' : days <= 14 ? 'warning' : 'normal';
|
const level = days <= 7 ? 'urgent' : days <= 14 ? 'warning' : 'normal';
|
||||||
const recs: Record<string, Record<string, string>> = {
|
const recs: Record<string, Record<string, string>> = {
|
||||||
urgent: {
|
urgent: {
|
||||||
cpu: i18n.t('aiops.predictutilsts.s4d0bd643'),
|
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||||
memory: i18n.t('aiops.predictutilsts.sb4593f3a'),
|
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||||
disk: i18n.t('aiops.predictutilsts.s6c25383f'),
|
disk: i18n.t('磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志'),
|
||||||
},
|
},
|
||||||
warning: {
|
warning: {
|
||||||
cpu: i18n.t('aiops.predictutilsts.s8ea826f4'),
|
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||||
memory: i18n.t('aiops.predictutilsts.sb08bd5fc'),
|
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||||
disk: i18n.t('aiops.predictutilsts.s4cdda5dc'),
|
disk: i18n.t('磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志'),
|
||||||
},
|
},
|
||||||
normal: {
|
normal: {
|
||||||
cpu: i18n.t('aiops.predictutilsts.sfa295c44'),
|
cpu: i18n.t('CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程'),
|
||||||
memory: i18n.t('aiops.predictutilsts.s7156a4c0'),
|
memory: i18n.t('内存增长趋势明显,建议增加内存或排查内存泄漏'),
|
||||||
disk: i18n.t('aiops.predictutilsts.s0073f3a3'),
|
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 {
|
export function computePredictions(input: ComputePredictionsInput): ComputedPredictions {
|
||||||
const { rawMetrics, serverStats, selectedTimeRange } = input;
|
const { rawMetrics, serverStats, selectedTimeRange } = input;
|
||||||
const horizonHours = TIME_RANGE_HOURS[selectedTimeRange] || 24;
|
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) => {
|
const predictions: PredictionMetric[] = METRIC_DEFS.map((def) => {
|
||||||
@@ -177,18 +177,18 @@ export function trendColorClass(trend: string): string {
|
|||||||
export function buildCapacityInsightPrompt(forecasts: CapacityForecast[]): string {
|
export function buildCapacityInsightPrompt(forecasts: CapacityForecast[]): string {
|
||||||
if (forecasts.length === 0) return '';
|
if (forecasts.length === 0) return '';
|
||||||
const lines = forecasts.map((f) => {
|
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 `- ${f.resource}:当前 ${f.currentUsage}% → 7天后预测 ${f.predictedUsage}%(阈值 ${f.threshold}%),${risk}`;
|
||||||
});
|
});
|
||||||
return [
|
return [
|
||||||
i18n.t('aiops.predictutilsts.s3b46e5a0'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
'',
|
'',
|
||||||
i18n.t('aiops.predictutilsts.s586bac5d'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
...lines,
|
...lines,
|
||||||
'',
|
'',
|
||||||
i18n.t('aiops.predictutilsts.sdf6ebee3'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
i18n.t('aiops.predictutilsts.s534b6893'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
i18n.t('aiops.predictutilsts.saf173e7a'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
i18n.t('aiops.predictutilsts.s4ed1d035'),
|
i18n.t('你是 AIOps 容量规划专家。基于以下服务器资源容量预测数据,给出综合风险评估与可执行的运维建议:'),
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
@@ -83,15 +83,15 @@ function costTrendFromSlope(slope: number): 'up' | 'down' | 'stable' {
|
|||||||
/** 成本优化建议 */
|
/** 成本优化建议 */
|
||||||
export function costRecommendation(trend: 'up' | 'down' | 'stable', ratio: number): string {
|
export function costRecommendation(trend: 'up' | 'down' | 'stable', ratio: number): string {
|
||||||
if (trend === 'up' && ratio >= 0.85) {
|
if (trend === 'up' && ratio >= 0.85) {
|
||||||
return i18n.t('aiops.predictutilsts.sa7d4e3c1');
|
return i18n.t('排查内存泄漏,优化进程内存配置,考虑增加节点');
|
||||||
}
|
}
|
||||||
if (trend === 'up') {
|
if (trend === 'up') {
|
||||||
return i18n.t('aiops.predictutilsts.sb3f5a2d8');
|
return i18n.t('排查内存泄漏,优化进程内存配置,考虑增加节点');
|
||||||
}
|
}
|
||||||
if (trend === 'down') {
|
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 =
|
const allRatio =
|
||||||
summary.predictedMonthEnd > 0 ? summary.monthCost / summary.predictedMonthEnd : 0;
|
summary.predictedMonthEnd > 0 ? summary.monthCost / summary.predictedMonthEnd : 0;
|
||||||
dimensionForecasts.push({
|
dimensionForecasts.push({
|
||||||
dimension: i18n.t('aiops.predictutilsts.sa1b2c3d4'),
|
dimension: i18n.t('清理历史数据和日志,实施数据归档策略,扩容磁盘'),
|
||||||
currentMonth: summary.monthCost,
|
currentMonth: summary.monthCost,
|
||||||
predictedMonthEnd: summary.predictedMonthEnd,
|
predictedMonthEnd: summary.predictedMonthEnd,
|
||||||
dailyAvg: summary.dailyAvg,
|
dailyAvg: summary.dailyAvg,
|
||||||
@@ -302,7 +302,7 @@ export function computeCostPredictions(input: ComputeCostPredictionsInput): Comp
|
|||||||
|
|
||||||
const metric = (rule.metric === 'daily' ? 'daily' : 'monthly') as 'daily' | 'monthly';
|
const metric = (rule.metric === 'daily' ? 'daily' : 'monthly') as 'daily' | 'monthly';
|
||||||
const ruleProvider = String(rule.provider || '');
|
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 current = 0;
|
||||||
let predicted = 0;
|
let predicted = 0;
|
||||||
@@ -339,7 +339,7 @@ export function computeCostPredictions(input: ComputeCostPredictionsInput): Comp
|
|||||||
if (current >= threshold) probability += 25;
|
if (current >= threshold) probability += 25;
|
||||||
probability = Math.max(5, Math.min(92, probability));
|
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) {
|
if (slope > 0.01 && threshold > current) {
|
||||||
const days = (threshold - current) / slope;
|
const days = (threshold - current) / slope;
|
||||||
if (days < 1) timeframe = metric === 'daily' ? i18n.t('aiops.predictutilsts.se5f6g7h8') : i18n.t('aiops.predictutilsts.sf6g7h8i9');
|
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 → 展示标签 / 告警表达式前缀 / 阈值 */
|
/** 指标定义:后端 metric name → 展示标签 / 告警表达式前缀 / 阈值 */
|
||||||
export const METRIC_DEFS = [
|
export const METRIC_DEFS = [
|
||||||
{ key: 'cpu', label: i18n.t('aiops.predictutilsts.s7054bc34'), exprKey: 'cpu_usage', threshold: 85 },
|
{ key: 'cpu', label: i18n.t('CPU使用率'), exprKey: 'cpu_usage', threshold: 85 },
|
||||||
{ key: 'memory', label: i18n.t('aiops.predictutilsts.s82c0d1b0'), exprKey: 'memory_usage', threshold: 85 },
|
{ key: 'memory', label: i18n.t('内存使用率'), exprKey: 'memory_usage', threshold: 85 },
|
||||||
{ key: 'disk', label: i18n.t('aiops.predictutilsts.s4e2d8f91'), exprKey: 'disk_usage', threshold: 90 },
|
{ key: 'disk', label: i18n.t('磁盘使用率'), exprKey: 'disk_usage', threshold: 90 },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const TIME_RANGE_LABELS: Record<string, string> = {
|
export const TIME_RANGE_LABELS: Record<string, string> = {
|
||||||
'1h': i18n.t('aiops.predictutilsts.s75719bb8'),
|
'1h': i18n.t('1小时后'),
|
||||||
'24h': i18n.t('aiops.predictutilsts.sfc78646e'),
|
'24h': i18n.t('24小时后'),
|
||||||
'7d': i18n.t('aiops.predictutilsts.s5b5a820c'),
|
'7d': i18n.t('7天后'),
|
||||||
'30d': i18n.t('aiops.predictutilsts.s933ab0a6'),
|
'30d': i18n.t('30天后'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TIME_RANGE_HOURS: Record<string, number> = {
|
export const TIME_RANGE_HOURS: Record<string, number> = {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.provider || !form.billing_date || !form.cost) {
|
if (!form.provider || !form.billing_date || !form.cost) {
|
||||||
toast.error(i18n.t('cloud.billingrecorddi.sd8a97c17'));
|
toast.error(i18n.t('请填写必填字段'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -92,7 +92,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
|||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-md">
|
<DialogContent className="max-w-md">
|
||||||
<DialogHeader>
|
<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>
|
<DialogDescription> {i18n.t('cloud.billingrecorddi.s09e541fd')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
@@ -130,7 +130,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label className="text-sm text-[var(--dg-text-secondary)]"> {i18n.t('cloud.accountName')} </Label>
|
<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>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export function BillingRuleDialog({ open, onOpenChange, editingRule, onSuccess }
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.name || !form.threshold) {
|
if (!form.name || !form.threshold) {
|
||||||
toast.error(i18n.t('cloud.billingruledial.sd36855b1'));
|
toast.error(i18n.t('请填写规则名称和阈值'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -83,13 +83,13 @@ export function BillingRuleDialog({ open, onOpenChange, editingRule, onSuccess }
|
|||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-md">
|
<DialogContent className="max-w-md">
|
||||||
<DialogHeader>
|
<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>
|
<DialogDescription> {i18n.t('cloud.billingruledial.s75227f20')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div>
|
<div>
|
||||||
<Label className="text-sm text-[var(--dg-text-secondary)]"> {i18n.t('monitor.silenceDialog.ruleNameRequired')} </Label>
|
<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>
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import type { JsonData } from '@/types/common';
|
|||||||
import i18n from '@/i18n';
|
import i18n from '@/i18n';
|
||||||
|
|
||||||
const typeLabels: Record<string, string> = {
|
const typeLabels: Record<string, string> = {
|
||||||
public: i18n.t('server.cloudserverimpo.s7ef31abb'),
|
public: i18n.t('公有云'),
|
||||||
private: i18n.t('cloud.privateCloud'),
|
private: i18n.t('cloud.privateCloud'),
|
||||||
hybrid: i18n.t('cloud.hybridCloud'),
|
hybrid: i18n.t('cloud.hybridCloud'),
|
||||||
};
|
};
|
||||||
@@ -138,7 +138,7 @@ export function PlatformManager() {
|
|||||||
<div className="relative w-72">
|
<div className="relative w-72">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
||||||
<Input
|
<Input
|
||||||
placeholder={i18n.t('cloud.platformmanager.s783a513f')}
|
placeholder={i18n.t('搜索平台名称或编码...')}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
className="pl-9 h-9 dg-input"
|
className="pl-9 h-9 dg-input"
|
||||||
@@ -150,7 +150,7 @@ export function PlatformManager() {
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="all"> {i18n.t('k8s.topology.allTypes')} </SelectItem>
|
<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="private"> {i18n.t('cloud.privateCloud')} </SelectItem>
|
||||||
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -162,7 +162,7 @@ export function PlatformManager() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('cloud.title')}
|
title={i18n.t('cloud.title')}
|
||||||
subtitle={i18n.t('cloud.platformmanager.s7012045f')}
|
subtitle={i18n.t('管理公有云、私有云与混合云平台信息')}
|
||||||
icon={<CloudCog className="h-5 w-5" />}
|
icon={<CloudCog className="h-5 w-5" />}
|
||||||
metrics={
|
metrics={
|
||||||
!loading ? (
|
!loading ? (
|
||||||
@@ -170,7 +170,7 @@ export function PlatformManager() {
|
|||||||
items={[
|
items={[
|
||||||
{ label: i18n.t('system.auditTotal'), value: stats.total, color: 'blue' },
|
{ label: i18n.t('system.auditTotal'), value: stats.total, color: 'blue' },
|
||||||
{ label: i18n.t('system.userActive'), value: stats.active, color: 'green' },
|
{ 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
|
) : undefined
|
||||||
@@ -194,7 +194,7 @@ export function PlatformManager() {
|
|||||||
) : filtered.length === 0 ? (
|
) : filtered.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<CloudCog className="h-12 w-12" />}
|
icon={<CloudCog className="h-12 w-12" />}
|
||||||
title={i18n.t('cloud.platformmanager.sb9f478da')}
|
title={i18n.t('暂无云平台数据')}
|
||||||
action={(
|
action={(
|
||||||
<Button size="sm" className="dg-btn-primary" onClick={openCreate}>
|
<Button size="sm" className="dg-btn-primary" onClick={openCreate}>
|
||||||
<Plus className="h-4 w-4 mr-1" />
|
<Plus className="h-4 w-4 mr-1" />
|
||||||
@@ -261,26 +261,26 @@ export function PlatformManager() {
|
|||||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<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>
|
<DialogDescription className="sr-only"> {i18n.t('aiops.llmModelDesc')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-4 py-2">
|
<div className="space-y-4 py-2">
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<Label> {i18n.t('cloud.platformmanager.seac7fc68')} </Label>
|
<Label> {i18n.t('如:阿里云')} </Label>
|
||||||
<Input
|
<Input
|
||||||
value={formData.name}
|
value={formData.name}
|
||||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||||
placeholder={i18n.t('cloud.platformmanager.sa39d9635')}
|
placeholder={i18n.t('如:阿里云')}
|
||||||
className="dg-input"
|
className="dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<Label> {i18n.t('cloud.platformmanager.se21e278f')} </Label>
|
<Label> {i18n.t('如:阿里云')} </Label>
|
||||||
<Input
|
<Input
|
||||||
value={formData.code}
|
value={formData.code}
|
||||||
onChange={(e) => setFormData({ ...formData, code: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, code: e.target.value })}
|
||||||
placeholder={i18n.t('cloud.platformmanager.s7b09b049')}
|
placeholder={i18n.t('如:阿里云')}
|
||||||
className="dg-input"
|
className="dg-input"
|
||||||
disabled={!!editingItem}
|
disabled={!!editingItem}
|
||||||
/>
|
/>
|
||||||
@@ -294,7 +294,7 @@ export function PlatformManager() {
|
|||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<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="private"> {i18n.t('cloud.privateCloud')} </SelectItem>
|
||||||
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
<SelectItem value="hybrid"> {i18n.t('cloud.hybridCloud')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -314,7 +314,7 @@ export function PlatformManager() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<Label> {i18n.t('cloud.platformmanager.saf587eb5')} </Label>
|
<Label> {i18n.t('如:阿里云')} </Label>
|
||||||
<Input
|
<Input
|
||||||
value={formData.website}
|
value={formData.website}
|
||||||
onChange={(e) => setFormData({ ...formData, website: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, website: e.target.value })}
|
||||||
@@ -327,7 +327,7 @@ export function PlatformManager() {
|
|||||||
<Input
|
<Input
|
||||||
value={formData.description}
|
value={formData.description}
|
||||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
||||||
placeholder={i18n.t('cloud.platformmanager.sc44dd421')}
|
placeholder={i18n.t('平台描述...')}
|
||||||
className="dg-input"
|
className="dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
const srvList = (srvRes as { list?: ServerItem[] })?.list || [];
|
const srvList = (srvRes as { list?: ServerItem[] })?.list || [];
|
||||||
setServers(srvList);
|
setServers(srvList);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(i18n.t('pipeline.buildnodesmanag.sb9faa2a3'));
|
toast.error(i18n.t('加载构建节点失败'));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!name.trim() || !serverId) {
|
if (!name.trim() || !serverId) {
|
||||||
toast.error(i18n.t('pipeline.buildnodesmanag.sda51a736'));
|
toast.error(i18n.t('加载构建节点失败'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -128,7 +128,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
toast.success(i18n.t('monitor.silenceRules.deleted'));
|
toast.success(i18n.t('monitor.silenceRules.deleted'));
|
||||||
load();
|
load();
|
||||||
} catch {
|
} 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 handleSaveMaster = async () => {
|
||||||
const n = Number(masterMax);
|
const n = Number(masterMax);
|
||||||
if (!n || n < 1) {
|
if (!n || n < 1) {
|
||||||
toast.error(i18n.t('pipeline.buildnodesmanag.s5f25f49a'));
|
toast.error(i18n.t('加载构建节点失败'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSavingMaster(true);
|
setSavingMaster(true);
|
||||||
@@ -172,7 +172,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
max_executors: m?.max_executors ?? n,
|
max_executors: m?.max_executors ?? n,
|
||||||
running_count: m?.running_count ?? prev.running_count,
|
running_count: m?.running_count ?? prev.running_count,
|
||||||
}));
|
}));
|
||||||
toast.success(i18n.t('pipeline.buildnodesmanag.scb1ab6ab'));
|
toast.success(i18n.t('已删除'));
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(i18n.t('kubernetes.deployment.imageUpdateFailed'));
|
toast.error(i18n.t('kubernetes.deployment.imageUpdateFailed'));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -218,7 +218,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
className="h-7 w-16 text-xs dg-input"
|
className="h-7 w-16 text-xs dg-input"
|
||||||
/>
|
/>
|
||||||
<Button size="sm" className="h-7 text-xs" onClick={handleSaveMaster} disabled={savingMaster}>
|
<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>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -229,8 +229,8 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
|
|
||||||
{nodes.length === 0 ? (
|
{nodes.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
title={i18n.t('pipeline.buildnodesmanag.s2795bd4a')}
|
title={i18n.t('暂无远程构建节点')}
|
||||||
description={i18n.t('pipeline.buildnodesmanag.s90fb5e18')}
|
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>}
|
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>
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
<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)}>
|
<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>
|
||||||
<Button variant="ghost" size="sm" className="h-7 text-xs" onClick={() => handleToggle(node)}>
|
<Button variant="ghost" size="sm" className="h-7 text-xs" onClick={() => handleToggle(node)}>
|
||||||
{node.enabled ? i18n.t('system.userInactive') : i18n.t('system.userActive')}
|
{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" />
|
<Input value={name} onChange={(e) => setName(e.target.value)} className="h-8 text-xs dg-input" placeholder="build-node-01" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1">
|
<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)}>
|
<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>
|
<SelectContent>
|
||||||
<SelectItem value="__none"> {i18n.t('k8s.storage.pleaseSelect')} </SelectItem>
|
<SelectItem value="__none"> {i18n.t('k8s.storage.pleaseSelect')} </SelectItem>
|
||||||
{servers.map((s) => (
|
{servers.map((s) => (
|
||||||
@@ -326,7 +326,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end gap-2 pt-2">
|
<div className="flex justify-end gap-2 pt-2">
|
||||||
<Button variant="outline" onClick={() => setDialogOpen(false)}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
@@ -343,7 +343,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell title={i18n.t('pipeline.buildNodes')} subtitle={i18n.t('pipeline.buildnodesmanag.sb2b825e4')}>
|
<PageShell title={i18n.t('pipeline.buildNodes')} subtitle={i18n.t('构建节点')}>
|
||||||
{panel}
|
{panel}
|
||||||
{dialog}
|
{dialog}
|
||||||
</PageShell>
|
</PageShell>
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export default function DeployRBAC() {
|
|||||||
|
|
||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
||||||
toast.error(i18n.t('monitor.logrbactsx.sf6e80bf0')); return;
|
toast.error(i18n.t('请填写名称、标识与正则')); return;
|
||||||
}
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
@@ -147,7 +147,7 @@ export default function DeployRBAC() {
|
|||||||
|
|
||||||
const handleDelete = async (role: ItemRole) => {
|
const handleDelete = async (role: ItemRole) => {
|
||||||
const ok = await _confirm({
|
const ok = await _confirm({
|
||||||
title: i18n.t('monitor.logrbactsx.s5d79e436'),
|
title: i18n.t('删除权限'),
|
||||||
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个发布任务`,
|
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个发布任务`,
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
@@ -165,7 +165,7 @@ export default function DeployRBAC() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAssign = async () => {
|
const handleAssign = async () => {
|
||||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('monitor.logrbactsx.s0fc53985')); return; }
|
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('请选择用户和权限')); return; }
|
||||||
setAssignLoading(true);
|
setAssignLoading(true);
|
||||||
try {
|
try {
|
||||||
await deployApi.assignItemRole(Number(selectedUserId), {
|
await deployApi.assignItemRole(Number(selectedUserId), {
|
||||||
@@ -190,8 +190,8 @@ export default function DeployRBAC() {
|
|||||||
|
|
||||||
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
||||||
const pageTabs = [
|
const pageTabs = [
|
||||||
{ id: 'roles', label: i18n.t('monitor.logrbactsx.s93ef07cd'), badge: roles.length || undefined },
|
{ id: 'roles', label: i18n.t('权限策略'), badge: roles.length || undefined },
|
||||||
{ id: 'users', label: i18n.t('monitor.logrbactsx.s2de89571') },
|
{ id: 'users', label: i18n.t('用户授权') },
|
||||||
{ id: 'groups', label: i18n.t('pipeline.groupLabel') },
|
{ id: 'groups', label: i18n.t('pipeline.groupLabel') },
|
||||||
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
||||||
];
|
];
|
||||||
@@ -200,7 +200,7 @@ export default function DeployRBAC() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('deploy.deployNav.jobPermission')}
|
title={i18n.t('deploy.deployNav.jobPermission')}
|
||||||
subtitle={i18n.t('pipeline.deployrbactsx.sa596d659')}
|
subtitle={i18n.t('按流水线 code / Job 名称正则分配发布权限')}
|
||||||
icon={<Shield className="h-5 w-5" />}
|
icon={<Shield className="h-5 w-5" />}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
tabs={pageTabs}
|
tabs={pageTabs}
|
||||||
@@ -217,8 +217,8 @@ export default function DeployRBAC() {
|
|||||||
roles.length === 0 ? (
|
roles.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<Shield className="h-10 w-10" />}
|
icon={<Shield className="h-10 w-10" />}
|
||||||
title={i18n.t('pipeline.deployrbactsx.sca578c70')}
|
title={i18n.t('暂无 Job 权限策略')}
|
||||||
description={i18n.t('pipeline.deployrbactsx.s5ac38262')}
|
description={i18n.t('创建策略后,用户将按正则自动获得匹配流水线的访问权限')}
|
||||||
action={<Button onClick={() => setCreateOpen(true)}><Plus className="h-4 w-4 mr-1" /> {i18n.t('monitor.logrbactsx.s6058845c')} </Button>}
|
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>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1 w-48">
|
<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}>
|
<Select value={assignRoleId} onValueChange={setAssignRoleId}>
|
||||||
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ export default function UserGroupsManager({ embedded = false }: { embedded?: boo
|
|||||||
const listBody = !loading && groups.length === 0 ? (
|
const listBody = !loading && groups.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<Users className="h-10 w-10" />}
|
icon={<Users className="h-10 w-10" />}
|
||||||
title={i18n.t('pipeline.usergroupsmanag.sd1edd832')}
|
title={i18n.t('暂无用户组')}
|
||||||
description={i18n.t('pipeline.usergroupsmanag.scf98655a')}
|
description={i18n.t('点击「新建用户组」创建第一个用户组')}
|
||||||
action={(
|
action={(
|
||||||
<Button size="sm" onClick={() => { setEditId(null); setFormName(''); setFormDesc(''); setFormOpen(true); }}>
|
<Button size="sm" onClick={() => { setEditId(null); setFormName(''); setFormDesc(''); setFormOpen(true); }}>
|
||||||
<Plus className="w-4 h-4 mr-1" />新建用户组
|
<Plus className="w-4 h-4 mr-1" />新建用户组
|
||||||
@@ -165,7 +165,7 @@ export default function UserGroupsManager({ embedded = false }: { embedded?: boo
|
|||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader><DialogTitle>{editId ? i18n.t('deploy.rbac.groupEditTitle') : i18n.t('pipeline.newGroup')}</DialogTitle></DialogHeader>
|
<DialogHeader><DialogTitle>{editId ? i18n.t('deploy.rbac.groupEditTitle') : i18n.t('pipeline.newGroup')}</DialogTitle></DialogHeader>
|
||||||
<div className="space-y-3">
|
<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 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>
|
||||||
<div className="flex justify-end gap-2 mt-4 pt-4 border-t">
|
<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
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('pipeline.releaseTitle')}
|
title={i18n.t('pipeline.releaseTitle')}
|
||||||
subtitle={i18n.t('pipeline.usergroupsmanag.sf80ecf33')}
|
subtitle={i18n.t('用户组 — 批量授权流水线访问权限')}
|
||||||
icon={<Users className="h-5 w-5" />}
|
icon={<Users className="h-5 w-5" />}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
metrics={(
|
metrics={(
|
||||||
<StatStrip
|
<StatStrip
|
||||||
items={[
|
items={[
|
||||||
{ label: i18n.t('pipeline.groupLabel'), value: groups.length, color: 'blue' },
|
{ 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">
|
<div className="space-y-4">
|
||||||
{/* 基本信息 // Logan.Li */}
|
{/* 基本信息 // Logan.Li */}
|
||||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
<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('>名称:</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('pipeline.creddetaildialo.se91f5a13')} </span>
|
<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>
|
<Badge variant="outline" className={`text-xs ml-1 ${TYPE_BADGE_CLASS[st] || ''}`}>{cfg?.label || st}</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div><span className="text-[var(--dg-text-muted)]"> {i18n.t('approval.detail.statusLabel')} </span>
|
<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>
|
</div>
|
||||||
{(detailRecord?.tags as string[])?.length > 0 && (
|
{(detailRecord?.tags as string[])?.length > 0 && (
|
||||||
<div className="col-span-2">
|
<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) => (
|
{(detailRecord?.tags as string[]).map((t: string) => (
|
||||||
<Badge key={t} variant="outline" className="text-xs ml-1 border-[var(--dg-border)]">{t}</Badge>
|
<Badge key={t} variant="outline" className="text-xs ml-1 border-[var(--dg-border)]">{t}</Badge>
|
||||||
))}
|
))}
|
||||||
</div>
|
</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 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('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('>创建:</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('pipeline.creddetaildialo.s3820b7e1')} </span><span className="text-[var(--dg-text-secondary)] text-xs">{new Date(detailRecord?.updated_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>
|
</div>
|
||||||
|
|
||||||
{/* 密钥数据 // Logan.Li */}
|
{/* 密钥数据 // Logan.Li */}
|
||||||
@@ -119,12 +119,12 @@ export function CredDetailDialog({ open, onClose, credId }: CredDetailDialogProp
|
|||||||
<Key className="h-4 w-4 text-yellow-500" />密钥数据
|
<Key className="h-4 w-4 text-yellow-500" />密钥数据
|
||||||
</div>
|
</div>
|
||||||
<div className="p-3 rounded-md bg-yellow-500/5 border border-yellow-500/20 mb-3">
|
<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>
|
</div>
|
||||||
|
|
||||||
{st === 'ssh' && <>
|
{st === 'ssh' && <>
|
||||||
<Field label={i18n.t('pipeline.creddetaildialo.s2272f5e9')} value={content.ssh_user} />
|
<Field label={i18n.t('SSH 用户')} value={content.ssh_user} />
|
||||||
<Field label={i18n.t('pipeline.creddetaildialo.s3f284a59')} value={content.ssh_port} />
|
<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.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.sshPrivateKey')} value={content.private_key} sensitive fieldKey="ssh_private_key" />
|
||||||
<Field label={i18n.t('system.sshPublicKey')} value={content.public_key} fieldKey="ssh_public_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" />
|
<Field label={i18n.t('system.passwordLabel')} value={content.password} sensitive fieldKey="docker_password" />
|
||||||
</>}
|
</>}
|
||||||
{st === 'tls' && <>
|
{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('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' && <>
|
{st === 'aksk' && <>
|
||||||
<Field label="Access Key ID" value={content.access_key} />
|
<Field label="Access Key ID" value={content.access_key} />
|
||||||
<Field label="Secret Access Key" value={content.secret_key} sensitive fieldKey="aksk_secret_key" />
|
<Field label="Secret Access Key" value={content.secret_key} sensitive fieldKey="aksk_secret_key" />
|
||||||
</>}
|
</>}
|
||||||
{st === 'database' && <>
|
{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('agent.agentHost')} value={content.host} />
|
||||||
<Field label={i18n.t('system.ldapPort')} value={content.port} />
|
<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.userName')} value={content.username} />
|
||||||
<Field label={i18n.t('system.passwordLabel')} value={content.password} sensitive fieldKey="db_password" />
|
<Field label={i18n.t('system.passwordLabel')} value={content.password} sensitive fieldKey="db_password" />
|
||||||
</>}
|
</>}
|
||||||
{st === 'api' && <>
|
{st === 'api' && <>
|
||||||
<Field label="API Key" value={content.api_key} sensitive fieldKey="api_key" />
|
<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' && <>
|
{st === 'generic' && <>
|
||||||
<Field label="Key" value={content.generic_key} />
|
<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="space-y-3">
|
||||||
<div className="flex gap-1 p-1 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]">
|
<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: 'ssh' as const, label: i18n.t('主机发布'), icon: Server },
|
||||||
{ key: 'k8s' as const, label: i18n.t('pipeline.deploytargetfie.s7ff062d5'), icon: Network },
|
{ key: 'k8s' as const, label: i18n.t('主机发布'), icon: Network },
|
||||||
]).map((item) => {
|
]).map((item) => {
|
||||||
const active = value.deployTarget === item.key;
|
const active = value.deployTarget === item.key;
|
||||||
const Icon = item.icon;
|
const Icon = item.icon;
|
||||||
@@ -200,7 +200,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
|||||||
<Input
|
<Input
|
||||||
value={serverSearch}
|
value={serverSearch}
|
||||||
onChange={(e) => setServerSearch(e.target.value)}
|
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"
|
className="pl-8 h-8 text-xs dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
<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="grid grid-cols-2 gap-2">
|
||||||
<div className="space-y-1">
|
<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
|
<Input
|
||||||
value={value.deployRemotePath}
|
value={value.deployRemotePath}
|
||||||
onChange={(e) => onChange({ deployRemotePath: e.target.value })}
|
onChange={(e) => onChange({ deployRemotePath: e.target.value })}
|
||||||
@@ -254,7 +254,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1">
|
<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
|
<Input
|
||||||
value={value.deployScript}
|
value={value.deployScript}
|
||||||
onChange={(e) => onChange({ deployScript: e.target.value })}
|
onChange={(e) => onChange({ deployScript: e.target.value })}
|
||||||
@@ -292,11 +292,11 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1">
|
<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
|
<Input
|
||||||
readOnly
|
readOnly
|
||||||
value={value.k8sDeployment ? `${value.k8sNamespace}/${value.k8sDeployment}` : ''}
|
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"
|
className="h-8 text-xs dg-input font-mono"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -308,7 +308,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
|||||||
<Input
|
<Input
|
||||||
value={depSearch}
|
value={depSearch}
|
||||||
onChange={(e) => setDepSearch(e.target.value)}
|
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"
|
className="pl-8 h-8 text-xs dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -353,7 +353,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
|||||||
<Input
|
<Input
|
||||||
value={value.k8sContainerName}
|
value={value.k8sContainerName}
|
||||||
onChange={(e) => onChange({ k8sContainerName: e.target.value })}
|
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"
|
className="h-8 text-xs font-mono dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import {
|
|||||||
|
|
||||||
// 流水线阶段定义(固定顺序) // Logan.Li
|
// 流水线阶段定义(固定顺序) // Logan.Li
|
||||||
export const STAGE_DEFS = [
|
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: '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('pipeline.constantsts.s3318af6f') },
|
{ 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('pipeline.constantsts.s350a98e1') },
|
{ 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('pipeline.constantsts.s98ea1149') },
|
{ 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('pipeline.constantsts.s45f0eba0') },
|
{ 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('pipeline.constantsts.seb164cd5') },
|
{ key: 'verify', label: i18n.t('system.credentialVerify'), icon: ShieldCheck, color: '#3B82F6', order: 6, needs: [], desc: i18n.t('验证') },
|
||||||
].sort((a, b) => a.order - b.order);
|
].sort((a, b) => a.order - b.order);
|
||||||
|
|
||||||
// 运行日志条目 // Logan.Li
|
// 运行日志条目 // Logan.Li
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default function CapacityPage() {
|
|||||||
</TableRow></TableHeader>
|
</TableRow></TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{rows.length === 0 ? (
|
{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) => (
|
) : rows.map((r, i) => (
|
||||||
<TableRow key={`${r.deployment}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
<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>
|
<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);
|
const current = list.find((c: JsonData) => (c.code || String(c.id)) === clusterCode);
|
||||||
setClusterInfo(current || null);
|
setClusterInfo(current || null);
|
||||||
if (!current && list.length > 0 && clusterCode) {
|
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([]); }
|
} catch { setClusters([]); }
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -85,8 +85,8 @@ export default function ClusterOverviewPage() {
|
|||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
variant="default"
|
variant="default"
|
||||||
title={clusterCode || i18n.t('kubernetes.clusteroverview.s066c0aa3')}
|
title={clusterCode || i18n.t('集群概览')}
|
||||||
subtitle={clusterInfo?.version ? `集群概览 · Kubernetes ${clusterInfo.version}` : i18n.t('kubernetes.clusteroverview.s066c0aa3')}
|
subtitle={clusterInfo?.version ? `集群概览 · Kubernetes ${clusterInfo.version}` : i18n.t('集群概览')}
|
||||||
icon={<Server className="h-5 w-5" />}
|
icon={<Server className="h-5 w-5" />}
|
||||||
metrics={!loading ? (
|
metrics={!loading ? (
|
||||||
<StatStrip
|
<StatStrip
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
|||||||
setPods(allPods.filter((p: JsonData) => p.namespace === namespace && p.name.startsWith(deploymentName)));
|
setPods(allPods.filter((p: JsonData) => p.namespace === namespace && p.name.startsWith(deploymentName)));
|
||||||
setHpas(allHpas.filter((h: JsonData) => h.target_name === deploymentName && h.namespace === namespace));
|
setHpas(allHpas.filter((h: JsonData) => h.target_name === deploymentName && h.namespace === namespace));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(i18n.t('kubernetes.deploymentdetai.sb46ea9c4'), e);
|
console.error(i18n.t('加载详情失败:'), e);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
|||||||
setActionLoading('restart');
|
setActionLoading('restart');
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
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) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e?.message || String(e), variant: 'destructive' });
|
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||||
} finally { setActionLoading(''); }
|
} finally { setActionLoading(''); }
|
||||||
@@ -97,7 +97,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
|||||||
setActionLoading('image');
|
setActionLoading('image');
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.updateDeploymentImage(clusterCode, namespace, deploymentName, newImage);
|
await kubernetesApi.updateDeploymentImage(clusterCode, namespace, deploymentName, newImage);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s6df3c303'), description: `正在滚动更新为 ${newImage}` });
|
toast({ title: i18n.t('镜像更新成功'), description: `正在滚动更新为 ${newImage}` });
|
||||||
setShowImageUpdate(false);
|
setShowImageUpdate(false);
|
||||||
loadData();
|
loadData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -115,7 +115,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.deleteHPA(clusterCode, namespace, hpa.name);
|
await kubernetesApi.deleteHPA(clusterCode, namespace, hpa.name);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s0f958f8e') });
|
toast({ title: i18n.t('HPA 已删除') });
|
||||||
loadData();
|
loadData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.msg.deleteFailed2'), description: e?.message || String(e), variant: 'destructive' });
|
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
|
// validate
|
||||||
for (const c of [...initContainers, ...containers]) {
|
for (const c of [...initContainers, ...containers]) {
|
||||||
if (!c.name.trim()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (!c.image.trim()) {
|
if (!c.image.trim()) {
|
||||||
@@ -102,7 +102,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
|||||||
? imagePullSecrets.filter(s => s.trim()).map((s: string) => ({ name: s }))
|
? imagePullSecrets.filter(s => s.trim()).map((s: string) => ({ name: s }))
|
||||||
: undefined;
|
: undefined;
|
||||||
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
||||||
toast({ title: i18n.t('kubernetes.deploymenteditc.sdf22b91b'), description: `${deploymentName} 更新已提交` });
|
toast({ title: i18n.t('容器配置已保存'), description: `${deploymentName} 更新已提交` });
|
||||||
onSaved(base);
|
onSaved(base);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: e?.message || String(e), variant: 'destructive' });
|
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>}
|
{imagePullSecrets.length === 0 && <span className="text-[11px] dg-text-muted">无</span>}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<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) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
const val = (e.target as HTMLInputElement).value.trim();
|
const val = (e.target as HTMLInputElement).value.trim();
|
||||||
@@ -170,7 +170,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
|||||||
{/* 初始化容器 */}
|
{/* 初始化容器 */}
|
||||||
<ContainerGroupSection
|
<ContainerGroupSection
|
||||||
title={i18n.t('kubernetes.container.initContainers')}
|
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" />}
|
icon={<Play className="h-4 w-4 dg-text-purple" />}
|
||||||
containers={initContainers}
|
containers={initContainers}
|
||||||
accentColor="purple"
|
accentColor="purple"
|
||||||
@@ -181,8 +181,8 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
|||||||
|
|
||||||
{/* 工作容器 */}
|
{/* 工作容器 */}
|
||||||
<ContainerGroupSection
|
<ContainerGroupSection
|
||||||
title={i18n.t('kubernetes.deploymenteditc.sc61b83bd')}
|
title={i18n.t('初始化容器')}
|
||||||
description={i18n.t('kubernetes.deploymenteditc.s43eebd4d')}
|
description={i18n.t('在主容器启动前按顺序执行的容器,用于初始化环境')}
|
||||||
icon={<Container className="h-4 w-4 dg-text-blue" />}
|
icon={<Container className="h-4 w-4 dg-text-blue" />}
|
||||||
containers={containers}
|
containers={containers}
|
||||||
accentColor="blue"
|
accentColor="blue"
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
|||||||
try {
|
try {
|
||||||
const yaml = await dumpManifest(svcManifest);
|
const yaml = await dumpManifest(svcManifest);
|
||||||
await kubernetesApi.applyYAML(clusterCode, yaml);
|
await kubernetesApi.applyYAML(clusterCode, yaml);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentedits.sabd7e004'), description: name });
|
toast({ title: i18n.t('Service 已创建'), description: name });
|
||||||
setShowCreate(null);
|
setShowCreate(null);
|
||||||
load();
|
load();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -209,7 +209,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
|||||||
try {
|
try {
|
||||||
const yaml = await dumpManifest(ingManifest);
|
const yaml = await dumpManifest(ingManifest);
|
||||||
await kubernetesApi.applyYAML(clusterCode, yaml);
|
await kubernetesApi.applyYAML(clusterCode, yaml);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentedits.se356fbe5'), description: name });
|
toast({ title: i18n.t('Service 已创建'), description: name });
|
||||||
setShowCreate(null);
|
setShowCreate(null);
|
||||||
load();
|
load();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -221,7 +221,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
|||||||
// 删除资源
|
// 删除资源
|
||||||
const deleteResource = async (kind: 'service' | 'ingress', name: string) => {
|
const deleteResource = async (kind: 'service' | 'ingress', name: string) => {
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: i18n.t('kubernetes.deploymentedits.s8a2a35a5'),
|
title: i18n.t('删除资源'),
|
||||||
description: `确认删除 ${kind === 'service' ? 'Service' : 'Ingress'} 「${name}」?此操作不可撤销。`,
|
description: `确认删除 ${kind === 'service' ? 'Service' : 'Ingress'} 「${name}」?此操作不可撤销。`,
|
||||||
confirmText: i18n.t('kubernetes.storage.delete2'),
|
confirmText: i18n.t('kubernetes.storage.delete2'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VOLUME_TYPES: { key: VolumeForm['type']; label: string; icon: typeof HardDrive; color: string }[] = [
|
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: 'persistentVolumeClaim', label: i18n.t('存储卷声明'), icon: Database, color: 'dg-text-green' },
|
||||||
{ key: 'emptyDir', label: i18n.t('kubernetes.deploymentedits.s5449b239'), icon: Disc, color: 'dg-text-secondary' },
|
{ key: 'emptyDir', label: i18n.t('临时目录(EmptyDir)'), icon: Disc, color: 'dg-text-secondary' },
|
||||||
{ key: 'hostPath', label: 'HostPath', icon: HardDrive, color: 'dg-text-yellow' },
|
{ key: 'hostPath', label: 'HostPath', icon: HardDrive, color: 'dg-text-yellow' },
|
||||||
{ key: 'nfs', label: 'NFS', icon: Server, color: 'dg-text-purple' },
|
{ 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: 'configMap', label: i18n.t('配置字典'), icon: File, color: 'dg-text-blue' },
|
||||||
{ key: 'secret', label: i18n.t('kubernetes.deploymentedits.sc099362a'), icon: Lock, color: 'text-rose-400' },
|
{ key: 'secret', label: i18n.t('密文'), icon: Lock, color: 'text-rose-400' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const SELECTABLE_TYPES = new Set(VOLUME_TYPES.map((t) => t.key));
|
const SELECTABLE_TYPES = new Set(VOLUME_TYPES.map((t) => t.key));
|
||||||
@@ -129,20 +129,20 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
|||||||
const save = async () => {
|
const save = async () => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (!entry.volume.name.trim()) {
|
if (!entry.volume.name.trim()) {
|
||||||
toast({ title: i18n.t('kubernetes.deploymentedits.s5b59d298'), variant: 'destructive' });
|
toast({ title: i18n.t('请填写数据卷名称'), variant: 'destructive' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!formToVolume(entry.volume)) {
|
if (!formToVolume(entry.volume)) {
|
||||||
const hint = entry.volume.type === 'configMap' ? i18n.t('kubernetes.deploymentedits.s2a6856ee')
|
const hint = entry.volume.type === 'configMap' ? i18n.t('请选择 ConfigMap')
|
||||||
: entry.volume.type === 'secret' ? i18n.t('kubernetes.deploymentedits.s1f31e442')
|
: entry.volume.type === 'secret' ? i18n.t('请选择 Secret')
|
||||||
: entry.volume.type === 'persistentVolumeClaim' ? i18n.t('kubernetes.deploymentedits.sba9fc667')
|
: entry.volume.type === 'persistentVolumeClaim' ? i18n.t('请选择 PVC')
|
||||||
: i18n.t('kubernetes.deploymentedits.s03480abb');
|
: i18n.t('的类型必填项');
|
||||||
toast({ title: i18n.t('kubernetes.deploymentedits.se542a63b'), description: `请为「${entry.volume.name}」${hint}`, variant: 'destructive' });
|
toast({ title: i18n.t('数据卷配置不完整'), description: `请为「${entry.volume.name}」${hint}`, variant: 'destructive' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const validMounts = entry.mounts.filter((m) => m.mountPath.trim());
|
const validMounts = entry.mounts.filter((m) => m.mountPath.trim());
|
||||||
if (validMounts.length === 0) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
|||||||
const { volumes, mounts } = volumeEntriesToStorage(entries);
|
const { volumes, mounts } = volumeEntriesToStorage(entries);
|
||||||
const base = applyStorageToManifest(rawManifest, volumes, mounts, passthroughVolumes);
|
const base = applyStorageToManifest(rawManifest, volumes, mounts, passthroughVolumes);
|
||||||
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
await saveDeploymentManifest(clusterCode, namespace, deploymentName, base);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentedits.sa8cd7d90'), description: `${deploymentName} 更新已提交` });
|
toast({ title: i18n.t('存储配置已保存'), description: `${deploymentName} 更新已提交` });
|
||||||
onSaved(base);
|
onSaved(base);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.msg.saveFailed'), description: (e as Error)?.message || String(e), variant: 'destructive' });
|
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) {
|
if (!manifest) {
|
||||||
return (
|
return (
|
||||||
<Card className="dg-card">
|
<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>
|
</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>
|
<Badge variant="outline" className="border-[var(--dg-border)] dg-text-secondary">{entries.length}</Badge>
|
||||||
</CardTitle>
|
</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>
|
</div>
|
||||||
<Button size="sm" variant="outline" className="h-7 border-[var(--dg-border)] text-[var(--dg-text-secondary)] text-xs shrink-0" onClick={addEntry}>
|
<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" />添加数据卷
|
<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;
|
if (vol.type === 'persistentVolumeClaim' && !vol.pvcName) patch.pvcName = name;
|
||||||
updateVolume(i, patch);
|
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"
|
className="h-8 w-44 dg-input text-sm font-mono"
|
||||||
/>
|
/>
|
||||||
{/* 原生 select,避免 Radix Select 在 overflow 容器内无法下拉 // Logan.Li */}
|
{/* 原生 select,避免 Radix Select 在 overflow 容器内无法下拉 // Logan.Li */}
|
||||||
@@ -312,7 +312,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
|||||||
<Input
|
<Input
|
||||||
value={mount.mountPath}
|
value={mount.mountPath}
|
||||||
onChange={(e) => updateMount(i, mi, { mountPath: e.target.value })}
|
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"
|
className="h-8 flex-1 min-w-[200px] dg-input text-sm font-mono"
|
||||||
/>
|
/>
|
||||||
{entry.mounts.length > 1 && (
|
{entry.mounts.length > 1 && (
|
||||||
@@ -326,7 +326,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
|||||||
<Input
|
<Input
|
||||||
value={mount.subPath}
|
value={mount.subPath}
|
||||||
onChange={(e) => updateMount(i, mi, { subPath: e.target.value })}
|
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"
|
className="h-7 flex-1 max-w-md dg-input text-[var(--dg-text-secondary)] text-xs font-mono"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
|||||||
const handleRollback = async (rev: JsonData) => {
|
const handleRollback = async (rev: JsonData) => {
|
||||||
const revision = rev.revision ?? rev.revision_number ?? rev.number;
|
const revision = rev.revision ?? rev.revision_number ?? rev.number;
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: i18n.t('kubernetes.deploymentviewt.s6a374e98'),
|
title: i18n.t('回滚版本'),
|
||||||
description: `确认回滚到修订版本 #${revision}?`,
|
description: `确认回滚到修订版本 #${revision}?`,
|
||||||
confirmText: i18n.t('pipeline.rollback'),
|
confirmText: i18n.t('pipeline.rollback'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
@@ -148,7 +148,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
|||||||
setRollbackLoading(revision);
|
setRollbackLoading(revision);
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.rollbackDeployment(clusterCode, namespace, deployment.name, Number(revision));
|
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();
|
onRefresh();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('pipeline.rollbackFailed'), description: e?.message || String(e), variant: 'destructive' });
|
toast({ title: i18n.t('pipeline.rollbackFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||||
@@ -160,7 +160,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
|||||||
setScaleLoading(true);
|
setScaleLoading(true);
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.scaleDeployment(clusterCode, namespace, deployment.name, scaleValue);
|
await kubernetesApi.scaleDeployment(clusterCode, namespace, deployment.name, scaleValue);
|
||||||
toast({ title: i18n.t('kubernetes.deploymentviewt.sb9c9e03e'), description: `副本数 → ${scaleValue}` });
|
toast({ title: i18n.t('伸缩已提交'), description: `副本数 → ${scaleValue}` });
|
||||||
onRefresh();
|
onRefresh();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.msg.scaleFailed'), description: e?.message || String(e), variant: 'destructive' });
|
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 = [
|
const TABS = [
|
||||||
{ key: 'pods', label: i18n.t('kubernetes.deploymentviewt.s479692cc'), icon: Container, count: pods.length },
|
{ key: 'pods', label: i18n.t('容器组'), icon: Container, count: pods.length },
|
||||||
{ key: 'services', label: i18n.t('kubernetes.deploymentviewt.s7068046e'), icon: Network, count: services.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: '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 },
|
{ 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'}
|
{isHealthy ? 'Running' : 'Updating'}
|
||||||
</Badge>
|
</Badge>
|
||||||
} />
|
} />
|
||||||
<InfoItem label={i18n.t('kubernetes.capacitypagetsx.s0428b36a')} value={<span className="font-mono">{ready}/{total}</span>} />
|
<InfoItem label={i18n.t('状态')} value={<span className="font-mono">{ready}/{total}</span>} />
|
||||||
<InfoItem label={i18n.t('kubernetes.deploymentviewt.s66914536')} value={deployment?.strategy || 'RollingUpdate'} />
|
<InfoItem label={i18n.t('状态')} value={deployment?.strategy || 'RollingUpdate'} />
|
||||||
{pods[0] && (
|
{pods[0] && (
|
||||||
<>
|
<>
|
||||||
<InfoItem label={i18n.t('kubernetes.pod.nodeName')} value={
|
<InfoItem label={i18n.t('kubernetes.pod.nodeName')} value={
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
|
|
||||||
setRevisions(toArray(revRes));
|
setRevisions(toArray(revRes));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(i18n.t('kubernetes.deploymentdetai.sb46ea9c4'), e);
|
console.error(i18n.t('加载详情失败:'), e);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
const { manifest: parsed } = await parseEditableManifest(yamlText);
|
const { manifest: parsed } = await parseEditableManifest(yamlText);
|
||||||
setManifest(parsed || deployment);
|
setManifest(parsed || deployment);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(i18n.t('kubernetes.deploymentworkl.sce123fbd'), e);
|
console.warn(i18n.t('加载 manifest 失败(编辑功能降级):'), e);
|
||||||
setManifest(deployment);
|
setManifest(deployment);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -191,7 +191,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
setActionLoading('restart');
|
setActionLoading('restart');
|
||||||
try {
|
try {
|
||||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
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);
|
setTimeout(loadData, 1500);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e?.message || String(e), variant: 'destructive' });
|
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(
|
await kubernetesApi.updateDeploymentImage(
|
||||||
clusterCode, namespace, deploymentName, newImage, cicdContainerName || undefined,
|
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);
|
setModal(null);
|
||||||
loadData();
|
loadData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -288,7 +288,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
// ============ 渲染 // Logan.Li ============
|
// ============ 渲染 // Logan.Li ============
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
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}
|
{null}
|
||||||
</PageShell>
|
</PageShell>
|
||||||
);
|
);
|
||||||
@@ -308,7 +308,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
if (name) navigate(`/kubernetes/${clusterCode}/namespace/${namespace}/workload/view/Deployment/${name}`);
|
if (name) navigate(`/kubernetes/${clusterCode}/namespace/${namespace}/workload/view/Deployment/${name}`);
|
||||||
};
|
};
|
||||||
return (
|
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} />
|
<EditModeContainer clusterCode={clusterCode} namespace={namespace} deploymentName={CREATE_DEPLOYMENT_SLUG} manifest={manifest} isCreate onSaved={handleCreated} onCancel={onBack} />
|
||||||
</PageShell>
|
</PageShell>
|
||||||
);
|
);
|
||||||
@@ -379,7 +379,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
resource="deployments"
|
resource="deployments"
|
||||||
name={deploymentName}
|
name={deploymentName}
|
||||||
inline
|
inline
|
||||||
resourceHint={i18n.t('kubernetes.deploymentworkl.s239604b0')}
|
resourceHint={i18n.t('含关联 Service')}
|
||||||
loadYamlFn={loadBundleYaml}
|
loadYamlFn={loadBundleYaml}
|
||||||
saveYamlFn={saveBundleYaml}
|
saveYamlFn={saveBundleYaml}
|
||||||
onSaved={loadData}
|
onSaved={loadData}
|
||||||
@@ -404,7 +404,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
|||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
resource="deployments"
|
resource="deployments"
|
||||||
name={deploymentName}
|
name={deploymentName}
|
||||||
resourceHint={i18n.t('kubernetes.deploymentworkl.s239604b0')}
|
resourceHint={i18n.t('含关联 Service')}
|
||||||
loadYamlFn={loadBundleYaml}
|
loadYamlFn={loadBundleYaml}
|
||||||
saveYamlFn={saveBundleYaml}
|
saveYamlFn={saveBundleYaml}
|
||||||
onClose={() => setModal(null)}
|
onClose={() => setModal(null)}
|
||||||
|
|||||||
@@ -179,16 +179,16 @@ export default function EventsPage() {
|
|||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('kubernetes.eventspagetsx.s08bf79b4')}
|
title={i18n.t('事件中心')}
|
||||||
subtitle={clusterName ? `${clusterName} · 集群事件与告警` : i18n.t('kubernetes.eventspagetsx.s6bef2ba0')}
|
subtitle={clusterName ? `${clusterName} · 集群事件与告警` : i18n.t('集群事件与告警')}
|
||||||
icon={<Bell className="h-5 w-5" />}
|
icon={<Bell className="h-5 w-5" />}
|
||||||
metrics={!loading ? (
|
metrics={!loading ? (
|
||||||
<StatStrip
|
<StatStrip
|
||||||
items={[
|
items={[
|
||||||
{ label: i18n.t('kubernetes.eventspagetsx.s0d3047da'), value: summary?.total ?? events.length, color: 'muted' },
|
{ label: i18n.t('正常事件'), value: summary?.total ?? events.length, color: 'muted' },
|
||||||
{ label: i18n.t('kubernetes.eventspagetsx.s0e5b83cc'), value: summary?.warning_count ?? warningCount, color: 'amber' },
|
{ label: i18n.t('告警事件'), value: summary?.warning_count ?? warningCount, color: 'amber' },
|
||||||
{ label: i18n.t('kubernetes.eventspagetsx.s349c629f'), value: summary?.normal_count ?? normalCount, color: 'green' },
|
{ label: i18n.t('正常事件'), value: summary?.normal_count ?? normalCount, color: 'green' },
|
||||||
{ label: i18n.t('kubernetes.eventspagetsx.sc62e34c5'), value: reasonData.length, color: 'red' },
|
{ label: i18n.t('告警类型'), value: reasonData.length, color: 'red' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
@@ -229,10 +229,10 @@ export default function EventsPage() {
|
|||||||
>
|
>
|
||||||
{reasonData.length > 0 && (
|
{reasonData.length > 0 && (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
<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} />}
|
{nsData.length > 0 && <RankPanel title={i18n.t('kubernetes.namespace.title')} items={nsData} />}
|
||||||
{kindData.length > 0 && (
|
{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>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export function KubernetesClusterDialog({
|
|||||||
if (!value.trim()) {
|
if (!value.trim()) {
|
||||||
setNameError('');
|
setNameError('');
|
||||||
} else if (!NAME_RE.test(value)) {
|
} else if (!NAME_RE.test(value)) {
|
||||||
setNameError(i18n.t('kubernetes.kubernetesclust.sc7ec6c52'));
|
setNameError(i18n.t('只允许英文、数字和连字符(-),首尾不能是连字符'));
|
||||||
} else {
|
} else {
|
||||||
setNameError('');
|
setNameError('');
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ export function KubernetesClusterDialog({
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!formData.name.trim() || !NAME_RE.test(formData.name.trim())) {
|
if (!formData.name.trim() || !NAME_RE.test(formData.name.trim())) {
|
||||||
toast.error(i18n.t('kubernetes.kubernetesclust.s38bbfe92')); return;
|
toast.error(i18n.t('请输入有效的集群名称(英文/数字/连字符)')); return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -133,7 +133,7 @@ export function KubernetesClusterDialog({
|
|||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
onSaved();
|
onSaved();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(i18n.t('kubernetes.kubernetesclust.s7aa44ba2'), e);
|
console.error(i18n.t('保存集群失败:'), e);
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ export function KubernetesClusterDialog({
|
|||||||
{editingCluster ? i18n.t('kubernetes.cluster.editCluster') : i18n.t('kubernetes.cluster.addCluster')}
|
{editingCluster ? i18n.t('kubernetes.cluster.editCluster') : i18n.t('kubernetes.cluster.addCluster')}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription className="text-[var(--dg-text-secondary)]">
|
<DialogDescription className="text-[var(--dg-text-secondary)]">
|
||||||
{editingCluster ? i18n.t('kubernetes.kubernetesclust.s2d42f245') : i18n.t('kubernetes.kubernetesclust.sfe6c791d')}
|
{editingCluster ? i18n.t('编辑集群') : i18n.t('添加集群')}
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-4 py-2 max-h-[60vh] overflow-y-auto pr-1">
|
<div className="space-y-4 py-2 max-h-[60vh] overflow-y-auto pr-1">
|
||||||
@@ -159,7 +159,7 @@ export function KubernetesClusterDialog({
|
|||||||
<Input
|
<Input
|
||||||
value={formData.name}
|
value={formData.name}
|
||||||
onChange={(e) => handleNameChange(e.target.value)}
|
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' : ''}`}
|
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>}
|
{nameError && <p className="text-xs dg-text-red">{nameError}</p>}
|
||||||
@@ -172,7 +172,7 @@ export function KubernetesClusterDialog({
|
|||||||
<Input
|
<Input
|
||||||
value={formData.version}
|
value={formData.version}
|
||||||
onChange={(e) => setFormData({ ...formData, version: e.target.value })}
|
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)]"
|
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -183,7 +183,7 @@ export function KubernetesClusterDialog({
|
|||||||
<Input
|
<Input
|
||||||
value={formData.description}
|
value={formData.description}
|
||||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
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)]"
|
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -224,7 +224,7 @@ export function KubernetesClusterDialog({
|
|||||||
<Textarea
|
<Textarea
|
||||||
value={formData.token}
|
value={formData.token}
|
||||||
onChange={(e) => setFormData({ ...formData, token: e.target.value })}
|
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}
|
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"
|
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
|
<Textarea
|
||||||
value={formData.kube_config}
|
value={formData.kube_config}
|
||||||
onChange={(e) => handleKubeConfigChange(e.target.value)}
|
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}
|
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"
|
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 />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="all"> {i18n.t('kubernetes.kubernetesnodes.s5bcc10f8')} </SelectItem>
|
<SelectItem value="all"> {i18n.t('选择集群')} </SelectItem>
|
||||||
<SelectItem value="master">Master</SelectItem>
|
<SelectItem value="master">Master</SelectItem>
|
||||||
<SelectItem value="worker">Worker</SelectItem>
|
<SelectItem value="worker">Worker</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -86,7 +86,7 @@ export function KubernetesNodes() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('menu.nodeManagement')}
|
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" />}
|
icon={<Server className="h-5 w-5" />}
|
||||||
actions={(
|
actions={(
|
||||||
<>
|
<>
|
||||||
@@ -125,7 +125,7 @@ export function KubernetesNodes() {
|
|||||||
{loading ? (
|
{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>
|
<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 ? (
|
) : 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) => (
|
filtered.map((n) => (
|
||||||
<TableRow key={n.id} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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
|
<Input
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
placeholder={i18n.t('kubernetes.namespacemanage.se91247a0')}
|
placeholder={i18n.t('搜索命名空间...')}
|
||||||
className="max-w-xs dg-input"
|
className="max-w-xs dg-input"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -120,7 +120,7 @@ export default function NamespaceManagementPage() {
|
|||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('kubernetes.namespacemanage.se935a33d')}
|
title={i18n.t('命名空间管理')}
|
||||||
subtitle={`${clusterCode} · 资源配额与生命周期管理`}
|
subtitle={`${clusterCode} · 资源配额与生命周期管理`}
|
||||||
icon={<Boxes className="h-5 w-5" />}
|
icon={<Boxes className="h-5 w-5" />}
|
||||||
metrics={!loading ? (
|
metrics={!loading ? (
|
||||||
@@ -130,7 +130,7 @@ export default function NamespaceManagementPage() {
|
|||||||
{ label: 'Deployments', value: totalDeploys, color: 'blue' },
|
{ label: 'Deployments', value: totalDeploys, color: 'blue' },
|
||||||
{ label: 'Pods', value: totalPods, color: 'purple' },
|
{ label: 'Pods', value: totalPods, color: 'purple' },
|
||||||
{ label: 'Services', value: totalSvcs, color: 'cyan' },
|
{ label: 'Services', value: totalSvcs, color: 'cyan' },
|
||||||
{ label: i18n.t('kubernetes.namespacemanage.s47c3aee9'), value: quotaCount, color: 'amber' },
|
{ label: i18n.t('配额限制'), value: quotaCount, color: 'amber' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
@@ -148,7 +148,7 @@ export default function NamespaceManagementPage() {
|
|||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle> {i18n.t('kubernetes.namespacemanage.s737f41e9')} </DialogTitle>
|
<DialogTitle> {i18n.t('例如: my-app')} </DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-4 py-4">
|
<div className="space-y-4 py-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -156,7 +156,7 @@ export default function NamespaceManagementPage() {
|
|||||||
<Input
|
<Input
|
||||||
value={newName}
|
value={newName}
|
||||||
onChange={(e) => setNewName(e.target.value)}
|
onChange={(e) => setNewName(e.target.value)}
|
||||||
placeholder={i18n.t('kubernetes.namespacemanage.scba00862')}
|
placeholder={i18n.t('例如: my-app')}
|
||||||
onKeyDown={(e) => e.key === 'Enter' && handleCreate()}
|
onKeyDown={(e) => e.key === 'Enter' && handleCreate()}
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-[var(--dg-text-muted)]">
|
<p className="text-xs text-[var(--dg-text-muted)]">
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ import type { JsonData } from '@/types/common';
|
|||||||
import i18n from '@/i18n';
|
import i18n from '@/i18n';
|
||||||
|
|
||||||
const RESOURCE_LINKS = [
|
const RESOURCE_LINKS = [
|
||||||
{ type: 'deployments', label: 'Deployments', icon: Boxes, desc: i18n.t('kubernetes.namespaceovervi.sb68c634e') },
|
{ type: 'deployments', label: 'Deployments', icon: Boxes, desc: i18n.t('工作负载副本管理') },
|
||||||
{ type: 'pods', label: 'Pods', icon: Container, desc: i18n.t('kubernetes.namespaceovervi.sfdac258b') },
|
{ type: 'pods', label: 'Pods', icon: Container, desc: i18n.t('容器实例运行状态') },
|
||||||
{ type: 'cronjobs', label: 'CronJobs', icon: Clock, desc: i18n.t('kubernetes.namespaceovervi.s9c9fc523') },
|
{ type: 'cronjobs', label: 'CronJobs', icon: Clock, desc: i18n.t('定时任务管理') },
|
||||||
{ type: 'services', label: 'Services', icon: Network, desc: i18n.t('kubernetes.namespaceovervi.s3a3f6d6c') },
|
{ type: 'services', label: 'Services', icon: Network, desc: i18n.t('服务发现与负载均衡') },
|
||||||
{ type: 'ingresses', label: 'Ingresses', icon: Network, desc: i18n.t('kubernetes.namespaceovervi.scc6971c7') },
|
{ type: 'ingresses', label: 'Ingresses', icon: Network, desc: i18n.t('外部流量路由规则') },
|
||||||
{ type: 'configmaps', label: 'ConfigMaps', icon: FileText, desc: i18n.t('kubernetes.namespaceovervi.s0986a6e7') },
|
{ type: 'configmaps', label: 'ConfigMaps', icon: FileText, desc: i18n.t('配置字典') },
|
||||||
{ type: 'secrets', label: 'Secrets', icon: Shield, desc: i18n.t('kubernetes.namespaceovervi.sb3fb72cd') },
|
{ type: 'secrets', label: 'Secrets', icon: Shield, desc: i18n.t('密钥与凭证') },
|
||||||
{ type: 'hpas', label: 'HPAs', icon: Activity, desc: i18n.t('kubernetes.namespaceovervi.sa84da2c5') },
|
{ type: 'hpas', label: 'HPAs', icon: Activity, desc: i18n.t('水平自动伸缩策略') },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function NamespaceOverviewPage() {
|
export default function NamespaceOverviewPage() {
|
||||||
@@ -71,7 +71,7 @@ export default function NamespaceOverviewPage() {
|
|||||||
subtitle={`${clusterCode} · 命名空间概览`}
|
subtitle={`${clusterCode} · 命名空间概览`}
|
||||||
icon={<Cloud className="h-5 w-5" />}
|
icon={<Cloud className="h-5 w-5" />}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
loadingLabel={i18n.t('kubernetes.namespaceovervi.sfa525ae0')}
|
loadingLabel={i18n.t('加载资源统计...')}
|
||||||
>
|
>
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
{RESOURCE_LINKS.map((r) => (
|
{RESOURCE_LINKS.map((r) => (
|
||||||
|
|||||||
@@ -204,16 +204,16 @@ export default function NamespaceResourcePage() {
|
|||||||
</Button>
|
</Button>
|
||||||
{BULK_EXPORT_TYPES.includes(type) && (
|
{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
|
<Download className="h-3 w-3 mr-1" />CSV
|
||||||
</Button>
|
</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
|
<Download className="h-3 w-3 mr-1" />JSON
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{EXPORT_YAML_TYPES.includes(type) && (
|
{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
|
<Download className="h-3 w-3 mr-1" />导出YAML
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export function PodExecTerminal({
|
|||||||
console.error('[PodExec:connect] WS error event fired, readyState=', ws.readyState, 'type=', ev.type);
|
console.error('[PodExec:connect] WS error event fired, readyState=', ws.readyState, 'type=', ev.type);
|
||||||
setConnState('error');
|
setConnState('error');
|
||||||
setHasOutput(true);
|
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]);
|
}, [clusterId, namespace, podName, container, shell]);
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function PodFileBrowser({
|
|||||||
setEntries(list);
|
setEntries(list);
|
||||||
setCurrentPath(path);
|
setCurrentPath(path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError((e as JsonData).message || i18n.t('kubernetes.podfilebrowsert.s78d4a7c6'));
|
setError((e as JsonData).message || i18n.t('加载文件列表失败'));
|
||||||
setEntries([]);
|
setEntries([]);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -183,11 +183,11 @@ export function PodLogsViewer({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
flush();
|
flush();
|
||||||
appendLines([i18n.t('kubernetes.podlogsviewerts.s4f0e17cd')]);
|
appendLines([i18n.t('\\x1b[33m— 流式结束 —\\x1b[0m')]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const errName = (e as { name?: string })?.name;
|
const errName = (e as { name?: string })?.name;
|
||||||
if (errName === 'AbortError') {
|
if (errName === 'AbortError') {
|
||||||
appendLines([i18n.t('kubernetes.podlogsviewerts.s1ca9010d')]);
|
appendLines([i18n.t('\\x1b[33m— 已停止 —\\x1b[0m')]);
|
||||||
} else {
|
} else {
|
||||||
const msg = e instanceof Error ? e.message : String(e);
|
const msg = e instanceof Error ? e.message : String(e);
|
||||||
appendLines([`\x1b[31m[流式连接中断: ${msg}]\x1b[0m`]);
|
appendLines([`\x1b[31m[流式连接中断: ${msg}]\x1b[0m`]);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export default function PodMetricsPage() {
|
|||||||
metrics={!loading ? (
|
metrics={!loading ? (
|
||||||
<StatStrip
|
<StatStrip
|
||||||
items={[
|
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.cpu'), value: `${totalCPU}m`, color: 'blue' },
|
||||||
{ label: i18n.t('k8s.podMetrics.memory'), value: `${totalMem.toFixed(0)}Mi`, color: 'green' },
|
{ label: i18n.t('k8s.podMetrics.memory'), value: `${totalMem.toFixed(0)}Mi`, color: 'green' },
|
||||||
]}
|
]}
|
||||||
@@ -132,7 +132,7 @@ export default function PodMetricsPage() {
|
|||||||
</TableRow></TableHeader>
|
</TableRow></TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{rows.length === 0 ? (
|
{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) => (
|
) : rows.map((r, i) => (
|
||||||
<TableRow key={`${r.pod}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
<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>
|
<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);
|
setManifest(parsed);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
setMode('yaml');
|
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) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.msg.loadFailed'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
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);
|
const yamlStr = await prepareYamlForSave(editYaml);
|
||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
await kubernetesApi.applyYAML(clusterCode, yamlStr);
|
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 {
|
} else {
|
||||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
|
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
|
||||||
toast({ title: i18n.t('kubernetes.msg.saveSuccess'), description: `${resource}/${name} 已更新` });
|
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 switchToVisual = async () => {
|
||||||
const parsed = await parseManifest(editYaml);
|
const parsed = await parseManifest(editYaml);
|
||||||
if (!parsed) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
setManifest(parsed);
|
setManifest(parsed);
|
||||||
@@ -156,7 +156,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
|||||||
const downloadYamlContent = () => {
|
const downloadYamlContent = () => {
|
||||||
const fname = yamlDownloadFilename(resource, namespace, name || manifest?.metadata?.name || 'resource');
|
const fname = yamlDownloadFilename(resource, namespace, name || manifest?.metadata?.name || 'resource');
|
||||||
downloadYamlFile(fname, currentYamlText());
|
downloadYamlFile(fname, currentYamlText());
|
||||||
toast({ title: i18n.t('kubernetes.yamlviewertsx.s9719fec8'), description: fname });
|
toast({ title: i18n.t('已下载'), description: fname });
|
||||||
};
|
};
|
||||||
|
|
||||||
const resCfg = getYamlResourceConfig(resource);
|
const resCfg = getYamlResourceConfig(resource);
|
||||||
@@ -262,7 +262,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
|||||||
{!['configmaps', 'secrets', 'services', 'ingresses', 'pvcs'].includes(resource) && (
|
{!['configmaps', 'secrets', 'services', 'ingresses', 'pvcs'].includes(resource) && (
|
||||||
<div className="flex-1 flex items-center justify-center text-center text-[var(--dg-text-muted)]">
|
<div className="flex-1 flex items-center justify-center text-center text-[var(--dg-text-muted)]">
|
||||||
<div>
|
<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>
|
<Button variant="outline" size="sm" className="mt-4" onClick={() => setMode('yaml')}> {i18n.t('kubernetes.resourcevisuale.s54c78d4f')} </Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -270,7 +270,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-center py-12 text-[var(--dg-text-muted)]">
|
<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>
|
<Button variant="outline" size="sm" className="mt-4" onClick={() => setMode('yaml')}> {i18n.t('kubernetes.resourcevisuale.s54c78d4f')} </Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export default function WorkloadViewPage() {
|
|||||||
} else {
|
} else {
|
||||||
await kubernetesApi.restartDaemonSet(clusterCode, namespace, name);
|
await kubernetesApi.restartDaemonSet(clusterCode, namespace, name);
|
||||||
}
|
}
|
||||||
toast({ title: i18n.t('kubernetes.deploymentdetai.s68a70009'), description: `${kind} 滚动重启已触发` });
|
toast({ title: i18n.t('重启指令已下发'), description: `${kind} 滚动重启已触发` });
|
||||||
setTimeout(loadData, 1000);
|
setTimeout(loadData, 1000);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: i18n.t('kubernetes.deployment.restartFailed'), description: e instanceof Error ? e.message : String(e), variant: 'destructive' });
|
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);
|
setScaleModal(false);
|
||||||
setTimeout(loadData, 1000);
|
setTimeout(loadData, 1000);
|
||||||
} catch (e) {
|
} 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); }
|
} finally { setActionLoading(false); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ export default function WorkloadViewPage() {
|
|||||||
subtitle={`${clusterCode} / ${namespace} · ${kind}`}
|
subtitle={`${clusterCode} / ${namespace} · ${kind}`}
|
||||||
icon={<Boxes className="h-5 w-5" />}
|
icon={<Boxes className="h-5 w-5" />}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
loadingLabel={i18n.t('kubernetes.workloadviewpag.s4eb429cb')}
|
loadingLabel={i18n.t('加载工作负载...')}
|
||||||
actions={(
|
actions={(
|
||||||
<>
|
<>
|
||||||
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => navigate(-1)}>
|
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => navigate(-1)}>
|
||||||
@@ -162,7 +162,7 @@ export default function WorkloadViewPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button variant="outline" size="sm" className="dg-btn-secondary" disabled={actionLoading} onClick={handleRestart}>
|
<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>
|
||||||
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => setYamlModal(true)}>
|
<Button variant="outline" size="sm" className="dg-btn-secondary" onClick={() => setYamlModal(true)}>
|
||||||
<FileCode className="h-3.5 w-3.5 mr-1" />YAML
|
<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.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.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.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('当前副本')} 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={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('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('期望调度')} 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={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.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('kubernetes.daemonset.numberAvailable')} value={numberAvailable} color={STATUS_COLORS.green} />
|
||||||
<StatCard label={i18n.t('deploy.toast.updated')} value={numberUpdated} color="var(--dg-text-secondary)" />
|
<StatCard label={i18n.t('deploy.toast.updated')} value={numberUpdated} color="var(--dg-text-secondary)" />
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function YamlViewer({
|
|||||||
setRawYaml(text);
|
setRawYaml(text);
|
||||||
await applyStripped(text);
|
await applyStripped(text);
|
||||||
} catch (e) {
|
} 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}`;
|
const err = `# Error: ${(e as Error).message}`;
|
||||||
setRawYaml(err);
|
setRawYaml(err);
|
||||||
setDisplayYaml(err);
|
setDisplayYaml(err);
|
||||||
@@ -104,7 +104,7 @@ export function YamlViewer({
|
|||||||
} else {
|
} else {
|
||||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
|
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);
|
setEditing(false);
|
||||||
setRawYaml(yamlStr);
|
setRawYaml(yamlStr);
|
||||||
setDisplayYaml(yamlStr);
|
setDisplayYaml(yamlStr);
|
||||||
@@ -125,7 +125,7 @@ export function YamlViewer({
|
|||||||
|
|
||||||
const downloadYaml = () => {
|
const downloadYaml = () => {
|
||||||
downloadYamlFile(yamlDownloadFilename(resource, namespace, name), currentYaml());
|
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);
|
const display = editing ? editYaml : (showRaw ? rawYaml : displayYaml);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export async function saveDeploymentBundleYaml(
|
|||||||
for (const manifest of manifests) {
|
for (const manifest of manifests) {
|
||||||
const kind = String(manifest.kind || '').toLowerCase();
|
const kind = String(manifest.kind || '').toLowerCase();
|
||||||
const name = String(manifest.metadata?.name || '').trim();
|
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);
|
const docYaml = await prepareManifestForSave(manifest);
|
||||||
if (kind === 'deployment') {
|
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">
|
<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 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}>
|
<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>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
renderRow: (item: any, opts: ResourceRowOpts) => React.ReactNode;
|
renderRow: (item: any, opts: ResourceRowOpts) => React.ReactNode;
|
||||||
}> = {
|
}> = {
|
||||||
deployments: {
|
deployments: {
|
||||||
title: 'Deployments', subtitle: i18n.t('kubernetes.namespaceresour.s35c744fb'), icon: Boxes,
|
title: 'Deployments', subtitle: i18n.t('Deployment 工作负载运行状态'), icon: Boxes,
|
||||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.capacitypagetsx.s0428b36a'), i18n.t('kubernetes.container.image')],
|
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('kubernetes.container.image')],
|
||||||
renderRow: (d, opts) => (
|
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)}>
|
<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>
|
<TableCell className="font-medium text-[var(--dg-text-primary)]">{d.name}</TableCell>
|
||||||
@@ -77,7 +77,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
pods: {
|
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')],
|
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) => {
|
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' };
|
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: {
|
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')],
|
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) => (
|
renderRow: (s, opts) => (
|
||||||
<TableRow key={s.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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: {
|
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')],
|
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), 'Hosts', 'TLS', i18n.t('system.auditAction')],
|
||||||
renderRow: (i, opts) => {
|
renderRow: (i, opts) => {
|
||||||
const hosts = i.hosts || [];
|
const hosts = i.hosts || [];
|
||||||
@@ -143,8 +143,8 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
configmaps: {
|
configmaps: {
|
||||||
title: 'ConfigMaps', subtitle: i18n.t('kubernetes.namespaceovervi.s0986a6e7'), icon: FileText,
|
title: 'ConfigMaps', subtitle: i18n.t('配置字典'), icon: FileText,
|
||||||
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('kubernetes.namespaceresour.sbd1fa02a'), i18n.t('system.auditAction')],
|
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('名称'), i18n.t('system.auditAction')],
|
||||||
renderRow: (c, opts) => (
|
renderRow: (c, opts) => (
|
||||||
<TableRow key={c.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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>
|
<TableCell className="font-medium text-[var(--dg-text-primary)]">{c.name}</TableCell>
|
||||||
@@ -155,7 +155,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
secrets: {
|
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')],
|
columns: [i18n.t('kubernetes.secret.secretName'), i18n.t('kubernetes.namespace.title'), i18n.t('system.credentialType'), i18n.t('system.auditAction')],
|
||||||
renderRow: (s, opts) => (
|
renderRow: (s, opts) => (
|
||||||
<TableRow key={s.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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: {
|
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%'],
|
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) => (
|
renderRow: (h, _opts) => (
|
||||||
<TableRow key={h.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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: {
|
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')],
|
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) => (
|
renderRow: (p, opts) => (
|
||||||
<TableRow key={p.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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: {
|
statefulsets: {
|
||||||
title: 'StatefulSets', subtitle: i18n.t('kubernetes.namespaceresour.sbfeb44d8'), icon: Boxes,
|
title: 'StatefulSets', subtitle: i18n.t('有状态应用'), 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')],
|
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) => (
|
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)}>
|
<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>
|
<TableCell className="font-medium text-[var(--dg-text-primary)]">{s.name}</TableCell>
|
||||||
@@ -221,7 +221,7 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
daemonsets: {
|
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')],
|
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) => (
|
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)}>
|
<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: {
|
serviceaccounts: {
|
||||||
title: 'ServiceAccounts', subtitle: i18n.t('kubernetes.namespaceresour.s645c9a3d'), icon: Shield,
|
title: 'ServiceAccounts', subtitle: i18n.t('服务账号(RBAC 身份标识)'), 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')],
|
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) => (
|
renderRow: (sa, opts) => (
|
||||||
<TableRow key={sa.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/30">
|
<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>
|
<TableCell className="font-medium text-[var(--dg-text-primary)]">{sa.name}</TableCell>
|
||||||
@@ -247,15 +247,15 @@ export const RESOURCE_CONFIG: Record<ResourceType, {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="text-xs text-[var(--dg-text-muted)]">{sa.age || '-'}</TableCell>
|
<TableCell className="text-xs text-[var(--dg-text-muted)]">{sa.age || '-'}</TableCell>
|
||||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
<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>
|
onClick={() => opts.onYaml?.(sa.name)}><FileCode className="h-3.5 w-3.5" /></Button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
roles: {
|
roles: {
|
||||||
title: 'Roles', subtitle: i18n.t('kubernetes.namespaceresour.s8905a680'), icon: Shield,
|
title: 'Roles', subtitle: i18n.t('命名空间级角色权限(RBAC)'), 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')],
|
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) => {
|
renderRow: (r, opts) => {
|
||||||
const verbs = r.verbs || [];
|
const verbs = r.verbs || [];
|
||||||
const resources = r.resources || [];
|
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 className="text-xs text-[var(--dg-text-muted)]">{r.age || '-'}</TableCell>
|
||||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||||
<div className="flex items-center gap-0.5">
|
<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>
|
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')}
|
<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>
|
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: {
|
rolebindings: {
|
||||||
title: 'RoleBindings', subtitle: i18n.t('kubernetes.namespaceresour.sca10fe5c'), icon: Shield,
|
title: 'RoleBindings', subtitle: i18n.t('角色绑定关系(RBAC 授权)'), 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')],
|
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) => {
|
renderRow: (rb, opts) => {
|
||||||
const subjects = rb.subjects || [];
|
const subjects = rb.subjects || [];
|
||||||
const subjStr = subjects.length > 3 ? subjects.slice(0, 3).join(', ') + ` +${subjects.length - 3}` : subjects.join(', ');
|
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 className="text-xs text-[var(--dg-text-muted)]">{rb.age || '-'}</TableCell>
|
||||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||||
<div className="flex items-center gap-0.5">
|
<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>
|
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')}
|
<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>
|
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"
|
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)]')}
|
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}
|
onClick={onPreviousToggle}
|
||||||
title={i18n.t('kubernetes.podlogsviewerts.s76a2e637')}
|
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||||
>
|
>
|
||||||
<History className="h-3.5 w-3.5 mr-1" />
|
<History className="h-3.5 w-3.5 mr-1" />
|
||||||
previous
|
previous
|
||||||
@@ -102,7 +102,7 @@ export function ControlBar(props: ControlBarProps) {
|
|||||||
onSinceTimeChange(v ? new Date(v).toISOString() : '');
|
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)]"
|
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>
|
</div>
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ export function ControlBar(props: ControlBarProps) {
|
|||||||
<Input
|
<Input
|
||||||
value={keyword}
|
value={keyword}
|
||||||
onChange={(e) => onKeywordChange(e.target.value)}
|
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)]"
|
className="h-8 w-[160px] pl-7 text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +124,7 @@ export function ControlBar(props: ControlBarProps) {
|
|||||||
variant="outline" size="sm"
|
variant="outline" size="sm"
|
||||||
className="h-8 text-xs border-[var(--dg-border)] text-[var(--dg-text-secondary)]"
|
className="h-8 text-xs border-[var(--dg-border)] text-[var(--dg-text-secondary)]"
|
||||||
onClick={onDownload}
|
onClick={onDownload}
|
||||||
title={i18n.t('kubernetes.podlogsviewerts.s1a023dfb')}
|
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||||
disabled={filteredLineCount === 0}
|
disabled={filteredLineCount === 0}
|
||||||
>
|
>
|
||||||
<Download className="h-3.5 w-3.5 mr-1" />导出
|
<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)]"
|
className="h-8 text-xs border-[var(--dg-border)] text-[var(--dg-text-secondary)]"
|
||||||
onClick={onRefresh}
|
onClick={onRefresh}
|
||||||
disabled={loading}
|
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')} />刷新
|
<RefreshCw className={cn('h-3.5 w-3.5 mr-1', loading && 'animate-spin')} />刷新
|
||||||
</Button>
|
</Button>
|
||||||
@@ -148,7 +148,7 @@ export function ControlBar(props: ControlBarProps) {
|
|||||||
className="h-8 text-xs bg-emerald-600 hover:bg-emerald-700"
|
className="h-8 text-xs bg-emerald-600 hover:bg-emerald-700"
|
||||||
onClick={onStartStream}
|
onClick={onStartStream}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
title={i18n.t('kubernetes.podlogsviewerts.s0d519cc0')}
|
title={i18n.t('查看上一次(崩溃)容器的日志')}
|
||||||
>
|
>
|
||||||
<Play className="h-3.5 w-3.5 mr-1" />实时
|
<Play className="h-3.5 w-3.5 mr-1" />实时
|
||||||
</Button>
|
</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-1 min-h-0 flex flex-col mt-3">
|
||||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
<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">
|
<div className="flex gap-1">
|
||||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={() => setExpandAll(!expandAll)}>
|
<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>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
@@ -63,13 +63,13 @@ export function ConfigMapEditor({ manifest, onSave, saving, isCreate }: ConfigMa
|
|||||||
<Input
|
<Input
|
||||||
value={entry.key}
|
value={entry.key}
|
||||||
onChange={e => update(i, 'key', e.target.value)}
|
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)]"
|
className="flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
value={entry.value}
|
value={entry.value}
|
||||||
onChange={e => update(i, 'value', e.target.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)}
|
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"
|
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>
|
</div>
|
||||||
))}
|
))}
|
||||||
{entries.length === 0 && (
|
{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>
|
||||||
</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)]">
|
<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>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{ingressClasses.length > 0 ? (
|
{ingressClasses.length > 0 ? (
|
||||||
@@ -131,7 +131,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
|||||||
</SelectItem>
|
</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) && (
|
{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-1 min-h-0 flex flex-col mt-3">
|
||||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
<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>
|
<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>
|
||||||
<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)]">
|
<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) => (
|
{rules.map((rule, ri) => (
|
||||||
@@ -178,7 +178,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
|||||||
<Input
|
<Input
|
||||||
value={rule.host}
|
value={rule.host}
|
||||||
onChange={e => updateRule(ri, e.target.value)}
|
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)]"
|
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}
|
title={rule.host}
|
||||||
/>
|
/>
|
||||||
@@ -187,7 +187,7 @@ export function IngressEditor({ manifest, clusterCode, onSave, saving, isCreate
|
|||||||
{rule.paths.map((p, pi) => (
|
{rule.paths.map((p, pi) => (
|
||||||
<div key={pi} className="overflow-x-auto pl-4">
|
<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]">
|
<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)}>
|
<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>
|
<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>
|
<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>
|
<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>
|
</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>
|
</div>
|
||||||
<div className="shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]">
|
<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>
|
||||||
<div className="grid grid-cols-2 gap-4 mt-3 shrink-0">
|
<div className="grid grid-cols-2 gap-4 mt-3 shrink-0">
|
||||||
<div>
|
<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
|
<Input
|
||||||
value={size}
|
value={size}
|
||||||
onChange={e => setSize(e.target.value)}
|
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)]"
|
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>
|
||||||
<div>
|
<div>
|
||||||
<Label className="text-[var(--dg-text-secondary)] text-xs"> {i18n.t('kubernetes.storage.accessModes')} </Label>
|
<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
|
<Input
|
||||||
value={storageClass}
|
value={storageClass}
|
||||||
onChange={e => setStorageClass(e.target.value)}
|
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)]"
|
className="mt-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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-1 min-h-0 flex flex-col mt-3">
|
||||||
<div className="flex items-center justify-between mb-2 shrink-0">
|
<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">
|
<div className="flex gap-1">
|
||||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={() => setExpandAll(!expandAll)}>
|
<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>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
@@ -82,13 +82,13 @@ export function SecretEditor({ manifest, onSave, saving, isCreate }: SecretEdito
|
|||||||
<Input
|
<Input
|
||||||
value={entry.key}
|
value={entry.key}
|
||||||
onChange={e => update(i, 'key', e.target.value)}
|
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)]"
|
className="flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
value={entry.value}
|
value={entry.value}
|
||||||
onChange={e => update(i, 'value', e.target.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)}
|
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"
|
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>
|
</div>
|
||||||
))}
|
))}
|
||||||
{entries.length === 0 && (
|
{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>
|
||||||
</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 className="flex-1 min-h-0 overflow-y-auto mt-3 pr-1 space-y-3">
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center justify-between mb-2">
|
<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>
|
<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>
|
||||||
<div className="space-y-2 border border-[var(--dg-border)] rounded-lg p-2 bg-[var(--dg-bg-secondary)]">
|
<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>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Selector */}
|
{/* Selector */}
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center justify-between mb-2">
|
<div className="flex items-center justify-between mb-2">
|
||||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('kubernetes.resourcevisuale.scecdd712')} </Label>
|
<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('kubernetes.resourcevisuale.s736eaaae')} </Button>
|
<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>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{selector.map((s, i) => (
|
{selector.map((s, i) => (
|
||||||
<div key={i} className="flex items-center gap-2 min-w-0">
|
<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>
|
<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>
|
<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>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pt-0 space-y-2 text-xs">
|
<CardContent className="pt-0 space-y-2 text-xs">
|
||||||
<div className="flex justify-between">
|
<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>
|
<Badge variant="outline" className="border-[var(--dg-border)] text-[var(--dg-text-secondary)]">{strategyType}</Badge>
|
||||||
</div>
|
</div>
|
||||||
{strategyType === 'RollingUpdate' && isSts && updateStrategy.rollingUpdate && (
|
{strategyType === 'RollingUpdate' && isSts && updateStrategy.rollingUpdate && (
|
||||||
<>
|
<>
|
||||||
<div className="flex justify-between">
|
<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>
|
<span className="text-[var(--dg-text-secondary)] font-mono">{updateStrategy.rollingUpdate.partition ?? 0}</span>
|
||||||
</div>
|
</div>
|
||||||
{updateStrategy.rollingUpdate.maxUnavailable && (
|
{updateStrategy.rollingUpdate.maxUnavailable && (
|
||||||
@@ -47,7 +47,7 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
|||||||
)}
|
)}
|
||||||
{updateStrategy.rollingUpdate.maxSurge && (
|
{updateStrategy.rollingUpdate.maxSurge && (
|
||||||
<div className="flex justify-between">
|
<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>
|
<span className="text-[var(--dg-text-secondary)] font-mono">{typeof updateStrategy.rollingUpdate.maxSurge === 'object' ? JSON.stringify(updateStrategy.rollingUpdate.maxSurge) : updateStrategy.rollingUpdate.maxSurge}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -60,7 +60,7 @@ export function UpdateStrategySelectorCards({ stats }: { stats: WorkloadStats })
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex justify-between">
|
<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>
|
<span className="text-[var(--dg-text-secondary)] font-mono">{spec.revisionHistoryLimit ?? 10}</span>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export function AlertChannelDialog({
|
|||||||
{/* 渠道列表 */}
|
{/* 渠道列表 */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="flex items-center justify-between">
|
<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
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@@ -207,10 +207,10 @@ export function AlertChannelDialog({
|
|||||||
{/* 渠道表单 */}
|
{/* 渠道表单 */}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<Label className="text-[var(--dg-text-secondary)] text-sm">
|
<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>
|
</Label>
|
||||||
<div className="space-y-1.5">
|
<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
|
<Input
|
||||||
value={channelForm.name}
|
value={channelForm.name}
|
||||||
onChange={(e) => setChannelForm({ ...channelForm, name: e.target.value })}
|
onChange={(e) => setChannelForm({ ...channelForm, name: e.target.value })}
|
||||||
|
|||||||
@@ -76,15 +76,15 @@ export function AlertManager() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const pageTabs = [
|
const pageTabs = [
|
||||||
{ id: 'events', label: i18n.t('kubernetes.eventspagetsx.s0e5b83cc') },
|
{ id: 'events', label: i18n.t('告警事件') },
|
||||||
{ id: 'rules', label: i18n.t('monitor.alertRules') },
|
{ id: 'rules', label: i18n.t('monitor.alertRules') },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('monitor.alertmanagertsx.sa57c10a3')}
|
title={i18n.t('监控告警')}
|
||||||
subtitle={i18n.t('monitor.alertmanagertsx.s1a70ca90')}
|
subtitle={i18n.t('告警规则管理与告警事件处理')}
|
||||||
icon={<Bell className="h-5 w-5" />}
|
icon={<Bell className="h-5 w-5" />}
|
||||||
tabs={pageTabs}
|
tabs={pageTabs}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
@@ -94,7 +94,7 @@ export function AlertManager() {
|
|||||||
items={[
|
items={[
|
||||||
{ label: i18n.t('monitor.alertRules'), value: rules.length, color: 'blue' },
|
{ 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.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' },
|
{ 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">
|
<DialogContent className="dg-input max-w-lg">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-[var(--dg-text-primary)]">
|
<DialogTitle className="text-[var(--dg-text-primary)]">
|
||||||
{editingRule ? i18n.t('monitor.alertruledialog.sb62c8bc1') : i18n.t('monitor.alertruledialog.s3564fa12')}
|
{editingRule ? i18n.t('编辑告警规则') : i18n.t('新建告警规则')}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription className="dg-text-muted">
|
<DialogDescription className="dg-text-muted">
|
||||||
{editingRule ? i18n.t('monitor.alertruledialog.s44a3bb2d') : i18n.t('monitor.alertruledialog.sb785eced')}
|
{editingRule ? i18n.t('编辑告警规则') : i18n.t('新建告警规则')}
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ export function AlertRuleDialog({
|
|||||||
<Input
|
<Input
|
||||||
value={ruleForm.name}
|
value={ruleForm.name}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, name: e.target.value })}
|
||||||
placeholder={i18n.t('monitor.alertruledialog.sf111cd25')}
|
placeholder={i18n.t('如:CPU 使用率告警')}
|
||||||
className="dg-input"
|
className="dg-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -151,7 +151,7 @@ export function AlertRuleDialog({
|
|||||||
<Textarea
|
<Textarea
|
||||||
value={ruleForm.description}
|
value={ruleForm.description}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, description: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, description: e.target.value })}
|
||||||
placeholder={i18n.t('monitor.alertruledialog.scc807bdb')}
|
placeholder={i18n.t('如:CPU 使用率告警')}
|
||||||
rows={2}
|
rows={2}
|
||||||
className="dg-input resize-none"
|
className="dg-input resize-none"
|
||||||
/>
|
/>
|
||||||
@@ -159,7 +159,7 @@ export function AlertRuleDialog({
|
|||||||
|
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div className="space-y-1.5">
|
<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
|
<select
|
||||||
value={ruleForm.type}
|
value={ruleForm.type}
|
||||||
onChange={(e) => {
|
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"
|
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="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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
@@ -199,13 +199,13 @@ export function AlertRuleDialog({
|
|||||||
|
|
||||||
{ruleForm.type === 'log' && (
|
{ruleForm.type === 'log' && (
|
||||||
<div className="space-y-1.5">
|
<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
|
<select
|
||||||
value={ruleForm.datasource_id || ''}
|
value={ruleForm.datasource_id || ''}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, datasource_id: Number(e.target.value) || undefined })}
|
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"
|
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) => (
|
{logSources.map((s) => (
|
||||||
<option key={s.id} value={s.id}>{s.name}{s.is_default ? i18n.t('monitor.logPanel.defaultSuffix') : ''}</option>
|
<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">
|
<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
|
<Input
|
||||||
value={ruleForm.expression}
|
value={ruleForm.expression}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, expression: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, expression: e.target.value })}
|
||||||
@@ -226,14 +226,14 @@ export function AlertRuleDialog({
|
|||||||
/>
|
/>
|
||||||
<p className="text-xs dg-text-muted">
|
<p className="text-xs dg-text-muted">
|
||||||
{ruleForm.type === 'log'
|
{ruleForm.type === 'log'
|
||||||
? (ruleForm.source === 'loki' ? i18n.t('monitor.alertruledialog.s465c2bb1') : i18n.t('monitor.alertruledialog.s7072bc91'))
|
? (ruleForm.source === 'loki' ? i18n.t('LogQL 查询或 count_over_time 表达式') : i18n.t('Elasticsearch Lucene 查询'))
|
||||||
: i18n.t('monitor.alertruledialog.se2017efe')}
|
: i18n.t('PromQL 或指标表达式,例如 cpu_usage > 80')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div className="space-y-1.5">
|
<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
|
<select
|
||||||
value={ruleForm.severity}
|
value={ruleForm.severity}
|
||||||
onChange={(e) => setRuleForm({ ...ruleForm, severity: e.target.value })}
|
onChange={(e) => setRuleForm({ ...ruleForm, severity: e.target.value })}
|
||||||
@@ -245,7 +245,7 @@ export function AlertRuleDialog({
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<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
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
value={ruleForm.duration}
|
value={ruleForm.duration}
|
||||||
@@ -303,7 +303,7 @@ export function AlertRuleDialog({
|
|||||||
onClick={handleSaveRule}
|
onClick={handleSaveRule}
|
||||||
>
|
>
|
||||||
{ruleSaving && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
|
{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>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -54,15 +54,15 @@ export function AlertRulesTab({
|
|||||||
|
|
||||||
const handleDeleteRule = async ( id: number) => {
|
const handleDeleteRule = async ( id: number) => {
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: i18n.t('monitor.alertrulestabts.sfa5bfdc3'),
|
title: i18n.t('删除告警规则'),
|
||||||
description: i18n.t('monitor.alertrulestabts.sd301558d'),
|
description: i18n.t('确定删除此告警规则?'),
|
||||||
confirmText: i18n.t('kubernetes.storage.delete2'),
|
confirmText: i18n.t('kubernetes.storage.delete2'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await alertApi.deleteRule(id);
|
await alertApi.deleteRule(id);
|
||||||
toast.success(i18n.t('monitor.alertrulestabts.s20b3fdcd'));
|
toast.success(i18n.t('告警规则已删除'));
|
||||||
onReload();
|
onReload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to delete rule:', error);
|
console.error('Failed to delete rule:', error);
|
||||||
@@ -74,7 +74,7 @@ export function AlertRulesTab({
|
|||||||
const handleBatchDelete = async () => {
|
const handleBatchDelete = async () => {
|
||||||
if (selectedIds.length === 0) return;
|
if (selectedIds.length === 0) return;
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: i18n.t('monitor.alertrulestabts.sbb457b70'),
|
title: i18n.t('删除告警规则'),
|
||||||
description: `确定删除选中的 ${selectedIds.length} 条告警规则吗?此操作不可撤销。`,
|
description: `确定删除选中的 ${selectedIds.length} 条告警规则吗?此操作不可撤销。`,
|
||||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||||
variant: 'destructive',
|
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>
|
<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: '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: '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('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: '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 }) => (
|
].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)}>
|
<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>
|
<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);
|
const [editingDs, setEditingDs] = useState<PromDS | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isError) toast.error(i18n.t('monitor.zabbixdatasourc.s45f81749'));
|
if (isError) toast.error(i18n.t('获取数据源列表失败'));
|
||||||
}, [isError]);
|
}, [isError]);
|
||||||
|
|
||||||
const openCreate = () => {
|
const openCreate = () => {
|
||||||
@@ -67,7 +67,7 @@ export default function PrometheusDatasourceManager() {
|
|||||||
await setDefaultMutation.mutateAsync(ds.id);
|
await setDefaultMutation.mutateAsync(ds.id);
|
||||||
toast.success(`已将「${ds.name}」设为默认数据源`);
|
toast.success(`已将「${ds.name}」设为默认数据源`);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(i18n.t('monitor.zabbixdatasourc.s9f96034c'));
|
toast.error(i18n.t('删除失败'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ export default function PrometheusDatasourceManager() {
|
|||||||
{sources.length === 0 ? (
|
{sources.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<Database className="h-12 w-12" />}
|
icon={<Database className="h-12 w-12" />}
|
||||||
title={i18n.t('monitor.prometheusdatas.s99ed81c8')}
|
title={i18n.t('暂无 Prometheus 数据源')}
|
||||||
description={i18n.t('monitor.prometheusdatas.sd9a356b8')}
|
description={i18n.t('添加数据源后可用于指标监控与监控大屏')}
|
||||||
action={(
|
action={(
|
||||||
<Button onClick={openCreate} size="sm" className="dg-btn-primary">
|
<Button onClick={openCreate} size="sm" className="dg-btn-primary">
|
||||||
<Plus className="w-4 h-4 mr-1" />添加数据源
|
<Plus className="w-4 h-4 mr-1" />添加数据源
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default function ZabbixDatasourceManager() {
|
|||||||
const res: JsonData = await zabbixDatasourceApi.list();
|
const res: JsonData = await zabbixDatasourceApi.list();
|
||||||
setSources(res?.data || res || []);
|
setSources(res?.data || res || []);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(i18n.t('monitor.zabbixdatasourc.s45f81749'));
|
toast.error(i18n.t('获取数据源列表失败'));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -117,17 +117,17 @@ export default function ZabbixDatasourceManager() {
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.name.trim()) { toast.error(i18n.t('monitor.promDs.nameRequired')); return; }
|
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.username.trim()) { toast.error(i18n.t('pipeline.usernameRequired')); return; }
|
||||||
if (!form.password.trim()) { toast.error(i18n.t('login.passwordRequired')); return; }
|
if (!form.password.trim()) { toast.error(i18n.t('login.passwordRequired')); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (editingId) {
|
if (editingId) {
|
||||||
await zabbixDatasourceApi.update(editingId, form);
|
await zabbixDatasourceApi.update(editingId, form);
|
||||||
toast.success(i18n.t('monitor.zabbixdatasourc.s8dfdd2f4'));
|
toast.success(i18n.t('数据源已更新'));
|
||||||
} else {
|
} else {
|
||||||
await zabbixDatasourceApi.create(form);
|
await zabbixDatasourceApi.create(form);
|
||||||
toast.success(i18n.t('monitor.zabbixdatasourc.sa6def01f'));
|
toast.success(i18n.t('数据源已更新'));
|
||||||
}
|
}
|
||||||
setDialogOpen(false);
|
setDialogOpen(false);
|
||||||
fetchList();
|
fetchList();
|
||||||
@@ -155,12 +155,12 @@ export default function ZabbixDatasourceManager() {
|
|||||||
await zabbixDatasourceApi.setDefault(ds.id);
|
await zabbixDatasourceApi.setDefault(ds.id);
|
||||||
toast.success(`已将「${ds.name}」设为默认`);
|
toast.success(`已将「${ds.name}」设为默认`);
|
||||||
fetchList();
|
fetchList();
|
||||||
} catch { toast.error(i18n.t('monitor.zabbixdatasourc.s9f96034c')); }
|
} catch { toast.error(i18n.t('删除失败')); }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTest = async () => {
|
const handleTest = async () => {
|
||||||
if (!form.url.trim() || !form.username.trim()) {
|
if (!form.url.trim() || !form.username.trim()) {
|
||||||
toast.error(i18n.t('monitor.zabbixdatasourc.s1d3562b7'));
|
toast.error(i18n.t('获取数据源列表失败'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTesting(true);
|
setTesting(true);
|
||||||
@@ -264,7 +264,7 @@ export default function ZabbixDatasourceManager() {
|
|||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2">
|
<DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2">
|
||||||
<Database className="h-5 w-5 dg-text-orange" />
|
<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>
|
</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
配置 Zabbix API 连接,用于主机监控与告警数据获取
|
配置 Zabbix API 连接,用于主机监控与告警数据获取
|
||||||
@@ -276,7 +276,7 @@ export default function ZabbixDatasourceManager() {
|
|||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
<Label className="text-xs text-[var(--dg-text-secondary)]"> {i18n.t('deploy.form.nameStar')} </Label>
|
<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)} />
|
value={form.name} onChange={e => updateForm('name', e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end pb-1">
|
<div className="flex items-end pb-1">
|
||||||
@@ -366,7 +366,7 @@ export default function ZabbixDatasourceManager() {
|
|||||||
onClick={() => setShowOther(!showOther)}>
|
onClick={() => setShowOther(!showOther)}>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Settings className="w-4 h-4" />
|
<Settings className="w-4 h-4" />
|
||||||
<span> {i18n.t('monitor.zabbixdatasourc.sdda36edb')} </span>
|
<span> {i18n.t('编辑 Zabbix 数据源')} </span>
|
||||||
</div>
|
</div>
|
||||||
{showOther ? <ChevronUp className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />}
|
{showOther ? <ChevronUp className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -147,10 +147,10 @@ export function LogDatasourcePage() {
|
|||||||
rowKey={(ds) => ds.id}
|
rowKey={(ds) => ds.id}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
searchable
|
searchable
|
||||||
searchPlaceholder={i18n.t('monitor.logdatasourcepa.seb5e4d30')}
|
searchPlaceholder={i18n.t('搜索数据源名称或地址...')}
|
||||||
searchKeys={['name', 'url']}
|
searchKeys={['name', 'url']}
|
||||||
sortable
|
sortable
|
||||||
emptyText={i18n.t('monitor.logdatasourcepa.sc8a96073')}
|
emptyText={i18n.t('暂无数据源,点击上方按钮添加')}
|
||||||
toolbarExtra={
|
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}>
|
<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
|
<input
|
||||||
value={search}
|
value={search}
|
||||||
onChange={e => setSearch(e.target.value)}
|
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"
|
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)' }}
|
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 }> = {
|
const STATUS_LABEL: Record<string, { text: string; color: string }> = {
|
||||||
precise: { text: i18n.t('monitor.logquerytoolbar.sd0368470'), color: '#22c55e' },
|
precise: { text: i18n.t('结果精确'), color: '#22c55e' },
|
||||||
partial: { text: i18n.t('monitor.logquerytoolbar.s8b09f4fe'), color: '#f59e0b' },
|
partial: { text: i18n.t('部分命中'), color: '#f59e0b' },
|
||||||
failed: { text: i18n.t('monitor.logPanel.queryFailed'), color: '#ef4444' },
|
failed: { text: i18n.t('monitor.logPanel.queryFailed'), color: '#ef4444' },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import i18n from '@/i18n';
|
|||||||
|
|
||||||
const ROLE_LABEL: Record<string, string> = {
|
const ROLE_LABEL: Record<string, string> = {
|
||||||
viewer: i18n.t('pipeline.viewer'),
|
viewer: i18n.t('pipeline.viewer'),
|
||||||
analyst: i18n.t('monitor.logrbactsx.sa72dec16'),
|
analyst: i18n.t('分析者'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const ENGINE_LABEL: Record<string, string> = {
|
const ENGINE_LABEL: Record<string, string> = {
|
||||||
@@ -108,7 +108,7 @@ export default function LogRBAC() {
|
|||||||
|
|
||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
if (!newName.trim() || !newCode.trim() || !newPattern.trim()) {
|
||||||
toast.error(i18n.t('monitor.logrbactsx.sf6e80bf0')); return;
|
toast.error(i18n.t('请填写名称、标识与正则')); return;
|
||||||
}
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
@@ -147,7 +147,7 @@ export default function LogRBAC() {
|
|||||||
|
|
||||||
const handleDelete = async (role: LogScopeRole) => {
|
const handleDelete = async (role: LogScopeRole) => {
|
||||||
const ok = await _confirm({
|
const ok = await _confirm({
|
||||||
title: i18n.t('monitor.logrbactsx.s5d79e436'),
|
title: i18n.t('删除权限'),
|
||||||
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个示例范围`,
|
description: `确定删除「${role.name}」?将影响 ${matchCount[role.id]?.length || 0} 个示例范围`,
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
@@ -165,7 +165,7 @@ export default function LogRBAC() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAssign = async () => {
|
const handleAssign = async () => {
|
||||||
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('monitor.logrbactsx.s0fc53985')); return; }
|
if (!selectedUserId || !assignRoleId) { toast.error(i18n.t('请选择用户和权限')); return; }
|
||||||
setAssignLoading(true);
|
setAssignLoading(true);
|
||||||
try {
|
try {
|
||||||
await logRbacApi.assignRole(Number(selectedUserId), {
|
await logRbacApi.assignRole(Number(selectedUserId), {
|
||||||
@@ -189,8 +189,8 @@ export default function LogRBAC() {
|
|||||||
|
|
||||||
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
const selectedUser = users.find((u) => String(u.id) === selectedUserId);
|
||||||
const pageTabs = [
|
const pageTabs = [
|
||||||
{ id: 'roles', label: i18n.t('monitor.logrbactsx.s93ef07cd'), badge: roles.length || undefined },
|
{ id: 'roles', label: i18n.t('权限策略'), badge: roles.length || undefined },
|
||||||
{ id: 'users', label: i18n.t('monitor.logrbactsx.s2de89571') },
|
{ id: 'users', label: i18n.t('用户授权') },
|
||||||
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
{ id: 'preview', label: i18n.t('pipeline.matchPreview') },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -215,8 +215,8 @@ export default function LogRBAC() {
|
|||||||
roles.length === 0 ? (
|
roles.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<Shield className="h-10 w-10" />}
|
icon={<Shield className="h-10 w-10" />}
|
||||||
title={i18n.t('monitor.logrbactsx.s4a00d253')}
|
title={i18n.t('暂无日志权限策略')}
|
||||||
description={i18n.t('monitor.logrbactsx.sd11b7407')}
|
description={i18n.t('创建策略并分配给用户后,将按正则限制可查询的索引与 Label 范围')}
|
||||||
action={<Button onClick={() => setCreateOpen(true)}><Plus className="h-4 w-4 mr-1" /> {i18n.t('monitor.logrbactsx.s6058845c')} </Button>}
|
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>
|
<SelectTrigger className="h-7 w-20 text-xs"><SelectValue /></SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="viewer"> {i18n.t('pipeline.viewer')} </SelectItem>
|
<SelectItem value="viewer"> {i18n.t('pipeline.viewer')} </SelectItem>
|
||||||
<SelectItem value="analyst"> {i18n.t('monitor.logrbactsx.sa72dec16')} </SelectItem>
|
<SelectItem value="analyst"> {i18n.t('分析者')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => handleUpdate(role.id)}><Check className="w-3.5 h-3.5" /></Button>
|
<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>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1 w-48">
|
<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}>
|
<Select value={assignRoleId} onValueChange={setAssignRoleId}>
|
||||||
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
<SelectTrigger className="h-8 text-sm dg-input"><SelectValue placeholder={i18n.t('kubernetes.hpa.selectPolicy')} /></SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
@@ -4,36 +4,36 @@ import i18n from '@/i18n';
|
|||||||
|
|
||||||
const ALL_TEMPLATES: Record<'loki' | 'elasticsearch', { label: string; query: string }[]> = {
|
const ALL_TEMPLATES: Record<'loki' | 'elasticsearch', { label: string; query: string }[]> = {
|
||||||
loki: [
|
loki: [
|
||||||
{ label: i18n.t('monitor.quickquerybarts.s64559524'), query: '{job="nginx"} |= "error"' },
|
{ label: i18n.t('Nginx 错误'), query: '{job="nginx"} |= "error"' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.s315990ac'), query: '{namespace="prod"} | json | level="warn"' },
|
{ label: i18n.t('JSON 过滤'), query: '{namespace="prod"} | json | level="warn"' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.sfc6d4276'), query: '{app="api"} |= "timeout"' },
|
{ label: i18n.t('超时搜索'), query: '{app="api"} |= "timeout"' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.s0ce3d219'), query: 'sum by(level) (count_over_time({job="app"}[5m]))' },
|
{ label: i18n.t('级别统计'), 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('正则多级别'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.sf839efd6'), query: '{job="api"} | json | response_time > 1000' },
|
{ label: i18n.t('慢请求>1s'), 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('错误率统计'), 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('追踪ID查询'), 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('错误率统计'), 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('高延迟筛选'), query: '{app="cex-admin-api"} | json | response_time > 500' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.sb8edf48d'), query: '{app="cex-admin-api"} |= "Exception"' },
|
{ 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.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('正则提取'), 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"} | json | line_format "{{.level}} {{.message}}"' },
|
||||||
],
|
],
|
||||||
elasticsearch: [
|
elasticsearch: [
|
||||||
{ label: 'API 5xx', query: 'status:500 AND path:"/api/*"' },
|
{ 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('错误超时'), 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('排除调试'), query: 'host.name:server-* AND NOT level:debug' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.s0876c43d'), query: 'response_time:>1000 AND method:POST' },
|
{ label: i18n.t('慢请求'), 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('严重错误'), 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('严重错误'), 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('组合查询'), 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('模糊匹配'), 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('范围查询'), 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('排除路径'), 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('时间过滤'), 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('IP段过滤'), 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('多级别筛选'), 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: 'labels.orgId:10001 AND app:cex-admin-api' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,27 +6,27 @@ import i18n from '@/i18n';
|
|||||||
|
|
||||||
// 相对时间预设:最近N... 每次点击时计算 start = now - N // Logan.Li
|
// 相对时间预设:最近N... 每次点击时计算 start = now - N // Logan.Li
|
||||||
const RELATIVE_PRESETS = [
|
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.logPanel.last5min'), value: '5m' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.sd4962f4b'), value: '15m' },
|
{ label: i18n.t('最近15分钟'), value: '15m' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.sd8a81545'), value: '1h' },
|
{ label: i18n.t('最近1小时'), value: '1h' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s0823ad83'), value: '4h' },
|
{ label: i18n.t('最近4小时'), value: '4h' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s77be0dba'), value: '24h' },
|
{ label: i18n.t('最近1天'), value: '24h' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s2ba41ef4'), value: '7d' },
|
{ label: i18n.t('最近1周'), value: '7d' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s63f66f1f'), value: '30d' },
|
{ label: i18n.t('最近30天'), value: '30d' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 绝对时间预设:固定的自然日/周/月/季/年 // Logan.Li
|
// 绝对时间预设:固定的自然日/周/月/季/年 // Logan.Li
|
||||||
const ABSOLUTE_PRESETS = [
|
const ABSOLUTE_PRESETS = [
|
||||||
{ label: i18n.t('audit.terminal.presetToday'), value: 'today' },
|
{ label: i18n.t('audit.terminal.presetToday'), value: 'today' },
|
||||||
{ label: i18n.t('common.yesterday'), value: 'yesterday' },
|
{ 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.thisWeek'), value: 'this_week' },
|
||||||
{ label: i18n.t('common.lastWeek'), value: 'last_week' },
|
{ label: i18n.t('common.lastWeek'), value: 'last_week' },
|
||||||
{ label: i18n.t('cloud.thisMonth'), value: 'this_month' },
|
{ label: i18n.t('cloud.thisMonth'), value: 'this_month' },
|
||||||
{ label: i18n.t('common.lastMonth'), value: 'last_month' },
|
{ label: i18n.t('common.lastMonth'), value: 'last_month' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s0477ce74'), value: 'this_quarter' },
|
{ label: i18n.t('本季度'), value: 'this_quarter' },
|
||||||
{ label: i18n.t('monitor.timerangepicker.s77df6c8e'), value: 'this_year' },
|
{ label: i18n.t('本年度'), value: 'this_year' },
|
||||||
];
|
];
|
||||||
|
|
||||||
function getPresetRange(value: string): { start: Date; end: Date; label: string } {
|
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)' }}>
|
<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)' }} />
|
<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
|
<button
|
||||||
onClick={openCustom}
|
onClick={openCustom}
|
||||||
className="text-xs ml-2 px-2 py-0.5 rounded transition-colors"
|
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' ? (
|
{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">
|
<div className="grid grid-cols-4 gap-1.5 mb-3">
|
||||||
{RELATIVE_PRESETS.map(p => (
|
{RELATIVE_PRESETS.map(p => (
|
||||||
<button
|
<button
|
||||||
@@ -171,7 +171,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
|||||||
</div>
|
</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">
|
<div className="grid grid-cols-5 gap-1.5">
|
||||||
{ABSOLUTE_PRESETS.map(p => (
|
{ABSOLUTE_PRESETS.map(p => (
|
||||||
<button
|
<button
|
||||||
@@ -192,7 +192,7 @@ export function TimeRangePicker({ value, onChange }: Props) {
|
|||||||
) : (
|
) : (
|
||||||
/* 自定义日历模式 */
|
/* 自定义日历模式 */
|
||||||
<div className="space-y-3">
|
<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 className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[10px] block mb-1" style={{ color: 'var(--dg-text-muted)' }}> {i18n.t('system.terminalStartTime')} </label>
|
<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',
|
color: '#f97316',
|
||||||
queryPlaceholder: 'keyword | SELECT * WHERE level = "info"',
|
queryPlaceholder: 'keyword | SELECT * WHERE level = "info"',
|
||||||
statPlaceholder: '* | SELECT level, COUNT(*) as cnt GROUP BY level',
|
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
|
// 快捷查询模板 // Logan.Li
|
||||||
export const QUICK_TEMPLATES: Record<LogEngine, { label: string; query: string }[]> = {
|
export const QUICK_TEMPLATES: Record<LogEngine, { label: string; query: string }[]> = {
|
||||||
loki: [
|
loki: [
|
||||||
{ label: i18n.t('monitor.typesv3ts.s70d6c24a'), query: '{job="nginx"} |= "error"' },
|
{ label: i18n.t('Nginx 错误日志'), query: '{job="nginx"} |= "error"' },
|
||||||
{ label: i18n.t('monitor.typesv3ts.saf1cb054'), query: '{namespace="prod"} | json | level="warn"' },
|
{ label: i18n.t('JSON 解析过滤'), query: '{namespace="prod"} | json | level="warn"' },
|
||||||
{ label: i18n.t('monitor.quickquerybarts.sfc6d4276'), query: '{app="api"} |= "timeout"' },
|
{ label: i18n.t('超时搜索'), query: '{app="api"} |= "timeout"' },
|
||||||
{ label: i18n.t('monitor.typesv3ts.s475a42fe'), query: 'sum by (level) (count_over_time({job="app"}[5m]))' },
|
{ label: i18n.t('按级别统计'), 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('正则匹配多级别'), query: '{container="frontend"} |~ "ERROR|WARN|FATAL"' },
|
||||||
{ label: i18n.t('monitor.typesv3ts.s4dc793a9'), query: '{job="api"} | json | response_time > 1000' },
|
{ label: i18n.t('慢请求 >1s'), query: '{job="api"} | json | response_time > 1000' },
|
||||||
],
|
],
|
||||||
elasticsearch: [
|
elasticsearch: [
|
||||||
{ label: i18n.t('monitor.typesv3ts.sd81428f4'), query: 'status:500 AND path:"/api/*"' },
|
{ label: i18n.t('API 5xx 错误'), 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('错误超时日志'), 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('排除调试日志'), 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('慢请求检测'), 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('最近1小时严重错误'), 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('最近1小时严重错误'), query: 'service:nginx AND (level:(error OR fatal) OR log.level:(error OR fatal))' },
|
||||||
],
|
],
|
||||||
sls: [
|
sls: [
|
||||||
{ label: i18n.t('monitor.typesv3ts.sf8889aa4'), query: "* | select * where level = 'error'" },
|
{ label: i18n.t('错误日志筛选'), query: "* | select * where level = 'error'" },
|
||||||
{ label: i18n.t('monitor.typesv3ts.s475a42fe'), query: "* | select count(*) as cnt, level group by level" },
|
{ label: i18n.t('按级别统计'), 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('时间聚合'), 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('状态码分布'), 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('慢请求分析'), 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 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 || []);
|
setBreadcrumbs(data.breadcrumbs || []);
|
||||||
setCurrentPath(data.path || path);
|
setCurrentPath(data.path || path);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err?.message || i18n.t('server.serverfilebrows.s4be30fcb'));
|
setError(err?.message || i18n.t('加载目录失败'));
|
||||||
setItems([]);
|
setItems([]);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -97,7 +97,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
|||||||
try {
|
try {
|
||||||
await serverApi.downloadFile(serverId, filePath);
|
await serverApi.downloadFile(serverId, filePath);
|
||||||
} catch (err) {
|
} 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) => {
|
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 {
|
try {
|
||||||
await serverApi.deleteFile(serverId, filePath);
|
await serverApi.deleteFile(serverId, filePath);
|
||||||
await fetchDir(currentPath);
|
await fetchDir(currentPath);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function escapeCsv(s: string): string {
|
|||||||
// exportAuditReportCsv 导出会话审计报告 CSV // Logan.Li
|
// exportAuditReportCsv 导出会话审计报告 CSV // Logan.Li
|
||||||
export function exportAuditReportCsv(meta: ReplaySessionMeta, commands: CommandBookmark[]) {
|
export function exportAuditReportCsv(meta: ReplaySessionMeta, commands: CommandBookmark[]) {
|
||||||
const lines: string[] = [
|
const lines: string[] = [
|
||||||
i18n.t('system.exportauditts.s3cb7eb59'),
|
i18n.t('# 终端会话审计报告'),
|
||||||
`会话ID,${meta.id}`,
|
`会话ID,${meta.id}`,
|
||||||
`用户,${escapeCsv(meta.username || '')}`,
|
`用户,${escapeCsv(meta.username || '')}`,
|
||||||
`目标主机,${escapeCsv(meta.server_name || '')}`,
|
`目标主机,${escapeCsv(meta.server_name || '')}`,
|
||||||
@@ -33,7 +33,7 @@ export function exportAuditReportCsv(meta: ReplaySessionMeta, commands: CommandB
|
|||||||
`时长(秒),${meta.duration || 0}`,
|
`时长(秒),${meta.duration || 0}`,
|
||||||
`录制大小,${meta.record_size || 0}`,
|
`录制大小,${meta.record_size || 0}`,
|
||||||
'',
|
'',
|
||||||
i18n.t('system.exportauditts.s7a85eed7'),
|
i18n.t('# 终端会话审计报告'),
|
||||||
];
|
];
|
||||||
for (const c of commands) {
|
for (const c of commands) {
|
||||||
lines.push(`${c.label},${escapeCsv(c.command)},${c.highRisk ? '是' : '否'}`);
|
lines.push(`${c.label},${escapeCsv(c.command)},${c.highRisk ? '是' : '否'}`);
|
||||||
@@ -55,7 +55,7 @@ export interface CommandExportRow {
|
|||||||
|
|
||||||
// exportCommandsListCsv 导出命令列表 CSV // Logan.Li
|
// exportCommandsListCsv 导出命令列表 CSV // Logan.Li
|
||||||
export function exportCommandsListCsv(commands: CommandExportRow[]) {
|
export function exportCommandsListCsv(commands: CommandExportRow[]) {
|
||||||
const lines: string[] = [i18n.t('system.exportauditts.s6e047305')];
|
const lines: string[] = [i18n.t('时间,用户,命令,输出大小,会话ID,高危')];
|
||||||
for (const c of commands) {
|
for (const c of commands) {
|
||||||
const ts = c.timestamp || c.created_at || '';
|
const ts = c.timestamp || c.created_at || '';
|
||||||
const highRisk = isHighRiskCommand(c.command || '');
|
const highRisk = isHighRiskCommand(c.command || '');
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
|||||||
if (msg.includes('Already Exists') || msg.includes('68')) {
|
if (msg.includes('Already Exists') || msg.includes('68')) {
|
||||||
toast.error(i18n.t('system.useldapmanageme.s1a2b3c4d', { name: ouForm.ou_name }));
|
toast.error(i18n.t('system.useldapmanageme.s1a2b3c4d', { name: ouForm.ou_name }));
|
||||||
} else {
|
} else {
|
||||||
toast.error(i18n.t('system.useldapmanageme.s2b3c4d5e') + msg);
|
toast.error(i18n.t('创建失败: ') + msg);
|
||||||
}
|
}
|
||||||
} finally { setLdapSaving(false); }
|
} finally { setLdapSaving(false); }
|
||||||
};
|
};
|
||||||
@@ -168,7 +168,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
|||||||
/** 删除 LDAP 条目 // Logan.Li */
|
/** 删除 LDAP 条目 // Logan.Li */
|
||||||
const handleDeleteLDAPEntry = async (dn: string, silent = false) => {
|
const handleDeleteLDAPEntry = async (dn: string, silent = false) => {
|
||||||
if (!silent) {
|
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;
|
if (!ok) return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -190,7 +190,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
|||||||
await ldapApi.updateUser({ dn: editLdapUser.dn, ...editLdapForm });
|
await ldapApi.updateUser({ dn: editLdapUser.dn, ...editLdapForm });
|
||||||
setEditLdapUser(null);
|
setEditLdapUser(null);
|
||||||
await loadLdapOUUsers(selectedOUDN);
|
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 */
|
/** 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 });
|
const res = await ldapApi.testConnection({ test_user: ldapTestUser, test_password: ldapTestPass });
|
||||||
setLdapUserTestResult(res);
|
setLdapUserTestResult(res);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setLdapUserTestResult({ success: false, message: e?.message || i18n.t('system.useldapmanageme.se441b11e') });
|
setLdapUserTestResult({ success: false, message: e?.message || i18n.t('验证失败') });
|
||||||
} finally { setLdapUserTesting(false); }
|
} finally { setLdapUserTesting(false); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,11 +234,11 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
|||||||
} else if (opts?.importAll) {
|
} else if (opts?.importAll) {
|
||||||
selected = ldapUsers;
|
selected = ldapUsers;
|
||||||
} else {
|
} else {
|
||||||
toast.error(i18n.t('system.useldapmanageme.sa8ca9651'));
|
toast.error(i18n.t('请至少选择一个用户'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
toast.error(i18n.t('system.useldapmanageme.sd196a1c0'));
|
toast.error(i18n.t('请至少选择一个用户'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setImporting(true);
|
setImporting(true);
|
||||||
@@ -265,7 +265,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
|||||||
await onUsersChanged();
|
await onUsersChanged();
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const errMsg = error instanceof Error ? error.message : i18n.t('monitor.dashboard.agent.toast.unknownError');
|
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) {
|
if (opts?.setResult) {
|
||||||
opts.setResult(result);
|
opts.setResult(result);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ import i18n from '@/i18n';
|
|||||||
|
|
||||||
// 定时任务类型定义 // Logan.Li
|
// 定时任务类型定义 // Logan.Li
|
||||||
const jobTypes = [
|
const jobTypes = [
|
||||||
{ value: 'shell', label: 'Shell', desc: i18n.t('task.cronjobformdial.s570531a7') },
|
{ value: 'shell', label: 'Shell', desc: i18n.t('关联脚本库中的 Shell 脚本') },
|
||||||
{ value: 'python', label: 'Python', desc: i18n.t('task.cronjobformdial.s021fae85') },
|
{ value: 'python', label: 'Python', desc: i18n.t('关联脚本库中的 Python 脚本') },
|
||||||
{ value: 'powershell', label: 'PowerShell', desc: i18n.t('task.cronjobformdial.s783cca2d') },
|
{ value: 'powershell', label: 'PowerShell', desc: i18n.t('关联脚本库中的 PowerShell 脚本') },
|
||||||
{ value: 'command', label: i18n.t('task.cronjobformdial.sad6526bb'), desc: i18n.t('task.cronjobformdial.s492a4c28') },
|
{ value: 'command', label: i18n.t('自定义命令'), desc: i18n.t('手动输入命令或脚本路径') },
|
||||||
];
|
];
|
||||||
|
|
||||||
const scriptJobTypes = ['shell', 'python', 'powershell'];
|
const scriptJobTypes = ['shell', 'python', 'powershell'];
|
||||||
@@ -121,12 +121,12 @@ export function CronJobFormDialog({
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.name || !form.cron_expr) {
|
if (!form.name || !form.cron_expr) {
|
||||||
toast.error(i18n.t('task.cronjobformdial.s69fb01d7'));
|
toast.error(i18n.t('请填写任务名称和 Cron 表达式'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 脚本类型必须选关联脚本 // Logan.Li
|
// 脚本类型必须选关联脚本 // Logan.Li
|
||||||
if (scriptJobTypes.includes(form.type) && !form.script_id) {
|
if (scriptJobTypes.includes(form.type) && !form.script_id) {
|
||||||
toast.error(i18n.t('task.cronjobformdial.sd4df2957'));
|
toast.error(i18n.t('请填写任务名称和 Cron 表达式'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -141,10 +141,10 @@ export function CronJobFormDialog({
|
|||||||
};
|
};
|
||||||
if (editJob) {
|
if (editJob) {
|
||||||
await cronJobApi.updateJob(editJob.id, payload);
|
await cronJobApi.updateJob(editJob.id, payload);
|
||||||
toast.success(i18n.t('task.cronjobformdial.s8398c31d'));
|
toast.success(i18n.t('任务更新成功'));
|
||||||
} else {
|
} else {
|
||||||
await cronJobApi.createJob(payload);
|
await cronJobApi.createJob(payload);
|
||||||
toast.success(i18n.t('task.cronjobformdial.s3799bdae'));
|
toast.success(i18n.t('任务更新成功'));
|
||||||
}
|
}
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
onSuccess();
|
onSuccess();
|
||||||
@@ -160,7 +160,7 @@ export function CronJobFormDialog({
|
|||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
<DialogContent className="max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
||||||
<DialogHeader>
|
<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>
|
<DialogDescription className="text-[var(--dg-text-secondary)]"> {i18n.t('task.cronjobformdial.s2e10ee70')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1">
|
<div className="space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1">
|
||||||
@@ -170,7 +170,7 @@ export function CronJobFormDialog({
|
|||||||
<Input
|
<Input
|
||||||
value={form.name}
|
value={form.name}
|
||||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
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"
|
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -181,7 +181,7 @@ export function CronJobFormDialog({
|
|||||||
<Textarea
|
<Textarea
|
||||||
value={form.description}
|
value={form.description}
|
||||||
onChange={(e) => setForm({ ...form, description: e.target.value })}
|
onChange={(e) => setForm({ ...form, description: e.target.value })}
|
||||||
placeholder={i18n.t('task.cronjobformdial.s405de06b')}
|
placeholder={i18n.t('例如: 数据库备份')}
|
||||||
rows={2}
|
rows={2}
|
||||||
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
|
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 })}>
|
<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">
|
<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>
|
</SelectTrigger>
|
||||||
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
<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>
|
<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}
|
onValueChange={handleSelectScript}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1">
|
<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>
|
</SelectTrigger>
|
||||||
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
||||||
{filteredScripts.map(sc => (
|
{filteredScripts.map(sc => (
|
||||||
@@ -284,7 +284,7 @@ export function CronJobFormDialog({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</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">
|
<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>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -311,7 +311,7 @@ export function CronJobFormDialog({
|
|||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
disabled={submitting}
|
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>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export function CronJobManager() {
|
|||||||
const handleToggleJob = async (id: number) => {
|
const handleToggleJob = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
await cronJobApi.toggleJob(id);
|
await cronJobApi.toggleJob(id);
|
||||||
toast.success(i18n.t('task.cronjobmanagert.sa925eb6b'));
|
toast.success(i18n.t('状态已切换'));
|
||||||
refreshData();
|
refreshData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to toggle job:', error);
|
console.error('Failed to toggle job:', error);
|
||||||
@@ -157,7 +157,7 @@ export function CronJobManager() {
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await cronJobApi.deleteJob(job.id);
|
await cronJobApi.deleteJob(job.id);
|
||||||
toast.success(i18n.t('monitor.sitemonitortsx.sb2ae04aa'));
|
toast.success(i18n.t('状态已切换'));
|
||||||
refreshData();
|
refreshData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to delete job:', error);
|
console.error('Failed to delete job:', error);
|
||||||
@@ -178,7 +178,7 @@ export function CronJobManager() {
|
|||||||
const handleBatchDelete = async () => {
|
const handleBatchDelete = async () => {
|
||||||
if (selectedIds.length === 0) return;
|
if (selectedIds.length === 0) return;
|
||||||
const ok = await _confirm({
|
const ok = await _confirm({
|
||||||
title: i18n.t('task.cronjobmanagert.sc247b256'),
|
title: i18n.t('删除定时任务'),
|
||||||
description: `确定删除选中的 ${selectedIds.length} 个任务吗?此操作不可恢复。`,
|
description: `确定删除选中的 ${selectedIds.length} 个任务吗?此操作不可恢复。`,
|
||||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
@@ -203,7 +203,7 @@ export function CronJobManager() {
|
|||||||
<div className="relative flex-1 min-w-[180px] max-w-md">
|
<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" />
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
||||||
<Input
|
<Input
|
||||||
placeholder={i18n.t('task.cronjobmanagert.safab8783')}
|
placeholder={i18n.t('搜索名称、描述、脚本…')}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
className="pl-10 dg-input h-9"
|
className="pl-10 dg-input h-9"
|
||||||
@@ -224,7 +224,7 @@ export function CronJobManager() {
|
|||||||
<SelectValue placeholder={i18n.t('k8s.clusters.statusHealthy')} />
|
<SelectValue placeholder={i18n.t('k8s.clusters.statusHealthy')} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<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="healthy"> {i18n.t('agent.heartbeatNormal')} </SelectItem>
|
||||||
<SelectItem value="failed"> {i18n.t('monitor.siteProtocol.tcp.lastFail')} </SelectItem>
|
<SelectItem value="failed"> {i18n.t('monitor.siteProtocol.tcp.lastFail')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -276,7 +276,7 @@ export function CronJobManager() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('automation.cronJobs')}
|
title={i18n.t('automation.cronJobs')}
|
||||||
subtitle={i18n.t('task.cronjobmanagert.sfb75a12d')}
|
subtitle={i18n.t('Cron 调度 · 脚本执行 · 内置系统任务')}
|
||||||
icon={<Clock className="h-5 w-5" />}
|
icon={<Clock className="h-5 w-5" />}
|
||||||
tabs={pageTabs}
|
tabs={pageTabs}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function RemoteExecPage() {
|
|||||||
try {
|
try {
|
||||||
const res = await serverApi.getServers({ page: 1, page_size: 500, keyword });
|
const res = await serverApi.getServers({ page: 1, page_size: 500, keyword });
|
||||||
setServers(((res as JsonData)?.list as RemoteServer[]) || []);
|
setServers(((res as JsonData)?.list as RemoteServer[]) || []);
|
||||||
} catch { toast.error(i18n.t('task.remoteexecpaget.s68755a4d')); }
|
} catch { toast.error(i18n.t('加载服务器列表失败')); }
|
||||||
finally { setLoading(false); }
|
finally { setLoading(false); }
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -64,10 +64,10 @@ export function RemoteExecPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const doExec = async () => {
|
const doExec = async () => {
|
||||||
if (!command.trim()) { toast.error(i18n.t('agent.agentmonitortsx.s9358aada')); return; }
|
if (!command.trim()) { toast.error(i18n.t('请输入要执行的命令')); return; }
|
||||||
if (selCount === 0) { toast.error(i18n.t('task.remoteexecpaget.se62f41c4')); return; }
|
if (selCount === 0) { toast.error(i18n.t('请至少选择一台主机')); return; }
|
||||||
const ok = await _confirm({
|
const ok = await _confirm({
|
||||||
title: i18n.t('task.remoteexecpaget.s110b7142'),
|
title: i18n.t('确认批量执行命令'),
|
||||||
description: `将在 ${selCount} 台主机上执行该命令,请确认命令安全:\n\n${command}`,
|
description: `将在 ${selCount} 台主机上执行该命令,请确认命令安全:\n\n${command}`,
|
||||||
confirmText: i18n.t('deploy.label.execute'), variant: 'destructive',
|
confirmText: i18n.t('deploy.label.execute'), variant: 'destructive',
|
||||||
});
|
});
|
||||||
@@ -83,9 +83,9 @@ export function RemoteExecPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const doUpload = async () => {
|
const doUpload = async () => {
|
||||||
if (!file) { toast.error(i18n.t('task.remoteexecpaget.s68ea13ee')); return; }
|
if (!file) { toast.error(i18n.t('请选择要上传的文件')); return; }
|
||||||
if (!remotePath.trim()) { toast.error(i18n.t('task.remoteexecpaget.sb68231b8')); return; }
|
if (!remotePath.trim()) { toast.error(i18n.t('请填写远程目标路径')); return; }
|
||||||
if (selCount === 0) { toast.error(i18n.t('task.remoteexecpaget.se62f41c4')); return; }
|
if (selCount === 0) { toast.error(i18n.t('请至少选择一台主机')); return; }
|
||||||
const dst = remotePath.trim().endsWith('/') ? remotePath.trim() + file.name : remotePath.trim();
|
const dst = remotePath.trim().endsWith('/') ? remotePath.trim() + file.name : remotePath.trim();
|
||||||
setRunning(true); setUploadResults([]);
|
setRunning(true); setUploadResults([]);
|
||||||
try {
|
try {
|
||||||
@@ -101,7 +101,7 @@ export function RemoteExecPage() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="workspace"
|
variant="workspace"
|
||||||
title={i18n.t('automation.remoteExec')}
|
title={i18n.t('automation.remoteExec')}
|
||||||
subtitle={i18n.t('task.remoteexecpaget.s123ad5f6')}
|
subtitle={i18n.t('关联主机后批量执行命令 / 上传文件(Go-native SSH)')}
|
||||||
icon={<Terminal className="h-5 w-5" />}
|
icon={<Terminal className="h-5 w-5" />}
|
||||||
contentClassName="flex-1 min-h-0"
|
contentClassName="flex-1 min-h-0"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -119,7 +119,7 @@ export function RemoteExecPage() {
|
|||||||
<CardTitle className="text-sm flex items-center justify-between text-[var(--dg-text-primary)]">
|
<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>
|
<span className="flex items-center gap-2"><ServerIcon className="h-4 w-4 dg-text-blue" /> {i18n.t('automation.remoteSelectHost')} </span>
|
||||||
<Input
|
<Input
|
||||||
placeholder={i18n.t('task.remoteexecpaget.s253acd21')}
|
placeholder={i18n.t('搜索 主机名/IP')}
|
||||||
value={keyword}
|
value={keyword}
|
||||||
onChange={(e) => setKeyword(e.target.value)}
|
onChange={(e) => setKeyword(e.target.value)}
|
||||||
onKeyDown={(e) => e.key === 'Enter' && load()}
|
onKeyDown={(e) => e.key === 'Enter' && load()}
|
||||||
@@ -131,7 +131,7 @@ export function RemoteExecPage() {
|
|||||||
{servers.length === 0 ? (
|
{servers.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
title={i18n.t('dashboard.serversStatus.empty')}
|
title={i18n.t('dashboard.serversStatus.empty')}
|
||||||
description={i18n.t('task.remoteexecpaget.s0afbf1fc')}
|
description={i18n.t('请先在「服务器管理」添加')}
|
||||||
className="py-10"
|
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 className="text-[10px] text-[var(--dg-text-muted)] font-mono">{s.ip} · {s.username || 'root'}</div>
|
||||||
</div>
|
</div>
|
||||||
{s.has_auth === false
|
{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>}
|
: <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>
|
</label>
|
||||||
))}
|
))}
|
||||||
@@ -187,7 +187,7 @@ export function RemoteExecPage() {
|
|||||||
value={command}
|
value={command}
|
||||||
onChange={(e) => setCommand(e.target.value)}
|
onChange={(e) => setCommand(e.target.value)}
|
||||||
rows={5}
|
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"
|
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">
|
<div className="flex items-center gap-3">
|
||||||
@@ -213,7 +213,7 @@ export function RemoteExecPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<span className="text-xs dg-text-secondary"> {i18n.t('task.remoteexecpaget.sb47f0323')} </span>
|
<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" />
|
className="h-8 text-xs font-mono dg-input" />
|
||||||
</div>
|
</div>
|
||||||
<Button onClick={doUpload} disabled={running} className="dg-btn-primary h-8 text-xs">
|
<Button onClick={doUpload} disabled={running} className="dg-btn-primary h-8 text-xs">
|
||||||
@@ -238,7 +238,7 @@ export function RemoteExecPage() {
|
|||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<pre className="text-[10px] font-mono dg-text-secondary whitespace-pre-wrap break-all max-h-32 overflow-y-auto">
|
<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>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export function ScriptManager() {
|
|||||||
const items = (res as JsonData)?.list || [];
|
const items = (res as JsonData)?.list || [];
|
||||||
setScripts(items.map(mapScript));
|
setScripts(items.map(mapScript));
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(i18n.t('task.scriptmanagerts.s0fa2607f'));
|
toast.error(i18n.t('获取脚本列表失败'));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ export function ScriptManager() {
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!formData.name.trim() || !formData.content.trim()) {
|
if (!formData.name.trim() || !formData.content.trim()) {
|
||||||
toast.error(i18n.t('task.scriptmanagerts.s54c121b2'));
|
toast.error(i18n.t('获取脚本列表失败'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -127,10 +127,10 @@ export function ScriptManager() {
|
|||||||
try {
|
try {
|
||||||
if (editingId !== null) {
|
if (editingId !== null) {
|
||||||
await scriptApi.updateScript(editingId, payload);
|
await scriptApi.updateScript(editingId, payload);
|
||||||
toast.success(i18n.t('task.scriptmanagerts.sdb91e3c4'));
|
toast.success(i18n.t('脚本更新成功'));
|
||||||
} else {
|
} else {
|
||||||
await scriptApi.createScript(payload);
|
await scriptApi.createScript(payload);
|
||||||
toast.success(i18n.t('task.scriptmanagerts.s4aac59ea'));
|
toast.success(i18n.t('脚本更新成功'));
|
||||||
}
|
}
|
||||||
setEditorOpen(false);
|
setEditorOpen(false);
|
||||||
fetchScripts();
|
fetchScripts();
|
||||||
@@ -194,7 +194,7 @@ export function ScriptManager() {
|
|||||||
const handleBatchDelete = async () => {
|
const handleBatchDelete = async () => {
|
||||||
if (selectedIds.length === 0) return;
|
if (selectedIds.length === 0) return;
|
||||||
const ok = await _confirm({
|
const ok = await _confirm({
|
||||||
title: i18n.t('task.scriptmanagerts.sd730a0fc'),
|
title: i18n.t('删除脚本'),
|
||||||
description: `确定删除选中的 ${selectedIds.length} 个脚本吗?此操作不可恢复。`,
|
description: `确定删除选中的 ${selectedIds.length} 个脚本吗?此操作不可恢复。`,
|
||||||
confirmText: i18n.t('system.terminalBatchDelete'),
|
confirmText: i18n.t('system.terminalBatchDelete'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
@@ -242,7 +242,7 @@ export function ScriptManager() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('automation.scripts')}
|
title={i18n.t('automation.scripts')}
|
||||||
subtitle={i18n.t('task.scriptmanagerts.sed1decc7')}
|
subtitle={i18n.t('脚本编辑与管理')}
|
||||||
icon={<FileCode className="h-5 w-5" />}
|
icon={<FileCode className="h-5 w-5" />}
|
||||||
toolbar={toolbar}
|
toolbar={toolbar}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -295,8 +295,8 @@ export function ScriptManager() {
|
|||||||
|
|
||||||
{filteredScripts.length === 0 ? (
|
{filteredScripts.length === 0 ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
title={scripts.length === 0 ? i18n.t('automation.noScript') : i18n.t('task.scriptmanagerts.s83533de7')}
|
title={scripts.length === 0 ? i18n.t('automation.noScript') : i18n.t('暂无脚本')}
|
||||||
description={scripts.length === 0 ? i18n.t('task.scriptmanagerts.sc31b6baa') : undefined}
|
description={scripts.length === 0 ? i18n.t('点击「新建脚本」创建第一个') : undefined}
|
||||||
action={scripts.length === 0 && canWrite ? (
|
action={scripts.length === 0 && canWrite ? (
|
||||||
<Button className="dg-btn-primary" onClick={openCreate}>
|
<Button className="dg-btn-primary" onClick={openCreate}>
|
||||||
<Plus className="w-4 h-4 mr-2" />
|
<Plus className="w-4 h-4 mr-2" />
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function CopyButton({
|
|||||||
} else {
|
} else {
|
||||||
toast({
|
toast({
|
||||||
title: i18n.t('monitor.logPanel.copyFailed'),
|
title: i18n.t('monitor.logPanel.copyFailed'),
|
||||||
description: i18n.t('common.copybuttontsx.s76597b46'),
|
description: i18n.t('请手动选中内容后复制'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import type { JsonData } from '@/types/common';
|
|||||||
import i18n from '@/i18n';
|
import i18n from '@/i18n';
|
||||||
|
|
||||||
const TABS = [
|
const TABS = [
|
||||||
{ id: 'basic', label: i18n.t('monitor.hostmonitortsx.s00303869'), icon: <Monitor className="w-3.5 h-3.5" /> },
|
{ id: 'basic', label: i18n.t('基础监控'), icon: <Monitor className="w-3.5 h-3.5" /> },
|
||||||
{ id: 'disk', label: i18n.t('monitor.hostmonitortsx.s5dd0a090'), icon: <HardDrive className="w-3.5 h-3.5" /> },
|
{ id: 'disk', label: i18n.t('磁盘监控'), icon: <HardDrive className="w-3.5 h-3.5" /> },
|
||||||
{ id: 'network', label: i18n.t('monitor.hostmonitortsx.s59805cc8'), icon: <Network className="w-3.5 h-3.5" /> },
|
{ id: 'network', label: i18n.t('网络监控'), icon: <Network className="w-3.5 h-3.5" /> },
|
||||||
{ id: 'ports', label: i18n.t('agent.portMonitor'), icon: <Server className="w-3.5 h-3.5" /> },
|
{ id: 'ports', label: i18n.t('agent.portMonitor'), icon: <Server className="w-3.5 h-3.5" /> },
|
||||||
{ id: 'process', label: i18n.t('monitor.hostProcess'), icon: <List className="w-3.5 h-3.5" /> },
|
{ id: 'process', label: i18n.t('monitor.hostProcess'), icon: <List className="w-3.5 h-3.5" /> },
|
||||||
{ id: 'system', label: i18n.t('system.systemInfo'), icon: <Info className="w-3.5 h-3.5" /> },
|
{ id: 'system', label: i18n.t('system.systemInfo'), icon: <Info className="w-3.5 h-3.5" /> },
|
||||||
@@ -118,7 +118,7 @@ export function HostMonitor({ embedded = false }: { embedded?: boolean }) {
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Select value={selectedHost} onValueChange={setSelectedHost}>
|
<Select value={selectedHost} onValueChange={setSelectedHost}>
|
||||||
<SelectTrigger className="w-52 h-8 text-xs dg-input">
|
<SelectTrigger className="w-52 h-8 text-xs dg-input">
|
||||||
<SelectValue placeholder={i18n.t('monitor.hostmonitortsx.sb6637d99')} />
|
<SelectValue placeholder={i18n.t('选择主机...')} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent className="dg-input">
|
<SelectContent className="dg-input">
|
||||||
{hosts.map((h: JsonData) => (
|
{hosts.map((h: JsonData) => (
|
||||||
@@ -136,9 +136,9 @@ export function HostMonitor({ embedded = false }: { embedded?: boolean }) {
|
|||||||
<Select value={aggType} onValueChange={(v) => setAggType(v as AggType)}>
|
<Select value={aggType} onValueChange={(v) => setAggType(v as AggType)}>
|
||||||
<SelectTrigger className="w-24 h-7 text-xs dg-input"><SelectValue /></SelectTrigger>
|
<SelectTrigger className="w-24 h-7 text-xs dg-input"><SelectValue /></SelectTrigger>
|
||||||
<SelectContent className="dg-input">
|
<SelectContent className="dg-input">
|
||||||
<SelectItem value="avg"> {i18n.t('monitor.hostmonitortsx.se68632a3')} </SelectItem>
|
<SelectItem value="avg"> {i18n.t('选择主机...')} </SelectItem>
|
||||||
<SelectItem value="max"> {i18n.t('monitor.hostmonitortsx.s5da89314')} </SelectItem>
|
<SelectItem value="max"> {i18n.t('选择主机...')} </SelectItem>
|
||||||
<SelectItem value="min"> {i18n.t('monitor.hostmonitortsx.sc322edb8')} </SelectItem>
|
<SelectItem value="min"> {i18n.t('选择主机...')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<div className="flex flex-col items-end gap-0.5">
|
<div className="flex flex-col items-end gap-0.5">
|
||||||
@@ -213,7 +213,7 @@ export function HostMonitor({ embedded = false }: { embedded?: boolean }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell variant="workspace" title={i18n.t('monitor.alertRulesTab.catHost')}
|
<PageShell variant="workspace" title={i18n.t('monitor.alertRulesTab.catHost')}
|
||||||
subtitle={selectedHost ? `当前主机: ${selectedHost}` : i18n.t('monitor.hostmonitortsx.s8d493048')}
|
subtitle={selectedHost ? `当前主机: ${selectedHost}` : i18n.t('选择主机查看监控指标')}
|
||||||
icon={<Server className="h-5 w-5" />} toolbar={toolbar}
|
icon={<Server className="h-5 w-5" />} toolbar={toolbar}
|
||||||
loading={loading && !history.length} loadingLabel={i18n.t('monitor.hostmonitortsx.sc23e802e')}
|
loading={loading && !history.length} loadingLabel={i18n.t('monitor.hostmonitortsx.sc23e802e')}
|
||||||
contentClassName="space-y-3">
|
contentClassName="space-y-3">
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const METRIC_CATEGORIES: Record<string, { label: string; icon: React.ReactNode }
|
|||||||
disk: { label: i18n.t('monitor.dashboard.col.disk'), icon: <HardDrive className="h-4 w-4" /> },
|
disk: { label: i18n.t('monitor.dashboard.col.disk'), icon: <HardDrive className="h-4 w-4" /> },
|
||||||
network: { label: i18n.t('monitor.hostMetric.network'), icon: <Network className="h-4 w-4" /> },
|
network: { label: i18n.t('monitor.hostMetric.network'), icon: <Network className="h-4 w-4" /> },
|
||||||
middleware: { label: i18n.t('monitor.alertRulesTab.catMiddleware'), icon: <Database className="h-4 w-4" /> },
|
middleware: { label: i18n.t('monitor.alertRulesTab.catMiddleware'), icon: <Database className="h-4 w-4" /> },
|
||||||
device: { label: i18n.t('monitor.metricsexplorer.sf55f1736'), icon: <Activity className="h-4 w-4" /> },
|
device: { label: i18n.t('设备'), icon: <Activity className="h-4 w-4" /> },
|
||||||
};
|
};
|
||||||
|
|
||||||
export function MetricsExplorer() {
|
export function MetricsExplorer() {
|
||||||
@@ -109,7 +109,7 @@ export function MetricsExplorer() {
|
|||||||
<div className="flex items-center gap-4 flex-wrap w-full">
|
<div className="flex items-center gap-4 flex-wrap w-full">
|
||||||
<Select value={selectedTarget} onValueChange={setSelectedTarget}>
|
<Select value={selectedTarget} onValueChange={setSelectedTarget}>
|
||||||
<SelectTrigger className="w-64 dg-input">
|
<SelectTrigger className="w-64 dg-input">
|
||||||
<SelectValue placeholder={loading ? i18n.t('monitor.logPanel.logResults.loading') : i18n.t('monitor.metricsexplorer.sce4193cc')} />
|
<SelectValue placeholder={loading ? i18n.t('monitor.logPanel.logResults.loading') : i18n.t('加载中...')} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent className="dg-input max-h-80">
|
<SelectContent className="dg-input max-h-80">
|
||||||
{targets.map(t => (
|
{targets.map(t => (
|
||||||
@@ -126,7 +126,7 @@ export function MetricsExplorer() {
|
|||||||
<Search className="absolute left-2.5 top-2 h-4 w-4 dg-text-muted" />
|
<Search className="absolute left-2.5 top-2 h-4 w-4 dg-text-muted" />
|
||||||
<Input
|
<Input
|
||||||
className="pl-8 dg-input h-9"
|
className="pl-8 dg-input h-9"
|
||||||
placeholder={i18n.t('monitor.metricsexplorer.s21512a93')}
|
placeholder={i18n.t('搜索指标...')}
|
||||||
value={searchKw}
|
value={searchKw}
|
||||||
onChange={(e) => setSearchKw(e.target.value)}
|
onChange={(e) => setSearchKw(e.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -140,19 +140,19 @@ export function MetricsExplorer() {
|
|||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
variant="workspace"
|
variant="workspace"
|
||||||
title={i18n.t('monitor.metricsexplorer.s26a10dc0')}
|
title={i18n.t('指标浏览器')}
|
||||||
subtitle={i18n.t('monitor.metricsexplorer.s454945df')}
|
subtitle={i18n.t('按分类/主机浏览所有指标,支持叠加对比')}
|
||||||
icon={<Activity className="h-5 w-5" />}
|
icon={<Activity className="h-5 w-5" />}
|
||||||
toolbar={toolbar}
|
toolbar={toolbar}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
loadingLabel={i18n.t('monitor.metricsexplorer.s17f42742')}
|
loadingLabel={i18n.t('加载监控目标...')}
|
||||||
contentClassName="space-y-6"
|
contentClassName="space-y-6"
|
||||||
>
|
>
|
||||||
{!selectedTarget ? (
|
{!selectedTarget ? (
|
||||||
<PageEmpty
|
<PageEmpty
|
||||||
icon={<Filter className="h-12 w-12" />}
|
icon={<Filter className="h-12 w-12" />}
|
||||||
title={i18n.t('monitor.metricsexplorer.sce251ece')}
|
title={i18n.t('请选择监控目标')}
|
||||||
description={i18n.t('monitor.metricsexplorer.sc1966a27')}
|
description={i18n.t('选择目标主机后,从左侧勾选要查看的指标')}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||||
@@ -205,7 +205,7 @@ export function MetricsExplorer() {
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
{selectedMetrics.length === 0 ? (
|
{selectedMetrics.length === 0 ? (
|
||||||
<PageEmpty icon={<Plus className="h-8 w-8" />} title={i18n.t('monitor.metricsexplorer.s701e608d')} className="py-16" />
|
<PageEmpty icon={<Plus className="h-8 w-8" />} title={i18n.t('请从左侧勾选指标')} className="py-16" />
|
||||||
) : sortedTimes.length === 0 ? (
|
) : sortedTimes.length === 0 ? (
|
||||||
<PageEmpty title={i18n.t('aiops.assistantNoData')} className="py-16" />
|
<PageEmpty title={i18n.t('aiops.assistantNoData')} className="py-16" />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function MiddlewareMonitor() {
|
|||||||
const warnCount = targets.filter((t) => worstHealthLevel(evalMwHealth(t)) !== 'ok').length;
|
const warnCount = targets.filter((t) => worstHealthLevel(evalMwHealth(t)) !== 'ok').length;
|
||||||
|
|
||||||
const handleDelete = async (target: MwTarget) => {
|
const handleDelete = async (target: MwTarget) => {
|
||||||
const ok = await confirm({ title: i18n.t('monitor.middlewaremonit.sf9be97ed'), description: `确认删除 "${target.name}"?`, confirmText: i18n.t('kubernetes.storage.delete2') });
|
const ok = await confirm({ title: i18n.t('删除监控'), description: `确认删除 "${target.name}"?`, confirmText: i18n.t('kubernetes.storage.delete2') });
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
try {
|
try {
|
||||||
await middlewareMonitorApi.delete(target.id);
|
await middlewareMonitorApi.delete(target.id);
|
||||||
@@ -115,9 +115,9 @@ export function MiddlewareMonitor() {
|
|||||||
try {
|
try {
|
||||||
const res = await middlewareMonitorApi.seedDefaults() as { created: number; message: string; failed?: string[] };
|
const res = await middlewareMonitorApi.seedDefaults() as { created: number; message: string; failed?: string[] };
|
||||||
await loadTargets();
|
await loadTargets();
|
||||||
if (res.failed?.length) toast.error(i18n.t('monitor.middlewaremonit.s669e8995'), { description: res.message });
|
if (res.failed?.length) toast.error(i18n.t('部分失败'), { description: res.message });
|
||||||
else if (res.created > 0) toast.success(i18n.t('monitor.middlewaremonit.s11a31e75'), { description: res.message });
|
else if (res.created > 0) toast.success(i18n.t('已添加默认监控'), { description: res.message });
|
||||||
else toast.success(i18n.t('monitor.middlewaremonit.s7dda0fcb'));
|
else toast.success(i18n.t('默认目标已存在'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(i18n.t('monitor.dashboard.custom.toastPanelFailed'), { description: (err as { message?: string }).message });
|
toast.error(i18n.t('monitor.dashboard.custom.toastPanelFailed'), { description: (err as { message?: string }).message });
|
||||||
} finally {
|
} finally {
|
||||||
@@ -128,10 +128,10 @@ export function MiddlewareMonitor() {
|
|||||||
const handleCollectNow = async () => {
|
const handleCollectNow = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await middlewareMonitorApi.collectNow() as { message: string };
|
const res = await middlewareMonitorApi.collectNow() as { message: string };
|
||||||
toast.success(i18n.t('monitor.middlewaremonit.sc2c744ef'), { description: res.message });
|
toast.success(i18n.t('采集完成'), { description: res.message });
|
||||||
loadTargets(true);
|
loadTargets(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(i18n.t('monitor.middlewaremonit.s5665b68b'), { description: (err as { message?: string }).message });
|
toast.error(i18n.t('删除失败'), { description: (err as { message?: string }).message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ export function MiddlewareMonitor() {
|
|||||||
{lastRefreshAt && (
|
{lastRefreshAt && (
|
||||||
<span className="ml-2">
|
<span className="ml-2">
|
||||||
上次更新 {lastRefreshAt.toLocaleTimeString()}
|
上次更新 {lastRefreshAt.toLocaleTimeString()}
|
||||||
{refreshing && i18n.t('monitor.middlewaremonit.s4d2bc924')}
|
{refreshing && i18n.t(' · 刷新中...')}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
@@ -206,7 +206,7 @@ export function MiddlewareMonitor() {
|
|||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-2 md:grid-cols-5 gap-3">
|
<div className="grid grid-cols-2 md:grid-cols-5 gap-3">
|
||||||
{[
|
{[
|
||||||
{ label: i18n.t('monitor.middlewaremonit.s35a55853'), value: targets.length, icon: Activity },
|
{ label: i18n.t('监控实例'), value: targets.length, icon: Activity },
|
||||||
{ label: i18n.t('agent.agentOnline'), value: onlineCount, icon: Database, color: 'dg-text-green' },
|
{ label: i18n.t('agent.agentOnline'), value: onlineCount, icon: Database, color: 'dg-text-green' },
|
||||||
{ label: i18n.t('monitor.hostDashboard.alert'), value: warnCount, icon: Activity, color: warnCount > 0 ? 'dg-text-yellow' : 'dg-text-green' },
|
{ label: i18n.t('monitor.hostDashboard.alert'), value: warnCount, icon: Activity, color: warnCount > 0 ? 'dg-text-yellow' : 'dg-text-green' },
|
||||||
{ label: 'Redis', value: redisTargets.length, icon: Database, color: 'dg-text-red' },
|
{ label: 'Redis', value: redisTargets.length, icon: Database, color: 'dg-text-red' },
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import i18n from '@/i18n';
|
|||||||
type TabId = 'host' | 'middleware' | 'snmp' | 'site';
|
type TabId = 'host' | 'middleware' | 'snmp' | 'site';
|
||||||
|
|
||||||
const tabs: { id: TabId; name: string; description: string }[] = [
|
const tabs: { id: TabId; name: string; description: string }[] = [
|
||||||
{ id: 'host', name: i18n.t('monitor.alertRulesTab.catHost'), description: i18n.t('monitor.monitorcenterts.s811145d6') },
|
{ id: 'host', name: i18n.t('monitor.alertRulesTab.catHost'), description: i18n.t('主机监控') },
|
||||||
{ id: 'middleware', name: i18n.t('monitor.alertRulesTab.catMiddleware'), description: i18n.t('monitor.monitorcenterts.s757cdaf9') },
|
{ id: 'middleware', name: i18n.t('monitor.alertRulesTab.catMiddleware'), description: i18n.t('中间件') },
|
||||||
{ id: 'snmp', name: 'SNMP', description: i18n.t('monitor.monitorcenterts.s24f24e6f') },
|
{ id: 'snmp', name: 'SNMP', description: i18n.t('网络设备 / BMC 采集与趋势') },
|
||||||
{ id: 'site', name: i18n.t('monitor.alertRulesTab.catSite'), description: i18n.t('monitor.monitorcenterts.s5ea4cd7a') },
|
{ id: 'site', name: i18n.t('monitor.alertRulesTab.catSite'), description: i18n.t('站点拨测') },
|
||||||
];
|
];
|
||||||
|
|
||||||
const TAB_IDS: TabId[] = ['host', 'middleware', 'snmp', 'site'];
|
const TAB_IDS: TabId[] = ['host', 'middleware', 'snmp', 'site'];
|
||||||
@@ -44,7 +44,7 @@ export function MonitorCenter() {
|
|||||||
<PageShell
|
<PageShell
|
||||||
variant="list"
|
variant="list"
|
||||||
title={i18n.t('monitor.title')}
|
title={i18n.t('monitor.title')}
|
||||||
subtitle={current?.description ?? i18n.t('monitor.monitorcenterts.s771120b2')}
|
subtitle={current?.description ?? i18n.t('全面的基础设施与应用监控')}
|
||||||
icon={<Activity className="h-5 w-5" />}
|
icon={<Activity className="h-5 w-5" />}
|
||||||
tabs={tabs.map((t) => ({ id: t.id, label: t.name }))}
|
tabs={tabs.map((t) => ({ id: t.id, label: t.name }))}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export function SNMPMonitor() {
|
|||||||
|
|
||||||
const handleAdd = async () => {
|
const handleAdd = async () => {
|
||||||
if (!form.name.trim() || !form.ip.trim() || !form.template_id) {
|
if (!form.name.trim() || !form.ip.trim() || !form.template_id) {
|
||||||
toast.error(i18n.t('monitor.snmpmonitortsx.se385b8ab'));
|
toast.error(i18n.t('请填写设备名称、IP 并选择 OID 模板'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -118,7 +118,7 @@ export function SNMPMonitor() {
|
|||||||
template_id: Number(form.template_id),
|
template_id: Number(form.template_id),
|
||||||
vendor: tpl?.vendor || '', device_type: tpl?.device_type || 'switch',
|
vendor: tpl?.vendor || '', device_type: tpl?.device_type || 'switch',
|
||||||
});
|
});
|
||||||
toast.success(i18n.t('monitor.snmpmonitortsx.sbd007705'));
|
toast.success(i18n.t('设备已添加'));
|
||||||
setDialogOpen(false);
|
setDialogOpen(false);
|
||||||
setForm({ ...emptyForm });
|
setForm({ ...emptyForm });
|
||||||
refresh();
|
refresh();
|
||||||
@@ -137,7 +137,7 @@ export function SNMPMonitor() {
|
|||||||
toast.success(`${d.name} 采集成功`);
|
toast.success(`${d.name} 采集成功`);
|
||||||
refresh();
|
refresh();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error((err as { message?: string }).message || i18n.t('monitor.middlewaremonit.s5665b68b'));
|
toast.error((err as { message?: string }).message || i18n.t('采集失败'));
|
||||||
refresh();
|
refresh();
|
||||||
} finally {
|
} finally {
|
||||||
setCollectingId(null);
|
setCollectingId(null);
|
||||||
@@ -203,7 +203,7 @@ export function SNMPMonitor() {
|
|||||||
<div className="grid gap-3 py-2">
|
<div className="grid gap-3 py-2">
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('monitor.snmpmonitortsx.s9f694f60')} </Label>
|
<Label> {i18n.t('monitor.snmpmonitortsx.s9f694f60')} </Label>
|
||||||
<Input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} placeholder={i18n.t('monitor.snmpmonitortsx.s490f68f6')} />
|
<Input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} placeholder={i18n.t('核心交换机-A')} />
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
@@ -257,10 +257,10 @@ export function SNMPMonitor() {
|
|||||||
{/* 紧凑统计 */}
|
{/* 紧凑统计 */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
|
||||||
{[
|
{[
|
||||||
{ label: i18n.t('monitor.snmpmonitortsx.sc615660d'), value: stats.total, color: '' },
|
{ label: i18n.t('设备总数'), value: stats.total, color: '' },
|
||||||
{ label: i18n.t('agent.agentOnline'), value: stats.online, color: 'dg-text-green' },
|
{ label: i18n.t('agent.agentOnline'), value: stats.online, color: 'dg-text-green' },
|
||||||
{ label: i18n.t('agent.heartbeatAbnormal'), value: stats.abnormal, color: 'dg-text-red' },
|
{ label: i18n.t('agent.heartbeatAbnormal'), value: stats.abnormal, color: 'dg-text-red' },
|
||||||
{ label: i18n.t('monitor.snmpmonitortsx.s48cfbb79'), value: templates.length, color: 'dg-text-cyan' },
|
{ label: i18n.t('OID 模板'), value: templates.length, color: 'dg-text-cyan' },
|
||||||
].map((item) => (
|
].map((item) => (
|
||||||
<div key={item.label} className="rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2 text-center">
|
<div key={item.label} className="rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2 text-center">
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ export function SiteMonitor() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.name.trim() || !form.url.trim()) { toast.error(i18n.t('monitor.sitemonitortsx.s8eb6b1a6')); return; }
|
if (!form.name.trim() || !form.url.trim()) { toast.error(i18n.t('名称和地址不能为空')); return; }
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
const payload = {
|
const payload = {
|
||||||
name: form.name.trim(), url: form.url.trim(), type: form.type.toLowerCase(),
|
name: form.name.trim(), url: form.url.trim(), type: form.type.toLowerCase(),
|
||||||
@@ -146,8 +146,8 @@ export function SiteMonitor() {
|
|||||||
expected_status_code: Number(form.expected_status_code) || 200,
|
expected_status_code: Number(form.expected_status_code) || 200,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
if (editingTaskId) { await siteApi.updateTask(editingTaskId, payload); toast.success(i18n.t('monitor.sitemonitortsx.se01498ee')); }
|
if (editingTaskId) { await siteApi.updateTask(editingTaskId, payload); toast.success(i18n.t('任务已更新')); }
|
||||||
else { await siteApi.createTask(payload); toast.success(i18n.t('monitor.sitemonitortsx.s48723e14')); }
|
else { await siteApi.createTask(payload); toast.success(i18n.t('拨测任务已创建')); }
|
||||||
setFormOpen(false); setEditingTaskId(null);
|
setFormOpen(false); setEditingTaskId(null);
|
||||||
loadTasks(); loadStats();
|
loadTasks(); loadStats();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -163,7 +163,7 @@ export function SiteMonitor() {
|
|||||||
if (taskIdParam === String(task.id)) {
|
if (taskIdParam === String(task.id)) {
|
||||||
closeDetail();
|
closeDetail();
|
||||||
}
|
}
|
||||||
toast.success(i18n.t('monitor.sitemonitortsx.sb2ae04aa'));
|
toast.success(i18n.t('任务已删除'));
|
||||||
loadTasks(); loadStats();
|
loadTasks(); loadStats();
|
||||||
} catch (e) { toast.error((e as JsonData).message || i18n.t('kubernetes.msg.deleteFailed2')); }
|
} catch (e) { toast.error((e as JsonData).message || i18n.t('kubernetes.msg.deleteFailed2')); }
|
||||||
};
|
};
|
||||||
@@ -227,11 +227,11 @@ export function SiteMonitor() {
|
|||||||
<div className="xl:col-span-8 space-y-4">
|
<div className="xl:col-span-8 space-y-4">
|
||||||
<div className="grid grid-cols-2 md:grid-cols-5 gap-2">
|
<div className="grid grid-cols-2 md:grid-cols-5 gap-2">
|
||||||
{[
|
{[
|
||||||
{ label: i18n.t('monitor.sitemonitortsx.s0f7991c2'), value: stats?.total_tasks ?? '--' },
|
{ label: i18n.t('总任务'), value: stats?.total_tasks ?? '--' },
|
||||||
{ label: i18n.t('agent.heartbeatNormal'), value: stats?.up_count ?? '--', color: 'dg-text-green' },
|
{ label: i18n.t('agent.heartbeatNormal'), value: stats?.up_count ?? '--', color: 'dg-text-green' },
|
||||||
{ label: i18n.t('agent.heartbeatAbnormal'), value: stats?.down_count ?? '--', color: 'dg-text-red' },
|
{ label: i18n.t('agent.heartbeatAbnormal'), value: stats?.down_count ?? '--', color: 'dg-text-red' },
|
||||||
{ label: i18n.t('monitor.sitemonitortsx.s72a1a913'), value: availStr, color: 'dg-text-blue' },
|
{ label: i18n.t('可用率(24h)'), value: availStr, color: 'dg-text-blue' },
|
||||||
{ label: i18n.t('monitor.sitemonitortsx.s0fad73a6'), value: probeCountStr },
|
{ label: i18n.t('探测次数'), value: probeCountStr },
|
||||||
].map((item) => (
|
].map((item) => (
|
||||||
<div key={item.label} className="rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2 text-center">
|
<div key={item.label} className="rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2 text-center">
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
||||||
@@ -272,7 +272,7 @@ export function SiteMonitor() {
|
|||||||
|
|
||||||
{filteredTasks.length === 0 ? (
|
{filteredTasks.length === 0 ? (
|
||||||
<div className="text-center py-10 text-sm text-[var(--dg-text-muted)]">
|
<div className="text-center py-10 text-sm text-[var(--dg-text-muted)]">
|
||||||
{tasks.length === 0 ? i18n.t('monitor.sitemonitortsx.sdd8ebb79') : i18n.t('monitor.sitemonitortsx.s0f961fe6')}
|
{tasks.length === 0 ? i18n.t('暂无拨测任务') : i18n.t('当前筛选无任务')}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
@@ -282,8 +282,8 @@ export function SiteMonitor() {
|
|||||||
<TableHead className="text-xs"> {i18n.t('kubernetes.secret.secretName')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('kubernetes.secret.secretName')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('system.credentialType')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.credentialType')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteTask.frequency')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteTask.frequency')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.sitemonitortsx.sdb4470d9')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('全部')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.sitemonitortsx.s4fe553c8')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('全部')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('system.userActive')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.userActive')} </TableHead>
|
||||||
<TableHead className="text-xs w-24" />
|
<TableHead className="text-xs w-24" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -349,10 +349,10 @@ export function SiteMonitor() {
|
|||||||
<div className="grid gap-4 py-2">
|
<div className="grid gap-4 py-2">
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('automation.cronJobName')} </Label>
|
<Label> {i18n.t('automation.cronJobName')} </Label>
|
||||||
<Input placeholder={i18n.t('monitor.sitemonitortsx.s024a6a59')} value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
<Input placeholder={i18n.t('例如:官网首页')} value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('monitor.sitemonitortsx.se825ec78')} </Label>
|
<Label> {i18n.t('保存')} </Label>
|
||||||
<Select value={form.type} onValueChange={(v) => {
|
<Select value={form.type} onValueChange={(v) => {
|
||||||
const t = v as ProbeType;
|
const t = v as ProbeType;
|
||||||
setForm({ ...form, type: t, frequency_sec: editingTaskId ? form.frequency_sec : defaultProbeFrequency(t) });
|
setForm({ ...form, type: t, frequency_sec: editingTaskId ? form.frequency_sec : defaultProbeFrequency(t) });
|
||||||
@@ -370,20 +370,20 @@ export function SiteMonitor() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('monitor.sitemonitortsx.s4966e6e5')} </Label>
|
<Label> {i18n.t('保存')} </Label>
|
||||||
<Input type="number" min={MIN_PROBE_FREQUENCY[form.type]} max={86400} value={form.frequency_sec}
|
<Input type="number" min={MIN_PROBE_FREQUENCY[form.type]} max={86400} value={form.frequency_sec}
|
||||||
onChange={(e) => setForm({ ...form, frequency_sec: Number(e.target.value) || defaultProbeFrequency(form.type) })} />
|
onChange={(e) => setForm({ ...form, frequency_sec: Number(e.target.value) || defaultProbeFrequency(form.type) })} />
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)]">{probeFrequencyHint(form.type)}</p>
|
<p className="text-[10px] text-[var(--dg-text-muted)]">{probeFrequencyHint(form.type)}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('monitor.sitemonitortsx.s52e9bc2c')} </Label>
|
<Label> {i18n.t('保存')} </Label>
|
||||||
<Input type="number" min={1} max={300} value={form.timeout_sec}
|
<Input type="number" min={1} max={300} value={form.timeout_sec}
|
||||||
onChange={(e) => setForm({ ...form, timeout_sec: Number(e.target.value) || 10 })} />
|
onChange={(e) => setForm({ ...form, timeout_sec: Number(e.target.value) || 10 })} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{form.type === 'HTTP' && (
|
{form.type === 'HTTP' && (
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<Label> {i18n.t('monitor.sitemonitortsx.s88cbfb5c')} </Label>
|
<Label> {i18n.t('保存')} </Label>
|
||||||
<Input type="number" min={100} max={599} value={form.expected_status_code}
|
<Input type="number" min={100} max={599} value={form.expected_status_code}
|
||||||
onChange={(e) => setForm({ ...form, expected_status_code: Number(e.target.value) || 200 })} />
|
onChange={(e) => setForm({ ...form, expected_status_code: Number(e.target.value) || 200 })} />
|
||||||
</div>
|
</div>
|
||||||
@@ -393,7 +393,7 @@ export function SiteMonitor() {
|
|||||||
<Button variant="outline" onClick={() => { setFormOpen(false); setEditingTaskId(null); }} disabled={saving}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
<Button variant="outline" onClick={() => { setFormOpen(false); setEditingTaskId(null); }} disabled={saving}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
||||||
<Button onClick={handleSave} disabled={saving}>
|
<Button onClick={handleSave} disabled={saving}>
|
||||||
{saving && <Loader2 className="h-4 w-4 animate-spin mr-1" />}
|
{saving && <Loader2 className="h-4 w-4 animate-spin mr-1" />}
|
||||||
{editingTaskId ? i18n.t('task.script.save') : i18n.t('monitor.sitemonitortsx.s6ef95fe9')}
|
{editingTaskId ? i18n.t('task.script.save') : i18n.t('保存')}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
|
|
||||||
const handleDeleteProbe = async (p: Record<string, unknown>) => {
|
const handleDeleteProbe = async (p: Record<string, unknown>) => {
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: i18n.t('monitor.healthprobesect.s9da33b04'),
|
title: i18n.t('删除探针'),
|
||||||
description: `确定删除探针「${p.name}」?`,
|
description: `确定删除探针「${p.name}」?`,
|
||||||
confirmText: i18n.t('kubernetes.storage.delete2'),
|
confirmText: i18n.t('kubernetes.storage.delete2'),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
@@ -89,7 +89,7 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
<>
|
<>
|
||||||
<TabsContent value="health_probes" className="mt-3 space-y-3">
|
<TabsContent value="health_probes" className="mt-3 space-y-3">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h3 className="text-xs font-medium text-[var(--dg-text-primary)]"> {i18n.t('monitor.healthprobesect.s518614fc')} </h3>
|
<h3 className="text-xs font-medium text-[var(--dg-text-primary)]"> {i18n.t('无限制')} </h3>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button size="sm" variant="outline" className="h-7 text-[11px]" onClick={() => refetch()} disabled={isFetching}>
|
<Button size="sm" variant="outline" className="h-7 text-[11px]" onClick={() => refetch()} disabled={isFetching}>
|
||||||
<RefreshCw className={cn('w-3 h-3 mr-1', isFetching && 'animate-spin')} />刷新
|
<RefreshCw className={cn('w-3 h-3 mr-1', isFetching && 'animate-spin')} />刷新
|
||||||
@@ -102,7 +102,7 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
{probes.length === 0 ? (
|
{probes.length === 0 ? (
|
||||||
<Card className="bg-[var(--dg-bg-secondary)] border-dashed border-[var(--dg-border)]">
|
<Card className="bg-[var(--dg-bg-secondary)] border-dashed border-[var(--dg-border)]">
|
||||||
<CardContent className="p-8 text-center text-xs text-[var(--dg-text-muted)]">
|
<CardContent className="p-8 text-center text-xs text-[var(--dg-text-muted)]">
|
||||||
暂无健康探针,点击i18n.t('monitor.healthprobesect.s5bf2e80a')创建
|
暂无健康探针,点击i18n.t('添加探针')创建
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
@@ -140,8 +140,8 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
<div className="truncate font-mono">{String(p.exec_command)}</div>
|
<div className="truncate font-mono">{String(p.exec_command)}</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span> {i18n.t('monitor.healthprobesect.s13b5c750')} <span className={p.last_status === 'up' ? 'dg-text-green' : p.last_status === 'down' ? 'dg-text-red' : 'dg-text-secondary'}>
|
<span> {i18n.t('无限制')} <span className={p.last_status === 'up' ? 'dg-text-green' : p.last_status === 'down' ? 'dg-text-red' : 'dg-text-secondary'}>
|
||||||
{p.last_status ? String(p.last_status).toUpperCase() : i18n.t('monitor.healthprobesect.s5c6585e0')}
|
{p.last_status ? String(p.last_status).toUpperCase() : i18n.t('未检测')}
|
||||||
</span></span>
|
</span></span>
|
||||||
{Number(p.last_latency_ms) > 0 && <span>延迟: {String(p.last_latency_ms)}ms</span>}
|
{Number(p.last_latency_ms) > 0 && <span>延迟: {String(p.last_latency_ms)}ms</span>}
|
||||||
{Number(p.fail_count) > 0 && <span className="dg-text-red">连续失败: {String(p.fail_count)}次</span>}
|
{Number(p.fail_count) > 0 && <span className="dg-text-red">连续失败: {String(p.fail_count)}次</span>}
|
||||||
@@ -159,16 +159,16 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
<DialogContent showOverlay={false} className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg">
|
<DialogContent showOverlay={false} className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-[var(--dg-text-primary)]">
|
<DialogTitle className="text-[var(--dg-text-primary)]">
|
||||||
{editingProbe ? i18n.t('monitor.healthprobesect.sc7c452e5') : i18n.t('monitor.healthprobesect.s5bf2e80a')}
|
{editingProbe ? i18n.t('编辑探针') : i18n.t('添加探针')}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription className="text-[var(--dg-text-secondary)]">
|
<DialogDescription className="text-[var(--dg-text-secondary)]">
|
||||||
{editingProbe ? i18n.t('monitor.healthprobesect.se98536d2') : i18n.t('monitor.healthprobesect.s6f43d059')}
|
{editingProbe ? i18n.t('编辑探针') : i18n.t('添加探针')}
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-3 max-h-[60vh] overflow-y-auto pr-1">
|
<div className="space-y-3 max-h-[60vh] overflow-y-auto pr-1">
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('monitor.healthprobesect.s1fdfad47')} <span className="dg-text-red">*</span></label>
|
<label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('>探针名称 <span className=')} <span className="dg-text-red">*</span></label>
|
||||||
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.name} onChange={e => setProbeForm({ ...probeForm, name: e.target.value })} placeholder={i18n.t('monitor.healthprobesect.s2b576719')} />
|
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.name} onChange={e => setProbeForm({ ...probeForm, name: e.target.value })} placeholder={i18n.t('如:cex-agent 健康检查')} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('agent.installTarget')} </label>
|
<label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('agent.installTarget')} </label>
|
||||||
@@ -188,9 +188,9 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block">HTTP URL <span className="dg-text-red">*</span></label>
|
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block">HTTP URL <span className="dg-text-red">*</span></label>
|
||||||
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_url} onChange={e => setProbeForm({ ...probeForm, http_url: e.target.value })} placeholder="http://localhost:8080/health" /></div>
|
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_url} onChange={e => setProbeForm({ ...probeForm, http_url: e.target.value })} placeholder="http://localhost:8080/health" /></div>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('monitor.sitemonitortsx.s88cbfb5c')} </label>
|
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('无限制')} </label>
|
||||||
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_expect_code} onChange={e => setProbeForm({ ...probeForm, http_expect_code: Number(e.target.value) })} /></div>
|
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_expect_code} onChange={e => setProbeForm({ ...probeForm, http_expect_code: Number(e.target.value) })} /></div>
|
||||||
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('monitor.healthprobesect.s27f2c428')} </label>
|
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('无限制')} </label>
|
||||||
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_expect_body} onChange={e => setProbeForm({ ...probeForm, http_expect_body: e.target.value })} /></div>
|
<input className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.http_expect_body} onChange={e => setProbeForm({ ...probeForm, http_expect_body: e.target.value })} /></div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -213,7 +213,7 @@ export function HealthProbeSection({ selectedHost }: HealthProbeSectionProps) {
|
|||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('automation.remoteTimeout')} </label>
|
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('automation.remoteTimeout')} </label>
|
||||||
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.timeout} onChange={e => setProbeForm({ ...probeForm, timeout: Number(e.target.value) })} /></div>
|
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.timeout} onChange={e => setProbeForm({ ...probeForm, timeout: Number(e.target.value) })} /></div>
|
||||||
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('monitor.healthprobesect.sc7f8350a')} </label>
|
<div><label className="text-[11px] text-[var(--dg-text-muted)] mb-1 block"> {i18n.t('>执行命令 <span className=')} </label>
|
||||||
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.interval} onChange={e => setProbeForm({ ...probeForm, interval: Number(e.target.value) })} /></div>
|
<input type="number" className="w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]" value={probeForm.interval} onChange={e => setProbeForm({ ...probeForm, interval: Number(e.target.value) })} /></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function HostTimeRangePicker({ value, onChange }: Props) {
|
|||||||
</Button>
|
</Button>
|
||||||
{customOpen && (
|
{customOpen && (
|
||||||
<div className="absolute right-0 top-full mt-1 z-50 w-72 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-primary)] p-3 shadow-lg">
|
<div className="absolute right-0 top-full mt-1 z-50 w-72 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-primary)] p-3 shadow-lg">
|
||||||
<p className="text-xs font-medium text-[var(--dg-text-primary)] mb-2"> {i18n.t('monitor.hosttimerangepi.s0122e022')} </p>
|
<p className="text-xs font-medium text-[var(--dg-text-primary)] mb-2"> {i18n.t('无限制')} </p>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[10px] dg-text-muted"> {i18n.t('common.start')} </label>
|
<label className="text-[10px] dg-text-muted"> {i18n.t('common.start')} </label>
|
||||||
@@ -98,7 +98,7 @@ export function HostTimeRangePicker({ value, onChange }: Props) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[10px] dg-text-muted"> {i18n.t('monitor.hosttimerangepi.s12f1d7ef')} </label>
|
<label className="text-[10px] dg-text-muted"> {i18n.t('无限制')} </label>
|
||||||
<Input
|
<Input
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
value={customEnd}
|
value={customEnd}
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ export function PortPolicyDialog({
|
|||||||
</div>
|
</div>
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1.5 leading-relaxed">
|
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1.5 leading-relaxed">
|
||||||
{portPolicyMode === 'whitelist'
|
{portPolicyMode === 'whitelist'
|
||||||
? i18n.t('monitor.portpolicydialo.sf5cd9d7c')
|
? i18n.t('所有发现的端口都上报,任意端口变化都会触发告警 + 恢复通知。')
|
||||||
: i18n.t('monitor.portpolicydialo.sf3bf3319')}
|
: i18n.t('仅上报选中端口的变化,其余端口变化静默忽略(不告警)。系统进程端口(sshd/rpcbind/systemd等)永远忽略。')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ export function PortPolicyDialog({
|
|||||||
const val = e.target.value;
|
const val = e.target.value;
|
||||||
onWhitelistChange(parsePortList(val));
|
onWhitelistChange(parsePortList(val));
|
||||||
}}
|
}}
|
||||||
placeholder={portPolicyMode === 'whitelist' ? i18n.t('monitor.portpolicydialo.s51b8453b') : '80,443,3306,6379'}
|
placeholder={portPolicyMode === 'whitelist' ? i18n.t('白名单模式下所有端口自动上报') : '80,443,3306,6379'}
|
||||||
readOnly={portPolicyMode === 'whitelist'}
|
readOnly={portPolicyMode === 'whitelist'}
|
||||||
/>
|
/>
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1">
|
<p className="text-[10px] text-[var(--dg-text-muted)] mt-1">
|
||||||
@@ -90,7 +90,7 @@ export function PortPolicyDialog({
|
|||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" size="sm" className="h-7 text-[11px]" onClick={() => onOpenChange(false)}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
<Button variant="outline" size="sm" className="h-7 text-[11px]" onClick={() => onOpenChange(false)}> {i18n.t('rbac.jobRole.cancel')} </Button>
|
||||||
<Button size="sm" className="h-7 text-[11px] bg-blue-600 hover:bg-blue-500" onClick={onSave} disabled={saving}>
|
<Button size="sm" className="h-7 text-[11px] bg-blue-600 hover:bg-blue-500" onClick={onSave} disabled={saving}>
|
||||||
{saving ? i18n.t('monitor.silenceDialog.saving') : i18n.t('monitor.portpolicydialo.s2d3f52b4')}
|
{saving ? i18n.t('monitor.silenceDialog.saving') : i18n.t('保存中…')}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -316,11 +316,11 @@ export const ZoomableAreaChart = forwardRef<ZoomableChartHandle, Props>(function
|
|||||||
<DialogContent className={dialogClass}>
|
<DialogContent className={dialogClass}>
|
||||||
<DialogHeader className="shrink-0 flex-row items-start justify-between gap-4 space-y-0 pr-10">
|
<DialogHeader className="shrink-0 flex-row items-start justify-between gap-4 space-y-0 pr-10">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<DialogTitle className="text-base truncate">{title || i18n.t('monitor.zoomableareacha.sdaf53351')}</DialogTitle>
|
<DialogTitle className="text-base truncate">{title || i18n.t('指标详情')}</DialogTitle>
|
||||||
{subtitle && (
|
{subtitle && (
|
||||||
<p className="text-xs dg-text-muted mt-0.5 truncate">{subtitle}</p>
|
<p className="text-xs dg-text-muted mt-0.5 truncate">{subtitle}</p>
|
||||||
)}
|
)}
|
||||||
<DialogDescription className="sr-only"> {i18n.t('monitor.zoomableareacha.s365f8fe8')} </DialogDescription>
|
<DialogDescription className="sr-only"> {i18n.t('选择主机...')} </DialogDescription>
|
||||||
</div>
|
</div>
|
||||||
<ChartToolbar
|
<ChartToolbar
|
||||||
size="md"
|
size="md"
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ export interface BasicTabProps {
|
|||||||
export function BasicTab({ metrics, latest, currentVal, aggType, pctRefLines }: BasicTabProps) {
|
export function BasicTab({ metrics, latest, currentVal, aggType, pctRefLines }: BasicTabProps) {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s4e6cbf10')} value={currentVal('cpu')} icon={<Cpu />} iconTone="blue"
|
<MetricChartCard title={i18n.t('CPU 使用率(%)')} value={currentVal('cpu')} icon={<Cpu />} iconTone="blue"
|
||||||
data={metrics.cpu} color="#3b82f6" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.cpu} color="#3b82f6" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s79f80fbf')} value={latest?.cpu_iowait != null ? `${(latest.cpu_iowait as number).toFixed(1)}%` : '--'} icon={<Clock />} iconTone="orange"
|
<MetricChartCard title={i18n.t('CPU IO等待(%)')} value={latest?.cpu_iowait != null ? `${(latest.cpu_iowait as number).toFixed(1)}%` : '--'} icon={<Clock />} iconTone="orange"
|
||||||
data={metrics.iowait} color="#f97316" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.iowait} color="#f97316" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s78262b59')} value={currentVal('mem')} icon={<Server />} iconTone="green"
|
<MetricChartCard title={i18n.t('内存使用率(%)')} value={currentVal('mem')} icon={<Server />} iconTone="green"
|
||||||
data={metrics.mem} color="#10b981" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.mem} color="#10b981" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.sa23fcda0')} value={latest?.mem_available != null ? `${(latest.mem_available as number).toFixed(1)}GB` : '--'} icon={<Server />} iconTone="green"
|
<MetricChartCard title={i18n.t('可用内存(GB)')} value={latest?.mem_available != null ? `${(latest.mem_available as number).toFixed(1)}GB` : '--'} icon={<Server />} iconTone="green"
|
||||||
data={metrics.memAvail} color="#34d399" unit="GB" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.memAvail} color="#34d399" unit="GB" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s05589bfd')} value={currentVal('swap')} icon={<HardDrive />} iconTone="red"
|
<MetricChartCard title={i18n.t('Swap 使用率(%)')} value={currentVal('swap')} icon={<HardDrive />} iconTone="red"
|
||||||
data={metrics.swap} color="#ef4444" unit="%" domain={[0, 100]} aggType={aggType} />
|
data={metrics.swap} color="#ef4444" unit="%" domain={[0, 100]} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.sae62efb2')} value={currentVal('load1')} icon={<Activity />} iconTone="purple"
|
<MetricChartCard title={i18n.t('系统负载(1m)')} value={currentVal('load1')} icon={<Activity />} iconTone="purple"
|
||||||
data={metrics.load1} color="#8b5cf6" unit="" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.load1} color="#8b5cf6" unit="" domain={[0, 'auto']} aggType={aggType} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function ContextSwitchCard({ csInfo }: { csInfo: JsonData }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-center py-4 text-xs text-[var(--dg-text-muted)]"> {i18n.t('monitor.hostmonitortsx.sae1a30b7')} </div>
|
<div className="text-center py-4 text-xs text-[var(--dg-text-muted)]"> {i18n.t('无限制')} </div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ export function DiskTab({ metrics, latest, currentVal, aggType, pctRefLines, dis
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.sdf969221')} value={currentVal('disk')} icon={<HardDrive />} iconTone="orange"
|
<MetricChartCard title={i18n.t('磁盘使用率(%)')} value={currentVal('disk')} icon={<HardDrive />} iconTone="orange"
|
||||||
data={metrics.disk} color="#f97316" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.disk} color="#f97316" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s20296121')} value={inodeVal} icon={<HardDrive />} iconTone="purple"
|
<MetricChartCard title={i18n.t('Swap 使用率(%)')} value={inodeVal} icon={<HardDrive />} iconTone="purple"
|
||||||
data={metrics.inode} color="#8b5cf6" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.inode} color="#8b5cf6" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s72e3c273')} value={currentVal('ioR')} icon={<Disc />} iconTone="blue"
|
<MetricChartCard title={i18n.t('磁盘读取(KB/s)')} value={currentVal('ioR')} icon={<Disc />} iconTone="blue"
|
||||||
data={metrics.ioRead} color="#3b82f6" unit="KB/s" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.ioRead} color="#3b82f6" unit="KB/s" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.sa9b96f9b')} value={currentVal('ioW')} icon={<Disc />} iconTone="green"
|
<MetricChartCard title={i18n.t('磁盘写入(KB/s)')} value={currentVal('ioW')} icon={<Disc />} iconTone="green"
|
||||||
data={metrics.ioWrite} color="#10b981" unit="KB/s" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.ioWrite} color="#10b981" unit="KB/s" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s996adabd')} value={diskIOInfo?.util != null ? `${diskIOInfo.util.toFixed(1)}%` : '--'} icon={<Disc />} iconTone="red"
|
<MetricChartCard title={i18n.t('磁盘IO繁忙度(%)')} value={diskIOInfo?.util != null ? `${diskIOInfo.util.toFixed(1)}%` : '--'} icon={<Disc />} iconTone="red"
|
||||||
data={metrics.ioUtil} color="#ef4444" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
data={metrics.ioUtil} color="#ef4444" unit="%" domain={[0, 100]} aggType={aggType} referenceLines={pctRefLines} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export function FDUsageCard({ fdInfo, fdMetrics, aggType, fdChartRef, fdChartZoo
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('monitor.metricCatalog.colMax')} </span>
|
<span className="text-[var(--dg-text-muted)]"> {i18n.t('monitor.metricCatalog.colMax')} </span>
|
||||||
<span className="font-mono text-[var(--dg-text-primary)] font-semibold">{fdInfo.max === -1 ? i18n.t('monitor.hostmonitortsx.sbc436447') : fdInfo.max?.toLocaleString() || '—'}</span>
|
<span className="font-mono text-[var(--dg-text-primary)] font-semibold">{fdInfo.max === -1 ? i18n.t('无限制') : fdInfo.max?.toLocaleString() || '—'}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="text-[var(--dg-text-muted)]"> {i18n.t('server.usage')} </span>
|
<span className="text-[var(--dg-text-muted)]"> {i18n.t('server.usage')} </span>
|
||||||
@@ -57,11 +57,11 @@ export function FDUsageCard({ fdInfo, fdMetrics, aggType, fdChartRef, fdChartZoo
|
|||||||
<ZoomableAreaChart
|
<ZoomableAreaChart
|
||||||
ref={fdChartRef}
|
ref={fdChartRef}
|
||||||
data={fdMetrics.map((d) => ({ ...d, value: d[aggType] }))}
|
data={fdMetrics.map((d) => ({ ...d, value: d[aggType] }))}
|
||||||
series={[{ dataKey: 'value', color: '#a78bfa', label: i18n.t('monitor.hostmonitortsx.s28130dec') }]}
|
series={[{ dataKey: 'value', color: '#a78bfa', label: i18n.t('FD 使用率') }]}
|
||||||
yDomain={[0, 'auto']}
|
yDomain={[0, 'auto']}
|
||||||
unit="%"
|
unit="%"
|
||||||
chartId="fd-usage"
|
chartId="fd-usage"
|
||||||
title={i18n.t('monitor.hostmonitortsx.sc026a1ea')}
|
title={i18n.t('网卡带宽吞吐')}
|
||||||
subtitle={fdInfo?.usage_pct != null ? `当前 ${fdInfo.usage_pct.toFixed(1)}%` : undefined}
|
subtitle={fdInfo?.usage_pct != null ? `当前 ${fdInfo.usage_pct.toFixed(1)}%` : undefined}
|
||||||
height={160}
|
height={160}
|
||||||
toolbarPlacement="header"
|
toolbarPlacement="header"
|
||||||
@@ -71,7 +71,7 @@ export function FDUsageCard({ fdInfo, fdMetrics, aggType, fdChartRef, fdChartZoo
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-center py-4 text-xs text-[var(--dg-text-muted)]"> {i18n.t('monitor.hostmonitortsx.sae1a30b7')} </div>
|
<div className="text-center py-4 text-xs text-[var(--dg-text-muted)]"> {i18n.t('无限制')} </div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -30,20 +30,20 @@ export function NetworkTab({ metrics, netInfo, currentVal, aggType }: NetworkTab
|
|||||||
data={metrics.tcpTW} color="#f59e0b" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.tcpTW} color="#f59e0b" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title="TCP CLOSE_WAIT" value={netInfo?.tcp_close_wait != null ? String(netInfo.tcp_close_wait) : '--'} icon={<Clock />} iconTone="red"
|
<MetricChartCard title="TCP CLOSE_WAIT" value={netInfo?.tcp_close_wait != null ? String(netInfo.tcp_close_wait) : '--'} icon={<Clock />} iconTone="red"
|
||||||
data={metrics.tcpCW} color="#ef4444" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.tcpCW} color="#ef4444" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s56c1b42a')} value={connTotal} icon={<Network />} iconTone="cyan"
|
<MetricChartCard title={i18n.t('内存使用率(%)')} value={connTotal} icon={<Network />} iconTone="cyan"
|
||||||
data={metrics.connTotal} color="#22d3ee" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.connTotal} color="#22d3ee" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
||||||
</div>
|
</div>
|
||||||
<DualLineChart
|
<DualLineChart
|
||||||
title={i18n.t('monitor.hostmonitortsx.s1e2a9e41')}
|
title={i18n.t('主机监控')}
|
||||||
currentRx={netInfo?.net_rx_bps != null ? formatBPS(netInfo.net_rx_bps) : '--'}
|
currentRx={netInfo?.net_rx_bps != null ? formatBPS(netInfo.net_rx_bps) : '--'}
|
||||||
currentTx={netInfo?.net_tx_bps != null ? formatBPS(netInfo.net_tx_bps) : '--'}
|
currentTx={netInfo?.net_tx_bps != null ? formatBPS(netInfo.net_tx_bps) : '--'}
|
||||||
rxData={metrics.rx} txData={metrics.tx}
|
rxData={metrics.rx} txData={metrics.tx}
|
||||||
aggType={aggType} unit="KB/s"
|
aggType={aggType} unit="KB/s"
|
||||||
/>
|
/>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3 mt-3">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-3 mt-3">
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.s9f7e9902')} value={netInfo?.net_rx_errors != null ? String(netInfo.net_rx_errors) : '--'} icon={<XCircle />} iconTone="red"
|
<MetricChartCard title={i18n.t('网卡接收错误')} value={netInfo?.net_rx_errors != null ? String(netInfo.net_rx_errors) : '--'} icon={<XCircle />} iconTone="red"
|
||||||
data={metrics.rxErr} color="#ef4444" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.rxErr} color="#ef4444" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
||||||
<MetricChartCard title={i18n.t('monitor.hostmonitortsx.sb2ffd58e')} value={netInfo?.net_tx_errors != null ? String(netInfo.net_tx_errors) : '--'} icon={<XCircle />} iconTone="orange"
|
<MetricChartCard title={i18n.t('网卡发送错误')} value={netInfo?.net_tx_errors != null ? String(netInfo.net_tx_errors) : '--'} icon={<XCircle />} iconTone="orange"
|
||||||
data={metrics.txErr} color="#f97316" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
data={metrics.txErr} color="#f97316" unit="个" domain={[0, 'auto']} aggType={aggType} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function PortMonitorTab({ portInfo, portPolicyMode, portWhitelist, onOpen
|
|||||||
<tr className="text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]">
|
<tr className="text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]">
|
||||||
<th className="py-1.5 text-left font-medium"> {i18n.t('system.ldapPort')} </th>
|
<th className="py-1.5 text-left font-medium"> {i18n.t('system.ldapPort')} </th>
|
||||||
<th className="py-1.5 text-left font-medium"> {i18n.t('kubernetes.service.protocol')} </th>
|
<th className="py-1.5 text-left font-medium"> {i18n.t('kubernetes.service.protocol')} </th>
|
||||||
<th className="py-1.5 text-left font-medium"> {i18n.t('monitor.hostmonitortsx.sf88522cf')} </th>
|
<th className="py-1.5 text-left font-medium"> {i18n.t('进程监控')} </th>
|
||||||
<th className="py-1.5 text-right font-medium"> {i18n.t('system.terminalStatus')} </th>
|
<th className="py-1.5 text-right font-medium"> {i18n.t('system.terminalStatus')} </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ export function ProcessTable({ processTop }: { processTop: JsonData[] }) {
|
|||||||
<table className="w-full text-xs">
|
<table className="w-full text-xs">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]">
|
<tr className="text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]">
|
||||||
<th className="py-1.5 text-left font-medium w-[40%]"> {i18n.t('monitor.hostmonitortsx.s23ecaf10')} </th>
|
<th className="py-1.5 text-left font-medium w-[40%]"> {i18n.t('进程监控')} </th>
|
||||||
<th className="py-1.5 text-right font-medium w-[8%]">PID</th>
|
<th className="py-1.5 text-right font-medium w-[8%]">PID</th>
|
||||||
<th className="py-1.5 text-right font-medium w-[16%]"> {i18n.t('monitor.hostmonitortsx.s78262b59')} </th>
|
<th className="py-1.5 text-right font-medium w-[16%]"> {i18n.t('进程监控')} </th>
|
||||||
<th className="py-1.5 text-right font-medium w-[16%]">CPU使用率(%)</th>
|
<th className="py-1.5 text-right font-medium w-[16%]">CPU使用率(%)</th>
|
||||||
<th className="py-1.5 text-right font-medium w-[20%]"> {i18n.t('monitor.hostmonitortsx.s8fe5ed35')} </th>
|
<th className="py-1.5 text-right font-medium w-[20%]"> {i18n.t('进程监控')} </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -41,7 +41,7 @@ export function ProcessTable({ processTop }: { processTop: JsonData[] }) {
|
|||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
className="opacity-0 group-hover/cmd:opacity-100 transition-opacity p-0.5 hover:dg-text-cyan shrink-0"
|
className="opacity-0 group-hover/cmd:opacity-100 transition-opacity p-0.5 hover:dg-text-cyan shrink-0"
|
||||||
title={i18n.t('monitor.hostmonitortsx.s92cb88ae')}
|
title={i18n.t('FD 文件句柄使用率')}
|
||||||
onClick={async (e) => {
|
onClick={async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import i18n from '@/i18n';
|
|||||||
/** 预设时间范围(分钟粒度,支持 15/30 分钟) // Logan.Li */
|
/** 预设时间范围(分钟粒度,支持 15/30 分钟) // Logan.Li */
|
||||||
export const TIME_RANGE_PRESETS = [
|
export const TIME_RANGE_PRESETS = [
|
||||||
{ id: '15m', label: i18n.t('monitor.traceMgr.min15'), minutes: 15, buckets: 30 },
|
{ id: '15m', label: i18n.t('monitor.traceMgr.min15'), minutes: 15, buckets: 30 },
|
||||||
{ id: '30m', label: i18n.t('monitor.typests.s751a79af'), minutes: 30, buckets: 36 },
|
{ id: '30m', label: i18n.t('系统信息'), minutes: 30, buckets: 36 },
|
||||||
{ id: '1h', label: i18n.t('monitor.traceMgr.hour1'), minutes: 60, buckets: 60 },
|
{ id: '1h', label: i18n.t('monitor.traceMgr.hour1'), minutes: 60, buckets: 60 },
|
||||||
{ id: '6h', label: i18n.t('monitor.traceMgr.hour6'), minutes: 360, buckets: 72 },
|
{ id: '6h', label: i18n.t('monitor.traceMgr.hour6'), minutes: 360, buckets: 72 },
|
||||||
{ id: '12h', label: i18n.t('monitor.typests.sd04708fe'), minutes: 720, buckets: 72 },
|
{ id: '12h', label: i18n.t('系统信息'), minutes: 720, buckets: 72 },
|
||||||
{ id: '1d', label: i18n.t('monitor.typests.s7db888de'), minutes: 1440, buckets: 96 },
|
{ id: '1d', label: i18n.t('系统信息'), minutes: 1440, buckets: 96 },
|
||||||
{ id: '7d', label: i18n.t('monitor.traceMgr.day7'), minutes: 10080, buckets: 84 },
|
{ id: '7d', label: i18n.t('monitor.traceMgr.day7'), minutes: 10080, buckets: 84 },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function MiddlewareDialog({ open, onOpenChange, editTarget, onSuccess }:
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!form.name.trim() || !form.ip.trim()) {
|
if (!form.name.trim() || !form.ip.trim()) {
|
||||||
toast.error(i18n.t('monitor.middlewaredialo.s0fa2360e'));
|
toast.error(i18n.t('请填写名称和 IP'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
@@ -63,7 +63,7 @@ export function MiddlewareDialog({ open, onOpenChange, editTarget, onSuccess }:
|
|||||||
}
|
}
|
||||||
if (editTarget) {
|
if (editTarget) {
|
||||||
await middlewareMonitorApi.update(editTarget.id, payload);
|
await middlewareMonitorApi.update(editTarget.id, payload);
|
||||||
toast.success(i18n.t('monitor.middlewaredialo.s55aa6366'));
|
toast.success(i18n.t('更新成功'));
|
||||||
} else {
|
} else {
|
||||||
await middlewareMonitorApi.create(payload);
|
await middlewareMonitorApi.create(payload);
|
||||||
toast.success(i18n.t('monitor.dashboard.custom.toastCreateSuccess'));
|
toast.success(i18n.t('monitor.dashboard.custom.toastCreateSuccess'));
|
||||||
@@ -81,8 +81,8 @@ export function MiddlewareDialog({ open, onOpenChange, editTarget, onSuccess }:
|
|||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent showOverlay={false} className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-md">
|
<DialogContent showOverlay={false} className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-md">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{editTarget ? i18n.t('monitor.middlewaredialo.sc38ddef8') : i18n.t('monitor.middlewaredialo.sa24241b6')}</DialogTitle>
|
<DialogTitle>{editTarget ? i18n.t('编辑中间件') : i18n.t('添加中间件')}</DialogTitle>
|
||||||
<DialogDescription> {i18n.t('monitor.middlewaredialo.s6ee71754')} </DialogDescription>
|
<DialogDescription> {i18n.t('监控实例')} </DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-4 max-h-[60vh] overflow-y-auto pr-1">
|
<div className="space-y-4 max-h-[60vh] overflow-y-auto pr-1">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -100,7 +100,7 @@ export function MiddlewareDialog({ open, onOpenChange, editTarget, onSuccess }:
|
|||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label> {i18n.t('deploy.form.deployMode')} </Label>
|
<Label> {i18n.t('deploy.form.deployMode')} </Label>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
{[{ value: 'standalone' as const, label: i18n.t('monitor.helpersts.s047499fc') }, { value: 'cluster' as const, label: i18n.t('k8s.topology.typeCluster') }].map((opt) => (
|
{[{ value: 'standalone' as const, label: i18n.t('单机') }, { value: 'cluster' as const, label: i18n.t('k8s.topology.typeCluster') }].map((opt) => (
|
||||||
<button key={opt.value} type="button" onClick={() => setForm((f) => ({ ...f, redis_mode: opt.value }))}
|
<button key={opt.value} type="button" onClick={() => setForm((f) => ({ ...f, redis_mode: opt.value }))}
|
||||||
className={`flex-1 py-2 rounded-lg text-sm ${form.redis_mode === opt.value ? 'bg-blue-600 text-white' : 'bg-[var(--dg-bg-tertiary)]'}`}>
|
className={`flex-1 py-2 rounded-lg text-sm ${form.redis_mode === opt.value ? 'bg-blue-600 text-white' : 'bg-[var(--dg-bg-tertiary)]'}`}>
|
||||||
{opt.label}
|
{opt.label}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function MwOverviewCharts({ targets }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-3">
|
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-3">
|
||||||
<OverviewChartCard title={i18n.t('monitor.mwoverviewchart.s2eeb27f9')} icon={<PieChartIcon className="h-3.5 w-3.5 text-[var(--dg-text-muted)]" />} empty={statusData.length === 0}>
|
<OverviewChartCard title={i18n.t('实例状态')} icon={<PieChartIcon className="h-3.5 w-3.5 text-[var(--dg-text-muted)]" />} empty={statusData.length === 0}>
|
||||||
{(h) => (
|
{(h) => (
|
||||||
<ResponsiveContainer width="100%" height={h}>
|
<ResponsiveContainer width="100%" height={h}>
|
||||||
<PieChart>
|
<PieChart>
|
||||||
@@ -67,13 +67,13 @@ export function MwOverviewCharts({ targets }: Props) {
|
|||||||
)}
|
)}
|
||||||
</OverviewChartCard>
|
</OverviewChartCard>
|
||||||
|
|
||||||
<OverviewChartCard title={i18n.t('monitor.mwoverviewchart.s29d98d86')} icon={<Percent className="h-3.5 w-3.5 text-[var(--dg-text-muted)]" />} empty={redisHitData.length === 0}>
|
<OverviewChartCard title={i18n.t('在线')} icon={<Percent className="h-3.5 w-3.5 text-[var(--dg-text-muted)]" />} empty={redisHitData.length === 0}>
|
||||||
{(h) => (
|
{(h) => (
|
||||||
<ResponsiveContainer width="100%" height={h}>
|
<ResponsiveContainer width="100%" height={h}>
|
||||||
<BarChart data={redisHitData} layout="vertical" margin={{ left: 0, right: 8 }}>
|
<BarChart data={redisHitData} layout="vertical" margin={{ left: 0, right: 8 }}>
|
||||||
<XAxis type="number" domain={[0, 100]} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickFormatter={(v) => `${v}%`} />
|
<XAxis type="number" domain={[0, 100]} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickFormatter={(v) => `${v}%`} />
|
||||||
<YAxis type="category" dataKey="name" width={64} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickLine={false} axisLine={false} />
|
<YAxis type="category" dataKey="name" width={64} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickLine={false} axisLine={false} />
|
||||||
<Tooltip content={<MonitorChartTooltip valueFormatter={(v) => fmtHitRate(v / 100)} nameFormatter={() => i18n.t('monitor.mwtargetchartsp.s6787355b')} />} />
|
<Tooltip content={<MonitorChartTooltip valueFormatter={(v) => fmtHitRate(v / 100)} nameFormatter={() => i18n.t('命中率')} />} />
|
||||||
<Bar dataKey="value" radius={[0, 3, 3, 0]} maxBarSize={14} isAnimationActive={false}>
|
<Bar dataKey="value" radius={[0, 3, 3, 0]} maxBarSize={14} isAnimationActive={false}>
|
||||||
{redisHitData.map((e) => <Cell key={e.fullName} fill={e.fill} />)}
|
{redisHitData.map((e) => <Cell key={e.fullName} fill={e.fill} />)}
|
||||||
</Bar>
|
</Bar>
|
||||||
@@ -103,7 +103,7 @@ export function MwOverviewCharts({ targets }: Props) {
|
|||||||
<BarChart data={mysqlConnData} layout="vertical" margin={{ left: 0, right: 8 }}>
|
<BarChart data={mysqlConnData} layout="vertical" margin={{ left: 0, right: 8 }}>
|
||||||
<XAxis type="number" tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} />
|
<XAxis type="number" tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} />
|
||||||
<YAxis type="category" dataKey="name" width={64} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickLine={false} axisLine={false} />
|
<YAxis type="category" dataKey="name" width={64} tick={{ fontSize: 9, fill: 'var(--dg-text-muted)' }} tickLine={false} axisLine={false} />
|
||||||
<Tooltip content={<MonitorChartTooltip valueFormatter={(v) => fmtVal(v)} nameFormatter={() => i18n.t('monitor.mwoverviewchart.s30f7dd4e')} />} />
|
<Tooltip content={<MonitorChartTooltip valueFormatter={(v) => fmtVal(v)} nameFormatter={() => i18n.t('连接')} />} />
|
||||||
<Bar dataKey="value" radius={[0, 3, 3, 0]} maxBarSize={14} isAnimationActive={false}>
|
<Bar dataKey="value" radius={[0, 3, 3, 0]} maxBarSize={14} isAnimationActive={false}>
|
||||||
{mysqlConnData.map((e) => <Cell key={e.fullName} fill={e.fill} />)}
|
{mysqlConnData.map((e) => <Cell key={e.fullName} fill={e.fill} />)}
|
||||||
</Bar>
|
</Bar>
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export function MwTargetChartsPanel({ target, chartDefs, accent }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<Button variant="ghost" size="sm" className="h-7 text-xs" onClick={() => setShowAll((v) => !v)}>
|
<Button variant="ghost" size="sm" className="h-7 text-xs" onClick={() => setShowAll((v) => !v)}>
|
||||||
{showAll ? i18n.t('monitor.mwtargetchartsp.s9e75621e') : i18n.t('monitor.mwtargetchartsp.s9dea79ec')}
|
{showAll ? i18n.t('核心指标') : i18n.t('全部指标')}
|
||||||
</Button>
|
</Button>
|
||||||
<Select value={timeRange} onValueChange={(v) => setTimeRange(v as MwTimeRange)}>
|
<Select value={timeRange} onValueChange={(v) => setTimeRange(v as MwTimeRange)}>
|
||||||
<SelectTrigger className="h-7 w-[92px] text-xs"><SelectValue /></SelectTrigger>
|
<SelectTrigger className="h-7 w-[92px] text-xs"><SelectValue /></SelectTrigger>
|
||||||
@@ -116,17 +116,17 @@ export function MwTargetChartsPanel({ target, chartDefs, accent }: Props) {
|
|||||||
{accent === 'redis' && (
|
{accent === 'redis' && (
|
||||||
<>
|
<>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('monitor.mwtargetchartsp.s6787355b')}
|
label={i18n.t('命中率')}
|
||||||
value={(m.redis_hit_rate || 0) * 100}
|
value={(m.redis_hit_rate || 0) * 100}
|
||||||
display={fmtHitRate(m.redis_hit_rate)}
|
display={fmtHitRate(m.redis_hit_rate)}
|
||||||
level={m.redis_hit_rate > 0 ? gaugeToneLow((m.redis_hit_rate || 0) * 100, 90, 80) : 'ok'}
|
level={m.redis_hit_rate > 0 ? gaugeToneLow((m.redis_hit_rate || 0) * 100, 90, 80) : 'ok'}
|
||||||
/>
|
/>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('monitor.mwtargetchartsp.s44cdb3f7')}
|
label={i18n.t('命中率')}
|
||||||
value={memPct ?? (m.redis_used_memory > 0 ? 50 : 0)}
|
value={memPct ?? (m.redis_used_memory > 0 ? 50 : 0)}
|
||||||
display={fmtMemory(m.redis_used_memory)}
|
display={fmtMemory(m.redis_used_memory)}
|
||||||
level={memPct != null ? gaugeTone(memPct, 80, 90) : 'ok'}
|
level={memPct != null ? gaugeTone(memPct, 80, 90) : 'ok'}
|
||||||
hint={memPct != null ? `已用 ${memPct.toFixed(0)}%` : i18n.t('monitor.mwtargetchartsp.s1c1ce805')}
|
hint={memPct != null ? `已用 ${memPct.toFixed(0)}%` : i18n.t('未配置 maxmemory')}
|
||||||
/>
|
/>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('kubernetes.topology.connections')}
|
label={i18n.t('kubernetes.topology.connections')}
|
||||||
@@ -140,19 +140,19 @@ export function MwTargetChartsPanel({ target, chartDefs, accent }: Props) {
|
|||||||
{accent === 'mysql' && (
|
{accent === 'mysql' && (
|
||||||
<>
|
<>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('monitor.mwtargetchartsp.sa2d02e56')}
|
label={i18n.t('命中率')}
|
||||||
value={(m.mysql_buffer_hit_rate || 0) * 100}
|
value={(m.mysql_buffer_hit_rate || 0) * 100}
|
||||||
display={fmtHitRate(m.mysql_buffer_hit_rate)}
|
display={fmtHitRate(m.mysql_buffer_hit_rate)}
|
||||||
level={m.mysql_buffer_hit_rate > 0 ? gaugeToneLow((m.mysql_buffer_hit_rate || 0) * 100, 95, 90) : 'ok'}
|
level={m.mysql_buffer_hit_rate > 0 ? gaugeToneLow((m.mysql_buffer_hit_rate || 0) * 100, 95, 90) : 'ok'}
|
||||||
/>
|
/>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('monitor.mwtargetchartsp.se84e4bc5')}
|
label={i18n.t('命中率')}
|
||||||
value={connPct ?? 0}
|
value={connPct ?? 0}
|
||||||
display={`${fmtVal(m.mysql_connections)} / ${fmtVal(m.mysql_max_connections)}`}
|
display={`${fmtVal(m.mysql_connections)} / ${fmtVal(m.mysql_max_connections)}`}
|
||||||
level={connPct != null ? gaugeTone(connPct, 80, 90) : 'ok'}
|
level={connPct != null ? gaugeTone(connPct, 80, 90) : 'ok'}
|
||||||
/>
|
/>
|
||||||
<MwGaugeBar
|
<MwGaugeBar
|
||||||
label={i18n.t('monitor.mwtargetchartsp.se0f6abb7')}
|
label={i18n.t('命中率')}
|
||||||
value={Math.min(100, (m.mysql_threads_running || 0) * 5)}
|
value={Math.min(100, (m.mysql_threads_running || 0) * 5)}
|
||||||
display={fmtVal(m.mysql_threads_running)}
|
display={fmtVal(m.mysql_threads_running)}
|
||||||
level={(m.mysql_threads_running || 0) > 20 ? 'warn' : 'ok'}
|
level={(m.mysql_threads_running || 0) > 20 ? 'warn' : 'ok'}
|
||||||
@@ -167,15 +167,15 @@ export function MwTargetChartsPanel({ target, chartDefs, accent }: Props) {
|
|||||||
{accent === 'redis' ? (
|
{accent === 'redis' ? (
|
||||||
<>
|
<>
|
||||||
<SummaryTile label="QPS" value={fmtVal(m.redis_qps, 1)} />
|
<SummaryTile label="QPS" value={fmtVal(m.redis_qps, 1)} />
|
||||||
<SummaryTile label={i18n.t('monitor.mwtargetchartsp.s196eef1f')} value={fmtVal(m.redis_db_size)} />
|
<SummaryTile label={i18n.t('碎片率')} value={fmtVal(m.redis_db_size)} />
|
||||||
<SummaryTile label={i18n.t('monitor.mwtargetchartsp.s0a5e7a61')} value={fmtVal(m.redis_evicted_keys)} warn={(m.redis_evicted_keys || 0) > 0} />
|
<SummaryTile label={i18n.t('碎片率')} value={fmtVal(m.redis_evicted_keys)} warn={(m.redis_evicted_keys || 0) > 0} />
|
||||||
<SummaryTile label={i18n.t('monitor.mwtargetchartsp.s3bc8dd1f')} value={m.redis_mem_fragmentation_ratio ? fmtVal(m.redis_mem_fragmentation_ratio, 2) : '--'} />
|
<SummaryTile label={i18n.t('逐出 Key')} value={m.redis_mem_fragmentation_ratio ? fmtVal(m.redis_mem_fragmentation_ratio, 2) : '--'} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<SummaryTile label="QPS" value={fmtVal(m.mysql_qps, 1)} />
|
<SummaryTile label="QPS" value={fmtVal(m.mysql_qps, 1)} />
|
||||||
<SummaryTile label={i18n.t('monitor.mwtargetchartsp.s3e54c81c')} value={fmtMemory(m.mysql_bytes_received)} />
|
<SummaryTile label={i18n.t('发送流量')} value={fmtMemory(m.mysql_bytes_received)} />
|
||||||
<SummaryTile label={i18n.t('monitor.mwtargetchartsp.s90d6afb7')} value={fmtMemory(m.mysql_bytes_sent)} />
|
<SummaryTile label={i18n.t('发送流量')} value={fmtMemory(m.mysql_bytes_sent)} />
|
||||||
<SummaryTile label={i18n.t('agent.agentUptime')} value={m.mysql_uptime ? `${Math.floor(m.mysql_uptime / 3600)}h` : '--'} />
|
<SummaryTile label={i18n.t('agent.agentUptime')} value={m.mysql_uptime ? `${Math.floor(m.mysql_uptime / 3600)}h` : '--'} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -59,20 +59,20 @@ export const MYSQL_PRIMARY_KEYS = ['mysql_qps', 'mysql_connections', 'mysql_buff
|
|||||||
|
|
||||||
export const REDIS_CHARTS: MwChartDef[] = [
|
export const REDIS_CHARTS: MwChartDef[] = [
|
||||||
{ key: 'redis_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'ops/s' },
|
{ key: 'redis_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'ops/s' },
|
||||||
{ key: 'redis_used_memory', label: i18n.t('monitor.mwtargetchartsp.s44cdb3f7'), color: 'var(--dg-red)', formatter: fmtMemory },
|
{ key: 'redis_used_memory', label: i18n.t('内存占用'), color: 'var(--dg-red)', formatter: fmtMemory },
|
||||||
{ key: 'redis_hit_rate', label: i18n.t('monitor.mwtargetchartsp.s6787355b'), color: 'var(--dg-green)', percent: true },
|
{ key: 'redis_hit_rate', label: i18n.t('命中率'), color: 'var(--dg-green)', percent: true },
|
||||||
{ key: 'redis_connected_clients', label: i18n.t('kubernetes.topology.connections'), color: 'var(--dg-cyan)' },
|
{ key: 'redis_connected_clients', label: i18n.t('kubernetes.topology.connections'), color: 'var(--dg-cyan)' },
|
||||||
{ key: 'redis_db_size', label: i18n.t('monitor.helpersts.sc5f65eec'), color: 'var(--dg-purple)' },
|
{ key: 'redis_db_size', label: i18n.t('慢查询速率'), color: 'var(--dg-purple)' },
|
||||||
{ key: 'redis_blocked_clients', label: i18n.t('monitor.helpersts.s2ad27e85'), color: 'var(--dg-orange)' },
|
{ key: 'redis_blocked_clients', label: i18n.t('阻塞客户端'), color: 'var(--dg-orange)' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const MYSQL_CHARTS: MwChartDef[] = [
|
export const MYSQL_CHARTS: MwChartDef[] = [
|
||||||
{ key: 'mysql_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'q/s' },
|
{ key: 'mysql_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'q/s' },
|
||||||
{ key: 'mysql_connections', label: i18n.t('kubernetes.topology.connections'), color: 'var(--dg-cyan)' },
|
{ key: 'mysql_connections', label: i18n.t('kubernetes.topology.connections'), color: 'var(--dg-cyan)' },
|
||||||
{ key: 'mysql_threads_running', label: i18n.t('monitor.mwtargetchartsp.se0f6abb7'), color: 'var(--dg-purple)' },
|
{ key: 'mysql_threads_running', label: i18n.t('活跃线程'), color: 'var(--dg-purple)' },
|
||||||
{ key: 'mysql_buffer_hit_rate', label: i18n.t('monitor.mwtargetchartsp.sa2d02e56'), color: 'var(--dg-green)', percent: true },
|
{ key: 'mysql_buffer_hit_rate', label: i18n.t('缓冲池命中率'), color: 'var(--dg-green)', percent: true },
|
||||||
{ key: 'mysql_slow_queries', label: i18n.t('monitor.helpersts.sbd73bca3'), color: 'var(--dg-orange)', unit: i18n.t('monitor.helpersts.s3878fe68'), counterDelta: true },
|
{ key: 'mysql_slow_queries', label: i18n.t('慢查询速率'), color: 'var(--dg-orange)', unit: i18n.t('次/周期'), counterDelta: true },
|
||||||
{ key: 'mysql_bytes_sent', label: i18n.t('monitor.mwtargetchartsp.s90d6afb7'), color: 'var(--dg-amber)', formatter: fmtMemory },
|
{ key: 'mysql_bytes_sent', label: i18n.t('缓冲池命中率'), color: 'var(--dg-amber)', formatter: fmtMemory },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function fmtMemory(bytes: number): string {
|
export function fmtMemory(bytes: number): string {
|
||||||
@@ -139,7 +139,7 @@ export function statusBg(status: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function redisModeLabel(mode?: string): string {
|
export function redisModeLabel(mode?: string): string {
|
||||||
return mode === 'cluster' ? i18n.t('k8s.topology.typeCluster') : i18n.t('monitor.helpersts.s047499fc');
|
return mode === 'cluster' ? i18n.t('k8s.topology.typeCluster') : i18n.t('集群');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function redisMemoryPct(metrics: Record<string, number>): number | null {
|
export function redisMemoryPct(metrics: Record<string, number>): number | null {
|
||||||
@@ -209,27 +209,27 @@ export function evalMwHealth(target: MwTarget): MwHealthIssue[] {
|
|||||||
const m = target.latest_metrics || {};
|
const m = target.latest_metrics || {};
|
||||||
const issues: MwHealthIssue[] = [];
|
const issues: MwHealthIssue[] = [];
|
||||||
if (target.status !== 'online') {
|
if (target.status !== 'online') {
|
||||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpersts.s4ace6502') });
|
issues.push({ level: 'crit', message: i18n.t('实例离线') });
|
||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
if (target.description === 'redis') {
|
if (target.description === 'redis') {
|
||||||
if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.8) issues.push({ level: 'crit', message: i18n.t('monitor.helpersts.sff1d979b') });
|
if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.8) issues.push({ level: 'crit', message: i18n.t('命中率 < 80%') });
|
||||||
else if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.9) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.s11902306') });
|
else if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.9) issues.push({ level: 'warn', message: i18n.t('命中率 < 90%') });
|
||||||
const memPct = redisMemoryPct(m);
|
const memPct = redisMemoryPct(m);
|
||||||
if (memPct != null && memPct > 90) issues.push({ level: 'crit', message: i18n.t('monitor.helpersts.s07eee3b9') });
|
if (memPct != null && memPct > 90) issues.push({ level: 'crit', message: i18n.t('内存 > 90%') });
|
||||||
else if (memPct != null && memPct > 80) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.sbb098add') });
|
else if (memPct != null && memPct > 80) issues.push({ level: 'warn', message: i18n.t('内存 > 80%') });
|
||||||
if (m.redis_blocked_clients > 0) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.s2ad27e85') });
|
if (m.redis_blocked_clients > 0) issues.push({ level: 'warn', message: i18n.t('阻塞客户端') });
|
||||||
if (m.redis_evicted_keys > 0) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.sc4db73a4') });
|
if (m.redis_evicted_keys > 0) issues.push({ level: 'warn', message: i18n.t('Key 逐出') });
|
||||||
} else if (target.description === 'mysql') {
|
} else if (target.description === 'mysql') {
|
||||||
if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.9) {
|
if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.9) {
|
||||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpersts.s99844184') });
|
issues.push({ level: 'crit', message: i18n.t('缓冲池命中 < 90%') });
|
||||||
} else if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.95) {
|
} else if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.95) {
|
||||||
issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.s41ec17d6') });
|
issues.push({ level: 'warn', message: i18n.t('缓冲池命中 < 95%') });
|
||||||
}
|
}
|
||||||
const connPct = mysqlConnPct(m);
|
const connPct = mysqlConnPct(m);
|
||||||
if (connPct != null && connPct > 90) issues.push({ level: 'crit', message: i18n.t('monitor.helpersts.s5b95d546') });
|
if (connPct != null && connPct > 90) issues.push({ level: 'crit', message: i18n.t('连接 > 90% 上限') });
|
||||||
else if (connPct != null && connPct > 80) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.se0b952ab') });
|
else if (connPct != null && connPct > 80) issues.push({ level: 'warn', message: i18n.t('连接 > 80% 上限') });
|
||||||
if (m.mysql_threads_running > 20) issues.push({ level: 'warn', message: i18n.t('monitor.helpersts.s56174d14') });
|
if (m.mysql_threads_running > 20) issues.push({ level: 'warn', message: i18n.t('活跃线程偏多') });
|
||||||
}
|
}
|
||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function SiteProtocolPieChart({ tasks }: Props) {
|
|||||||
if (tasks.length === 0) {
|
if (tasks.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Card className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
<Card className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
|
||||||
<CardContent className="p-6 text-center text-sm text-[var(--dg-text-muted)]"> {i18n.t('monitor.siteprotocolpie.s0589e591')} </CardContent>
|
<CardContent className="p-6 text-center text-sm text-[var(--dg-text-muted)]"> {i18n.t('可用率(24h)')} </CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ export function SiteProtocolPieChart({ tasks }: Props) {
|
|||||||
<CardContent className="p-4">
|
<CardContent className="p-4">
|
||||||
<div className="flex items-center gap-2 mb-2">
|
<div className="flex items-center gap-2 mb-2">
|
||||||
<PieChartIcon className="h-4 w-4 text-[var(--dg-text-muted)]" />
|
<PieChartIcon className="h-4 w-4 text-[var(--dg-text-muted)]" />
|
||||||
<h3 className="text-sm font-medium text-[var(--dg-text-primary)]"> {i18n.t('monitor.siteprotocolpie.s20721c88')} </h3>
|
<h3 className="text-sm font-medium text-[var(--dg-text-primary)]"> {i18n.t('可用率(24h)')} </h3>
|
||||||
<span className="text-[10px] text-[var(--dg-text-muted)]">共 {tasks.length} 个任务</span>
|
<span className="text-[10px] text-[var(--dg-text-muted)]">共 {tasks.length} 个任务</span>
|
||||||
</div>
|
</div>
|
||||||
<ResponsiveContainer width="100%" height={200}>
|
<ResponsiveContainer width="100%" height={200}>
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
setProbing(true);
|
setProbing(true);
|
||||||
try {
|
try {
|
||||||
await siteApi.probeNow(task.id);
|
await siteApi.probeNow(task.id);
|
||||||
toast.success(i18n.t('monitor.siteresultspane.sb8649f2b'));
|
toast.success(i18n.t('拨测完成'));
|
||||||
loadResults();
|
loadResults();
|
||||||
onProbed();
|
onProbed();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.error((e as { message?: string }).message || i18n.t('monitor.siteresultspane.s3f60d8f1'));
|
toast.error((e as { message?: string }).message || i18n.t('拨测失败'));
|
||||||
} finally {
|
} finally {
|
||||||
setProbing(false);
|
setProbing(false);
|
||||||
}
|
}
|
||||||
@@ -128,8 +128,8 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
return (
|
return (
|
||||||
<TableRow className="border-[var(--dg-border)] hover:bg-transparent">
|
<TableRow className="border-[var(--dg-border)] hover:bg-transparent">
|
||||||
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteresultspane.s3f04bb50')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('编辑拨测任务')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteresultspane.s499b9a62')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('编辑拨测任务')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.ssl.daysName')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.ssl.daysName')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.ssl.issuer')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.ssl.issuer')} </TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -140,7 +140,7 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.tcp.connected')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.tcp.connected')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.latency.latencyName')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.latency.latencyName')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteresultspane.sa7d1436b')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('编辑拨测任务')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('cloud.colDescription')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('cloud.colDescription')} </TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
@@ -150,7 +150,7 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.auditTime')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('system.terminalStatus')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('system.terminalStatus')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.latency.latencyName')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('monitor.siteProtocol.latency.latencyName')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('monitor.siteresultspane.s3197ed7a')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('编辑拨测任务')} </TableHead>
|
||||||
<TableHead className="text-xs"> {i18n.t('cloud.colDescription')} </TableHead>
|
<TableHead className="text-xs"> {i18n.t('cloud.colDescription')} </TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
@@ -223,10 +223,10 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
<Select value={timeRange} onValueChange={(v) => setTimeRange(v as SiteTimeRange)}>
|
<Select value={timeRange} onValueChange={(v) => setTimeRange(v as SiteTimeRange)}>
|
||||||
<SelectTrigger className="h-7 w-[92px] text-xs"><SelectValue /></SelectTrigger>
|
<SelectTrigger className="h-7 w-[92px] text-xs"><SelectValue /></SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="1h"> {i18n.t('monitor.helpersts.sf972b7b1')} </SelectItem>
|
<SelectItem value="1h"> {i18n.t('探测次数')} </SelectItem>
|
||||||
<SelectItem value="6h"> {i18n.t('monitor.siteProtocol.rangeDefault')} </SelectItem>
|
<SelectItem value="6h"> {i18n.t('monitor.siteProtocol.rangeDefault')} </SelectItem>
|
||||||
<SelectItem value="24h"> {i18n.t('monitor.helpersts.s6e99b786')} </SelectItem>
|
<SelectItem value="24h"> {i18n.t('探测次数')} </SelectItem>
|
||||||
<SelectItem value="7d"> {i18n.t('monitor.helpersts.sd765efc4')} </SelectItem>
|
<SelectItem value="7d"> {i18n.t('探测次数')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={loadResults} disabled={loading}>
|
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={loadResults} disabled={loading}>
|
||||||
@@ -259,7 +259,7 @@ export function SiteResultsPanel({ task, onProbed, fullPage = false }: Props) {
|
|||||||
<SiteProtocolObs task={task} results={results} rangeLabel={rangeLabel} />
|
<SiteProtocolObs task={task} results={results} rangeLabel={rangeLabel} />
|
||||||
<div className={`mt-4 overflow-x-auto ${fullPage ? 'max-h-80' : 'max-h-56'}`}>
|
<div className={`mt-4 overflow-x-auto ${fullPage ? 'max-h-80' : 'max-h-56'}`}>
|
||||||
{results.length === 0 ? (
|
{results.length === 0 ? (
|
||||||
<p className="text-center py-6 text-sm text-[var(--dg-text-muted)]"> {i18n.t('monitor.siteresultspane.s592b56ff')} </p>
|
<p className="text-center py-6 text-sm text-[var(--dg-text-muted)]"> {i18n.t('可用率(24h)')} </p>
|
||||||
) : (
|
) : (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>{renderTableHead()}</TableHeader>
|
<TableHeader>{renderTableHead()}</TableHeader>
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ export const SITE_TIME_RANGE_HOURS: Record<SiteTimeRange, number> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SITE_TIME_RANGE_LABELS: Record<SiteTimeRange, string> = {
|
export const SITE_TIME_RANGE_LABELS: Record<SiteTimeRange, string> = {
|
||||||
'1h': i18n.t('monitor.helpersts.sf972b7b1'),
|
'1h': i18n.t('近 1 小时'),
|
||||||
'6h': i18n.t('monitor.siteProtocol.rangeDefault'),
|
'6h': i18n.t('monitor.siteProtocol.rangeDefault'),
|
||||||
'24h': i18n.t('monitor.helpersts.s6e99b786'),
|
'24h': i18n.t('近 24 小时'),
|
||||||
'7d': i18n.t('monitor.helpersts.sd765efc4'),
|
'7d': i18n.t('近 7 天'),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 各协议推荐默认拨测间隔(秒)// Logan.Li */
|
/** 各协议推荐默认拨测间隔(秒)// Logan.Li */
|
||||||
@@ -86,11 +86,11 @@ export function defaultProbeFrequency(type: ProbeType): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const probeTypeMeta: Record<ProbeType, { label: string; placeholder: string; hint: string }> = {
|
export const probeTypeMeta: Record<ProbeType, { label: string; placeholder: string; hint: string }> = {
|
||||||
HTTP: { label: i18n.t('monitor.helpersts.s277c74b4'), placeholder: 'https://example.com/health', hint: i18n.t('monitor.helpersts.s953f0b93') },
|
HTTP: { label: i18n.t('目标 URL'), placeholder: 'https://example.com/health', hint: i18n.t('Web 请求(支持 http/https),检测状态码与响应时间') },
|
||||||
SSL: { label: i18n.t('monitor.helpersts.s8e3a1ea5'), placeholder: i18n.t('monitor.helpersts.s8a6cb9ae'), hint: i18n.t('monitor.helpersts.sefe596b0') },
|
SSL: { label: i18n.t('SSL 地址'), placeholder: i18n.t('example.com:443 或 https://example.com'), hint: i18n.t('TLS 握手检测证书(支持 host:port / https:// 域名,不发起 HTTP 请求)') },
|
||||||
TCP: { label: i18n.t('monitor.helpersts.seeda3abc'), placeholder: i18n.t('monitor.helpersts.sd315f501'), hint: i18n.t('monitor.helpersts.s5a87d291') },
|
TCP: { label: i18n.t('主机:端口'), placeholder: i18n.t('192.168.1.1:8080 或 example.com:443'), hint: i18n.t('TCP 端口连通性') },
|
||||||
DNS: { label: i18n.t('cloud.domainName'), placeholder: 'example.com', hint: i18n.t('monitor.helpersts.sd3fd8f1d') },
|
DNS: { label: i18n.t('cloud.domainName'), placeholder: 'example.com', hint: i18n.t('monitor.helpersts.sd3fd8f1d') },
|
||||||
PING: { label: i18n.t('monitor.helpersts.saeb5271e'), placeholder: i18n.t('monitor.helpersts.sd6bbd624'), hint: i18n.t('monitor.helpersts.se850c8e9') },
|
PING: { label: i18n.t('主机地址'), placeholder: i18n.t('192.168.1.1 或 example.com'), hint: i18n.t('ICMP 连通性与延迟(默认 2 分钟/次)') },
|
||||||
};
|
};
|
||||||
|
|
||||||
export function probeFrequencyHint(type: ProbeType): string {
|
export function probeFrequencyHint(type: ProbeType): string {
|
||||||
|
|||||||
@@ -93,16 +93,16 @@ export function analyzeHttpResults(results: SiteResult[], task: SiteTask): HttpO
|
|||||||
}
|
}
|
||||||
if (code >= 500) {
|
if (code >= 500) {
|
||||||
err5xx++;
|
err5xx++;
|
||||||
pushEvent(events, r, `HTTP ${code}`, 'error', r.error_message || i18n.t('monitor.analyticsts.s71de8af8'));
|
pushEvent(events, r, `HTTP ${code}`, 'error', r.error_message || i18n.t('服务端错误'));
|
||||||
} else if (code >= 400) {
|
} else if (code >= 400) {
|
||||||
err4xx++;
|
err4xx++;
|
||||||
pushEvent(events, r, `HTTP ${code}`, 'warn', r.error_message || i18n.t('monitor.analyticsts.sdc751cd0'));
|
pushEvent(events, r, `HTTP ${code}`, 'warn', r.error_message || i18n.t('客户端/鉴权错误'));
|
||||||
} else if (r.status === 'timeout') {
|
} else if (r.status === 'timeout') {
|
||||||
otherErr++;
|
otherErr++;
|
||||||
pushEvent(events, r, i18n.t('common.timeoutError'), 'error', r.error_message);
|
pushEvent(events, r, i18n.t('common.timeoutError'), 'error', r.error_message);
|
||||||
} else {
|
} else {
|
||||||
otherErr++;
|
otherErr++;
|
||||||
pushEvent(events, r, code > 0 ? `HTTP ${code}` : i18n.t('monitor.analyticsts.sf50bf418'), 'error', r.error_message);
|
pushEvent(events, r, code > 0 ? `HTTP ${code}` : i18n.t('请求失败'), 'error', r.error_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const latest = results[0];
|
const latest = results[0];
|
||||||
@@ -128,7 +128,7 @@ export function analyzeSslResults(results: SiteResult[], task: SiteTask): SslObs
|
|||||||
const events: ProbeEvent[] = [];
|
const events: ProbeEvent[] = [];
|
||||||
for (const r of results) {
|
for (const r of results) {
|
||||||
if (r.status !== 'success') {
|
if (r.status !== 'success') {
|
||||||
pushEvent(events, r, i18n.t('monitor.analyticsts.sddbae5b7'), 'error', r.error_message);
|
pushEvent(events, r, i18n.t('请求超时'), 'error', r.error_message);
|
||||||
} else if (r.ssl_days_remaining != null && r.ssl_days_remaining < 30) {
|
} else if (r.ssl_days_remaining != null && r.ssl_days_remaining < 30) {
|
||||||
pushEvent(events, r, `证书剩余 ${r.ssl_days_remaining} 天`, r.ssl_days_remaining <= 7 ? 'error' : 'warn', expiry);
|
pushEvent(events, r, `证书剩余 ${r.ssl_days_remaining} 天`, r.ssl_days_remaining <= 7 ? 'error' : 'warn', expiry);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ export function analyzeTcpResults(results: SiteResult[]): ConnectivityObsSummary
|
|||||||
const failed = r.status !== 'success';
|
const failed = r.status !== 'success';
|
||||||
if (failed) {
|
if (failed) {
|
||||||
lastFailAt = r.checked_at;
|
lastFailAt = r.checked_at;
|
||||||
pushEvent(events, r, i18n.t('monitor.analyticsts.s0614a3ce'), 'error', r.error_message || i18n.t('aiops.llmTestFailed'));
|
pushEvent(events, r, i18n.t('连接失败'), 'error', r.error_message || i18n.t('aiops.llmTestFailed'));
|
||||||
}
|
}
|
||||||
return { time: fmtTime(r.checked_at).slice(-5), up: failed ? 0 : 100, failed };
|
return { time: fmtTime(r.checked_at).slice(-5), up: failed ? 0 : 100, failed };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ export function SnmpDeviceChartsPanel({ device, templateName }: Props) {
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="6h"> {i18n.t('monitor.siteProtocol.rangeDefault')} </SelectItem>
|
<SelectItem value="6h"> {i18n.t('monitor.siteProtocol.rangeDefault')} </SelectItem>
|
||||||
<SelectItem value="24h"> {i18n.t('monitor.helpersts.s6e99b786')} </SelectItem>
|
<SelectItem value="24h"> {i18n.t('选择模板')} </SelectItem>
|
||||||
<SelectItem value="7d"> {i18n.t('monitor.helpersts.sd765efc4')} </SelectItem>
|
<SelectItem value="7d"> {i18n.t('选择模板')} </SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={loadCharts} disabled={loading}>
|
<Button variant="outline" size="sm" className="h-7 text-xs" onClick={loadCharts} disabled={loading}>
|
||||||
@@ -129,9 +129,9 @@ export function SnmpDeviceChartsPanel({ device, templateName }: Props) {
|
|||||||
|
|
||||||
<div className="grid grid-cols-3 gap-3 mb-4">
|
<div className="grid grid-cols-3 gap-3 mb-4">
|
||||||
{[
|
{[
|
||||||
{ label: i18n.t('monitor.snmpdevicechart.s53a04150'), value: latestCpu ? fmtMetricValue(latestCpu.latest_value, latestCpu.unit || '%') : '--' },
|
{ label: i18n.t('设备总数'), value: latestCpu ? fmtMetricValue(latestCpu.latest_value, latestCpu.unit || '%') : '--' },
|
||||||
{ label: i18n.t('monitor.snmpdevicechart.s33962aa4'), value: latestMem ? fmtMetricValue(latestMem.latest_value, latestMem.unit || '%') : '--' },
|
{ label: i18n.t('设备总数'), value: latestMem ? fmtMetricValue(latestMem.latest_value, latestMem.unit || '%') : '--' },
|
||||||
{ label: i18n.t('monitor.snmpdevicechart.s26bddc00'), value: i18n.t('monitor.snmpdevicechart.sfdef8c23') },
|
{ label: i18n.t('设备总数'), value: i18n.t('设备总数') },
|
||||||
].map((item) => (
|
].map((item) => (
|
||||||
<div key={item.label} className="rounded-lg bg-[var(--dg-bg-tertiary)] p-3 text-center">
|
<div key={item.label} className="rounded-lg bg-[var(--dg-bg-tertiary)] p-3 text-center">
|
||||||
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
<p className="text-[10px] text-[var(--dg-text-muted)]">{item.label}</p>
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ export interface ThemeGroup {
|
|||||||
|
|
||||||
/** 主流主题 — 默认推荐 */
|
/** 主流主题 — 默认推荐 */
|
||||||
const MAINSTREAM_THEMES: ThemeOption[] = [
|
const MAINSTREAM_THEMES: ThemeOption[] = [
|
||||||
{ id: 'system', name: i18n.t('common.lightDark'), description: i18n.t('common.themets.s17d84295'), isDark: false, primaryColor: 'linear-gradient(135deg, #2563eb 50%, #0d1117 50%)' },
|
{ id: 'system', name: i18n.t('common.lightDark'), description: i18n.t('跟随系统'), isDark: false, primaryColor: 'linear-gradient(135deg, #2563eb 50%, #0d1117 50%)' },
|
||||||
{ id: 'ocean-deep', name: i18n.t('common.themets.s2f82cbb2'), description: i18n.t('common.themets.s29ee972b'), isDark: true, primaryColor: '#0d1117' },
|
{ id: 'ocean-deep', name: i18n.t('深海蓝'), description: i18n.t('深海蓝'), isDark: true, primaryColor: '#0d1117' },
|
||||||
{ id: 'light-professional', name: i18n.t('common.themets.s2d43cc04'), description: i18n.t('common.themets.s37e76182'), isDark: false, primaryColor: '#2563eb' },
|
{ id: 'light-professional', name: i18n.t('明亮白'), description: i18n.t('企业控制台清爽浅色'), isDark: false, primaryColor: '#2563eb' },
|
||||||
];
|
];
|
||||||
|
|
||||||
/** 开发者主题 — 高辨识度扩展 */
|
/** 开发者主题 — 高辨识度扩展 */
|
||||||
const DEVELOPER_THEMES: ThemeOption[] = [
|
const DEVELOPER_THEMES: ThemeOption[] = [
|
||||||
{ id: 'one-dark', name: 'One Dark', description: i18n.t('common.themets.s02b08e05'), isDark: true, primaryColor: '#c678dd' },
|
{ id: 'one-dark', name: 'One Dark', description: i18n.t('Atom 暖灰 IDE,紫绿语法渐变'), isDark: true, primaryColor: '#c678dd' },
|
||||||
{ id: 'dracula', name: 'Dracula', description: i18n.t('common.themets.s525ce260'), isDark: true, primaryColor: '#bd93f9' },
|
{ id: 'dracula', name: 'Dracula', description: i18n.t('经典紫粉暗色,极高辨识度'), isDark: true, primaryColor: '#bd93f9' },
|
||||||
{ id: 'tokyo-night', name: 'Tokyo Night', description: i18n.t('common.themets.s6f40fb5e'), isDark: true, primaryColor: '#7aa2f7' },
|
{ id: 'tokyo-night', name: 'Tokyo Night', description: i18n.t('东京霓虹深蓝紫,VS Code 热门'), isDark: true, primaryColor: '#7aa2f7' },
|
||||||
{ id: 'catppuccin', name: 'Catppuccin', description: i18n.t('common.themets.s571aa09d'), isDark: true, primaryColor: '#89b4fa' },
|
{ id: 'catppuccin', name: 'Catppuccin', description: i18n.t('马卡龙柔和暗色,护眼'), isDark: true, primaryColor: '#89b4fa' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const THEME_GROUPS: ThemeGroup[] = [
|
export const THEME_GROUPS: ThemeGroup[] = [
|
||||||
{ label: i18n.t('common.themets.s8392cae7'), options: MAINSTREAM_THEMES },
|
{ label: i18n.t('主流'), options: MAINSTREAM_THEMES },
|
||||||
{ label: i18n.t('common.themets.sc2e48855'), options: DEVELOPER_THEMES },
|
{ label: i18n.t('开发者'), options: DEVELOPER_THEMES },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const THEME_OPTIONS: ThemeOption[] = [
|
export const THEME_OPTIONS: ThemeOption[] = [
|
||||||
|
|||||||
Reference in new issue
Block a user