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..0846eb9 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 @@