mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
added stop task
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
|
||||
import requests
|
||||
from celery.worker.control import revoke
|
||||
|
||||
from constants.task import TaskStatus
|
||||
from db.manager import db_manager
|
||||
@@ -112,3 +113,10 @@ class TaskApi(BaseApi):
|
||||
'fields': fields,
|
||||
'items': items
|
||||
})
|
||||
|
||||
def stop(self, id):
|
||||
revoke(id, terminate=True)
|
||||
return {
|
||||
'id': id,
|
||||
'status': 'ok',
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row class="button-container">
|
||||
<el-button type="danger" @click="onRestart">Restart</el-button>
|
||||
<el-button v-if="isRunning" type="danger" @click="onStop">Stop</el-button>
|
||||
<!--<el-button type="danger" @click="onRestart">Restart</el-button>-->
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
@@ -53,10 +54,19 @@ export default {
|
||||
computed: {
|
||||
...mapState('task', [
|
||||
'taskForm'
|
||||
])
|
||||
]),
|
||||
isRunning () {
|
||||
return !['SUCCESS', 'FAILURE'].includes(this.taskForm.status)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
Restart () {
|
||||
onRestart () {
|
||||
},
|
||||
onStop () {
|
||||
this.$store.dispatch('task/stopTask', this.$route.params.id)
|
||||
.then(() => {
|
||||
this.$message.success(`Task "${this.$route.params.id}" has been sent signal to stop`)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ const actions = {
|
||||
dispatch('getTaskList')
|
||||
})
|
||||
},
|
||||
stopTask ({ state, dispatch }, id) {
|
||||
return request.post(`/tasks/${id}/stop`)
|
||||
.then(() => {
|
||||
dispatch('getTaskList')
|
||||
})
|
||||
},
|
||||
getTaskLog ({ state, commit }, id) {
|
||||
return request.get(`/tasks/${id}/get_log`)
|
||||
.then(response => {
|
||||
|
||||
Reference in New Issue
Block a user