feat: 计划任务失败告警支持全类型告警 (#6749)

pull/6757/head
1 month ago committed by GitHub
parent b99061777a
commit 227cc57426
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -25,8 +25,6 @@ import (
"github.com/pkg/errors"
)
var alertTypes = map[string]bool{"app": true, "website": true, "database": true, "directory": true, "log": true, "snapshot": true}
func (u *CronjobService) HandleJob(cronjob *model.Cronjob) {
var (
message []byte
@ -398,7 +396,6 @@ func hasBackup(cronjobType string) bool {
}
func handleCronJobAlert(cronjob *model.Cronjob) {
if alertTypes[cronjob.Type] {
pushAlert := dto.PushAlert{
TaskName: cronjob.Name,
AlertType: cronjob.Type,
@ -411,4 +408,3 @@ func handleCronJobAlert(cronjob *model.Cronjob) {
return
}
}
}

@ -1133,7 +1133,7 @@ const message = {
clamLog: 'Scan Logs',
freshClam: 'Update Virus Definitions',
freshClamLog: 'Update Virus Definitions Logs',
alertHelper: 'Professional version supports SMS alert',
alertHelper: 'Professional version supports scheduled scan and SMS alert',
alertTitle: 'Virus scanning {0} task failed alert',
},
},

@ -1070,7 +1070,7 @@ const message = {
clamLog: '',
freshClam: '',
freshClamLog: '',
alertHelper: '',
alertHelper: '',
alertTitle: '{0}',
},
},
@ -2292,7 +2292,7 @@ const message = {
isAlert: '',
alertCount: '',
clamHelper: '',
cronJobHelper: '',
cronJobHelper: '',
licenseHelper: '',
alertCountHelper: '',
},

@ -1072,7 +1072,7 @@ const message = {
clamLog: '',
freshClam: '',
freshClamLog: '',
alertHelper: '',
alertHelper: '',
alertTitle: ' {0} ',
},
},
@ -2295,7 +2295,7 @@ const message = {
isAlert: '',
alertCount: '',
clamHelper: '',
cronJobHelper: '',
cronJobHelper: '',
licenseHelper: '',
alertCountHelper: '',
},

@ -320,23 +320,7 @@
</el-form-item>
</div>
<el-form-item :label="$t('cronjob.retainCopies')" prop="retainCopies">
<el-input-number
style="width: 200px"
:min="1"
step-strictly
:step="1"
v-model.number="dialogData.rowData!.retainCopies"
></el-input-number>
<span v-if="isBackup()" class="input-help">{{ $t('cronjob.retainCopiesHelper1') }}</span>
<span v-else class="input-help">{{ $t('cronjob.retainCopiesHelper') }}</span>
</el-form-item>
<el-form-item v-if="dialogData.rowData!.type === 'curl'" :label="$t('cronjob.url')" prop="url">
<el-input clearable v-model.trim="dialogData.rowData!.url" />
</el-form-item>
<el-form-item prop="hasAlert" v-if="alertTypes.includes(dialogData.rowData!.type)">
<el-form-item prop="hasAlert">
<el-checkbox v-model="dialogData.rowData!.hasAlert" :label="$t('alert.isAlert')" />
<span class="input-help">{{ $t('alert.cronJobHelper') }}</span>
</el-form-item>
@ -361,6 +345,22 @@
</el-button>
</el-form-item>
<el-form-item :label="$t('cronjob.retainCopies')" prop="retainCopies">
<el-input-number
style="width: 200px"
:min="1"
step-strictly
:step="1"
v-model.number="dialogData.rowData!.retainCopies"
></el-input-number>
<span v-if="isBackup()" class="input-help">{{ $t('cronjob.retainCopiesHelper1') }}</span>
<span v-else class="input-help">{{ $t('cronjob.retainCopiesHelper') }}</span>
</el-form-item>
<el-form-item v-if="dialogData.rowData!.type === 'curl'" :label="$t('cronjob.url')" prop="url">
<el-input clearable v-model.trim="dialogData.rowData!.url" />
</el-form-item>
<el-form-item
v-if="hasExclusionRules()"
:label="$t('cronjob.exclusionRules')"
@ -429,7 +429,6 @@ const dialogData = ref<DialogProps>({
const globalStore = GlobalStore();
const licenseRef = ref();
const { isProductPro } = storeToRefs(globalStore);
const alertTypes = ['app', 'website', 'database', 'directory', 'log', 'snapshot'];
const acceptParams = (params: DialogProps): void => {
dialogData.value = params;
@ -805,7 +804,6 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
if (dialogData.value?.rowData?.exclusionRules) {
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll('\n', ',');
}
if (alertTypes.includes(dialogData.value.rowData.type)) {
dialogData.value.rowData.alertCount =
dialogData.value.rowData!.hasAlert && isProductPro.value ? dialogData.value.rowData.alertCount : 0;
dialogData.value.rowData.alertTitle =
@ -815,7 +813,6 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
dialogData.value.rowData.name,
])
: '';
}
if (!dialogData.value.rowData) return;
if (dialogData.value.title === 'create') {
await addCronjob(dialogData.value.rowData);

Loading…
Cancel
Save