1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 表单输入增加前后空格过滤

This commit is contained in:
ssongliu 2022-12-26 17:51:45 +08:00 committed by ssongliu
parent cecfecfe94
commit 2fe594df04
20 changed files with 61 additions and 84 deletions

View File

@ -110,8 +110,8 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) {
}
}
path := fmt.Sprintf("%s/Dockerfile", dir)
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
pathItem := fmt.Sprintf("%s/Dockerfile", dir)
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return "", err
}
@ -134,8 +134,8 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) {
}
logName := fmt.Sprintf("%s/build.log", req.Dockerfile)
path := logName
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
pathItem := logName
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return "", err
}
@ -165,8 +165,10 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
return "", err
}
}
path := fmt.Sprintf("%s/image_pull_%s_%s.log", dockerLogDir, strings.ReplaceAll(req.ImageName, ":", "_"), time.Now().Format("20060102150405"))
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
imageItemName := strings.ReplaceAll(req.ImageName, ":", "_")
imageItemName = strings.ReplaceAll(imageItemName, "/", "@")
pathItem := fmt.Sprintf("%s/image_pull_%s_%s.log", dockerLogDir, imageItemName, time.Now().Format("20060102150405"))
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return "", err
}
@ -182,7 +184,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
global.LOG.Debugf("pull image %s successful!", req.ImageName)
_, _ = io.Copy(file, out)
}()
return path, nil
return pathItem, nil
}
repo, err := imageRepoRepo.Get(commonRepo.WithByID(req.RepoID))
if err != nil {
@ -213,7 +215,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
global.LOG.Debugf("pull image %s successful!", req.ImageName)
_, _ = io.Copy(file, out)
}()
return path, nil
return pathItem, nil
}
func (u *ImageService) ImageLoad(req dto.ImageLoad) error {
@ -294,14 +296,15 @@ func (u *ImageService) ImagePush(req dto.ImagePush) (string, error) {
return "", err
}
}
if _, err := os.Stat(dockerLogDir); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(dockerLogDir, os.ModePerm); err != nil {
return "", err
}
}
path := fmt.Sprintf("%s/image_push_%s_%s.log", dockerLogDir, strings.ReplaceAll(req.Name, ":", "_"), time.Now().Format("20060102150405"))
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
imageItemName := strings.ReplaceAll(req.Name, ":", "_")
imageItemName = strings.ReplaceAll(imageItemName, "/", "@")
pathItem := fmt.Sprintf("%s/image_push_%s_%s.log", dockerLogDir, imageItemName, time.Now().Format("20060102150405"))
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return "", err
}
@ -317,7 +320,7 @@ func (u *ImageService) ImagePush(req dto.ImagePush) (string, error) {
_, _ = io.Copy(file, out)
}()
return path, nil
return pathItem, nil
}
func (u *ImageService) ImageRemove(req dto.BatchDelete) error {

View File

@ -13,6 +13,7 @@
v-if="p.type == 'password'"
:type="p.type"
show-password
clearable
@change="updateParam"
></el-input>
<el-select

View File

@ -8,7 +8,7 @@
<div v-loading="loading">
<el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('container.name')" prop="name">
<el-input v-model="form.name"></el-input>
<el-input v-model.trim="form.name"></el-input>
</el-form-item>
<el-form-item :label="$t('container.from')">
<el-radio-group v-model="form.from">
@ -19,7 +19,7 @@
</el-form-item>
<el-form-item v-if="form.from === 'path'" prop="path">
<el-input
clearable
disabled
:placeholder="$t('commons.example') + '/tmp/docker-compose.yml'"
v-model="form.path"
>

View File

@ -7,7 +7,7 @@
</template>
<el-form ref="formRef" v-loading="loading" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('container.name')" prop="name">
<el-input clearable v-model="form.name" />
<el-input clearable v-model.trim="form.name" />
</el-form-item>
<el-form-item :label="$t('container.image')" prop="image">
<el-select style="width: 100%" filterable v-model="form.image">

View File

@ -13,7 +13,7 @@
</template>
<el-form ref="formRef" :model="form" label-width="80px" :rules="rules">
<el-form-item :label="$t('container.name')" prop="name">
<el-input :placeholder="$t('container.imageNameHelper')" v-model="form.name" clearable />
<el-input :placeholder="$t('container.imageNameHelper')" v-model.trim="form.name" clearable />
</el-form-item>
<el-form-item label="Dockerfile" prop="from">
<el-radio-group v-model="form.from">

View File

@ -9,7 +9,7 @@
<span style="font-size: 14px">{{ $t('container.startIn') }}</span>
</el-card>
<el-card style="margin-top: 20px" :class="{ mask: dockerStatus != 'Running' }">
<ComplexTable :pagination-config="paginationConfig" v-model:selects="selects" :data="data" @search="search">
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search">
<template #toolbar>
<el-button @click="onOpenPull">
{{ $t('container.imagePull') }}
@ -21,7 +21,6 @@
{{ $t('container.build') }}
</el-button>
</template>
<el-table-column type="selection" fix />
<el-table-column label="ID" show-overflow-tooltip prop="id" min-width="60" />
<el-table-column :label="$t('container.tag')" prop="tags" min-width="160" fix>
<template #default="{ row }">
@ -99,7 +98,6 @@ const loading = ref(false);
const data = ref();
const repos = ref();
const selects = ref<any>([]);
const paginationConfig = reactive({
currentPage: 1,
pageSize: 10,

View File

@ -7,7 +7,7 @@
</template>
<el-form v-loading="loading" ref="formRef" :model="form" label-width="80px">
<el-form-item :label="$t('container.path')" :rules="Rules.requiredSelect" prop="path">
<el-input clearable v-model="form.path">
<el-input disabled v-model="form.path">
<template #append>
<FileList @choose="loadLoadDir" :dir="false"></FileList>
</template>

View File

@ -26,7 +26,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('container.imageName')" :rules="Rules.requiredInput" prop="imageName">
<el-input v-model="form.imageName">
<el-input v-model.trim="form.imageName">
<template v-if="form.fromRepo" #prepend>{{ loadDetailInfo(form.repoID) }}/</template>
</el-input>
</el-form-item>

View File

@ -23,7 +23,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('container.label')" :rules="Rules.requiredInput" prop="name">
<el-input v-model="form.name">
<el-input v-model.trim="form.name">
<template #prepend>{{ loadDetailInfo(form.repoID) }}/</template>
</el-input>
</el-form-item>

View File

@ -18,7 +18,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('container.path')" :rules="Rules.requiredSelect" prop="path">
<el-input clearable v-model="form.path">
<el-input disabled v-model="form.path">
<template #append>
<FileList @choose="loadSaveDir" :dir="true"></FileList>
</template>

View File

@ -7,7 +7,7 @@
</template>
<el-form ref="formRef" v-loading="loading" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('container.networkName')" prop="name">
<el-input clearable v-model="form.name" />
<el-input clearable v-model.trim="form.name" />
</el-form-item>
<el-form-item :label="$t('container.driver')" prop="driver">
<el-select v-model="form.driver">
@ -26,13 +26,13 @@
/>
</el-form-item>
<el-form-item :label="$t('container.subnet')" prop="subnet">
<el-input clearable v-model="form.subnet" />
<el-input clearable v-model.trim="form.subnet" />
</el-form-item>
<el-form-item :label="$t('container.gateway')" prop="gateway">
<el-input clearable v-model="form.gateway" />
<el-input clearable v-model.trim="form.gateway" />
</el-form-item>
<el-form-item :label="$t('container.scope')" prop="scope">
<el-input clearable v-model="form.scope" />
<el-input clearable v-model.trim="form.scope" />
</el-form-item>
<el-form-item :label="$t('container.tag')" prop="labelStr">
<el-input

View File

@ -10,7 +10,7 @@
<el-input
clearable
:disabled="dialogData.title === 'edit'"
v-model="dialogData.rowData!.name"
v-model.trim="dialogData.rowData!.name"
></el-input>
</el-form-item>
<el-form-item :label="$t('container.auth')" prop="auth">
@ -20,15 +20,20 @@
</el-radio-group>
</el-form-item>
<el-form-item v-if="dialogData.rowData!.auth" :label="$t('commons.login.username')" prop="username">
<el-input clearable v-model="dialogData.rowData!.username"></el-input>
<el-input clearable v-model.trim="dialogData.rowData!.username"></el-input>
</el-form-item>
<el-form-item v-if="dialogData.rowData!.auth" :label="$t('commons.login.password')" prop="password">
<el-input clearable type="password" show-password v-model="dialogData.rowData!.password"></el-input>
<el-input
clearable
type="password"
show-password
v-model.trim="dialogData.rowData!.password"
></el-input>
</el-form-item>
<el-form-item :label="$t('container.downloadUrl')" prop="downloadUrl">
<el-input
clearable
v-model="dialogData.rowData!.downloadUrl"
v-model.trim="dialogData.rowData!.downloadUrl"
:placeholder="'172.16.10.10:8081'"
></el-input>
<span v-if="dialogData.rowData!.downloadUrl" class="input-help">

View File

@ -29,7 +29,7 @@
</div>
</el-form-item>
<el-form-item :label="$t('container.daemonJsonPath')">
<el-input clearable v-model="daemonJsonPath">
<el-input disabled v-model="daemonJsonPath">
<template #append>
<FileList @choose="loadLoadDir" :dir="false"></FileList>
</template>

View File

@ -7,7 +7,7 @@
</template>
<el-form v-loading="loading" ref="formRef" :model="dialogData.rowData" :rules="rules" label-width="80px">
<el-form-item :label="$t('container.name')" prop="name">
<el-input :disabled="dialogData.title === 'edit'" v-model="dialogData.rowData!.name"></el-input>
<el-input :disabled="dialogData.title === 'edit'" v-model.trim="dialogData.rowData!.name"></el-input>
</el-form-item>
<el-form-item :label="$t('container.description')">
<el-input v-model="dialogData.rowData!.description"></el-input>

View File

@ -7,7 +7,7 @@
</template>
<el-form ref="formRef" v-loading="loading" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('container.volumeName')" prop="name">
<el-input clearable v-model="form.name" />
<el-input clearable v-model.trim="form.name" />
</el-form-item>
<el-form-item :label="$t('container.driver')" prop="driver">
<el-select v-model="form.driver">

View File

@ -139,9 +139,9 @@ const onOpenDialog = async (
rowData: Partial<Cronjob.CronjobInfo> = {
specType: 'perMonth',
week: 1,
day: 1,
hour: 2,
minute: 3,
day: 3,
hour: 1,
minute: 30,
keepLocal: true,
retainCopies: 7,
},

View File

@ -7,21 +7,17 @@
</template>
<el-form ref="formRef" :model="dialogData.rowData" label-position="left" :rules="rules" label-width="120px">
<el-form-item :label="$t('cronjob.taskType')" prop="type">
<el-select
@change="changeName(true, dialogData.rowData!.type)"
style="width: 100%"
v-model="dialogData.rowData!.type"
>
<el-select style="width: 100%" v-model="dialogData.rowData!.type">
<el-option value="shell" :label="$t('cronjob.shell')" />
<el-option value="website" :label="$t('cronjob.website')" />
<el-option value="database" :label="$t('cronjob.database')" />
<el-option value="directory" :label="$t('cronjob.directory')" />
<el-option value="curl" :label="$t('cronjob.curl')" />
<el-option value="curl" :label="$t('cronjob.curl') + ' URL'" />
</el-select>
</el-form-item>
<el-form-item :label="$t('cronjob.taskName')" prop="name">
<el-input style="width: 100%" clearable v-model="dialogData.rowData!.name" />
<el-input style="width: 100%" clearable v-model.trim="dialogData.rowData!.name" />
</el-form-item>
<el-form-item :label="$t('cronjob.cronSpec')" prop="spec">
@ -65,11 +61,7 @@
</el-form-item>
<el-form-item v-if="dialogData.rowData!.type === 'website'" :label="$t('cronjob.website')" prop="website">
<el-select
@change="changeName(false, dialogData.rowData!.type)"
style="width: 100%"
v-model="dialogData.rowData!.website"
>
<el-select style="width: 100%" v-model="dialogData.rowData!.website">
<el-option v-for="item in websiteOptions" :key="item" :value="item" :label="item" />
</el-select>
</el-form-item>
@ -87,12 +79,7 @@
:label="$t('cronjob.sourceDir')"
prop="sourceDir"
>
<el-input
@input="changeName(false, dialogData.rowData!.type)"
style="width: 100%"
clearable
v-model="dialogData.rowData!.sourceDir"
>
<el-input style="width: 100%" disabled v-model="dialogData.rowData!.sourceDir">
<template #append>
<FileList @choose="loadDir" :dir="true"></FileList>
</template>
@ -124,8 +111,8 @@
</el-form-item>
</div>
<el-form-item v-if="dialogData.rowData!.type === 'curl'" :label="$t('cronjob.url') + 'URL'" prop="url">
<el-input style="width: 100%" clearable v-model="dialogData.rowData!.url" />
<el-form-item v-if="dialogData.rowData!.type === 'curl'" :label="$t('cronjob.url')" prop="url">
<el-input style="width: 100%" clearable v-model.trim="dialogData.rowData!.url" />
</el-form-item>
<el-form-item
@ -344,16 +331,6 @@ function isBackup() {
function hasScript() {
return dialogData.value.rowData!.type === 'shell';
}
function changeName(isChangeType: boolean, type: string) {
if (isChangeType) {
if (isBackup()) {
if (backupOptions.value.length === 0) {
ElMessage.error(i18n.global.t('cronjob.missBackupAccount'));
}
}
}
dialogData.value.rowData!.name = `${type}_test`;
}
const onSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;

View File

@ -7,7 +7,7 @@
</template>
<el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('commons.table.name')" prop="name">
<el-input clearable v-model="form.name">
<el-input clearable v-model.trim="form.name">
<template #append>
<el-select v-model="form.format" style="width: 125px">
<el-option label="utf8mb4" value="utf8mb4" />
@ -19,10 +19,10 @@
</el-input>
</el-form-item>
<el-form-item :label="$t('commons.login.username')" prop="username">
<el-input clearable v-model="form.username" />
<el-input clearable v-model.trim="form.username" />
</el-form-item>
<el-form-item :label="$t('commons.login.password')" prop="password">
<el-input type="password" clearable show-password v-model="form.password" />
<el-input type="password" clearable show-password v-model.trim="form.password" />
</el-form-item>
<el-form-item :label="$t('database.permission')" prop="permission">

View File

@ -22,7 +22,7 @@
prop="varsJson['dir']"
:rules="Rules.requiredInput"
>
<el-input v-model="dialogData.rowData!.varsJson['dir']">
<el-input disabled v-model="dialogData.rowData!.varsJson['dir']">
<template #append>
<FileList @choose="loadDir" :dir="true"></FileList>
</template>
@ -34,7 +34,7 @@
prop="accessKey"
:rules="Rules.requiredInput"
>
<el-input v-model="dialogData.rowData!.accessKey" />
<el-input v-model.trim="dialogData.rowData!.accessKey" />
</el-form-item>
<el-form-item
v-if="hasBucket(dialogData.rowData!.type)"
@ -42,7 +42,7 @@
prop="credential"
:rules="Rules.requiredInput"
>
<el-input show-password clearable v-model="dialogData.rowData!.credential" />
<el-input show-password clearable v-model.trim="dialogData.rowData!.credential" />
</el-form-item>
<el-form-item
v-if="dialogData.rowData!.type === 'S3'"
@ -50,7 +50,7 @@
prop="varsJson.region"
:rules="Rules.requiredInput"
>
<el-input v-model="dialogData.rowData!.varsJson['region']" />
<el-input v-model.trim="dialogData.rowData!.varsJson['region']" />
</el-form-item>
<el-form-item
v-if="hasBucket(dialogData.rowData!.type) && dialogData.rowData!.type !== 'MINIO'"
@ -58,7 +58,7 @@
prop="varsJson.endpoint"
:rules="Rules.requiredInput"
>
<el-input v-model="dialogData.rowData!.varsJson['endpoint']" />
<el-input v-model.trim="dialogData.rowData!.varsJson['endpoint']" />
</el-form-item>
<el-form-item
v-if="dialogData.rowData!.type === 'MINIO'"
@ -68,7 +68,7 @@
>
<el-input v-model="dialogData.rowData!.varsJson['endpointItem']">
<template #prepend>
<el-select v-model="endpoints" style="width: 80px">
<el-select v-model.trim="endpoints" style="width: 80px">
<el-option label="http" value="http" />
<el-option label="https" value="https" />
</el-select>
@ -90,7 +90,7 @@
</el-form-item>
<div v-if="dialogData.rowData!.type === 'SFTP'">
<el-form-item :label="$t('setting.address')" prop="varsJson.address" :rules="Rules.requiredInput">
<el-input v-model="dialogData.rowData!.varsJson['address']" />
<el-input v-model.trim="dialogData.rowData!.varsJson['address']" />
</el-form-item>
<el-form-item :label="$t('setting.port')" prop="varsJson.port" :rules="[Rules.number]">
<el-input-number :min="0" :max="65535" v-model.number="dialogData.rowData!.varsJson['port']" />

View File

@ -1,7 +0,0 @@
<template>
<LayoutContent></LayoutContent>
</template>
<script lang="ts" setup>
import LayoutContent from '@/layout/layout-content.vue';
</script>