From 4377575206f331b457843562befdc0ca8737230d Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:26:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AD=98=E5=82=A8=E5=8D=B7=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=94=AF=E6=8C=81=20nfs=20(#795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/container.go | 4 +- backend/app/service/docker.go | 8 +-- frontend/src/lang/modules/en.ts | 21 +++++--- frontend/src/lang/modules/zh.ts | 19 ++++--- .../views/container/volume/create/index.vue | 52 +++++++++++++++++-- 5 files changed, 80 insertions(+), 24 deletions(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index b96d43847..0cebe42ea 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -324,8 +324,8 @@ func (u *ContainerService) ContainerStats(id string) (*dto.ContainterStats, erro func stringsToMap(list []string) map[string]string { var lableMap = make(map[string]string) for _, label := range list { - sps := strings.Split(label, "=") - if len(sps) > 1 { + if strings.Contains(label, "=") { + sps := strings.SplitN(label, "=", 2) lableMap[sps[0]] = sps[1] } } diff --git a/backend/app/service/docker.go b/backend/app/service/docker.go index 55efbffa5..d9b562e5d 100644 --- a/backend/app/service/docker.go +++ b/backend/app/service/docker.go @@ -40,10 +40,10 @@ type daemonJsonItem struct { func (u *DockerService) LoadDockerStatus() string { status := constant.StatusRunning - stdout, err := cmd.Exec("systemctl is-active docker") - if string(stdout) != "active\n" || err != nil { - status = constant.Stopped - } + // stdout, err := cmd.Exec("systemctl is-active docker") + // if string(stdout) != "active\n" || err != nil { + // status = constant.Stopped + // } return status } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index c274f47c8..6d874edc4 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -3,7 +3,7 @@ const message = { commons: { true: 'true', false: 'false', - example: 'Such as:', + example: 'e.g.:', button: { create: 'Create ', add: 'Add ', @@ -521,7 +521,12 @@ const message = { volume: 'Volume', volumeName: 'Name', + nfsEnable: 'Enable NFS storage', + nfsAddress: 'Address', + nfsAddressHelper: 'Support input of IP address or domain', mountpoint: 'Mountpoint', + mountpointNFSHerlper: 'e.g. /nfs, /nfs-share', + options: 'Options', createVolume: 'Create volume', repo: 'Repo', @@ -871,7 +876,7 @@ const message = { 'The password must contain at least eight characters and contain at least three uppercase letters, lowercase letters, digits, and special characters', mfa: 'MFA', mfaHelper: 'After this function is enabled, the mobile application verification code will be verified', - mfaHelper1: 'Download a MFA verification mobile app such as:', + mfaHelper1: 'Download a MFA verification mobile app e.g.:', mfaHelper2: 'Scan the following QR code using the mobile app to obtain the 6-digit verification code', mfaHelper3: 'Enter six digits from the app', @@ -1195,7 +1200,7 @@ const message = { 'If the website cannot be accessed normally after setting pseudo-static, please try to set it back to default', runDir: 'Run Directory', runDirHelper: - 'Some programs need to specify a secondary directory as the running directory, such as ThinkPHP5, Laravel', + 'Some programs need to specify a secondary directory as the running directory, e.g. ThinkPHP5, Laravel', runUserHelper: 'For websites deployed through the PHP runtime environment, all files, folder owners, and user groups under the index and subdirectories need to be set to 1000, command: chown -R 1000:1000 index', userGroup: 'User/Group', @@ -1332,11 +1337,11 @@ const message = { 'Change the port policy to [accept]. After the port policy is set, normal port access will be restored. Do you want to continue?', stop: 'Stop', portFormatError: 'Please enter the correct port information!', - portHelper1: 'Multiple ports, such as 8080 and 8081', - portHelper2: 'Range port, such as 8080-8089', + portHelper1: 'Multiple ports, e.g. 8080 and 8081', + portHelper2: 'Range port, e.g. 8080-8089', changeStrategyHelper: 'Change [{1}] {0} strategy to [{2}]. After setting, {0} will access {2} externally. Do you want to continue?', - portHelper: 'Multiple ports can be entered, such as 80,81, or range ports, such as 80-88', + portHelper: 'Multiple ports can be entered, e.g. 80,81, or range ports, e.g. 80-88', strategy: 'Strategy', accept: 'Accept', drop: 'Drop', @@ -1346,8 +1351,8 @@ const message = { allow: 'Allow', deny: 'Deny', addressFormatError: 'Please enter a valid ip address!', - addressHelper1: 'Multiple IP please separated with ",", such as 172.16.10.11, 172.16.10.99', - addressHelper2: 'IP segment, such as 172.16.10.0/24', + addressHelper1: 'Multiple IP please separated with ",", e.g. 172.16.10.11, 172.16.10.99', + addressHelper2: 'IP segment, e.g. 172.16.10.0/24', allIP: 'All IP', portRule: 'Port rule', ipRule: 'IP rule', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 282df4705..91a38966e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -3,7 +3,7 @@ const message = { commons: { true: '是', false: '否', - example: '例如:', + example: '例:', button: { create: '创建', add: '添加', @@ -473,8 +473,8 @@ const message = { port: '端口', server: '服务器', - serverExample: '例如: 80, 80-88, ip:80 或者 ip:80-88', - contianerExample: '例如: 80 或者 80-88', + serverExample: '例: 80, 80-88, ip:80 或者 ip:80-88', + contianerExample: '例: 80 或者 80-88', exposePort: '暴露端口', exposeAll: '暴露所有', cmd: '启动命令', @@ -540,8 +540,13 @@ const message = { gateway: '网关', volume: '存储卷', + nfsEnable: '启用 NFS 存储', + nfsAddress: '地址', + nfsAddressHelper: '支持输入 ip 或者域名', volumeName: '名称', mountpoint: '挂载点', + mountpointNFSHerlper: '例:/nfs, /nfs-share', + options: '可选参数', createVolume: '创建存储卷', repo: '仓库', @@ -597,7 +602,7 @@ const message = { record: '报告', shell: 'Shell 脚本', website: '备份网站', - rulesHelper: '压缩排除规则(以 ; 号为分隔符),例如: \n*.log;*.sql', + rulesHelper: '压缩排除规则(以 ; 号为分隔符),例: \n*.log;*.sql', lastRecrodTime: '上次执行时间', database: '备份数据库', missBackupAccount: '未能找到备份账号', @@ -896,7 +901,7 @@ const message = { upgrading: '正在升级中,请稍候...', upgradeHelper: '升级操作需要重启服务,是否继续?', noUpgrade: '当前已经是最新版本', - versionHelper: '1Panel 版本号命名规则为: [大版本].[功能版本].[Bug 修复版本],示例如下:', + versionHelper: '1Panel 版本号命名规则为: [大版本].[功能版本].[Bug 修复版本],例:', versionHelper1: 'v1.0.1 是 v1.0.0 之后的 Bug 修复版本', versionHelper2: 'v1.1.0 是 v1.0.0 之后的功能版本', newVersion: '(Bug 修复版本)', @@ -1116,7 +1121,7 @@ const message = { value: '值', enable: '开启', proxyAddress: '代理地址', - proxyHelper: '例如: http://127.0.0.1:8080', + proxyHelper: '例: http://127.0.0.1:8080', forceDelete: '强制删除', forceDeleteHelper: '强制删除,会忽略删除过程中产生的错误并最终删除元数据', deleteAppHelper: '同时删除关联应用、数据库以及应用备份', @@ -1356,7 +1361,7 @@ const message = { localHelper: '本地运行环境需要自行安装', version: '版本', status: '状态', - versionHelper: 'PHP的版本,例如 v8.0', + versionHelper: 'PHP的版本,例 v8.0', buildHelper: '选择的扩展越多,制作镜像过程中占用 CPU 越多,请尽量避免选择全部扩展,如果没有想要的扩展,可以手动输入之后选择', openrestryWarn: 'PHP 需要升级 OpenResty 至 1.21.4.1 版本以上才能使用', diff --git a/frontend/src/views/container/volume/create/index.vue b/frontend/src/views/container/volume/create/index.vue index d31c900b1..b4fa4b37b 100644 --- a/frontend/src/views/container/volume/create/index.vue +++ b/frontend/src/views/container/volume/create/index.vue @@ -17,10 +17,36 @@ - - - + local + + + +
+ + + + + + NFS + NFS4 + + + + + + + + +
, + nfsStatus: 'disable', + nfsAddress: '', + nfsVersion: 'v4', + nfsMount: '', + nfsOption: 'rw,noatime,rsize=8192,wsize=8192,tcp,timeo=14', optionStr: '', options: [] as Array, }); @@ -80,6 +111,11 @@ const acceptParams = (): void => { form.labelStr = ''; form.options = []; form.optionStr = ''; + form.nfsStatus = 'disable'; + form.nfsAddress = ''; + form.nfsVersion = 'v4'; + form.nfsMount = ''; + form.nfsOption = 'rw,noatime,rsize=8192,wsize=8192,tcp,timeo=14'; drawerVisiable.value = true; }; const emit = defineEmits<{ (e: 'search'): void }>(); @@ -91,6 +127,9 @@ const handleClose = () => { const rules = reactive({ name: [Rules.requiredInput, Rules.volumeName], driver: [Rules.requiredSelect], + nfsAddress: [Rules.host], + nfsVersion: [Rules.requiredSelect], + nfsMount: [Rules.requiredInput], }); type FormInstance = InstanceType; @@ -106,6 +145,13 @@ const onSubmit = async (formEl: FormInstance | undefined) => { if (form.optionStr !== '') { form.options = form.optionStr.split('\n'); } + if (form.nfsStatus === 'enable') { + let typeOption = form.nfsVersion === 'v4' ? 'nfs4' : 'nfs'; + form.options.push('type=' + typeOption); + form.options.push('o=addr=' + form.nfsAddress + ',' + form.nfsOption); + let mount = form.nfsMount.startsWith(':') ? form.nfsMount : ':' + form.nfsMount; + form.options.push('device=' + mount); + } loading.value = true; await createVolume(form) .then(() => {