From f07ed348fec7be5a4f7795d7a34abf569ec4bd90 Mon Sep 17 00:00:00 2001 From: zhouwuhong Date: Fri, 23 Jun 2017 14:07:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E4=B8=BA?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E7=8A=B6=E6=80=81&&=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=84=9A=E6=9C=AC=E6=90=9C=E7=B4=A2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=88=86=E7=BB=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/task.go | 60 ++++++++++++++++++++++++++++++++++++ static/css/bootstrap.min.css | 11 +++++++ views/layout/layout.html | 36 ++++++++++++++++++++++ views/task/list.html | 2 +- 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/app/controllers/task.go b/app/controllers/task.go index 7b3f7ac..1d01db7 100644 --- a/app/controllers/task.go +++ b/app/controllers/task.go @@ -70,6 +70,62 @@ func (this *TaskController) List() { this.display() } +func (this *TaskController) Search() { + page, _ := this.GetInt("page") + if page < 1 { + page = 1 + } + groupId, _ := this.GetInt("groupid") + filters := make([]interface{}, 0) + if groupId > 0 { + filters = append(filters, "group_id", groupId) + } + command := this.GetString("command") + filters = append(filters, "command__icontains", command) + result, count := models.TaskGetList(page, this.pageSize, filters...) + + list := make([]map[string]interface{}, len(result)) + for k, v := range result { + row := make(map[string]interface{}) + row["id"] = v.Id + row["name"] = v.TaskName + row["cron_spec"] = v.CronSpec + row["status"] = v.Status + row["description"] = v.Description + + e := jobs.GetEntryById(v.Id) + if e != nil { + row["next_time"] = beego.Date(e.Next, "Y-m-d H:i:s") + row["prev_time"] = "-" + if e.Prev.Unix() > 0 { + row["prev_time"] = beego.Date(e.Prev, "Y-m-d H:i:s") + } else if v.PrevTime > 0 { + row["prev_time"] = beego.Date(time.Unix(v.PrevTime, 0), "Y-m-d H:i:s") + } + row["running"] = 1 + } else { + row["next_time"] = "-" + if v.PrevTime > 0 { + row["prev_time"] = beego.Date(time.Unix(v.PrevTime, 0), "Y-m-d H:i:s") + } else { + row["prev_time"] = "-" + } + row["running"] = 0 + } + list[k] = row + } + + // 分组列表 + groups, _ := models.TaskGroupGetList(1, 100) + + this.Data["pageTitle"] = "任务列表" + this.Data["list"] = list + this.Data["groups"] = groups + this.Data["groupid"] = groupId + this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.URLFor("TaskController.Search", "groupid", groupId, "command", command), true).ToString() + this.display() +} + // 添加任务 func (this *TaskController) Add() { @@ -164,6 +220,10 @@ func (this *TaskController) Edit() { this.ajaxMsg(err.Error(), MSG_ERR) } + jobs.RemoveJob(id) + task.Status = 0 + task.Update() + this.ajaxMsg("", MSG_OK) } diff --git a/static/css/bootstrap.min.css b/static/css/bootstrap.min.css index 373f1d8..eda02f7 100755 --- a/static/css/bootstrap.min.css +++ b/static/css/bootstrap.min.css @@ -1834,6 +1834,17 @@ background-repeat:no-repeat; line-height: 22px; padding: 6px 14px; } +.btn-large-group { + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + -ms-border-radius: 6px; + -o-border-radius: 6px; + border-radius: 6px; + font-size: 16px; + line-height: 24px; + line-height: 22px; + padding: 1px 14px; +} .btn-large [class^="icon-"] { margin-top: 1px; } diff --git a/views/layout/layout.html b/views/layout/layout.html index b8bc3cb..9e0d745 100644 --- a/views/layout/layout.html +++ b/views/layout/layout.html @@ -1,5 +1,29 @@ + + @@ -82,6 +106,18 @@ + diff --git a/views/task/list.html b/views/task/list.html index ea69b6d..aeb0e4f 100644 --- a/views/task/list.html +++ b/views/task/list.html @@ -30,7 +30,7 @@

任务列表

- {{range $k, $v := .groups}} From f909f07bbb61821d54637dd3f14fb4ef402416d3 Mon Sep 17 00:00:00 2001 From: doubleuhy <282239271@qq.com> Date: Wed, 26 Jul 2017 17:21:56 +0800 Subject: [PATCH 2/2] format --- static/css/bootstrap.min.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/css/bootstrap.min.css b/static/css/bootstrap.min.css index eda02f7..0846eb9 100755 --- a/static/css/bootstrap.min.css +++ b/static/css/bootstrap.min.css @@ -1835,7 +1835,7 @@ background-repeat:no-repeat; padding: 6px 14px; } .btn-large-group { - -webkit-border-radius: 6px; + -webkit-border-radius: 6px; -moz-border-radius: 6px; -ms-border-radius: 6px; -o-border-radius: 6px;