enforce deploy before running a spider

This commit is contained in:
Marvin Zhang
2019-04-15 19:50:25 +08:00
parent f004c1a70a
commit d48fee0d03
10 changed files with 89 additions and 19 deletions

View File

@@ -61,7 +61,7 @@
</el-form>
</el-row>
<el-row class="button-container" v-if="!isView">
<el-button type="danger" @click="onRun">{{$t('Run')}}</el-button>
<el-button v-if="isShowRun" type="danger" @click="onRun">{{$t('Run')}}</el-button>
<el-button type="primary" @click="onDeploy">{{$t('Deploy')}}</el-button>
<el-button type="success" @click="onSave">{{$t('Save')}}</el-button>
</el-row>
@@ -109,7 +109,16 @@ export default {
computed: {
...mapState('spider', [
'spiderForm'
])
]),
isShowRun () {
if (!this.spiderForm.deploy_ts) {
return false
}
if (!this.spiderForm.cmd) {
return false
}
return true
}
},
methods: {
onRun () {
@@ -131,6 +140,11 @@ export default {
},
onDeploy () {
const row = this.spiderForm
// save spider
this.$store.dispatch('spider/editSpider', row._id)
// validate fields
this.$refs['spiderForm'].validate(res => {
if (res) {
this.$confirm(this.$t('Are you sure to deploy this spider?'), this.$t('Notification'), {

View File

@@ -32,13 +32,13 @@
</el-form-item>
<el-form-item :label="$t('Error Message')" v-if="taskForm.status === 'FAILURE'">
<div class="error-message">
{{taskForm.result}}
{{taskForm.log}}
</div>
</el-form-item>
</el-form>
</el-row>
<el-row class="button-container">
<el-button v-if="isRunning" type="danger" @click="onStop">Stop</el-button>
<el-button v-if="isRunning" type="danger" @click="onStop">{{$t('Stop')}}</el-button>
<!--<el-button type="danger" @click="onRestart">Restart</el-button>-->
</el-row>
</div>