Merge pull request #66 from tikazyq/develop

Develop
This commit is contained in:
Marvin Zhang
2019-06-18 12:35:26 +08:00
committed by GitHub
4 changed files with 59 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
# 0.2.4 (unreleased)
- **Documentation**: Better and much more detailed documentation.
- **Better Crontab**: Make crontab expression through crontab UI.
# 0.2.3 (2019-06-12)

View File

@@ -22,6 +22,7 @@
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path": "^0.12.7",
"vcrontab": "^0.3.3",
"vue": "^2.5.22",
"vue-ba": "^1.2.5",
"vue-codemirror-lite": "^1.0.4",

View File

@@ -29,12 +29,17 @@
</span>
</el-tooltip>
</template>
<el-input v-model="scheduleForm.cron" :placeholder="$t('Cron')"></el-input>
<el-input style="width:calc(100% - 100px);padding-right:10px"
v-model="scheduleForm.cron"
:placeholder="$t('Cron')">
</el-input>
<el-button style="width:100px" type="primary" @click="onShowCronDialog">{{$t('生成Cron')}}</el-button>
</el-form-item>
<el-form-item :label="$t('Execute Command')" prop="params">
<el-input v-model="spider.cmd"
:placeholder="$t('Execute Command')"
disabled></el-input>
disabled>
</el-input>
</el-form-item>
<el-form-item :label="$t('Parameters')" prop="params">
<el-input v-model="scheduleForm.params"
@@ -51,6 +56,11 @@
</span>
</el-dialog>
<!--cron generation popup-->
<el-dialog title="生成 Cron" :visible.sync="showCron">
<vcrontab @hide="showCron=false" @fill="onCrontabFill" :expression="expression"></vcrontab>
</el-dialog>
<!--filter-->
<div class="filter">
<div class="right">
@@ -95,19 +105,21 @@
</template>
<script>
import vcrontab from 'vcrontab'
import {
mapState
} from 'vuex'
export default {
name: 'ScheduleList',
components: { vcrontab },
data () {
const cronValidator = (rule, value, callback) => {
let patArr = []
for (let i = 0; i < 6; i++) {
patArr.push('[/*,0-9]+')
patArr.push('[/*,0-9-]+')
}
const pat = '^' + patArr.join(' ') + '$'
const pat = '^' + patArr.join(' ') + '( [/*,0-9-]+)?' + '$'
if (!value) {
callback(new Error('cron cannot be empty'))
} else if (!value.match(pat)) {
@@ -126,7 +138,9 @@ export default {
dialogVisible: false,
cronRules: [
{ validator: cronValidator, trigger: 'blur' }
]
],
showCron: false,
expression: ''
}
},
computed: {
@@ -201,6 +215,24 @@ export default {
this.$st.sendEv('定时任务', '删除', 'id', row._id)
},
onCrawl () {
},
onCrontabFill (value) {
value = value.replace(/[?]/g, '*')
this.$set(this.scheduleForm, 'cron', value)
this.$st.sendEv('定时任务', '提交生成Cron', 'cron', this.scheduleForm.cron)
},
onShowCronDialog () {
this.showCron = true
if (this.expression.split(' ').length < 7) {
// this.expression = (this.scheduleForm.cron + ' ').replace(/[?]/g, '*')
this.expression = this.scheduleForm.cron + ' '
} else {
// this.expression = this.scheduleForm.cron.replace(/[?]/g, '*')
this.expression = this.scheduleForm.cron
}
this.$st.sendEv('定时任务', '点击生成Cron', 'cron', this.scheduleForm.cron)
}
},
created () {

View File

@@ -2910,6 +2910,18 @@ element-ui@2.4.6:
resize-observer-polyfill "^1.5.0"
throttle-debounce "^1.0.1"
element-ui@^2.4.11:
version "2.9.1"
resolved "https://registry.npm.taobao.org/element-ui/download/element-ui-2.9.1.tgz#a05f2e76023d529ba0dfa2d03ae16e5134b20c4e"
integrity sha1-oF8udgI9Upug36LQOuFuUTSyDE4=
dependencies:
async-validator "~1.8.1"
babel-helper-vue-jsx-merge-props "^2.0.0"
deepmerge "^1.2.0"
normalize-wheel "^1.0.1"
resize-observer-polyfill "^1.5.0"
throttle-debounce "^1.0.1"
elliptic@^6.0.0:
version "6.4.1"
resolved "http://registry.npm.taobao.org/elliptic/download/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a"
@@ -8383,6 +8395,14 @@ vary@~1.1.2:
version "1.1.2"
resolved "http://registry.npm.taobao.org/vary/download/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
vcrontab@^0.3.3:
version "0.3.3"
resolved "https://registry.npm.taobao.org/vcrontab/download/vcrontab-0.3.3.tgz#c4cd48e6d1a74c9bb8d693f7b732463e8eebdef5"
integrity sha1-xM1I5tGnTJu41pP3tzJGPo7r3vU=
dependencies:
element-ui "^2.4.11"
vue "^2.5.17"
vendors@^1.0.0:
version "1.0.2"
resolved "http://registry.npm.taobao.org/vendors/download/vendors-1.0.2.tgz#7fcb5eef9f5623b156bcea89ec37d63676f21801"