Skip to content

Commit

Permalink
improve: show job name in excuting list
Browse files Browse the repository at this point in the history
  • Loading branch information
QLeelulu committed Sep 22, 2018
1 parent 8fbb71c commit a69961d
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 124 deletions.
20 changes: 17 additions & 3 deletions web/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (j *Job) GetExecutingJob(ctx *Context) {
return
}

var list = make([]*cronsun.Process, 0, 8)
var list = make([]*processInfo, 0, 8)
for i := range gresp.Kvs {
proc, err := cronsun.GetProcFromKey(string(gresp.Kvs[i].Key))
if err != nil {
Expand All @@ -358,7 +358,16 @@ func (j *Job) GetExecutingJob(ctx *Context) {
continue
}
proc.ProcessVal = *pv
list = append(list, proc)
procInfo := &processInfo{
Process: proc,
}
job, err := cronsun.GetJob(proc.Group, proc.JobID)
if err == nil && job != nil {
procInfo.JobName = job.Name
} else {
procInfo.JobName = proc.JobID
}
list = append(list, procInfo)
}

sort.Sort(ByProcTime(list))
Expand Down Expand Up @@ -441,7 +450,12 @@ func (opt *ProcFetchOptions) Match(proc *cronsun.Process) bool {
return true
}

type ByProcTime []*cronsun.Process
type processInfo struct {
*cronsun.Process
JobName string `json:"jobName"`
}

type ByProcTime []*processInfo

func (a ByProcTime) Len() int { return len(a) }
func (a ByProcTime) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
Expand Down
288 changes: 171 additions & 117 deletions web/static_assets.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div id="app">
<div id="initloader"></div>
</div>
<script src="build.js?v=265aca8"></script>
<script src="build.js?v=8fbb71c"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion web/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot",
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot --disableHostCheck=true",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules && cp index.html ./dist/",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
4 changes: 2 additions & 2 deletions web/ui/src/components/JobExecuting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<table class="ui hover blue table" v-if="executings.length > 0">
<thead>
<tr>
<th class="center aligned">{{$L('job ID')}}</th>
<th class="center aligned">{{$L('job name')}}</th>
<th width="200px" class="center aligned">{{$L('job group')}}</th>
<th class="center aligned">{{$L('node')}}</th>
<th class="center aligned">{{$L('process ID')}}</th>
Expand All @@ -39,7 +39,7 @@
</thead>
<tbody>
<tr v-for="(proc, index) in executings">
<td class="center aligned"><router-link :to="'/job/edit/'+proc.group+'/'+proc.jobId">{{proc.jobId}}</router-link></td>
<td class="center aligned"><router-link :to="'/job/edit/'+proc.group+'/'+proc.jobId">{{proc.jobName}}</router-link></td>
<td class="center aligned">{{proc.group}}</td>
<td class="center aligned">{{$store.getters.hostshows(proc.nodeId)}}</td>
<td class="center aligned">{{proc.id}}</td>
Expand Down

0 comments on commit a69961d

Please sign in to comment.