Browse Source

fix: redis 配置增加范围限制

pull/193/head
ssongliu 2 years ago committed by ssongliu
parent
commit
2061e00b29
  1. 2
      frontend/src/api/interface/database.ts
  2. 2
      frontend/src/lang/modules/en.ts
  3. 2
      frontend/src/lang/modules/zh.ts
  4. 34
      frontend/src/views/database/redis/setting/index.vue
  5. 13
      frontend/src/views/database/redis/setting/persistence/index.vue

2
frontend/src/api/interface/database.ts

@ -143,7 +143,7 @@ export namespace Database {
timeout: number;
maxclients: number;
requirepass: string;
maxmemory: number;
maxmemory: string;
}
export interface RedisPersistenceConf {
appendonly: string;

2
frontend/src/lang/modules/en.ts

@ -396,7 +396,7 @@ export default {
rdbHelper1: 'In seconds, insert',
rdbHelper2: 'The data',
rdbHelper3: 'Meeting either condition triggers RDB persistence',
rdbInfo: 'Rule list has 0 value, please confirm and try again!',
rdbInfo: 'Ensure that the value in the rule list ranges from 1 to 100000',
},
container: {
createContainer: 'Create container',

2
frontend/src/lang/modules/zh.ts

@ -409,7 +409,7 @@ export default {
rdbHelper1: '秒內,插入',
rdbHelper2: '条数据',
rdbHelper3: '符合任意一个条件将会触发RDB持久化',
rdbInfo: '规则列表存在 0 请确认后重试',
rdbInfo: '请确认规则列表中值在 1-100000 之间',
},
container: {
createContainer: '创建容器',

34
frontend/src/views/database/redis/setting/index.vue

@ -73,14 +73,19 @@
<el-col :span="1"><br /></el-col>
<el-col :span="10">
<el-form-item :label="$t('database.timeout')" prop="timeout">
<el-input clearable type="number" v-model.number="form.timeout" />
<el-input clearable type="number" v-model.number="form.timeout">
<template #append>{{ $t('home.Second') }}</template>
</el-input>
<span class="input-help">{{ $t('database.timeoutHelper') }}</span>
</el-form-item>
<el-form-item :label="$t('database.maxclients')" prop="maxclients">
<el-input clearable type="number" v-model.number="form.maxclients" />
</el-form-item>
<el-form-item :label="$t('database.maxmemory')" prop="maxmemory">
<el-input clearable type="number" v-model.number="form.maxmemory" />
<el-input clearable type="number" v-model.number="form.maxmemory">
<template #append>mb</template>
</el-input>
<span class="input-help">{{ $t('database.maxmemoryHelper') }}</span>
</el-form-item>
<el-form-item>
@ -178,6 +183,21 @@ interface DialogProps {
const changeTab = (val: string) => {
activeName.value = val;
switch (val) {
case 'conf':
loadConfFile();
break;
case 'persistence':
persistenceRef.value!.acceptParams({ status: redisStatus.value });
break;
case 'tuning':
case 'port':
loadform();
break;
case 'status':
statusRef.value!.acceptParams({ status: redisStatus.value });
break;
}
};
const changeLoading = (status: boolean) => {
@ -189,11 +209,6 @@ const acceptParams = (prop: DialogProps): void => {
redisName.value = prop.redisName;
settingShow.value = true;
loadConfFile();
if (redisStatus.value === 'Running') {
statusRef.value!.acceptParams({ status: prop.status });
persistenceRef.value!.acceptParams({ status: prop.status });
loadform();
}
};
const portRef = ref();
@ -220,7 +235,6 @@ function callback(error: any) {
}
}
const onChangePort = async (formEl: FormInstance | undefined) => {
console.log('asdqwdwqd');
if (!formEl) return;
const result = await formEl.validateField('port', callback);
if (!result) {
@ -260,7 +274,7 @@ const submtiForm = async () => {
let param = {
timeout: form.timeout + '',
maxclients: form.maxclients + '',
maxmemory: form.maxmemory + '',
maxmemory: form.maxmemory + 'mb',
};
loading.value = true;
await updateRedisConf(param)
@ -311,7 +325,7 @@ const loadform = async () => {
form.name = res.data?.name;
form.timeout = Number(res.data?.timeout);
form.maxclients = Number(res.data?.maxclients);
form.maxmemory = Number(res.data?.maxmemory);
form.maxmemory = Number(res.data?.maxmemory.replaceAll('mb', '')) / 1048576;
form.port = Number(res.data?.port);
};

13
frontend/src/views/database/redis/setting/persistence/index.vue

@ -48,13 +48,13 @@
<td width="32%">
<el-input type="number" v-model="row.second"></el-input>
</td>
<td width="60px">
<td width="80px">
{{ $t('database.rdbHelper1') }}
</td>
<td width="32%">
<el-input type="number" v-model="row.count"></el-input>
</td>
<td width="12%">
<td width="10%">
{{ $t('database.rdbHelper2') }}
</td>
<td>
@ -89,7 +89,11 @@
<el-table-column type="selection" fix />
<el-table-column :label="$t('commons.table.name')" show-overflow-tooltip prop="fileName" />
<el-table-column :label="$t('database.source')" prop="backupType">
<template #default="{ row }">{{ $t('setting.' + row.source) }}</template>
<template #default="{ row }">
<span v-if="row.source">
{{ $t('setting.' + row.source) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('file.dir')" show-overflow-tooltip prop="fileDir" />
<el-table-column :label="$t('commons.table.createdAt')" :formatter="dateFormat" prop="createdAt" />
@ -270,7 +274,7 @@ const onSave = async (formEl: FormInstance | undefined, type: string) => {
}
let itemSaves = [] as Array<string>;
for (const item of form.saves) {
if (item.count === 0 || item.second === 0) {
if (item.count < 0 || item.count > 100000 || item.second < 0 || item.second > 100000) {
MsgInfo(i18n.global.t('database.rdbInfo'));
return;
}
@ -290,6 +294,7 @@ const onSave = async (formEl: FormInstance | undefined, type: string) => {
};
const loadform = async () => {
console.log('adqwdqw');
form.saves = [];
const res = await redisPersistenceConf();
form.appendonly = res.data?.appendonly;

Loading…
Cancel
Save