Skip to content

Commit

Permalink
添加 Pod 页面的文件浏览器功能新增了一个文件浏览器抽屉,可以通过选择容器来查看和操作 Pod内的文件。功能包括下载文件、上传文件和编辑…
Browse files Browse the repository at this point in the history
…文件。这个新增的特性极大地增强了对 Pod内文件的管理能力。
  • Loading branch information
weibaohui committed Oct 17, 2024
1 parent 82550ee commit 49f38e3
Showing 1 changed file with 296 additions and 0 deletions.
296 changes: 296 additions & 0 deletions assets/pages/ns/pod.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,302 @@
],
"actions": []
}
},
{
"type": "button",
"icon": "fas fa-folder",
"actionType": "drawer",
"drawer": {
"closeOnOutside": true,
"closeOnEsc": true,
"position": "left",
"size": "xl",
"body": [
{
"type": "wrapper",
"size": "lg",
"className": "b",
"body": [
{
"type": "select",
"name": "containerName",
"source": "${spec.containers | pick:name | map: {label: item, value: item}}",
"value": "${spec.containers[0].name}",
"onEvent": {
"change": {
"actions": [
{
"componentId": "tree",
"actionType": "reload",
"data": {
"path": "${event.data.item.path}",
"isDir": "${event.data.item.isDir}"
}
}
]
}
}
},
{
"type": "tag",
"label": "${metadata.namespace}",
"displayMode": "normal",
"color": "active"
},
{
"type": "tag",
"label": "${metadata.name}",
"displayMode": "normal",
"color": "processing"
},
{
"type": "tag",
"label": "${containerName}",
"displayMode": "normal",
"color": "inactive"
}
]
},
{
"type": "page",
"body": [
{
"type": "page",
"asideResizor": true,
"asideMinWidth": 400,
"asideMaxWidth": 800,
"aside": [
{
"type": "input-tree",
"name": "tree",
"id": "tree",
"initiallyOpen": false,
"unfoldedLevel": 1,
"searchable": true,
"showOutline": true,
"showIcon": true,
"searchConfig": {
"sticky": true
},
"heightAuto": true,
"inputClassName": "no-border no-padder mt-1",
"source": {
"method": "post",
"url": "/k8s/file/list?path=/",
"data": {
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}"
}
},
"deferApi": {
"method": "post",
"url": "/k8s/file/list?path=$path",
"data": {
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}",
"path": "$path",
"isDir": "$isDir"
}
},
"labelField": "name",
"valueField": "path",
"deferField": "isDir",
"onEvent": {
"change": {
"actions": [
{
"componentId": "detail",
"actionType": "reload",
"data": {
"path": "${event.data.item.path}",
"isDir": "${event.data.item.isDir}"
}
}
]
}
}
}
],
"toolbar": [
],
"body": [
{
"type": "service",
"api": {
"method": "post",
"url": "/k8s/file/show",
"data": {
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}",
"isDir": "${isDir?isDir:false}",
"path": "${path}"
}
},
"body": [
{
"type": "form",
"title": "编辑",
"api": {
"method": "post",
"url": "/k8s/file/save",
"data": {
"fileContext": "${fileContext | base64Encode}",
"path": "${path}",
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}",
"isDir": false
}
},
"inline": true,
"body": [
{
"type": "wrapper",
"size": "lg",
"className": "b",
"body": [
{
"type": "grid",
"columns": [
{
"body": [
{
"type": "tpl",
"label": "当前选中",
"tpl": "<span class='text-primary bg-yellow-100 p-2 rounded'>${isDir?'Folder':'File'}</span>&nbsp;<span class='text-primary bg-indigo-100 p-2 rounded'>${path}</span>",
"visibleOn": "${path}"
}
]
},
{
"body": [
{
"type": "button",
"label": "Download File",
"actionType": "ajax",
"api": {
"method": "post",
"url": "/k8s/file/download",
"data": {
"path": "${path}",
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}",
"isDir": false
},
"responseType": "blob"
},
"onEvent": {
"submit": {
"actions": [
{
"actionType": "custom",
"script": "downloadFile(event.data)"
}
]
}
},
"visibleOn": "${isDir===false}"
}
]
},
{
"body": [
{
"type": "button",
"label": "上传文件",
"visibleOn": "${isDir===true}",
"icon": "fa fa-list",
"actionType": "dialog",
"dialog": {
"closeOnEsc": true,
"closeOnOutside": true,
"title": "上传文件",
"body": [
{
"type": "page",
"body": {
"type": "form",

"body": [

{
"type": "input-file",
"name": "file",
"label": "File",
"accept": "*",
"asBlob": true
},
{
"type": "input-text",
"name": "fileName",
"label": "文件名",
"value": "${file.name ||file[0].name ||file[0].path ||file.path ||''}"
}
],
"actions": [
{
"type": "button",
"label": "上传",
"level": "primary",
"actionType": "ajax",
"close": true,
"api": {
"method": "post",
"url": "/k8s/file/upload",
"data": {
"containerName": "${containerName}",
"podName": "${metadata.name}",
"namespace": "${metadata.namespace}",
"isDir": "${isDir?isDir:false}",
"path": "${path}",
"file": "${file}",
"fileName": "${fileName}"
}
}
}
]
}
}
],
"actions": []
}
}
]
}
]
}
]
},
{
"type": "editor",
"name": "fileContext",
"size": "xxl",
"allowFullscreen": true,
"visibleOn": "${isDir===false}",
"value": "${content|base64Decode}",
"language": "shell",
"options": {
"wordWrap": "on",
"scrollbar": {
"vertical": "auto"
}
}
}
]
}
],
"id": "detail"
}
]
}
]
}
]
}
}
],
"toggled": true
Expand Down

0 comments on commit 49f38e3

Please sign in to comment.