From 227cc57426fb418b2a4ce122a6ad8133714d7762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com>
Date: Thu, 17 Oct 2024 15:27:31 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=91=8A=E8=AD=A6=E6=94=AF=E6=8C=81=E5=85=A8?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=91=8A=E8=AD=A6=20(#6749)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/service/cronjob_helper.go | 24 ++++-----
frontend/src/lang/modules/en.ts | 2 +-
frontend/src/lang/modules/tw.ts | 4 +-
frontend/src/lang/modules/zh.ts | 4 +-
frontend/src/views/cronjob/operate/index.vue | 55 +++++++++-----------
5 files changed, 41 insertions(+), 48 deletions(-)
diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go
index cf31acfe8..50838f0c1 100644
--- a/backend/app/service/cronjob_helper.go
+++ b/backend/app/service/cronjob_helper.go
@@ -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,17 +396,15 @@ func hasBackup(cronjobType string) bool {
}
func handleCronJobAlert(cronjob *model.Cronjob) {
- if alertTypes[cronjob.Type] {
- pushAlert := dto.PushAlert{
- TaskName: cronjob.Name,
- AlertType: cronjob.Type,
- EntryID: cronjob.ID,
- Param: cronjob.Type,
- }
- err := xpack.PushAlert(pushAlert)
- if err != nil {
- global.LOG.Errorf("cronjob alert push failed, err: %v", err)
- return
- }
+ pushAlert := dto.PushAlert{
+ TaskName: cronjob.Name,
+ AlertType: cronjob.Type,
+ EntryID: cronjob.ID,
+ Param: cronjob.Type,
+ }
+ err := xpack.PushAlert(pushAlert)
+ if err != nil {
+ global.LOG.Errorf("cronjob alert push failed, err: %v", err)
+ return
}
}
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 0218ef995..19875d73c 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -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',
},
},
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index 9827c26a1..886f27f57 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -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: '每日最大告警次數',
},
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 246ba89fb..d0b9db0bd 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -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: '每日最大告警次数',
},
diff --git a/frontend/src/views/cronjob/operate/index.vue b/frontend/src/views/cronjob/operate/index.vue
index e002a2e3e..c98ae245f 100644
--- a/frontend/src/views/cronjob/operate/index.vue
+++ b/frontend/src/views/cronjob/operate/index.vue
@@ -320,23 +320,7 @@
-
-
- {{ $t('cronjob.retainCopiesHelper1') }}
- {{ $t('cronjob.retainCopiesHelper') }}
-
-
-
-
-
-
-
+
{{ $t('alert.cronJobHelper') }}
@@ -361,6 +345,22 @@
+
+
+ {{ $t('cronjob.retainCopiesHelper1') }}
+ {{ $t('cronjob.retainCopiesHelper') }}
+
+
+
+
+
+
({
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,17 +804,15 @@ 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 =
- dialogData.value.rowData!.hasAlert && isProductPro.value
- ? i18n.global.t('cronjob.alertTitle', [
- i18n.global.t('cronjob.' + dialogData.value.rowData.type),
- dialogData.value.rowData.name,
- ])
- : '';
- }
+ dialogData.value.rowData.alertCount =
+ dialogData.value.rowData!.hasAlert && isProductPro.value ? dialogData.value.rowData.alertCount : 0;
+ dialogData.value.rowData.alertTitle =
+ dialogData.value.rowData!.hasAlert && isProductPro.value
+ ? i18n.global.t('cronjob.alertTitle', [
+ i18n.global.t('cronjob.' + dialogData.value.rowData.type),
+ dialogData.value.rowData.name,
+ ])
+ : '';
if (!dialogData.value.rowData) return;
if (dialogData.value.title === 'create') {
await addCronjob(dialogData.value.rowData);