From f0a7ce855a90a3da80e3788ca618bbe39fcfe33f Mon Sep 17 00:00:00 2001 From: ssongliu Date: Thu, 22 Sep 2022 14:19:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/cronjob.go | 15 + backend/app/dto/cronjob.go | 8 +- frontend/src/api/interface/cronjob.ts | 3 + frontend/src/lang/modules/zh.ts | 3 +- frontend/src/views/cronjob/index.vue | 429 ++++--------------- frontend/src/views/cronjob/operate/index.vue | 341 +++++++++++++++ frontend/src/views/setting/helper.ts | 17 + frontend/src/views/setting/tabs/backup.vue | 17 +- 8 files changed, 460 insertions(+), 373 deletions(-) create mode 100644 frontend/src/views/cronjob/operate/index.vue create mode 100644 frontend/src/views/setting/helper.ts diff --git a/backend/app/api/v1/cronjob.go b/backend/app/api/v1/cronjob.go index 5275c1199..71348dda9 100644 --- a/backend/app/api/v1/cronjob.go +++ b/backend/app/api/v1/cronjob.go @@ -79,6 +79,21 @@ func (b *BaseApi) UpdateCronjob(c *gin.Context) { } upMap := make(map[string]interface{}) + upMap["name"] = req.Name + upMap["spec_type"] = req.SpecType + upMap["week"] = req.Week + upMap["day"] = req.Day + upMap["hour"] = req.Hour + upMap["minute"] = req.Minute + + upMap["script"] = req.Script + upMap["website"] = req.Website + upMap["database"] = req.Database + upMap["source_dir"] = req.SourceDir + upMap["target_dir_id"] = req.TargetDirID + upMap["exclusion_rules"] = req.ExclusionRules + upMap["retain_copies"] = req.RetainCopies + upMap["status"] = req.Status if err := cronjobService.Update(id, upMap); err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return diff --git a/backend/app/dto/cronjob.go b/backend/app/dto/cronjob.go index f71d69b2f..cd03aa02b 100644 --- a/backend/app/dto/cronjob.go +++ b/backend/app/dto/cronjob.go @@ -14,25 +14,26 @@ type CronjobCreate struct { ExclusionRules string `json:"exclusionRules"` Database string `json:"database"` URL string `json:"url"` + SourceDir string `json:"sourceDir"` TargetDirID int `json:"targetDirID"` RetainCopies int `json:"retainCopies" validate:"number,min=1"` } type CronjobUpdate struct { Name string `json:"name" validate:"required"` - Type string `json:"type" validate:"required"` SpecType string `json:"specType" validate:"required"` Week int `json:"week" validate:"number,max=7,min=1"` Day int `json:"day" validate:"number,max=31,min=1"` Hour int `json:"hour" validate:"number,max=23,min=0"` - Minute int `json:"minute" validate:"number,max=60,min=1"` + Minute int `json:"minute" validate:"number,max=59,min=0"` Script string `json:"script"` Website string `json:"website"` ExclusionRules string `json:"exclusionRules"` Database string `json:"database"` URL string `json:"url"` - TargetDirID int `json:"targetDirID" validate:"number,min=1"` + SourceDir string `json:"sourceDir"` + TargetDirID int `json:"targetDirID"` RetainCopies int `json:"retainCopies" validate:"number,min=1"` Status string `json:"status"` @@ -53,6 +54,7 @@ type CronjobInfo struct { ExclusionRules string `json:"exclusionRules"` Database string `json:"database"` URL string `json:"url"` + SourceDir string `json:"sourceDir"` TargetDir string `json:"targetDir"` TargetDirID int `json:"targetDirID"` RetainCopies int `json:"retainCopies"` diff --git a/frontend/src/api/interface/cronjob.ts b/frontend/src/api/interface/cronjob.ts index 21090a503..9d8d07055 100644 --- a/frontend/src/api/interface/cronjob.ts +++ b/frontend/src/api/interface/cronjob.ts @@ -14,6 +14,7 @@ export namespace Cronjob { exclusionRules: string; database: string; url: string; + sourceDir: string; targetDirID: number; targetDir: string; retainCopies: number; @@ -33,6 +34,7 @@ export namespace Cronjob { exclusionRules: string; database: string; url: string; + sourceDir: string; targetDirID: number; retainCopies: number; } @@ -49,6 +51,7 @@ export namespace Cronjob { exclusionRules: string; database: string; url: string; + sourceDir: string; targetDirID: number; retainCopies: number; status: string; diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index b91e4a6d0..dc9cfb2ff 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -17,6 +17,7 @@ export default { clean: '清空', login: '登录', close: '关闭', + view: '详情', saveAndEnable: '保存并启用', }, search: { @@ -134,7 +135,7 @@ export default { logout: '退出登录', }, cronjob: { - createCronTask: '创建计划任务', + cronTask: '计划任务', taskType: '任务类型', shell: 'Shell 脚本', website: '备份网站', diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index a44963d85..3f0fc1895 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -8,8 +8,8 @@ :data="data" > @@ -29,12 +29,16 @@ @@ -66,165 +70,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/frontend/src/views/cronjob/operate/index.vue b/frontend/src/views/cronjob/operate/index.vue new file mode 100644 index 000000000..76ded4c16 --- /dev/null +++ b/frontend/src/views/cronjob/operate/index.vue @@ -0,0 +1,341 @@ + + + diff --git a/frontend/src/views/setting/helper.ts b/frontend/src/views/setting/helper.ts new file mode 100644 index 000000000..0ca66dcd6 --- /dev/null +++ b/frontend/src/views/setting/helper.ts @@ -0,0 +1,17 @@ +import i18n from '@/lang'; + +export const loadBackupName = (type: string) => { + switch (type) { + case 'OSS': + return i18n.global.t('setting.OSS'); + break; + case 'S3': + return i18n.global.t('setting.S3'); + break; + case 'LOCAL': + return i18n.global.t('setting.serverDisk'); + break; + default: + return type; + } +}; diff --git a/frontend/src/views/setting/tabs/backup.vue b/frontend/src/views/setting/tabs/backup.vue index e014f58eb..9678add79 100644 --- a/frontend/src/views/setting/tabs/backup.vue +++ b/frontend/src/views/setting/tabs/backup.vue @@ -167,6 +167,7 @@