mirror of https://github.com/shunfei/cronsun
Fix style and job edit page bug
parent
5577e57633
commit
ed99459bfc
|
@ -1,17 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Cronsun Managerment</title>
|
||||
<style>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Cronsun Managerment</title>
|
||||
<style>
|
||||
.initial.error {
|
||||
margin: 170px 80px;
|
||||
color: red;
|
||||
font-size: 2em;
|
||||
line-height: 2em;
|
||||
}
|
||||
.loader, .loader:after {border-radius: 50%; width: 10em; height: 10em;}
|
||||
.loader {
|
||||
|
||||
#initloader,
|
||||
#initloader:after {
|
||||
border-radius: 50%;
|
||||
width: 10em;
|
||||
height: 10em;
|
||||
}
|
||||
|
||||
#initloader {
|
||||
margin: 180px auto;
|
||||
font-size: 10px;
|
||||
position: relative;
|
||||
|
@ -24,20 +32,36 @@
|
|||
-webkit-animation: load8 1.1s infinite linear;
|
||||
animation: load8 1.1s infinite linear;
|
||||
}
|
||||
|
||||
@-webkit-keyframes load8 {
|
||||
0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
|
||||
100% {-webkit-transform: rotate(360deg); transform: rotate(360deg);}
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes load8 {
|
||||
0% {-webkit-transform: rotate(0deg); transform: rotate(0deg);}
|
||||
100% {-webkit-transform: rotate(360deg); transform: rotate(360deg);}
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
<script src="build.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<div id="initloader"></div>
|
||||
</div>
|
||||
<script src="build.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -48,7 +48,7 @@ export default {
|
|||
vm.$store.commit('setEmail', resp.email);
|
||||
vm.$store.commit('setRole', resp.role);
|
||||
|
||||
vm.getConfig();
|
||||
vm.$loadConfiguration();
|
||||
}).onfailed((data, xhr) => {
|
||||
if (xhr.status !== 401) {
|
||||
vm.$bus.$emit('error', data);
|
||||
|
@ -83,19 +83,6 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
getConfig() {
|
||||
this.$rest.GET('configurations').
|
||||
onsucceed(200, (resp)=>{
|
||||
const Config = (Vue, options)=>{
|
||||
Vue.prototype.$appConfig = resp;
|
||||
}
|
||||
Vue.use(Config);
|
||||
}).onfailed((data, xhr)=>{
|
||||
var msg = data ? data : xhr.status+' '+xhr.statusText;
|
||||
vm.$bus.$emit('error', msg);
|
||||
}).do();
|
||||
},
|
||||
|
||||
logout() {
|
||||
var vm = this;
|
||||
this.$rest.DELETE('session').
|
||||
|
|
|
@ -83,7 +83,7 @@ export default {
|
|||
status: resp.status,
|
||||
}
|
||||
}).
|
||||
onfailed((msg)=>{vm.$bus.$emit(msg)}).
|
||||
onfailed((msg)=>{vm.$bus.$emit('error', msg)}).
|
||||
onend(()=>{vm.loading = false}).
|
||||
do();
|
||||
}
|
||||
|
|
|
@ -1,248 +1,30 @@
|
|||
<template>
|
||||
<div v-if="error != ''" class="ui negative message">
|
||||
<div class="header"><i class="attention icon"></i> {{error}}</div>
|
||||
<div v-if="confLoading" class="ui segment" style="height:180px; z-index: 10;">
|
||||
<div class="ui active inverted dimmer">
|
||||
<div class="ui large text loader">{{$L('loading configurations')}}...</div>
|
||||
</div>
|
||||
</div>
|
||||
<form v-else class="ui form" v-bind:class="{loading:loading}" v-on:submit.prevent>
|
||||
<h3 class="ui header">{{$L(action == 'CREATE' ? 'create job' : 'update job')}}
|
||||
<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'}">{{$L(job.pause ? 'pause' : 'open')}}</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>{{$L(job.fail_notify ? 'warning on' : 'warning off')}}</label>
|
||||
</div>
|
||||
</h3>
|
||||
<div class="inline fields" ref="kind">
|
||||
<label>{{$L('job type')}}</label>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="0" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('common job')}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="1" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('single node single process')}}
|
||||
<i class="help circle link icon" data-position="top right" :data-html="$L('at the same time only one job process is executed on one of node')" data-variation="wide"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="2" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('group level common')}}
|
||||
<i class="help circle link icon" data-position="top right" :data-html="$L('group level common help')" data-variation="wide"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>{{$L('job name')}}</label>
|
||||
<input type="text" ref="name" v-bind:value="job.name" v-on:input="updateValue($event.target.value)" :placeholder="$L('job name')">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{$L('job group')}}</label>
|
||||
<Dropdown :title="$L('select a group')" v-bind:allowAdditions="true" v-bind:items="groups" v-bind:selected="job.group" v-on:change="changeGroup"></Dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="twelve wide field">
|
||||
<label>{{$L('script path')}} {{allowSuffixsTip}}</label>
|
||||
<input type="text" v-model="job.cmd" :placeholder="$L('script path')">
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<label>{{$L($appConfig.security.open ? 'user(required)' : 'user(optional)')}}</label>
|
||||
<Dropdown v-if="$appConfig.security.open" :title="$L('the user which to execute the command')" v-bind:items="$appConfig.security.users" v-bind:selected="job.user" v-on:change="changeUser"></Dropdown>
|
||||
<input v-else type="text" v-model="job.user" :placeholder="$L('the user which to execute the command')">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" v-if="$appConfig.alarm && job.fail_notify">
|
||||
<label>{{$L('warning receiver')}}</label>
|
||||
<Dropdown :title="$L('e-mail address')" 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>{{$L('timeout(in seconds, 0 for no limits)')}}</label>
|
||||
<input type="number" ref="timeout" v-model.number="job.timeout">
|
||||
</div>
|
||||
<div class="field" v-show="job.kind === 0">
|
||||
<label>{{$L('parallel number in one node(0 for no limits)')}}</label>
|
||||
<input type="number" ref="parallels" v-model.number="job.parallels">
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>{{$L('retries(number of retries when failed, 0 means no retry)')}}</label>
|
||||
<input type="number" ref="retry" v-model.number="job.retry">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{$L('retry interval(in seconds)')}}</label>
|
||||
<input type="number" ref="interval" v-model.number="job.interval">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span v-if="!job.rules || job.rules.length == 0"><i class="warning circle icon"></i>{{$L('the job dose not have a timer currently, please click the button below to add a timer')}}</span>
|
||||
</div>
|
||||
<JobEditRule v-for="(rule, index) in job.rules" :key="rule.id" v-bind:rule="rule" :index="index" v-on:remove="removeRule" v-on:change="changeRule"/>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<button class="fluid ui button" v-on:click="addNewTimer" type="button"><i class="history icon"></i> {{$L('add timer')}}</button>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="fluid blue ui button" type="button" v-on:click="submit"><i class="upload icon"></i> {{$L('save job')}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<JobEditForm v-else/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import JobEditRule from './JobEditRule.vue';
|
||||
import Dropdown from './basic/Dropdown.vue';
|
||||
import {split} from '../libraries/functions';
|
||||
import JobEditForm from './JobEditForm.vue';
|
||||
|
||||
export default {
|
||||
name: 'job-edit',
|
||||
data: function(){
|
||||
return {
|
||||
action: 'CREATE',
|
||||
groups: [],
|
||||
alarmReceivers: [],
|
||||
loading: false,
|
||||
allowSuffixsTip: '',
|
||||
job: {
|
||||
id: '',
|
||||
kind: 0, // 0 == 普通任务,1 == 单机任务
|
||||
name: '',
|
||||
oldGroup: '',
|
||||
group: '',
|
||||
user: '',
|
||||
cmd: '',
|
||||
pause: false,
|
||||
parallels: 0,
|
||||
timeout: 0,
|
||||
interval: 0,
|
||||
retry: 0,
|
||||
rules: [],
|
||||
fail_notify: false,
|
||||
to: []
|
||||
},
|
||||
error: ''
|
||||
confLoading: true
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateValue: function(v){
|
||||
var tv = v.replace(/[\*\/]/g, '');
|
||||
this.job.name = tv;
|
||||
if (tv !== v) {
|
||||
this.$refs.name.value = tv;
|
||||
}
|
||||
},
|
||||
|
||||
addNewTimer: function(){
|
||||
if (!this.job.rules) this.job.rules = [];
|
||||
this.job.rules.push({id: this.newRandomRuleId()});
|
||||
},
|
||||
|
||||
changeGroup: function(val, text){
|
||||
this.job.group = val;
|
||||
},
|
||||
|
||||
changeUser: function(val, text){
|
||||
this.job.user = val;
|
||||
},
|
||||
|
||||
changeAlarmReceiver: function(val, text){
|
||||
this.job.to = split(val, ',');
|
||||
},
|
||||
|
||||
removeRule: function(index){
|
||||
this.job.rules.splice(index, 1);
|
||||
},
|
||||
|
||||
changeRule: function(index, key, val){
|
||||
this.job.rules[index][key] = val;
|
||||
},
|
||||
|
||||
submit: function(){
|
||||
var exceptCode = this.action == 'CREATE' ? 201 : 200;
|
||||
this.loading = true;
|
||||
var vm = this;
|
||||
this.$rest.PUT('job', this.job)
|
||||
.onsucceed(exceptCode, ()=>{vm.$router.push('/job')})
|
||||
.onfailed((resp)=>{vm.$bus.$emit('error', resp)})
|
||||
.onend(()=>{vm.loading=false})
|
||||
.do();
|
||||
},
|
||||
|
||||
newRandomRuleId: function(){
|
||||
return 'NEW'+Math.random().toString();
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function(){
|
||||
var vm = this;
|
||||
var secCnf = this.$appConfig.security;
|
||||
if (secCnf.open) {
|
||||
if (secCnf.ext && secCnf.ext.length > 0) {
|
||||
this.allowSuffixsTip = this.$L('(only [{.suffixs}] files can be allowed)', secCnf.ext.join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.$route.path.indexOf('/job/create') === 0) {
|
||||
this.action = 'CREATE';
|
||||
} else {
|
||||
this.action = 'UPDATE';
|
||||
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) {
|
||||
if (vm.job.rules[i].id.length == 0) {
|
||||
vm.job.rules[i].id = vm.newRandomRuleId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}).
|
||||
onfailed((msg)=>{vm.error = msg}).
|
||||
do();
|
||||
}
|
||||
|
||||
this.$rest.GET('job/groups').onsucceed(200, (resp)=>{
|
||||
!resp.includes('default') && resp.unshift('default');
|
||||
vm.groups = resp;
|
||||
}).do();
|
||||
|
||||
$(this.$refs.pause).checkbox({
|
||||
onChange: function(){
|
||||
vm.job.pause = !vm.job.pause;
|
||||
}
|
||||
});
|
||||
|
||||
$(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();
|
||||
}
|
||||
});
|
||||
|
||||
$(this.$el).find('i.help.icon').popup();
|
||||
this.$onConfigLoaded(() => vm.confLoading = false);
|
||||
},
|
||||
|
||||
components: {
|
||||
JobEditRule,
|
||||
Dropdown
|
||||
JobEditForm
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,242 @@
|
|||
<template>
|
||||
<form class="ui form" v-bind:class="{loading:loading}" v-on:submit.prevent>
|
||||
<h3 class="ui header">{{$L(action == 'CREATE' ? 'create job' : 'update job')}}
|
||||
<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'}">{{$L(job.pause ? 'pause' : 'open')}}</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>{{$L(job.fail_notify ? 'warning on' : 'warning off')}}</label>
|
||||
</div>
|
||||
</h3>
|
||||
<div class="inline fields" ref="kind">
|
||||
<label>{{$L('job type')}}</label>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="0" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('common job')}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="1" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('single node single process')}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" v-model="job.kind" name="kind" value="2" tabindex="0" class="hidden"/>
|
||||
<label>{{$L('group level common')}}
|
||||
<i class="help circle link icon" data-position="top right" :data-html="$L('group level common help')" data-variation="wide"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>{{$L('job name')}}</label>
|
||||
<input type="text" ref="name" v-bind:value="job.name" v-on:input="updateValue($event.target.value)" :placeholder="$L('job name')">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{$L('job group')}}</label>
|
||||
<Dropdown :title="$L('select a group')" v-bind:allowAdditions="true" v-bind:items="groups" v-bind:selected="job.group" v-on:change="changeGroup"></Dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="twelve wide field">
|
||||
<label>{{$L('script path')}} {{allowSuffixsTip}}</label>
|
||||
<input type="text" v-model="job.cmd" :placeholder="$L('script path')">
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<label>{{$L($appConfig.security.open ? 'user(required)' : 'user(optional)')}}</label>
|
||||
<Dropdown v-if="$appConfig.security.open" :title="$L('the user which to execute the command')" v-bind:items="$appConfig.security.users" v-bind:selected="job.user" v-on:change="changeUser"></Dropdown>
|
||||
<input v-else type="text" v-model="job.user" :placeholder="$L('the user which to execute the command')">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" v-if="$appConfig.alarm && job.fail_notify">
|
||||
<label>{{$L('warning receiver')}}</label>
|
||||
<Dropdown :title="$L('e-mail address')" 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>{{$L('timeout(in seconds, 0 for no limits)')}}</label>
|
||||
<input type="number" ref="timeout" v-model.number="job.timeout">
|
||||
</div>
|
||||
<div class="field" v-show="job.kind === 0">
|
||||
<label>{{$L('parallel number in one node(0 for no limits)')}}</label>
|
||||
<input type="number" ref="parallels" v-model.number="job.parallels">
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>{{$L('retries(number of retries when failed, 0 means no retry)')}}</label>
|
||||
<input type="number" ref="retry" v-model.number="job.retry">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{$L('retry interval(in seconds)')}}</label>
|
||||
<input type="number" ref="interval" v-model.number="job.interval">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span v-if="!job.rules || job.rules.length == 0"><i class="warning circle icon"></i>{{$L('the job dose not have a timer currently, please click the button below to add a timer')}}</span>
|
||||
</div>
|
||||
<JobEditRule v-for="(rule, index) in job.rules" :key="rule.id" v-bind:rule="rule" :index="index" v-on:remove="removeRule" v-on:change="changeRule"/>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<button class="fluid ui button" v-on:click="addNewTimer" type="button"><i class="history icon"></i> {{$L('add timer')}}</button>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="fluid blue ui button" type="button" v-on:click="submit"><i class="upload icon"></i> {{$L('save job')}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import JobEditRule from './JobEditRule.vue';
|
||||
import Dropdown from './basic/Dropdown.vue';
|
||||
import {split} from '../libraries/functions';
|
||||
|
||||
export default {
|
||||
name: 'job-edit-form',
|
||||
data: function(){
|
||||
return {
|
||||
action: 'CREATE',
|
||||
groups: [],
|
||||
alarmReceivers: [],
|
||||
loading: false,
|
||||
allowSuffixsTip: '',
|
||||
job: {
|
||||
id: '',
|
||||
kind: 0, // 0 == 普通任务,1 == 单机任务
|
||||
name: '',
|
||||
oldGroup: '',
|
||||
group: '',
|
||||
user: '',
|
||||
cmd: '',
|
||||
pause: false,
|
||||
parallels: 0,
|
||||
timeout: 0,
|
||||
interval: 0,
|
||||
retry: 0,
|
||||
rules: [],
|
||||
fail_notify: false,
|
||||
to: []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateValue: function(v){
|
||||
var tv = v.replace(/[\*\/]/g, '');
|
||||
this.job.name = tv;
|
||||
if (tv !== v) {
|
||||
this.$refs.name.value = tv;
|
||||
}
|
||||
},
|
||||
|
||||
addNewTimer: function(){
|
||||
if (!this.job.rules) this.job.rules = [];
|
||||
this.job.rules.push({id: this.newRandomRuleId()});
|
||||
},
|
||||
|
||||
changeGroup: function(val, text){
|
||||
this.job.group = val;
|
||||
},
|
||||
|
||||
changeUser: function(val, text){
|
||||
this.job.user = val;
|
||||
},
|
||||
|
||||
changeAlarmReceiver: function(val, text){
|
||||
this.job.to = split(val, ',');
|
||||
},
|
||||
|
||||
removeRule: function(index){
|
||||
this.job.rules.splice(index, 1);
|
||||
},
|
||||
|
||||
changeRule: function(index, key, val){
|
||||
this.job.rules[index][key] = val;
|
||||
},
|
||||
|
||||
submit: function(){
|
||||
var exceptCode = this.action == 'CREATE' ? 201 : 200;
|
||||
this.loading = true;
|
||||
var vm = this;
|
||||
this.$rest.PUT('job', this.job)
|
||||
.onsucceed(exceptCode, ()=>{vm.$router.push('/job')})
|
||||
.onfailed((resp)=>{vm.$bus.$emit('error', resp)})
|
||||
.onend(()=>{vm.loading=false})
|
||||
.do();
|
||||
},
|
||||
|
||||
newRandomRuleId: function(){
|
||||
return 'NEW'+Math.random().toString();
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function(){
|
||||
var vm = this;
|
||||
var secCnf = vm.$appConfig.security;
|
||||
if (secCnf.open) {
|
||||
if (secCnf.ext && secCnf.ext.length > 0) {
|
||||
vm.allowSuffixsTip = vm.$L('(only [{.suffixs}] files can be allowed)', secCnf.ext.join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.$route.path.indexOf('/job/create') === 0) {
|
||||
vm.action = 'CREATE';
|
||||
} else {
|
||||
vm.action = 'UPDATE';
|
||||
vm.$rest.GET('job/'+vm.$route.params.group+'-'+vm.$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) {
|
||||
if (vm.job.rules[i].id.length == 0) {
|
||||
vm.job.rules[i].id = vm.newRandomRuleId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}).
|
||||
onfailed((msg)=> vm.$bus.$emit('error', data)).
|
||||
do();
|
||||
}
|
||||
|
||||
vm.$rest.GET('job/groups').onsucceed(200, (resp)=>{
|
||||
!resp.includes('default') && resp.unshift('default');
|
||||
vm.groups = resp;
|
||||
}).do();
|
||||
|
||||
$(vm.$refs.pause).checkbox({
|
||||
onChange: function(){
|
||||
vm.job.pause = !vm.job.pause;
|
||||
}
|
||||
});
|
||||
|
||||
$(vm.$refs.fail_notify).checkbox({
|
||||
onChange: function(){
|
||||
vm.job.fail_notify = !vm.job.fail_notify;
|
||||
}
|
||||
});
|
||||
|
||||
$(vm.$refs.kind).find('.checkbox').checkbox({
|
||||
onChange: function(){
|
||||
vm.job.kind = +$(vm.$refs.kind).find('input[type=radio]:checked').val();
|
||||
}
|
||||
});
|
||||
|
||||
$(vm.$el).find('i.help.icon').popup();
|
||||
},
|
||||
|
||||
components: {
|
||||
JobEditRule,
|
||||
Dropdown
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -62,21 +62,9 @@ export default {
|
|||
vm.$store.commit('setRole', resp.role);
|
||||
vm.$store.commit('enabledAuth', resp.enabledAuth);
|
||||
vm.$router.push('/')
|
||||
vm.getConfig();
|
||||
vm.$loadConfiguration();
|
||||
}).
|
||||
do();
|
||||
},
|
||||
|
||||
getConfig(){
|
||||
this.$rest.GET('configurations').onsucceed(200, (resp)=>{
|
||||
const Config = (Vue, options)=>{
|
||||
Vue.prototype.$appConfig = resp;
|
||||
}
|
||||
Vue.use(Config);
|
||||
}).onfailed((data, xhr)=>{
|
||||
var msg = data ? data : xhr.status+' '+xhr.statusText;
|
||||
vm.$bus.$emit('error', msg);
|
||||
}).do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,13 +80,13 @@ var language = {
|
|||
'command': 'Command',
|
||||
'spend time': 'Spend time',
|
||||
'result': 'Result',
|
||||
'loading configurations': 'Loading configurations',
|
||||
|
||||
'job type': 'Job type',
|
||||
'common job': 'Common',
|
||||
'single node single process': 'Single Node Single Process',
|
||||
'at the same time only one job process is executed on the cluster': 'At the same time only one job process is executed on the cluster',
|
||||
'group level common': 'Group Level Common',
|
||||
'group level common help': 'It is difficult to name it, a simple way to explain is that we merge all selected nodes as a large node, then the kind of job behavior will looks like a Common job in a single node.',
|
||||
'group level common help': 'It is difficult to name it, a simple way to explain is that we merge all selected nodes as a large node, then the job\'s behavior will looks like a Common job in a single node.',
|
||||
'warning on': 'Warning ON',
|
||||
'warning off': 'Warning OFF',
|
||||
'job group': 'Job group',
|
||||
|
@ -101,7 +101,7 @@ var language = {
|
|||
'retries(number of retries when failed, 0 means no retry)': 'Retries(number of retries when failed, 0 means no retry)',
|
||||
'retry interval(in seconds)': 'Retry interval(in seconds)',
|
||||
'parallel number in one node(0 for no limits)': 'Parallel number in one node(0 for no limits)',
|
||||
'timeout(in seconds, 0 for no limits)':'Timeout(in seconds, 0 for no limits)',
|
||||
'timeout(in seconds, 0 for no limits)': 'Timeout(in seconds, 0 for no limits)',
|
||||
'<sec> <min> <hr> <day> <month> <week>, rule is same with Cron': '<sec> <min> <hr> <day> <month> <week>, rule is same with Cron',
|
||||
'and please running on those nodes': 'And please running on those nodes',
|
||||
'do not running on those nodes': 'Do not running on those nodes',
|
||||
|
|
|
@ -82,11 +82,11 @@ var language = {
|
|||
'command': '执行的命令',
|
||||
'spend time': '耗时',
|
||||
'result': '结果',
|
||||
'loading configurations': '正在加载配置',
|
||||
|
||||
'job type': '任务类型',
|
||||
'common job': '普通任务',
|
||||
'single node single process': '单机单进程',
|
||||
'at the same time only one job process is executed on the cluster': '同一时间集群中只有一个任务进程在执行',
|
||||
'group level common': '组级别普通任务',
|
||||
'group level common help': '暂时没想到好名字,一个比较简单的说明是,把所有选中的节点视为一个大节点,那么该类型的任务就相当于在单个节点上的普通任务',
|
||||
'warning on': '开启报警',
|
||||
|
@ -103,7 +103,7 @@ var language = {
|
|||
'retries(number of retries when failed, 0 means no retry)': '重试(失败时重试次数,0 为不重试)',
|
||||
'retry interval(in seconds)': '失败重试间隔时间(秒)',
|
||||
'parallel number in one node(0 for no limits)': '一个节点上面该任务并行数(0 表示不限制)',
|
||||
'timeout(in seconds, 0 for no limits)':'超时设置(单位“秒”,0 表示不限制)',
|
||||
'timeout(in seconds, 0 for no limits)': '超时设置(单位“秒”,0 表示不限制)',
|
||||
'<sec> <min> <hr> <day> <month> <week>, rule is same with Cron': '<秒> <分> <时> <日> <月> <周>,规则与 Cron 一样',
|
||||
'and please running on those nodes': '同时在这些节点上面运行',
|
||||
'do not running on those nodes': '不要在这些节点上面运行',
|
||||
|
|
|
@ -6,14 +6,14 @@ import Vue from 'vue';
|
|||
Vue.config.debug = true;
|
||||
|
||||
import Lang from './i18n/language';
|
||||
Vue.use((Vue)=>{
|
||||
Vue.use((Vue) => {
|
||||
Vue.prototype.$L = Lang.L
|
||||
Vue.prototype.$Lang = Lang
|
||||
});
|
||||
|
||||
// global event bus
|
||||
var bus = new Vue();
|
||||
Vue.use((Vue)=>{
|
||||
Vue.use((Vue) => {
|
||||
Vue.prototype.$bus = bus;
|
||||
});
|
||||
|
||||
|
@ -21,18 +21,57 @@ Vue.use((Vue)=>{
|
|||
import Rest from './libraries/rest-client.js';
|
||||
var restApi = new Rest('/v1/', (msg) => {
|
||||
bus.$emit('error', msg);
|
||||
}, (msg)=>{
|
||||
}, (msg) => {
|
||||
bus.$emit('error', msg);
|
||||
}, {
|
||||
401: (data, xhr) => {bus.$emit('goLogin')}
|
||||
});
|
||||
Vue.use((Vue, options)=>{
|
||||
401: (data, xhr) => { bus.$emit('goLogin') }
|
||||
});
|
||||
Vue.use((Vue, options) => {
|
||||
Vue.prototype.$rest = restApi;
|
||||
}, null);
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
Vue.use(VueRouter);
|
||||
|
||||
Vue.use((Vue) => {
|
||||
Vue.prototype.$loadConfiguration = () => {
|
||||
restApi.GET('configurations').
|
||||
onsucceed(200, (resp) => {
|
||||
const Config = (Vue, options) => {
|
||||
Vue.prototype.$appConfig = resp;
|
||||
}
|
||||
Vue.use(Config);
|
||||
bus.$emit('conf_loaded', resp);
|
||||
}).onfailed((data, xhr) => {
|
||||
var msg = data ? data : xhr.status + ' ' + xhr.statusText;
|
||||
bus.$emit('error', msg);
|
||||
}).do();
|
||||
}
|
||||
});
|
||||
|
||||
const onConfigLoaded = (Vue, options) => {
|
||||
let loaded = false;
|
||||
let queue = [];
|
||||
let appConfig;
|
||||
|
||||
Vue.prototype.$onConfigLoaded = (f) => {
|
||||
if (loaded) {
|
||||
f(appConfig);
|
||||
return;
|
||||
}
|
||||
queue.push(f);
|
||||
}
|
||||
|
||||
bus.$on('conf_loaded', (c) => {
|
||||
loaded = true;
|
||||
appConfig = c;
|
||||
queue.forEach((f) => {
|
||||
f(appConfig)
|
||||
})
|
||||
});
|
||||
}
|
||||
Vue.use(onConfigLoaded);
|
||||
|
||||
import App from './App.vue';
|
||||
import Dash from './components/Dash.vue';
|
||||
import Log from './components/Log.vue';
|
||||
|
@ -49,22 +88,22 @@ import Profile from './components/Profile.vue';
|
|||
import Login from './components/Login.vue';
|
||||
|
||||
var routes = [
|
||||
{path: '/', component: Dash},
|
||||
{path: '/log', component: Log},
|
||||
{path: '/log/:id', component: LogDetail},
|
||||
{path: '/job', component: Job},
|
||||
{path: '/job/create', component: JobEdit},
|
||||
{path: '/job/edit/:group/:id', component: JobEdit},
|
||||
{path: '/job/executing', component: JobExecuting},
|
||||
{path: '/node', component: Node},
|
||||
{path: '/node/group', component: NodeGroup},
|
||||
{path: '/node/group/create', component: NodeGroupEdit},
|
||||
{path: '/node/group/:id', component: NodeGroupEdit},
|
||||
{path: '/admin/account/list', component: Account},
|
||||
{path: '/admin/account/add', component: AccountEdit},
|
||||
{path: '/admin/account/edit', component: AccountEdit},
|
||||
{path: '/user/setpwd', component: Profile},
|
||||
{path: '/login', component: Login}
|
||||
{ path: '/', component: Dash },
|
||||
{ path: '/log', component: Log },
|
||||
{ path: '/log/:id', component: LogDetail },
|
||||
{ path: '/job', component: Job },
|
||||
{ path: '/job/create', component: JobEdit },
|
||||
{ path: '/job/edit/:group/:id', component: JobEdit },
|
||||
{ path: '/job/executing', component: JobExecuting },
|
||||
{ path: '/node', component: Node },
|
||||
{ path: '/node/group', component: NodeGroup },
|
||||
{ path: '/node/group/create', component: NodeGroupEdit },
|
||||
{ path: '/node/group/:id', component: NodeGroupEdit },
|
||||
{ path: '/admin/account/list', component: Account },
|
||||
{ path: '/admin/account/add', component: AccountEdit },
|
||||
{ path: '/admin/account/edit', component: AccountEdit },
|
||||
{ path: '/user/setpwd', component: Profile },
|
||||
{ path: '/login', component: Login }
|
||||
];
|
||||
|
||||
var router = new VueRouter({
|
||||
|
|
Loading…
Reference in New Issue