mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 15:06:37 +08:00
fix: Fix alert issue (#10281)
This commit is contained in:
parent
18214095ab
commit
7448953b7d
1 changed files with 42 additions and 60 deletions
|
@ -454,79 +454,61 @@ const allTaskOptions = [
|
||||||
{ value: 'panelUpdate', label: 'xpack.alert.panelUpdate', show: isMaster.value },
|
{ value: 'panelUpdate', label: 'xpack.alert.panelUpdate', show: isMaster.value },
|
||||||
];
|
];
|
||||||
|
|
||||||
function checkCycle(rule: any, value: any, callback: any) {
|
function checkRange(value: any, min: number, max: number, callback: any) {
|
||||||
if (value === '') {
|
const num = Number(value);
|
||||||
callback();
|
if (isNaN(num)) {
|
||||||
|
return callback(new Error(i18n.global.t('commons.rule.number')));
|
||||||
}
|
}
|
||||||
if (dialogData.value.rowData.type === 'ssl') {
|
if (num < min || num > max) {
|
||||||
const regex = /^(?:[1-9]|[1-5][0-9]|60)$/;
|
return callback(new Error(i18n.global.t('commons.rule.numberRange', [min, max])));
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 60])));
|
|
||||||
}
|
|
||||||
} else if (ipTypes.includes(dialogData.value.rowData.type)) {
|
|
||||||
const regex = /^(?:[1-9]|[1-5][0-9]|200)$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 200])));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const regex = /^(?:[1-9]|[12][0-9]|30)$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 30])));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkCycle(rule: any, value: any, callback: any) {
|
||||||
|
if (value === '') return callback();
|
||||||
|
|
||||||
|
const type = dialogData.value.rowData.type;
|
||||||
|
|
||||||
|
if (type === 'ssl') {
|
||||||
|
return checkRange(value, 1, 60, callback);
|
||||||
|
} else if (ipTypes.includes(type)) {
|
||||||
|
return checkRange(value, 1, 200, callback);
|
||||||
|
} else {
|
||||||
|
return checkRange(value, 1, 30, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkCount(rule: any, value: any, callback: any) {
|
function checkCount(rule: any, value: any, callback: any) {
|
||||||
if (value === '') {
|
if (value === '') return callback();
|
||||||
callback();
|
|
||||||
|
const type = dialogData.value.rowData.type;
|
||||||
|
const cycle = dialogData.value.rowData.cycle;
|
||||||
|
|
||||||
|
if (avgTypes.includes(type) || ipTypes.includes(type)) {
|
||||||
|
return checkRange(value, 1, 100, callback);
|
||||||
}
|
}
|
||||||
if (avgTypes.includes(dialogData.value.rowData.type) || ipTypes.includes(dialogData.value.rowData.type)) {
|
if (type === 'disk' && cycle === 2) {
|
||||||
const regex = /^(?:[1-9]|[1-9][0-9]|100)$/;
|
return checkRange(value, 1, 100, callback);
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 100])));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dialogData.value.rowData.type === 'disk' && dialogData.value.rowData.cycle === 2) {
|
|
||||||
const regex = /^(?:[1-9]|[1-9][0-9]|100)$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 100])));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSendCount(rule: any, value: any, callback: any) {
|
function checkSendCount(rule: any, value: any, callback: any) {
|
||||||
if (value === '') {
|
if (value === '') return callback();
|
||||||
callback();
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
dialogData.value.rowData.type === 'disk' ||
|
|
||||||
avgTypes.includes(dialogData.value.rowData.type) ||
|
|
||||||
ipTypes.includes(dialogData.value.rowData.type)
|
|
||||||
) {
|
|
||||||
const regex = /^(?:[1-9]|[1-4][0-9]|50)$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 50])));
|
|
||||||
}
|
|
||||||
} else if (noParamTypes.includes(dialogData.value.rowData.type)) {
|
|
||||||
const regex = /^(?:[1-9]|[12][0-9]|30)$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 30])));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (dialogData.value.rowData.cycle > 0) {
|
|
||||||
const minValue = 1;
|
|
||||||
const maxValue = dialogData.value.rowData.cycle;
|
|
||||||
const regex = new RegExp(`^(${minValue}|[2-9]|[1-9][0-9]*|${maxValue})$`);
|
|
||||||
if (!regex.test(value) || value > maxValue) {
|
|
||||||
return callback(
|
|
||||||
new Error(i18n.global.t('commons.rule.numberRange', [1, dialogData.value.rowData.cycle])),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const type = dialogData.value.rowData.type;
|
||||||
|
const cycle = dialogData.value.rowData.cycle;
|
||||||
|
|
||||||
|
if (type === 'disk' || avgTypes.includes(type) || ipTypes.includes(type)) {
|
||||||
|
return checkRange(value, 1, 50, callback);
|
||||||
|
} else if (noParamTypes.includes(type)) {
|
||||||
|
return checkRange(value, 1, 30, callback);
|
||||||
|
} else {
|
||||||
|
if (cycle > 0) {
|
||||||
|
return checkRange(value, 1, cycle, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue