feat: K8s集群导出改为导出所有命名空间资源,去掉命名空间选择
- 后端: 新增 ExportResourcesAllNS handler (GET /:clusterCode/export),遍历所有NS收集资源 - 前端: KubernetesClusters 导出弹窗去掉命名空间输入框,一键导出全部NS - API: exportResources → exportAllResources,无需传 namespace 参数
This commit is contained in:
1 parent
a54b2d86b0
commit
dd7cb6895e
4 files changed
+159
-23
No files matched your search
@@ -52,7 +52,6 @@ export function KubernetesClusters() {
|
||||
|
||||
// 导出资源弹窗
|
||||
const [exportCluster, setExportCluster] = useState<any>(null);
|
||||
const [exportNs, setExportNs] = useState('default');
|
||||
const [exporting, setExporting] = useState(false);
|
||||
|
||||
const loadData = async () => {
|
||||
@@ -113,11 +112,10 @@ export function KubernetesClusters() {
|
||||
const handleExport = async () => {
|
||||
if (!exportCluster) return;
|
||||
const code = exportCluster.code || String(exportCluster.id);
|
||||
if (!exportNs.trim()) { toast.error('请输入命名空间'); return; }
|
||||
try {
|
||||
setExporting(true);
|
||||
toast.info(`正在导出 ${exportNs} 命名空间的资源...`);
|
||||
await kubernetesApi.exportResources(code, exportNs.trim());
|
||||
toast.info(`正在导出 ${exportCluster.name} 所有命名空间的资源...`);
|
||||
await kubernetesApi.exportAllResources(code);
|
||||
toast.success('导出完成,已开始下载');
|
||||
setExportCluster(null);
|
||||
} catch (e: any) {
|
||||
@@ -359,7 +357,6 @@ export function KubernetesClusters() {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setExportCluster(cluster);
|
||||
setExportNs('default');
|
||||
}}
|
||||
>
|
||||
<Download className="h-4 w-4 mr-2" />
|
||||
@@ -473,16 +470,8 @@ export function KubernetesClusters() {
|
||||
<div className="bg-slate-900 border border-slate-700 rounded-lg p-5 w-96 shadow-xl" onClick={(e) => e.stopPropagation()}>
|
||||
<h3 className="text-base font-semibold text-slate-100 mb-1">导出集群资源</h3>
|
||||
<p className="text-xs text-slate-400 mb-4">
|
||||
导出 {exportCluster.name} 的 Deployment + Service + Ingress + ConfigMap + Secret 为 tar.gz
|
||||
导出 {exportCluster.name} 所有命名空间的 Deployment、Service、Ingress、ConfigMap、Secret 为 tar.gz
|
||||
</p>
|
||||
<label className="text-xs text-slate-300 mb-1.5 block">命名空间</label>
|
||||
<Input
|
||||
value={exportNs}
|
||||
onChange={(e) => setExportNs(e.target.value)}
|
||||
placeholder="default"
|
||||
className="bg-slate-800 border-slate-700 text-slate-100 mb-4"
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleExport()}
|
||||
/>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" className="border-slate-700 text-slate-300" onClick={() => setExportCluster(null)}>取消</Button>
|
||||
<Button className="bg-blue-600 hover:bg-blue-700 text-white" onClick={handleExport} disabled={exporting}>
|
||||
|
||||
Reference in new issue
Block a user