From de5c751eb96ee99d4292faac575bae9c9fbcd439 Mon Sep 17 00:00:00 2001 From: georgehao Date: Thu, 18 Apr 2019 22:29:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=A8=A1=E7=89=88+=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=A0=E9=99=A4=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通知模版新增任务执行server_id,优化任务执行按钮位置,增加删除功能 --- conf/app.conf | 2 +- jobs/job.go | 2 ++ notify/dingtalk.go | 7 ++++--- views/notifytpl/add.html | 1 + views/notifytpl/edit.html | 1 + views/public/main.html | 2 +- views/task/detail.html | 32 ++++++++++++++++++++++++++++++-- views/task/list.html | 4 ++-- 8 files changed, 42 insertions(+), 9 deletions(-) diff --git a/conf/app.conf b/conf/app.conf index d3cec2e..3848531 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -3,7 +3,7 @@ HTTPPort = 8080 RunMode = dev SessionOn = true -version= V2.5 +version= V2.6 # 允许同时运行的任务数 jobs.pool = 1000 diff --git a/jobs/job.go b/jobs/job.go index cfacc53..5b8a5ac 100644 --- a/jobs/job.go +++ b/jobs/job.go @@ -451,6 +451,7 @@ func (j *Job) Run() { if title != "" { title = strings.Replace(title, "{{TaskId}}", strconv.Itoa(j.task.Id), -1) + title = strings.Replace(title, "{{ServerId}}", strconv.Itoa(j.serverId), -1) title = strings.Replace(title, "{{TaskName}}", j.task.TaskName, -1) title = strings.Replace(title, "{{ExecuteCommand}}", j.task.Command, -1) title = strings.Replace(title, "{{ExecuteTime}}", beego.Date(time.Unix(log.CreateTime, 0), "Y-m-d H:i:s"), -1) @@ -462,6 +463,7 @@ func (j *Job) Run() { if content != "" { content = strings.Replace(content, "{{TaskId}}", strconv.Itoa(j.task.Id), -1) + content = strings.Replace(content, "{{ServerId}}", strconv.Itoa(j.serverId), -1) content = strings.Replace(content, "{{TaskName}}", j.task.TaskName, -1) content = strings.Replace(content, "{{ExecuteCommand}}", j.task.Command, -1) content = strings.Replace(content, "{{ExecuteTime}}", beego.Date(time.Unix(log.CreateTime, 0), "Y-m-d H:i:s"), -1) diff --git a/notify/dingtalk.go b/notify/dingtalk.go index 7f3e05f..9e841a3 100644 --- a/notify/dingtalk.go +++ b/notify/dingtalk.go @@ -8,13 +8,13 @@ package notify import ( + "bytes" + "encoding/json" + "fmt" "github.com/astaxie/beego" "github.com/george518/PPGo_Job/libs" "log" "time" - "fmt" - "encoding/json" - "bytes" ) type Dingtalk struct { @@ -41,6 +41,7 @@ func init() { } if err := m.SendDingtalk(); err != nil { beego.Error("SendDingtalk:", err.Error()) + } } } diff --git a/views/notifytpl/add.html b/views/notifytpl/add.html index c70ef52..4432b97 100644 --- a/views/notifytpl/add.html +++ b/views/notifytpl/add.html @@ -40,6 +40,7 @@
 
   {{"任务 ID {{TaskId}}"}}
+  {{"资源 ID {{ServerId}}"}}
   {{"任务名称 {{TaskName}}"}}
   {{"执行命令 {{ExecuteCommand}}"}}
   {{"执行时间 {{ExecuteTime}}"}}
diff --git a/views/notifytpl/edit.html b/views/notifytpl/edit.html
index 5978a11..db916e7 100644
--- a/views/notifytpl/edit.html
+++ b/views/notifytpl/edit.html
@@ -41,6 +41,7 @@
                 
 
   {{"任务 ID {{TaskId}}"}}
+  {{"资源 ID {{ServerId}}"}}
   {{"任务名称 {{TaskName}}"}}
   {{"执行命令 {{ExecuteCommand}}"}}
   {{"执行时间 {{ExecuteTime}}"}}
diff --git a/views/public/main.html b/views/public/main.html
index e55badd..c6c6d5e 100644
--- a/views/public/main.html
+++ b/views/public/main.html
@@ -84,7 +84,7 @@
 
     
 
 
diff --git a/views/task/detail.html b/views/task/detail.html
index 7f0ebca..41baa9f 100644
--- a/views/task/detail.html
+++ b/views/task/detail.html
@@ -25,6 +25,7 @@
         
         
         
+        
     
 
     
@@ -150,6 +151,7 @@
+ @@ -64,7 +64,7 @@ ,{field:'next_time', width:170,title: '下次执行时间'} ,{field:'pre_time', title: '上次执行时间'} ,{field:'execute_times', title: '次数'} - ,{fixed: 'right', width:150, align:'center', title:'操作', toolbar: '#bar'} + ,{width:120, align:'center', title:'操作', toolbar: '#bar'} ]] ,id: 'listReload' ,page: true