mirror of https://github.com/shunfei/cronsun
Node page
parent
3f293a91ab
commit
ff1d79bb4a
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
DefaultJobGroup = "Default"
|
||||
DefaultJobGroup = "default"
|
||||
)
|
||||
|
||||
// 需要执行的 cron cmd 命令
|
||||
|
|
|
@ -61,16 +61,15 @@ func (n *Node) Exist() (pid int, err error) {
|
|||
return -1, nil
|
||||
}
|
||||
|
||||
var procKeyLen = len(conf.Config.Proc)
|
||||
|
||||
func GetActivityNodeList() (ids []string, err error) {
|
||||
func GetActivityNodeList() (nodes []string, err error) {
|
||||
resp, err := DefalutClient.Get(conf.Config.Proc, client.WithPrefix(), client.WithKeysOnly())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
procKeyLen := len(conf.Config.Proc)
|
||||
for _, n := range resp.Kvs {
|
||||
ids = append(ids, string(n.Key[procKeyLen:]))
|
||||
nodes = append(nodes, string(n.Key[procKeyLen:]))
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -80,8 +80,6 @@ func (j *Job) UpdateJob(w http.ResponseWriter, r *http.Request) {
|
|||
outJSONWithCode(w, successCode, nil)
|
||||
}
|
||||
|
||||
var cmdKeyDeepLen = len(strings.Split(conf.Config.Cmd, "/"))
|
||||
|
||||
func (j *Job) GetGroups(w http.ResponseWriter, r *http.Request) {
|
||||
resp, err := models.DefalutClient.Get(conf.Config.Cmd, clientv3.WithPrefix(), clientv3.WithKeysOnly())
|
||||
if err != nil {
|
||||
|
@ -89,10 +87,12 @@ func (j *Job) GetGroups(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
var cmdKeyLen = len(conf.Config.Cmd)
|
||||
var groupMap = make(map[string]bool, 8)
|
||||
|
||||
for i := range resp.Kvs {
|
||||
ss := strings.Split(string(resp.Kvs[i].Key), "/")
|
||||
groupMap[ss[cmdKeyDeepLen]] = true
|
||||
ss := strings.Split(string(resp.Kvs[i].Key)[cmdKeyLen:], "/")
|
||||
groupMap[ss[0]] = true
|
||||
}
|
||||
|
||||
var groupList = make([]string, 0, len(groupMap))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<router-link class="item" to="/" v-bind:class="{active: this.$route.path == '/'}"><i class="dashboard icon"></i> 仪表盘</router-link>
|
||||
<router-link class="item" to="/log" v-bind:class="{active: this.$route.path.indexOf('/log') === 0}"><i class="file text icon"></i> 日志</router-link>
|
||||
<router-link class="item" to="/job" v-bind:class="{active: this.$route.path.indexOf('/job') === 0}"><i class="calendar icon"></i> 任务</router-link>
|
||||
<router-link class="item" to="/node" v-bind:class="{active: this.$route.path.indexOf('/node') === 0}"><i class="tasks icon"></i> 节点</router-link>
|
||||
<router-link class="item" to="/node" v-bind:class="{active: this.$route.path.indexOf('/node') === 0}"><i class="server icon"></i> 节点</router-link>
|
||||
</div>
|
||||
<div style="height: 55px;"></div>
|
||||
<div class="ui container">
|
||||
|
|
|
@ -1,16 +1,42 @@
|
|||
<template>
|
||||
<div>
|
||||
<job-toolbar></job-toolbar>
|
||||
<JobToolbar/>
|
||||
<form class="ui form">
|
||||
<div class="field">
|
||||
<label>任务分组</label>
|
||||
<Dropdown title="选择分组" v-bind:items="groups" v-on:change="changeGroup"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import JobToolbar from './JobToolbar.vue';
|
||||
import Dropdown from './basic/Dropdown.vue';
|
||||
|
||||
export default {
|
||||
name: 'job',
|
||||
data: function(){
|
||||
return {
|
||||
groups: []
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function(){
|
||||
var vm = this;
|
||||
this.$rest.GET('job/groups').onsucceed(200, (resp)=>{
|
||||
!resp.includes('default') && resp.unshift('default');
|
||||
vm.groups = resp;
|
||||
}).do();
|
||||
},
|
||||
|
||||
methods: {
|
||||
changeGroup: function(){}
|
||||
},
|
||||
|
||||
components: {
|
||||
JobToolbar
|
||||
JobToolbar,
|
||||
Dropdown
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,5 +1,7 @@
|
|||
<template>
|
||||
<router-link class="ui button" to="/job/create"><i class="add to calendar icon"></i> 新任务</router-link>
|
||||
<div>
|
||||
<router-link class="ui right floated primary button" to="/job/create"><i class="add to calendar icon"></i> 新任务</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
<template>
|
||||
<div>node</div>
|
||||
<div>
|
||||
<h3 class="ui horizontal divider header">当前活动节点: {{count}}</h3>
|
||||
<div class="ui label" v-for="node in nodes"><i class="cube icon"></i> {{node}}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'node'
|
||||
name: 'node',
|
||||
data: function(){
|
||||
return {
|
||||
count: 0,
|
||||
nodes: []
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function(){
|
||||
var vm = this;
|
||||
this.$rest.GET('node/activitys').onsucceed(200, (resp)=>{
|
||||
vm.nodes = resp;
|
||||
vm.count = resp.length;
|
||||
}).do();
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue