mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: redis 数据库样式调整,表单拆分
This commit is contained in:
parent
6dedb87349
commit
8bbc286f43
@ -128,10 +128,9 @@ type UploadRecover struct {
|
|||||||
|
|
||||||
// redis
|
// redis
|
||||||
type RedisConfUpdate struct {
|
type RedisConfUpdate struct {
|
||||||
Timeout string `json:"timeout"`
|
Timeout string `json:"timeout"`
|
||||||
Maxclients string `json:"maxclients"`
|
Maxclients string `json:"maxclients"`
|
||||||
Requirepass string `json:"requirepass"`
|
Maxmemory string `json:"maxmemory"`
|
||||||
Maxmemory string `json:"maxmemory"`
|
|
||||||
}
|
}
|
||||||
type RedisConfPersistenceUpdate struct {
|
type RedisConfPersistenceUpdate struct {
|
||||||
Type string `json:"type" validate:"required,oneof=aof rbd"`
|
Type string `json:"type" validate:"required,oneof=aof rbd"`
|
||||||
|
@ -40,7 +40,7 @@ func (s *DatabaseRouter) InitDatabaseRouter(Router *gin.RouterGroup) {
|
|||||||
cmdRouter.POST("/redis/password", baseApi.ChangeRedisPassword)
|
cmdRouter.POST("/redis/password", baseApi.ChangeRedisPassword)
|
||||||
cmdRouter.POST("/redis/backup", baseApi.RedisBackup)
|
cmdRouter.POST("/redis/backup", baseApi.RedisBackup)
|
||||||
cmdRouter.POST("/redis/recover", baseApi.RedisRecover)
|
cmdRouter.POST("/redis/recover", baseApi.RedisRecover)
|
||||||
cmdRouter.POST("/redis/backuplist/search", baseApi.RedisBackupList)
|
cmdRouter.POST("/redis/backup/search", baseApi.RedisBackupList)
|
||||||
cmdRouter.POST("/redis/conf/update", baseApi.UpdateRedisConf)
|
cmdRouter.POST("/redis/conf/update", baseApi.UpdateRedisConf)
|
||||||
cmdRouter.POST("/redis/conffile/update", baseApi.UpdateRedisConfByFile)
|
cmdRouter.POST("/redis/conffile/update", baseApi.UpdateRedisConfByFile)
|
||||||
cmdRouter.POST("/redis/persistence/update", baseApi.UpdateRedisPersistenceConf)
|
cmdRouter.POST("/redis/persistence/update", baseApi.UpdateRedisPersistenceConf)
|
||||||
|
@ -120,7 +120,6 @@ export namespace Database {
|
|||||||
export interface RedisConfUpdate {
|
export interface RedisConfUpdate {
|
||||||
timeout: string;
|
timeout: string;
|
||||||
maxclients: string;
|
maxclients: string;
|
||||||
requirepass: string;
|
|
||||||
maxmemory: string;
|
maxmemory: string;
|
||||||
}
|
}
|
||||||
export interface RedisConfPersistenceUpdate {
|
export interface RedisConfPersistenceUpdate {
|
||||||
|
@ -83,5 +83,5 @@ export const recoverRedis = (param: Database.RedisRecover) => {
|
|||||||
return http.post(`/databases/redis/recover`, param);
|
return http.post(`/databases/redis/recover`, param);
|
||||||
};
|
};
|
||||||
export const redisBackupRedisRecords = (param: ReqPage) => {
|
export const redisBackupRedisRecords = (param: ReqPage) => {
|
||||||
return http.post<ResPage<Database.FileRecord>>(`/databases/redis/backup/records`, param);
|
return http.post<ResPage<Database.FileRecord>>(`/databases/redis/backup/search`, param);
|
||||||
};
|
};
|
||||||
|
@ -132,6 +132,9 @@ export default {
|
|||||||
changePassword: 'Change Password',
|
changePassword: 'Change Password',
|
||||||
logout: 'Logout',
|
logout: 'Logout',
|
||||||
},
|
},
|
||||||
|
service: {
|
||||||
|
serviceNotStarted: 'The {0} service is not currently started',
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
running: 'running',
|
running: 'running',
|
||||||
stopped: 'stopped',
|
stopped: 'stopped',
|
||||||
|
@ -134,6 +134,9 @@ export default {
|
|||||||
changePassword: '修改密码',
|
changePassword: '修改密码',
|
||||||
logout: '退出登录',
|
logout: '退出登录',
|
||||||
},
|
},
|
||||||
|
service: {
|
||||||
|
serviceNotStarted: '当前未启动 {0} 服务',
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
running: '已启动',
|
running: '已启动',
|
||||||
success: '成功',
|
success: '成功',
|
||||||
|
@ -11,11 +11,7 @@
|
|||||||
<Setting ref="settingRef" style="margin-top: 20px" />
|
<Setting ref="settingRef" style="margin-top: 20px" />
|
||||||
|
|
||||||
<el-card width="30%" v-if="mysqlStatus != 'Running' && !isOnSetting && mysqlIsExist" class="mask-prompt">
|
<el-card width="30%" v-if="mysqlStatus != 'Running' && !isOnSetting && mysqlIsExist" class="mask-prompt">
|
||||||
<span style="font-size: 14px">{{ $t('database.mysqlBadStatus') }}</span>
|
<span style="font-size: 14px">{{ $t('commons.service.serviceNotStarted', ['Mysql']) }}</span>
|
||||||
<el-button type="primary" link style="font-size: 14px; margin-bottom: 5px" @click="onSetting">
|
|
||||||
【 {{ $t('database.setting') }} 】
|
|
||||||
</el-button>
|
|
||||||
<span style="font-size: 14px">{{ $t('database.adjust') }}</span>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<div v-if="mysqlIsExist" :class="{ mask: mysqlStatus != 'Running' }">
|
<div v-if="mysqlIsExist" :class="{ mask: mysqlStatus != 'Running' }">
|
||||||
<el-card v-if="!isOnSetting" style="margin-top: 20px">
|
<el-card v-if="!isOnSetting" style="margin-top: 20px">
|
||||||
|
@ -78,7 +78,7 @@ import Status from '@/views/database/mysql/setting/status/index.vue';
|
|||||||
import Variables from '@/views/database/mysql/setting/variables/index.vue';
|
import Variables from '@/views/database/mysql/setting/variables/index.vue';
|
||||||
import SlowLog from '@/views/database/mysql/setting/slow-log/index.vue';
|
import SlowLog from '@/views/database/mysql/setting/slow-log/index.vue';
|
||||||
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||||
import { onUnmounted, reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { Codemirror } from 'vue-codemirror';
|
import { Codemirror } from 'vue-codemirror';
|
||||||
import { javascript } from '@codemirror/lang-javascript';
|
import { javascript } from '@codemirror/lang-javascript';
|
||||||
import { oneDark } from '@codemirror/theme-one-dark';
|
import { oneDark } from '@codemirror/theme-one-dark';
|
||||||
@ -239,10 +239,6 @@ const loadMysqlConf = async (path: string) => {
|
|||||||
mysqlConf.value = res.data;
|
mysqlConf.value = res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
console.log('adasd');
|
|
||||||
});
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
onClose,
|
onClose,
|
||||||
|
@ -10,24 +10,22 @@
|
|||||||
@is-exist="checkExist"
|
@is-exist="checkExist"
|
||||||
v-model:loading="loading"
|
v-model:loading="loading"
|
||||||
></AppStatus>
|
></AppStatus>
|
||||||
|
|
||||||
<el-button style="margin-top: 20px" type="primary" plain @click="goDashboard" icon="Position">
|
|
||||||
Redis-Commander
|
|
||||||
</el-button>
|
|
||||||
|
|
||||||
<Setting ref="settingRef" style="margin-top: 10px" />
|
|
||||||
|
|
||||||
<el-card width="30%" v-if="redisStatus != 'Running' && !isOnSetting && redisIsExist" class="mask-prompt">
|
<el-card width="30%" v-if="redisStatus != 'Running' && !isOnSetting && redisIsExist" class="mask-prompt">
|
||||||
<span style="font-size: 14px">{{ $t('database.mysqlBadStatus') }}</span>
|
<span style="font-size: 14px">{{ $t('commons.service.serviceNotStarted', ['Redis']) }}</span>
|
||||||
<el-button type="primary" link style="font-size: 14px; margin-bottom: 5px" @click="onSetting">
|
|
||||||
【 {{ $t('database.setting') }} 】
|
|
||||||
</el-button>
|
|
||||||
<span style="font-size: 14px">{{ $t('database.adjust') }}</span>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<div v-show="redisIsExist" :class="{ mask: redisStatus != 'Running' }">
|
<div v-show="redisIsExist" :class="{ mask: redisStatus != 'Running' }">
|
||||||
<Terminal style="margin-top: 10px" ref="terminalRef" />
|
<el-button style="margin-top: 20px" type="primary" plain @click="goDashboard" icon="Position">
|
||||||
|
Redis-Commander
|
||||||
|
</el-button>
|
||||||
|
<el-button style="margin-top: 20px" type="primary" plain @click="onChangePassword">
|
||||||
|
{{ $t('database.changePassword') }}
|
||||||
|
</el-button>
|
||||||
|
<Terminal :key="isRefresh" style="margin-top: 10px" ref="terminalRef" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Setting ref="settingRef" style="margin-top: 10px" />
|
||||||
|
<Password ref="passwordRef" @check-exist="initTerminal" @close-terminal="closeTerminal(true)" />
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="commandVisiable"
|
v-model="commandVisiable"
|
||||||
:title="$t('app.checkTitle')"
|
:title="$t('app.checkTitle')"
|
||||||
@ -52,6 +50,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Submenu from '@/views/database/index.vue';
|
import Submenu from '@/views/database/index.vue';
|
||||||
import Setting from '@/views/database/redis/setting/index.vue';
|
import Setting from '@/views/database/redis/setting/index.vue';
|
||||||
|
import Password from '@/views/database/redis/password/index.vue';
|
||||||
import Terminal from '@/views/database/redis/terminal/index.vue';
|
import Terminal from '@/views/database/redis/terminal/index.vue';
|
||||||
import AppStatus from '@/components/app-status/index.vue';
|
import AppStatus from '@/components/app-status/index.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
@ -66,14 +65,17 @@ const settingRef = ref();
|
|||||||
const isOnSetting = ref(false);
|
const isOnSetting = ref(false);
|
||||||
const redisIsExist = ref(false);
|
const redisIsExist = ref(false);
|
||||||
const redisStatus = ref();
|
const redisStatus = ref();
|
||||||
|
const redisName = ref();
|
||||||
|
|
||||||
const redisCommandPort = ref();
|
const redisCommandPort = ref();
|
||||||
const commandVisiable = ref(false);
|
const commandVisiable = ref(false);
|
||||||
|
|
||||||
|
const isRefresh = ref();
|
||||||
|
|
||||||
const onSetting = async () => {
|
const onSetting = async () => {
|
||||||
isOnSetting.value = true;
|
isOnSetting.value = true;
|
||||||
terminalRef.value.onClose();
|
terminalRef.value.onClose(false);
|
||||||
settingRef.value!.acceptParams({ status: redisStatus.value });
|
settingRef.value!.acceptParams({ status: redisStatus.value, redisName: redisName.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const goRouter = async (path: string) => {
|
const goRouter = async (path: string) => {
|
||||||
@ -95,8 +97,14 @@ const loadDashboardPort = async () => {
|
|||||||
redisCommandPort.value = res.data;
|
redisCommandPort.value = res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const passwordRef = ref();
|
||||||
|
const onChangePassword = async () => {
|
||||||
|
passwordRef.value!.acceptParams();
|
||||||
|
};
|
||||||
|
|
||||||
const checkExist = (data: App.CheckInstalled) => {
|
const checkExist = (data: App.CheckInstalled) => {
|
||||||
redisIsExist.value = data.isExist;
|
redisIsExist.value = data.isExist;
|
||||||
|
redisName.value = data.name;
|
||||||
redisStatus.value = data.status;
|
redisStatus.value = data.status;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (redisStatus.value === 'Running') {
|
if (redisStatus.value === 'Running') {
|
||||||
@ -105,8 +113,18 @@ const checkExist = (data: App.CheckInstalled) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const initTerminal = async () => {
|
||||||
|
if (redisStatus.value === 'Running') {
|
||||||
|
terminalRef.value.acceptParams();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const closeTerminal = async (isKeepShow: boolean) => {
|
||||||
|
isRefresh.value = !isRefresh.value;
|
||||||
|
terminalRef.value!.onClose(isKeepShow);
|
||||||
|
};
|
||||||
|
|
||||||
const onBefore = () => {
|
const onBefore = () => {
|
||||||
terminalRef.value!.onClose();
|
closeTerminal(true);
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
89
frontend/src/views/database/redis/password/index.vue
Normal file
89
frontend/src/views/database/redis/password/index.vue
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="dialogVisiable" :destroy-on-close="true" :close-on-click-modal="false" width="30%">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>{{ $t('database.requirepass') }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-form v-loading="loading" ref="formRef" :model="form" label-width="80px">
|
||||||
|
<el-form-item :label="$t('database.requirepass')" :rules="Rules.requiredInput" prop="password">
|
||||||
|
<el-input type="password" show-password clearable v-model="form.password" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<ConfirmDialog ref="confirmDialogRef" @confirm="onSubmit"></ConfirmDialog>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||||
|
<el-button type="primary" @click="onSave(formRef)">
|
||||||
|
{{ $t('commons.button.confirm') }}
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import { Rules } from '@/global/form-rules';
|
||||||
|
import i18n from '@/lang';
|
||||||
|
import { ElForm, ElMessage } from 'element-plus';
|
||||||
|
import { changeRedisPassword } from '@/api/modules/database';
|
||||||
|
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const dialogVisiable = ref(false);
|
||||||
|
const form = reactive({
|
||||||
|
password: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const confirmDialogRef = ref();
|
||||||
|
|
||||||
|
const emit = defineEmits(['checkExist', 'closeTerminal']);
|
||||||
|
|
||||||
|
type FormInstance = InstanceType<typeof ElForm>;
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
|
||||||
|
const acceptParams = (): void => {
|
||||||
|
form.password = '';
|
||||||
|
dialogVisiable.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSubmit = async () => {
|
||||||
|
let param = {
|
||||||
|
id: 0,
|
||||||
|
value: form.password,
|
||||||
|
};
|
||||||
|
loading.value = true;
|
||||||
|
emit('closeTerminal');
|
||||||
|
await changeRedisPassword(param)
|
||||||
|
.then(() => {
|
||||||
|
loading.value = false;
|
||||||
|
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
|
dialogVisiable.value = false;
|
||||||
|
emit('checkExist');
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSave = async (formEl: FormInstance | undefined) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
formEl.validate(async (valid) => {
|
||||||
|
if (!valid) return;
|
||||||
|
let params = {
|
||||||
|
header: i18n.global.t('database.confChange'),
|
||||||
|
operationInfo: i18n.global.t('database.restartNowHelper'),
|
||||||
|
submitInputInfo: i18n.global.t('database.restartNow'),
|
||||||
|
};
|
||||||
|
confirmDialogRef.value!.acceptParams(params);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
acceptParams,
|
||||||
|
});
|
||||||
|
</script>
|
@ -3,89 +3,80 @@
|
|||||||
<el-card style="margin-top: 5px" v-loading="loading">
|
<el-card style="margin-top: 5px" v-loading="loading">
|
||||||
<LayoutContent :header="'Redis ' + $t('database.setting')" back-name="Redis" :reload="true">
|
<LayoutContent :header="'Redis ' + $t('database.setting')" back-name="Redis" :reload="true">
|
||||||
<el-collapse v-model="activeName" accordion>
|
<el-collapse v-model="activeName" accordion>
|
||||||
<el-collapse-item :title="$t('database.baseSetting')" name="1">
|
<el-collapse-item :title="$t('database.confChange')" name="1">
|
||||||
<el-radio-group v-model="confShowType" @change="onChangeMode">
|
<codemirror
|
||||||
<el-radio-button label="base">{{ $t('database.baseConf') }}</el-radio-button>
|
:autofocus="true"
|
||||||
<el-radio-button label="all">{{ $t('database.allConf') }}</el-radio-button>
|
placeholder="None data"
|
||||||
</el-radio-group>
|
:indent-with-tab="true"
|
||||||
<el-form
|
:tabSize="4"
|
||||||
v-if="confShowType === 'base'"
|
style="margin-top: 10px; height: calc(100vh - 280px)"
|
||||||
:model="form"
|
:lineWrapping="true"
|
||||||
ref="formRef"
|
:matchBrackets="true"
|
||||||
:rules="rules"
|
theme="cobalt"
|
||||||
label-width="120px"
|
:styleActiveLine="true"
|
||||||
>
|
:extensions="extensions"
|
||||||
<el-row style="margin-top: 20px">
|
v-model="redisConf"
|
||||||
<el-col :span="1"><br /></el-col>
|
:readOnly="true"
|
||||||
<el-col :span="10">
|
/>
|
||||||
<el-form-item :label="$t('setting.port')" prop="port" :rules="Rules.port">
|
<el-button type="primary" @click="onSaveFile" style="margin-top: 5px">
|
||||||
<el-input clearable type="number" v-model.number="form.port">
|
{{ $t('commons.button.save') }}
|
||||||
<template #append>
|
</el-button>
|
||||||
<el-button @click="onSavePort()" icon="Collection">
|
|
||||||
{{ $t('commons.button.save') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-input>
|
|
||||||
<span class="input-help">{{ $t('database.portHelper') }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="$t('setting.password')" prop="requirepass">
|
|
||||||
<el-input type="password" show-password clearable v-model="form.requirepass">
|
|
||||||
<template #append>
|
|
||||||
<el-button @click="onSavePassword()" icon="Collection">
|
|
||||||
{{ $t('commons.button.save') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-input>
|
|
||||||
<span class="input-help">{{ $t('database.requirepassHelper') }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
<div v-if="redisStatus === 'Running'">
|
|
||||||
<el-form-item :label="$t('database.timeout')" prop="timeout">
|
|
||||||
<el-input clearable type="number" v-model.number="form.timeout" />
|
|
||||||
<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" />
|
|
||||||
<span class="input-help">{{ $t('database.maxmemoryHelper') }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="onSave(formRef)">
|
|
||||||
{{ $t('commons.button.save') }}
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<div v-if="confShowType === 'all'">
|
|
||||||
<codemirror
|
|
||||||
:autofocus="true"
|
|
||||||
placeholder="None data"
|
|
||||||
:indent-with-tab="true"
|
|
||||||
:tabSize="4"
|
|
||||||
style="margin-top: 10px; height: calc(100vh - 280px)"
|
|
||||||
:lineWrapping="true"
|
|
||||||
:matchBrackets="true"
|
|
||||||
theme="cobalt"
|
|
||||||
:styleActiveLine="true"
|
|
||||||
:extensions="extensions"
|
|
||||||
v-model="redisConf"
|
|
||||||
:readOnly="true"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" @click="onSaveFile" style="margin-top: 5px">
|
|
||||||
{{ $t('commons.button.save') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item :disabled="redisStatus !== 'Running'" :title="$t('database.status')" name="2">
|
<el-collapse-item :disabled="redisStatus !== 'Running'" :title="$t('database.status')" name="2">
|
||||||
<Status ref="statusRef" />
|
<Status ref="statusRef" />
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item
|
<el-collapse-item
|
||||||
:disabled="redisStatus !== 'Running'"
|
:disabled="redisStatus !== 'Running'"
|
||||||
:title="$t('database.persistence')"
|
:title="$t('database.performanceTuning')"
|
||||||
name="3"
|
name="3"
|
||||||
|
>
|
||||||
|
<el-form :model="form" ref="formRef" :rules="rules" label-width="120px">
|
||||||
|
<el-row style="margin-top: 20px">
|
||||||
|
<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" />
|
||||||
|
<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" />
|
||||||
|
<span class="input-help">{{ $t('database.maxmemoryHelper') }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submtiForm(formRef)">
|
||||||
|
{{ $t('commons.button.save') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-collapse-item>
|
||||||
|
|
||||||
|
<el-collapse-item :title="$t('database.portSetting')" name="4">
|
||||||
|
<el-form :model="form" ref="portRef" label-width="120px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="1"><br /></el-col>
|
||||||
|
<el-col :span="10">
|
||||||
|
<el-form-item :label="$t('setting.port')" prop="port" :rules="Rules.port">
|
||||||
|
<el-input clearable type="number" v-model.number="form.port">
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="onSavePort(portRef)" icon="Collection">
|
||||||
|
{{ $t('commons.button.save') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item
|
||||||
|
:disabled="redisStatus !== 'Running'"
|
||||||
|
:title="$t('database.persistence')"
|
||||||
|
name="5"
|
||||||
>
|
>
|
||||||
<Persistence ref="persistenceRef" />
|
<Persistence ref="persistenceRef" />
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
@ -93,9 +84,9 @@
|
|||||||
</LayoutContent>
|
</LayoutContent>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<ConfirmDialog ref="confirmDialogRef" @confirm="onSubmitSave"></ConfirmDialog>
|
<ConfirmDialog ref="confirmFileRef" @confirm="submtiFile"></ConfirmDialog>
|
||||||
<ConfirmDialog ref="confirmDialogRef2" @confirm="onChangePort(formRef)"></ConfirmDialog>
|
<ConfirmDialog ref="confirmFormRef" @confirm="submtiForm"></ConfirmDialog>
|
||||||
<ConfirmDialog ref="confirmDialogRef3" @confirm="onChangePassword()"></ConfirmDialog>
|
<ConfirmDialog ref="confirmPortRef" @confirm="onChangePort(formRef)"></ConfirmDialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -110,20 +101,18 @@ import { LoadFile } from '@/api/modules/files';
|
|||||||
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||||
import Status from '@/views/database/redis/setting/status/index.vue';
|
import Status from '@/views/database/redis/setting/status/index.vue';
|
||||||
import Persistence from '@/views/database/redis/setting/persistence/index.vue';
|
import Persistence from '@/views/database/redis/setting/persistence/index.vue';
|
||||||
import { changeRedisPassword, loadRedisConf, updateRedisConf, updateRedisConfByFile } from '@/api/modules/database';
|
import { loadRedisConf, updateRedisConf, updateRedisConfByFile } from '@/api/modules/database';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import { ChangePort } from '@/api/modules/app';
|
import { ChangePort } from '@/api/modules/app';
|
||||||
|
|
||||||
const extensions = [javascript(), oneDark];
|
const extensions = [javascript(), oneDark];
|
||||||
const confShowType = ref('base');
|
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
requirepass: '',
|
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
maxclients: 0,
|
maxclients: 0,
|
||||||
maxmemory: 0,
|
maxmemory: 0,
|
||||||
@ -140,63 +129,56 @@ const statusRef = ref();
|
|||||||
const persistenceRef = ref();
|
const persistenceRef = ref();
|
||||||
|
|
||||||
const redisStatus = ref();
|
const redisStatus = ref();
|
||||||
|
const redisName = ref();
|
||||||
|
|
||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
const redisConf = ref();
|
const redisConf = ref();
|
||||||
const confirmDialogRef = ref();
|
const confirmDialogRef = ref();
|
||||||
const confirmDialogRef2 = ref();
|
|
||||||
|
|
||||||
const settingShow = ref<boolean>(false);
|
const settingShow = ref<boolean>(false);
|
||||||
|
|
||||||
interface DialogProps {
|
interface DialogProps {
|
||||||
|
redisName: string;
|
||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const acceptParams = (prop: DialogProps): void => {
|
const acceptParams = (prop: DialogProps): void => {
|
||||||
redisStatus.value = prop.status;
|
redisStatus.value = prop.status;
|
||||||
|
redisName.value = prop.redisName;
|
||||||
settingShow.value = true;
|
settingShow.value = true;
|
||||||
loadform();
|
loadConfFile();
|
||||||
statusRef.value!.acceptParams({ status: prop.status });
|
if (redisStatus.value === 'Running') {
|
||||||
persistenceRef.value!.acceptParams({ status: prop.status });
|
statusRef.value!.acceptParams({ status: prop.status });
|
||||||
|
persistenceRef.value!.acceptParams({ status: prop.status });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const onClose = (): void => {
|
const onClose = (): void => {
|
||||||
settingShow.value = false;
|
settingShow.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSavePort = async () => {
|
const portRef = ref();
|
||||||
|
const confirmPortRef = ref();
|
||||||
|
const onSavePort = async (formEl: FormInstance | undefined) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
const result = await formEl.validateField('port', callback);
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let params = {
|
let params = {
|
||||||
header: i18n.global.t('database.confChange'),
|
header: i18n.global.t('database.confChange'),
|
||||||
operationInfo: i18n.global.t('database.restartNowHelper1'),
|
operationInfo: i18n.global.t('database.restartNowHelper'),
|
||||||
submitInputInfo: i18n.global.t('database.restartNow'),
|
submitInputInfo: i18n.global.t('database.restartNow'),
|
||||||
};
|
};
|
||||||
confirmDialogRef2.value!.acceptParams(params);
|
confirmPortRef.value!.acceptParams(params);
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
function callback(error: any) {
|
||||||
const confirmDialogRef3 = ref();
|
if (error) {
|
||||||
const onSavePassword = async () => {
|
return error.message;
|
||||||
let params = {
|
} else {
|
||||||
header: i18n.global.t('database.confChange'),
|
return;
|
||||||
operationInfo: i18n.global.t('database.restartNowHelper1'),
|
}
|
||||||
submitInputInfo: i18n.global.t('database.restartNow'),
|
}
|
||||||
};
|
|
||||||
confirmDialogRef3.value!.acceptParams(params);
|
|
||||||
};
|
|
||||||
const onChangePassword = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
let param = {
|
|
||||||
id: 0,
|
|
||||||
value: form.requirepass,
|
|
||||||
};
|
|
||||||
changeRedisPassword(param)
|
|
||||||
.then(() => {
|
|
||||||
loading.value = false;
|
|
||||||
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onChangePort = async (formEl: FormInstance | undefined) => {
|
const onChangePort = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
const result = await formEl.validateField('port', callback);
|
const result = await formEl.validateField('port', callback);
|
||||||
@ -218,33 +200,30 @@ const onChangePort = async (formEl: FormInstance | undefined) => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
function callback(error: any) {
|
|
||||||
if (error) {
|
|
||||||
return error.message;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onChangeMode = async () => {
|
// const onChangePassword = async () => {
|
||||||
if (confShowType.value === 'all') {
|
// loading.value = true;
|
||||||
loadredisConf();
|
// let param = {
|
||||||
} else {
|
// id: 0,
|
||||||
loadform();
|
// value: form.requirepass,
|
||||||
}
|
// };
|
||||||
};
|
// changeRedisPassword(param)
|
||||||
|
// .then(() => {
|
||||||
|
// loading.value = false;
|
||||||
|
// ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
|
// })
|
||||||
|
// .finally(() => {
|
||||||
|
// loading.value = false;
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
const onSave = async (formEl: FormInstance | undefined) => {
|
const submtiForm = async (formEl: FormInstance | undefined) => {
|
||||||
if (confShowType.value === 'all') {
|
|
||||||
onSaveFile();
|
|
||||||
}
|
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
formEl.validate(async (valid) => {
|
formEl.validate(async (valid) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
let param = {
|
let param = {
|
||||||
timeout: form.timeout + '',
|
timeout: form.timeout + '',
|
||||||
maxclients: form.maxclients + '',
|
maxclients: form.maxclients + '',
|
||||||
requirepass: form.requirepass,
|
|
||||||
maxmemory: form.maxmemory + '',
|
maxmemory: form.maxmemory + '',
|
||||||
};
|
};
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@ -268,8 +247,7 @@ const onSaveFile = async () => {
|
|||||||
};
|
};
|
||||||
confirmDialogRef.value!.acceptParams(params);
|
confirmDialogRef.value!.acceptParams(params);
|
||||||
};
|
};
|
||||||
|
const submtiFile = async () => {
|
||||||
const onSubmitSave = async () => {
|
|
||||||
let param = {
|
let param = {
|
||||||
file: redisConf.value,
|
file: redisConf.value,
|
||||||
restartNow: true,
|
restartNow: true,
|
||||||
@ -293,7 +271,6 @@ const loadform = async () => {
|
|||||||
form.name = res.data?.name;
|
form.name = res.data?.name;
|
||||||
form.timeout = Number(res.data?.timeout);
|
form.timeout = Number(res.data?.timeout);
|
||||||
form.maxclients = Number(res.data?.maxclients);
|
form.maxclients = Number(res.data?.maxclients);
|
||||||
form.requirepass = res.data?.requirepass;
|
|
||||||
form.maxmemory = Number(res.data?.maxmemory);
|
form.maxmemory = Number(res.data?.maxmemory);
|
||||||
form.port = Number(res.data?.port);
|
form.port = Number(res.data?.port);
|
||||||
})
|
})
|
||||||
@ -302,8 +279,8 @@ const loadform = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadredisConf = async () => {
|
const loadConfFile = async () => {
|
||||||
let path = `/opt/1Panel/data/apps/redis/${form.name}/conf/redis.conf`;
|
let path = `/opt/1Panel/data/apps/redis/${redisName.value}/conf/redis.conf`;
|
||||||
const res = await LoadFile({ path: path });
|
const res = await LoadFile({ path: path });
|
||||||
redisConf.value = res.data;
|
redisConf.value = res.data;
|
||||||
};
|
};
|
||||||
|
@ -29,13 +29,15 @@ const acceptParams = async (): Promise<void> => {
|
|||||||
initTerm();
|
initTerm();
|
||||||
window.addEventListener('resize', changeTerminalSize);
|
window.addEventListener('resize', changeTerminalSize);
|
||||||
};
|
};
|
||||||
const onClose = async () => {
|
const onClose = async (isKeepShow: boolean) => {
|
||||||
window.removeEventListener('resize', changeTerminalSize);
|
window.removeEventListener('resize', changeTerminalSize);
|
||||||
if (isWsOpen()) {
|
if (isWsOpen()) {
|
||||||
terminalSocket && terminalSocket.close();
|
terminalSocket && terminalSocket.close();
|
||||||
|
}
|
||||||
|
if (!isKeepShow) {
|
||||||
term.dispose();
|
term.dispose();
|
||||||
}
|
}
|
||||||
terminalShow.value = false;
|
terminalShow.value = isKeepShow;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onWSReceive = (message: any) => {
|
const onWSReceive = (message: any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user