mirror of https://github.com/shunfei/cronsun
添加报警功能
parent
75c4519565
commit
8a1f13d677
|
@ -63,7 +63,7 @@ type Job struct {
|
|||
// 执行失败发送通知
|
||||
FailNotify bool `json:"fail_notify"`
|
||||
// 发送通知地址
|
||||
To []string
|
||||
To []string `json:"to"`
|
||||
|
||||
// 执行任务的结点,用于记录 job log
|
||||
runOn string
|
||||
|
|
|
@ -11,7 +11,9 @@ type Configuration struct{}
|
|||
func (cnf *Configuration) Configuratios(w http.ResponseWriter, r *http.Request) {
|
||||
outJSON(w, struct {
|
||||
Security *conf.Security `json:"security"`
|
||||
Alarm bool `json:"alarm"`
|
||||
}{
|
||||
Security: conf.Config.Security,
|
||||
Alarm: conf.Config.Mail.Enable,
|
||||
})
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,11 +4,15 @@
|
|||
</div>
|
||||
<form v-else class="ui form" v-bind:class="{loading:loading}" v-on:submit.prevent>
|
||||
<h3 class="ui header">{{action == 'CREATE' ? '添加' : '更新'}}任务
|
||||
<em v-if="job.id"> ID# {{job.id}}</em>
|
||||
<div class="ui toggle checkbox" ref="pause">
|
||||
<input type="checkbox" class="hidden" v-bind:checked="!job.pause">
|
||||
<label v-bind:style="{color: (job.pause?'red':'green')+' !important'}">{{job.pause ? '任务已暂停' : '开启'}}</label>
|
||||
<label v-bind:style="{color: (job.pause?'red':'green')+' !important'}">{{job.pause ? '任务暂停' : '任务开启'}}</label>
|
||||
</div>
|
||||
<div class="ui toggle checkbox" ref="fail_notify" v-if="$appConfig.alarm">
|
||||
<input type="checkbox" class="hidden" v-bind:checked="job.fail_notify">
|
||||
<label>{{job.fail_notify ? '开启报警' : '关闭报警'}}</label>
|
||||
</div>
|
||||
<em v-if="job.id"> ID# {{job.id}}</em>
|
||||
</h3>
|
||||
<div class="inline fields" ref="kind">
|
||||
<label>任务类型</label>
|
||||
|
@ -54,6 +58,10 @@
|
|||
<input v-else type="text" v-model="job.user" placeholder="指定执行用户">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" v-if="$appConfig.alarm && job.fail_notify">
|
||||
<label>指定报警额外接受人</label>
|
||||
<Dropdown title="邮件地址" v-bind:items="alarmReceivers" v-bind:selected="job.to" v-on:change="changeAlarmReceiver" v-bind:multiple="true" v-bind:allowAdditions="true"/>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>超时设置(单位“秒”,0 表示不限制)</label>
|
||||
|
@ -102,6 +110,7 @@ export default {
|
|||
return {
|
||||
action: 'CREATE',
|
||||
groups: [],
|
||||
alarmReceivers: [],
|
||||
loading: false,
|
||||
allowSuffixsTip: '',
|
||||
job: {
|
||||
|
@ -117,7 +126,9 @@ export default {
|
|||
timeout: 0,
|
||||
interval: 0,
|
||||
retry: 0,
|
||||
rules: []
|
||||
rules: [],
|
||||
fail_notify: false,
|
||||
to: []
|
||||
},
|
||||
error: ''
|
||||
}
|
||||
|
@ -145,6 +156,10 @@ export default {
|
|||
this.job.user = val;
|
||||
},
|
||||
|
||||
changeAlarmReceiver: function(val, text){
|
||||
this.job.to = val.split(',');
|
||||
},
|
||||
|
||||
removeRule: function(index){
|
||||
this.job.rules.splice(index, 1);
|
||||
},
|
||||
|
@ -185,6 +200,7 @@ export default {
|
|||
this.$rest.GET('job/'+this.$route.params.group+'-'+this.$route.params.id).
|
||||
onsucceed(200, (resp)=>{
|
||||
vm.job = resp;
|
||||
vm.alarmReceivers = resp.to;
|
||||
vm.job.oldGroup = resp.group;
|
||||
if (vm.job.rules) {
|
||||
for (var i in vm.job.rules) {
|
||||
|
@ -209,6 +225,12 @@ export default {
|
|||
}
|
||||
});
|
||||
|
||||
$(this.$refs.fail_notify).checkbox({
|
||||
onChange: function(){
|
||||
vm.job.fail_notify = !vm.job.fail_notify;
|
||||
}
|
||||
});
|
||||
|
||||
$(this.$refs.kind).find('.checkbox').checkbox({
|
||||
onChange: function(){
|
||||
vm.job.kind = +$(vm.$refs.kind).find('input[type=radio]:checked').val();
|
||||
|
|
Loading…
Reference in New Issue