修改任务组+首页统计数据
This commit is contained in:
@@ -25,22 +25,35 @@ type MainController struct {
|
||||
// 首页
|
||||
func (this *MainController) Index() {
|
||||
this.Data["pageTitle"] = "系统概况"
|
||||
|
||||
// 分组列表
|
||||
groups, _ := models.TaskGroupGetList(1, 100)
|
||||
groups_map := make(map[int]string)
|
||||
for _,gname := range groups {
|
||||
groups_map[gname.Id] = gname.GroupName
|
||||
}
|
||||
//计算总任务数量
|
||||
_, count := models.TaskGetList(1, 200)
|
||||
// 即将执行的任务
|
||||
entries := jobs.GetEntries(30)
|
||||
jobList := make([]map[string]interface{}, len(entries))
|
||||
startJob := 0 //即将执行的任务
|
||||
for k, v := range entries {
|
||||
row := make(map[string]interface{})
|
||||
job := v.Job.(*jobs.Job)
|
||||
task, _ := models.TaskGetById(job.GetId())
|
||||
row["task_id"] = job.GetId()
|
||||
row["task_name"] = job.GetName()
|
||||
row["task_group"] = groups_map[task.GroupId]
|
||||
row["next_time"] = beego.Date(v.Next, "Y-m-d H:i:s")
|
||||
jobList[k] = row
|
||||
startJob++
|
||||
}
|
||||
|
||||
// 最近执行的日志
|
||||
logs, _ := models.TaskLogGetList(1, 20)
|
||||
recentLogs := make([]map[string]interface{}, len(logs))
|
||||
failJob := 0 //最近失败的数量
|
||||
okJob:=0 //最近成功的数量
|
||||
for k, v := range logs {
|
||||
task, err := models.TaskGetById(v.TaskId)
|
||||
taskName := ""
|
||||
@@ -56,17 +69,24 @@ func (this *MainController) Index() {
|
||||
row["output"] = beego.Substr(v.Output, 0, 100)
|
||||
row["status"] = v.Status
|
||||
recentLogs[k] = row
|
||||
if v.Status!=0 {
|
||||
failJob++
|
||||
}else {
|
||||
okJob++
|
||||
}
|
||||
}
|
||||
|
||||
// 最近执行失败的日志
|
||||
logs, _ = models.TaskLogGetList(1, 20, "status__lt", 0)
|
||||
errLogs := make([]map[string]interface{}, len(logs))
|
||||
|
||||
for k, v := range logs {
|
||||
task, err := models.TaskGetById(v.TaskId)
|
||||
taskName := ""
|
||||
if err == nil {
|
||||
taskName = task.TaskName
|
||||
}
|
||||
|
||||
row := make(map[string]interface{})
|
||||
row["task_name"] = taskName
|
||||
row["id"] = v.Id
|
||||
@@ -76,9 +96,14 @@ func (this *MainController) Index() {
|
||||
row["error"] = beego.Substr(v.Error, 0, 100)
|
||||
row["status"] = v.Status
|
||||
errLogs[k] = row
|
||||
|
||||
}
|
||||
|
||||
this.Data["okTotal"] = 13
|
||||
this.Data["startJob"] = startJob
|
||||
this.Data["okJob"] = okJob
|
||||
this.Data["failJob"] = failJob
|
||||
this.Data["totalJob"] = count
|
||||
|
||||
this.Data["recentLogs"] = recentLogs
|
||||
// this.Data["errLogs"] = errLogs
|
||||
this.Data["jobs"] = jobList
|
||||
|
||||
@@ -36,6 +36,12 @@ func (this *TaskController) List() {
|
||||
result, count := models.TaskGetList(page, this.pageSize, filters...)
|
||||
|
||||
list := make([]map[string]interface{}, len(result))
|
||||
// 分组列表
|
||||
groups, _ := models.TaskGroupGetList(1, 100)
|
||||
groups_map := make(map[int]string)
|
||||
for _,gname := range groups {
|
||||
groups_map[gname.Id] = gname.GroupName
|
||||
}
|
||||
for k, v := range result {
|
||||
row := make(map[string]interface{})
|
||||
row["id"] = v.Id
|
||||
@@ -43,6 +49,9 @@ func (this *TaskController) List() {
|
||||
row["cron_spec"] = v.CronSpec
|
||||
row["status"] = v.Status
|
||||
row["description"] = v.Description
|
||||
row["group_id"] = v.GroupId
|
||||
row["group_name"] = groups_map[v.GroupId]
|
||||
|
||||
e := jobs.GetEntryById(v.Id)
|
||||
if e != nil {
|
||||
row["next_time"] = beego.Date(e.Next, "Y-m-d H:i:s")
|
||||
@@ -64,10 +73,6 @@ func (this *TaskController) List() {
|
||||
}
|
||||
list[k] = row
|
||||
}
|
||||
|
||||
// 分组列表
|
||||
groups, _ := models.TaskGroupGetList(1, 100)
|
||||
|
||||
this.Data["pageTitle"] = "任务列表"
|
||||
this.Data["list"] = list
|
||||
this.Data["groups"] = groups
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<!--content-list-->
|
||||
<div class="content-list">
|
||||
<!-- <div class="row" style="height: 120px">
|
||||
<div class="row" style="height: 120px">
|
||||
<div class="col-md-3">
|
||||
<div class="content" style="height: 110px;">
|
||||
<div class="w30 left-icon pull-left">
|
||||
@@ -24,9 +24,9 @@
|
||||
</div>
|
||||
<div class="w70 right-title pull-right">
|
||||
<div class="title-content">
|
||||
<p>今日执行任务成功的次数</p>
|
||||
<h3 class="number">11</h3>
|
||||
|
||||
<p>最近执行成功</p>
|
||||
<h3 class="number">{{.okJob}}</h3>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@@ -39,9 +39,9 @@
|
||||
</div>
|
||||
<div class="w70 right-title pull-right">
|
||||
<div class="title-content">
|
||||
<p>今日执行任务失败的次数</p>
|
||||
<h3 class="number">0</h3>
|
||||
|
||||
<p>最近执行失败</p>
|
||||
<h3 class="number">{{.failJob}}</h3>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@@ -55,8 +55,8 @@
|
||||
<div class="w70 right-title pull-right">
|
||||
<div class="title-content">
|
||||
<p>即将执行的任务</p>
|
||||
<h3 class="number">1</h3>
|
||||
|
||||
<h3 class="number">{{.startJob}}</h3>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@@ -70,13 +70,13 @@
|
||||
<div class="w70 right-title pull-right">
|
||||
<div class="title-content">
|
||||
<p>定时任务总数量</p>
|
||||
<h3 class="number">10</h3>
|
||||
<h3 class="number">{{.totalJob}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<!--信息列表-->
|
||||
<div class="row newslist" style="margin-top:20px;">
|
||||
<div class="col-md-6">
|
||||
@@ -122,7 +122,7 @@
|
||||
{{range $k, $v := .jobs}}
|
||||
<div class="panel-body">
|
||||
<div class="w50 pull-left">
|
||||
<a href="{{urlfor "TaskController.Logs" "id" $v.task_id}}" class="news-item-title">{{$v.task_name}} # {{$v.task_id}}</a>
|
||||
<a href="{{urlfor "TaskController.Logs" "id" $v.task_id}}" class="news-item-title">{{$v.task_name}}-{{$v.task_group}} # {{$v.task_id}}</a>
|
||||
</div>
|
||||
<div class="w50 pull-left">{{$v.next_time}}</div>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="form-group" style="margin-top: 15px">
|
||||
<label class="col-sm-3 control-label" for="task_name">任务名称</label>
|
||||
<div class="col-sm-3" >
|
||||
<input type="text" class="form-control input-sm" placeholder="任务名称" name="task_name" value="" required />
|
||||
<input type="text" class="form-control input-sm" placeholder="不需要带分组名称" name="task_name" value="" required />
|
||||
</div>
|
||||
<div class="col-sm-6" style="padding-top:5px;">
|
||||
<i style="color:red">*</i>
|
||||
|
||||
@@ -79,7 +79,9 @@
|
||||
<span class="glyphicon glyphicon-ok-sign brand-success " aria-hidden="true"></span>
|
||||
{{end}}
|
||||
|
||||
{{$v.name}}
|
||||
{{$v.name}}-{{$v.group_name}}
|
||||
|
||||
|
||||
</td>
|
||||
<td> {{$v.cron_spec}} </td>
|
||||
<td> {{$v.description}} </td>
|
||||
|
||||
Reference in New Issue
Block a user