mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 解决 mysql 慢日志设置修改失败的问题
This commit is contained in:
parent
11f4bc2c89
commit
9080824a59
12
frontend/package-lock.json
generated
12
frontend/package-lock.json
generated
@ -10643,9 +10643,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/webpack": {
|
||||
"version": "5.75.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
|
||||
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
|
||||
"version": "5.76.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.1.tgz",
|
||||
"integrity": "sha512-4+YIK4Abzv8172/SGqObnUjaIHjLEuUasz9EwQj/9xmPPkYJy2Mh03Q/lJfSD3YLzbxy5FeTq5Uw0323Oh6SJQ==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/eslint-scope": "^3.7.3",
|
||||
@ -18679,9 +18679,9 @@
|
||||
}
|
||||
},
|
||||
"webpack": {
|
||||
"version": "5.75.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
|
||||
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
|
||||
"version": "5.76.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.1.tgz",
|
||||
"integrity": "sha512-4+YIK4Abzv8172/SGqObnUjaIHjLEuUasz9EwQj/9xmPPkYJy2Mh03Q/lJfSD3YLzbxy5FeTq5Uw0323Oh6SJQ==",
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@types/eslint-scope": "^3.7.3",
|
||||
|
@ -77,7 +77,7 @@ const timeOptions = ref([
|
||||
|
||||
const searchLogs = async () => {
|
||||
const res = await logContainer(logSearch);
|
||||
logInfo.value = res.data;
|
||||
logInfo.value = res.data || '';
|
||||
nextTick(() => {
|
||||
const state = view.value.state;
|
||||
view.value.dispatch({
|
||||
|
@ -96,7 +96,7 @@ const handleClose = async () => {
|
||||
|
||||
const searchLogs = async () => {
|
||||
const res = await logContainer(logSearch);
|
||||
logInfo.value = res.data;
|
||||
logInfo.value = res.data || '';
|
||||
nextTick(() => {
|
||||
const state = view.value.state;
|
||||
view.value.dispatch({
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div style="float: left">
|
||||
<el-input type="number" v-model.number="variables.long_query_time" />
|
||||
</div>
|
||||
<el-button style="float: left; margin-left: 10px" @click="openSlowLogs">
|
||||
<el-button style="float: left; margin-left: 10px" @click="changeSlowLogs">
|
||||
{{ $t('commons.button.save') }}
|
||||
</el-button>
|
||||
<div style="float: left; margin-left: 20px">
|
||||
@ -56,7 +56,7 @@ import { updateMysqlVariables } from '@/api/modules/database';
|
||||
import { dateFormatForName } from '@/utils/util';
|
||||
import i18n from '@/lang';
|
||||
import { loadBaseDir } from '@/api/modules/setting';
|
||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||
import { MsgError, MsgInfo, MsgSuccess } from '@/utils/message';
|
||||
|
||||
const extensions = [javascript(), oneDark];
|
||||
const slowLogs = ref();
|
||||
@ -65,7 +65,7 @@ const handleReady = (payload) => {
|
||||
view.value = payload.view;
|
||||
};
|
||||
const detailShow = ref();
|
||||
const isOnEdit = ref();
|
||||
const currentStatus = ref();
|
||||
|
||||
const confirmDialogRef = ref();
|
||||
|
||||
@ -88,17 +88,18 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
|
||||
variables.slow_query_log = params.variables.slow_query_log;
|
||||
variables.long_query_time = Number(params.variables.long_query_time);
|
||||
|
||||
const pathRes = await loadBaseDir();
|
||||
let path = `${pathRes.data}/apps/mysql/${mysqlName.value}/data/1Panel-slow.log`;
|
||||
if (variables.slow_query_log === 'ON') {
|
||||
currentStatus.value = true;
|
||||
detailShow.value = true;
|
||||
const pathRes = await loadBaseDir();
|
||||
let path = `${pathRes.data}/apps/mysql/${mysqlName.value}/data/1Panel-slow.log`;
|
||||
loadMysqlSlowlogs(path);
|
||||
timer = setInterval(() => {
|
||||
if (variables.slow_query_log === 'ON' && isWatch.value) {
|
||||
loadMysqlSlowlogs(path);
|
||||
}
|
||||
}, 1000 * 5);
|
||||
}
|
||||
timer = setInterval(() => {
|
||||
if (variables.slow_query_log === 'ON' && isWatch.value) {
|
||||
loadMysqlSlowlogs(path);
|
||||
}
|
||||
}, 1000 * 5);
|
||||
oldVariables.value = { ...variables };
|
||||
};
|
||||
const emit = defineEmits(['loading']);
|
||||
@ -106,11 +107,6 @@ const emit = defineEmits(['loading']);
|
||||
const handleSlowLogs = async () => {
|
||||
if (variables.slow_query_log === 'ON') {
|
||||
detailShow.value = true;
|
||||
isOnEdit.value = true;
|
||||
return;
|
||||
}
|
||||
if (isOnEdit.value) {
|
||||
detailShow.value = false;
|
||||
return;
|
||||
}
|
||||
let params = {
|
||||
@ -121,7 +117,7 @@ const handleSlowLogs = async () => {
|
||||
confirmDialogRef.value!.acceptParams(params);
|
||||
};
|
||||
|
||||
const openSlowLogs = () => {
|
||||
const changeSlowLogs = () => {
|
||||
if (!(variables.long_query_time > 0 && variables.long_query_time <= 600)) {
|
||||
MsgError(i18n.global.t('database.thresholdRangeHelper'));
|
||||
return;
|
||||
@ -135,7 +131,7 @@ const openSlowLogs = () => {
|
||||
};
|
||||
|
||||
const onCancle = async () => {
|
||||
variables.slow_query_log = variables.slow_query_log === 'ON' ? 'OFF' : 'ON';
|
||||
variables.slow_query_log = currentStatus.value ? 'ON' : 'OFF';
|
||||
};
|
||||
|
||||
const onSave = async () => {
|
||||
@ -151,10 +147,9 @@ const onSave = async () => {
|
||||
await updateMysqlVariables(param)
|
||||
.then(() => {
|
||||
emit('loading', false);
|
||||
isOnEdit.value = false;
|
||||
if (variables.slow_query_log !== 'ON') {
|
||||
detailShow.value = false;
|
||||
}
|
||||
currentStatus.value = variables.slow_query_log === 'ON';
|
||||
detailShow.value = variables.slow_query_log === 'ON';
|
||||
oldVariables.value.slow_query_log = variables.slow_query_log;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
@ -163,6 +158,10 @@ const onSave = async () => {
|
||||
};
|
||||
|
||||
const onDownload = async () => {
|
||||
if (!slowLogs.value) {
|
||||
MsgInfo(i18n.global.t('database.noData'));
|
||||
return;
|
||||
}
|
||||
const downloadUrl = window.URL.createObjectURL(new Blob([slowLogs.value]));
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
@ -174,7 +173,7 @@ const onDownload = async () => {
|
||||
|
||||
const loadMysqlSlowlogs = async (path: string) => {
|
||||
const res = await LoadFile({ path: path });
|
||||
slowLogs.value = res.data;
|
||||
slowLogs.value = res.data || '';
|
||||
nextTick(() => {
|
||||
const state = view.value.state;
|
||||
view.value.dispatch({
|
||||
|
@ -79,7 +79,7 @@ import type { ElForm } from 'element-plus';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { addHost, editHost, testByInfo, GetGroupList } from '@/api/modules/host';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||
|
||||
const loading = ref();
|
||||
|
||||
@ -165,7 +165,7 @@ const submitAddHost = (formEl: FormInstance | undefined, ops: string) => {
|
||||
if (res.data) {
|
||||
MsgSuccess(i18n.global.t('terminal.connTestOk'));
|
||||
} else {
|
||||
MsgSuccess(i18n.global.t('terminal.connTestFailed'));
|
||||
MsgError(i18n.global.t('terminal.connTestFailed'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user