mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 06:32:59 +08:00
fix: 面板设置增加数字范围限制
This commit is contained in:
parent
1b862253bd
commit
220d329d8e
@ -124,15 +124,15 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error {
|
||||
backupDockerDir := fmt.Sprintf("%s/docker", rootDir)
|
||||
_ = os.MkdirAll(backupDockerDir, os.ModePerm)
|
||||
|
||||
_ = settingRepo.Update("SystemStatus", "Snapshoting")
|
||||
snap := model.Snapshot{
|
||||
Name: fmt.Sprintf("1panel_%s_%s", versionItem.Value, timeNow),
|
||||
Description: req.Description,
|
||||
From: req.From,
|
||||
Version: versionItem.Value,
|
||||
Status: constant.StatusWaiting,
|
||||
Status: constant.StatusSuccess,
|
||||
}
|
||||
_ = snapshotRepo.Create(&snap)
|
||||
_ = settingRepo.Update("SystemStatus", "Snapshoting")
|
||||
go func() {
|
||||
defer func() {
|
||||
_ = os.RemoveAll(rootDir)
|
||||
@ -153,7 +153,6 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error {
|
||||
updateSnapshotStatus(snap.ID, constant.StatusFailed, err.Error())
|
||||
return
|
||||
}
|
||||
_, _ = cmd.Exec("systemctl restart docker")
|
||||
|
||||
if err := u.handlePanelBinary(fileOp, "snapshot", "", backupPanelDir+"/1panel"); err != nil {
|
||||
updateSnapshotStatus(snap.ID, constant.StatusFailed, err.Error())
|
||||
@ -177,6 +176,7 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error {
|
||||
updateSnapshotStatus(snap.ID, constant.StatusFailed, err.Error())
|
||||
return
|
||||
}
|
||||
_, _ = cmd.Exec("systemctl restart docker")
|
||||
|
||||
snapJson := SnapshotJson{
|
||||
BaseDir: global.CONF.BaseDir,
|
||||
@ -664,11 +664,9 @@ func (u *SnapshotService) handlePanelDatas(snapID uint, fileOp files.FileOp, ope
|
||||
exclusionRules += ("." + strings.ReplaceAll(dockerDir, source, "") + ";")
|
||||
}
|
||||
|
||||
_ = snapshotRepo.Update(snapID, map[string]interface{}{"status": constant.StatusSuccess})
|
||||
if err := u.handleTar(source, target, "1panel_data.tar.gz", exclusionRules); err != nil {
|
||||
return fmt.Errorf("backup panel data failed, err: %v", err)
|
||||
}
|
||||
_ = snapshotRepo.Update(snapID, map[string]interface{}{"status": constant.StatusWaiting})
|
||||
case "recover":
|
||||
exclusionRules := "./tmp/;./cache;"
|
||||
if strings.Contains(backupDir, target) {
|
||||
@ -852,9 +850,9 @@ func (u *SnapshotService) handleTar(sourceDir, targetDir, name, exclusionRules s
|
||||
exStr += exclude
|
||||
}
|
||||
|
||||
ss := fmt.Sprintf("tar --warning=no-file-changed -zcf %s %s -C %s .", targetDir+"/"+name, exStr, sourceDir)
|
||||
global.LOG.Debug(ss)
|
||||
stdout, err := cmd.Exec(ss)
|
||||
commands := fmt.Sprintf("tar -zcf %s %s -C %s .", targetDir+"/"+name, exStr, sourceDir)
|
||||
global.LOG.Debug(commands)
|
||||
stdout, err := cmd.Exec(commands)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("do handle tar failed, stdout: %s, err: %v", stdout, err)
|
||||
return errors.New(stdout)
|
||||
@ -868,10 +866,13 @@ func (u *SnapshotService) handleUnTar(sourceDir, targetDir string) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
stdout, err := cmd.Exec(fmt.Sprintf("tar zxf %s -C %s .", sourceDir, targetDir))
|
||||
|
||||
commands := fmt.Sprintf("tar -zxf %s -C %s .", sourceDir, targetDir)
|
||||
global.LOG.Debug(commands)
|
||||
stdout, err := cmd.Exec(commands)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("do handle untar failed, stdout: %s, err: %v", stdout, err)
|
||||
return errors.New(string(stdout))
|
||||
return errors.New(stdout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ export default {
|
||||
fileExist: 'The file already exists in the current folder. Repeat uploading is not supported!',
|
||||
fileNameErr:
|
||||
'You can upload only files whose name contains 1 to 50 characters, including English, Chinese, digits, or periods (.-_)',
|
||||
comfimNoNull: 'Make sure the value {0} is not empty',
|
||||
},
|
||||
login: {
|
||||
firstLogin: 'First login, please create an initial administrator user!',
|
||||
|
@ -101,6 +101,7 @@ export default {
|
||||
unSupportSize: '上传文件超过 {0}M,请确认!',
|
||||
fileExist: '当前文件夹已存在该文件,不支持重复上传!',
|
||||
fileNameErr: '仅支持上传名称包含英文、中文、数字或者 .-_ ,长度 1-50 位的文件',
|
||||
comfimNoNull: '请确认 {0} 值不为空',
|
||||
},
|
||||
login: {
|
||||
firstLogin: '首次登录,请创建初始管理员用户!',
|
||||
|
@ -72,14 +72,14 @@
|
||||
v-if="dialogData.rowData!.type !== '' && hasBucket(dialogData.rowData!.type)"
|
||||
label="Bucket"
|
||||
prop="bucket"
|
||||
:rules="Rules.requiredSelect"
|
||||
>
|
||||
<el-select style="width: 80%" v-model="dialogData.rowData!.bucket">
|
||||
<el-select style="width: 80%" @change="errBuckets = false" v-model="dialogData.rowData!.bucket">
|
||||
<el-option v-for="item in buckets" :key="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button style="width: 20%" plain @click="getBuckets">
|
||||
<el-button style="width: 20%" plain @click="getBuckets(formRef)">
|
||||
{{ $t('setting.loadBucket') }}
|
||||
</el-button>
|
||||
<span v-if="errBuckets" class="input-error">{{ $t('commons.rule.requiredSelect') }}</span>
|
||||
</el-form-item>
|
||||
<div v-if="dialogData.rowData!.type === 'SFTP'">
|
||||
<el-form-item :label="$t('setting.address')" prop="varsJson.address" :rules="Rules.ip">
|
||||
@ -139,6 +139,7 @@ const loading = ref(false);
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
const formRef = ref<FormInstance>();
|
||||
const buckets = ref();
|
||||
const errBuckets = ref();
|
||||
|
||||
const endpoints = ref('http');
|
||||
|
||||
@ -181,33 +182,41 @@ function hasBucket(val: string) {
|
||||
return val === 'OSS' || val === 'S3' || val === 'MINIO';
|
||||
}
|
||||
|
||||
const getBuckets = async () => {
|
||||
loading.value = true;
|
||||
let item = deepCopy(dialogData.value.rowData!.varsJson);
|
||||
if (dialogData.value.rowData!.type === 'MINIO') {
|
||||
dialogData.value.rowData!.varsJson['endpointItem'] = dialogData.value
|
||||
.rowData!.varsJson['endpointItem'].replace('https://', '')
|
||||
.replace('http://', '');
|
||||
item['endpoint'] = endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
||||
item['endpointItem'] = undefined;
|
||||
}
|
||||
listBucket({
|
||||
type: dialogData.value.rowData!.type,
|
||||
vars: JSON.stringify(item),
|
||||
accessKey: dialogData.value.rowData!.accessKey,
|
||||
credential: dialogData.value.rowData!.credential,
|
||||
})
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
buckets.value = res.data;
|
||||
const getBuckets = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
loading.value = true;
|
||||
let item = deepCopy(dialogData.value.rowData!.varsJson);
|
||||
if (dialogData.value.rowData!.type === 'MINIO') {
|
||||
dialogData.value.rowData!.varsJson['endpointItem'] = dialogData.value
|
||||
.rowData!.varsJson['endpointItem'].replace('https://', '')
|
||||
.replace('http://', '');
|
||||
item['endpoint'] = endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
||||
item['endpointItem'] = undefined;
|
||||
}
|
||||
listBucket({
|
||||
type: dialogData.value.rowData!.type,
|
||||
vars: JSON.stringify(item),
|
||||
accessKey: dialogData.value.rowData!.accessKey,
|
||||
credential: dialogData.value.rowData!.credential,
|
||||
})
|
||||
.catch(() => {
|
||||
buckets.value = [];
|
||||
loading.value = false;
|
||||
});
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
buckets.value = res.data;
|
||||
})
|
||||
.catch(() => {
|
||||
buckets.value = [];
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
if (!dialogData.value.rowData.bucket) {
|
||||
errBuckets.value = true;
|
||||
return;
|
||||
}
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
|
@ -20,7 +20,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('setting.storeDays')"
|
||||
:rules="Rules.number"
|
||||
:rules="[Rules.number, checkNumberRange(1, 30)]"
|
||||
prop="monitorStoreDays"
|
||||
>
|
||||
<el-input clearable v-model.number="form.monitorStoreDays">
|
||||
@ -51,7 +51,7 @@ import { FormInstance } from 'element-plus';
|
||||
import LayoutContent from '@/layout/layout-content.vue';
|
||||
import { cleanMonitors, getSettingInfo, updateSetting } from '@/api/modules/setting';
|
||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
|
||||
|
@ -105,7 +105,9 @@
|
||||
>
|
||||
{{ $t('commons.button.sync') }}
|
||||
</el-button>
|
||||
<span v-show="show">{{ count }} {{ $t('setting.second') }}</span>
|
||||
<div style="width: 45px" v-show="show">
|
||||
<span>{{ count }} {{ $t('setting.second') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
@ -141,7 +141,7 @@ import { updateSetting, getMFA, bindMFA, getSettingInfo, updatePort } from '@/ap
|
||||
import i18n from '@/lang';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { dateFormatSimple } from '@/utils/util';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||
|
||||
const loading = ref(false);
|
||||
const form = reactive({
|
||||
@ -264,6 +264,10 @@ const handleClose = () => {
|
||||
};
|
||||
|
||||
const onBind = async () => {
|
||||
if (!mfaCode.value) {
|
||||
MsgError(i18n.global.t('commons.msg.comfimNoNull', ['code']));
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
await bindMFA({ code: mfaCode.value, secret: otp.secret })
|
||||
.then(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user