feat: 新增日志中心、功能优化与代码重构
- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
This commit is contained in:
1 parent
5ca0e6d83a
commit
8d46e8f352
197 files changed
+5014
-815
No files matched your search
@@ -25,6 +25,7 @@ import {
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Server, ChevronDown, Loader2, Save, Key, Shield } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { credentialApi } from '@/api';
|
||||
|
||||
// 表单数据结构
|
||||
@@ -96,8 +97,15 @@ export function ServerForm({
|
||||
onSave,
|
||||
formSaving,
|
||||
}: ServerFormProps) {
|
||||
const navigate = useNavigate();
|
||||
const [credentials, setCredentials] = useState<Credential[]>([]);
|
||||
|
||||
// 只显示 SSH 相关的凭证(ssh key / ssh password)
|
||||
const sshCredentials = credentials.filter((cred: any) => {
|
||||
const at = (cred.auth_type || cred.type || cred.secret_type || '').toLowerCase();
|
||||
return at === 'key' || at === 'password' || at === 'ssh_key' || at === 'ssh_password' || at.includes('ssh');
|
||||
});
|
||||
|
||||
// 加载凭证列表
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@@ -110,11 +118,10 @@ export function ServerForm({
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
// 选择凭证时自动填充
|
||||
// 选择凭证时自动填充(登录用户和认证方式由凭证提供,不再手动)
|
||||
const handleCredentialSelect = (credId: string) => {
|
||||
const id = Number(credId);
|
||||
if (!id) {
|
||||
// 手动输入模式
|
||||
setFormData({ ...formData, credential_id: null });
|
||||
return;
|
||||
}
|
||||
@@ -125,7 +132,7 @@ export function ServerForm({
|
||||
credential_id: id,
|
||||
username: cred.username || 'root',
|
||||
auth_type: cred.auth_type || 'password',
|
||||
password: '', // 已关联凭证,不需要重复输入
|
||||
password: '', // 已关联凭证
|
||||
ssh_key: '',
|
||||
});
|
||||
}
|
||||
@@ -194,7 +201,7 @@ export function ServerForm({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 凭证选择 — 下拉关联已有凭证 */}
|
||||
{/* SSH 凭证关联 — 只允许 SSH 密钥 / SSH 密码 类型 */}
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] flex items-center gap-1.5">
|
||||
<Key className="h-3.5 w-3.5" /> SSH 凭证
|
||||
@@ -205,71 +212,40 @@ export function ServerForm({
|
||||
onValueChange={handleCredentialSelect}
|
||||
>
|
||||
<SelectTrigger className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
||||
<SelectValue placeholder="选择已有凭证..." />
|
||||
<SelectValue placeholder="选择 SSH 凭证..." />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]">
|
||||
<SelectItem value="__manual">手动输入(不关联凭证)</SelectItem>
|
||||
{credentials.map((cred) => (
|
||||
{sshCredentials.map((cred) => (
|
||||
<SelectItem key={cred.id} value={String(cred.id)}>
|
||||
<span className="flex items-center gap-2">
|
||||
<Shield className="h-3 w-3 text-blue-400" />
|
||||
{cred.name} ({cred.username}@{cred.auth_type === 'key' ? '密钥' : '密码'})
|
||||
{cred.name} ({cred.username}@{ (cred.auth_type || '').toLowerCase() === 'key' ? '密钥' : '密码'})
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{sshCredentials.length === 0 && (
|
||||
<p className="text-xs text-[var(--dg-text-muted)]">
|
||||
暂无可用的 SSH 凭证(仅支持 SSH 密钥 和 SSH 密码 类型)。
|
||||
<span
|
||||
className="text-[var(--dg-blue)] hover:underline cursor-pointer ml-1"
|
||||
onClick={() => {
|
||||
onOpenChange(false);
|
||||
navigate('/credentials');
|
||||
}}
|
||||
>
|
||||
去系统管理 - 凭证配置创建
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{formData.credential_id && (
|
||||
<p className="text-[10px] text-green-400/70">已关联凭证,登录信息从凭证自动获取</p>
|
||||
<p className="text-[10px] text-green-400/70">已关联凭证,登录信息从凭证自动获取(登录用户和认证方式由凭证决定)</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 手动输入模式 — 仅当未选凭证时显示 */}
|
||||
{!formData.credential_id && (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]">登录用户</Label>
|
||||
<Input
|
||||
placeholder="root"
|
||||
value={formData.username}
|
||||
onChange={(e) => setFormData({ ...formData, username: e.target.value })}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]">认证方式</Label>
|
||||
<Select
|
||||
value={formData.auth_type}
|
||||
onValueChange={(v) => setFormData({ ...formData, auth_type: v })}
|
||||
>
|
||||
<SelectTrigger className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]">
|
||||
<SelectItem value="password">密码认证</SelectItem>
|
||||
<SelectItem value="key">密钥认证</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]">
|
||||
{formData.auth_type === 'key' ? 'SSH 私钥' : '登录密码'}
|
||||
{!editingId && <span className="text-red-400 ml-1">*</span>}
|
||||
{editingId && <span className="text-[var(--dg-text-muted)] ml-1 text-xs">(留空则不修改)</span>}
|
||||
</Label>
|
||||
<Textarea
|
||||
placeholder={formData.auth_type === 'key' ? '粘贴 SSH 私钥内容...' : '输入登录密码...'}
|
||||
value={formData.password}
|
||||
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
||||
className="bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] min-h-[50px] font-mono text-sm"
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 更多详情 */}
|
||||
<Collapsible open={detailsOpen} onOpenChange={setDetailsOpen}>
|
||||
<CollapsibleTrigger asChild>
|
||||
|
||||
Reference in new issue
Block a user