mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-26 17:49:15 +01:00
updated methodologies of deployment and running spider
This commit is contained in:
@@ -71,10 +71,19 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
onRun () {
|
||||
const row = this.spiderForm
|
||||
this.$refs['spiderForm'].validate(res => {
|
||||
if (res) {
|
||||
this.$store.commit('dialogView/SET_DIALOG_VISIBLE', true)
|
||||
this.$store.commit('dialogView/SET_DIALOG_TYPE', 'spiderRun')
|
||||
this.$confirm('Are you sure to run this spider', 'Notice', {
|
||||
confirmButtonText: 'Confirm',
|
||||
cancelButtonText: 'Cancel'
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.dispatch('spider/crawlSpider', { id: row._id.$oid })
|
||||
.then(() => {
|
||||
this.$message.success(`Running spider "${row._id.$oid}" has been scheduled`)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -87,10 +87,8 @@ const actions = {
|
||||
})
|
||||
},
|
||||
crawlSpider ({ state, dispatch }, payload) {
|
||||
const { id, nodeId } = payload
|
||||
return request.post(`/spiders/${id}/crawl`, {
|
||||
node_id: nodeId
|
||||
})
|
||||
const { id } = payload
|
||||
return request.post(`/spiders/${id}/on_crawl`)
|
||||
.then(response => {
|
||||
console.log(response.data)
|
||||
})
|
||||
@@ -124,6 +122,12 @@ const actions = {
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
})
|
||||
},
|
||||
deployAll () {
|
||||
return request.post('/spiders/manage/deploy_all')
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
@change="onSearch">
|
||||
</el-input>
|
||||
<div class="right">
|
||||
<el-button type="primary" icon="el-icon-upload" @click="openImportDialog">
|
||||
<el-button type="primary" icon="fa fa-cloud" @click="onDeployAll">
|
||||
Deploy All
|
||||
</el-button>
|
||||
<el-button type="primary" icon="fa fa-download" @click="openImportDialog">
|
||||
Import Spiders
|
||||
</el-button>
|
||||
<el-button type="success"
|
||||
@@ -243,9 +246,16 @@ export default {
|
||||
this.$store.commit('dialogView/SET_DIALOG_TYPE', 'spiderDeploy')
|
||||
},
|
||||
onCrawl (row) {
|
||||
this.$store.dispatch('spider/getSpiderData', row._id.$oid)
|
||||
this.$store.commit('dialogView/SET_DIALOG_VISIBLE', true)
|
||||
this.$store.commit('dialogView/SET_DIALOG_TYPE', 'spiderRun')
|
||||
this.$confirm('Are you sure to run this spider', 'Notice', {
|
||||
confirmButtonText: 'Confirm',
|
||||
cancelButtonText: 'Cancel'
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.dispatch('spider/crawlSpider', { id: row._id.$oid })
|
||||
.then(() => {
|
||||
this.$message.success(`Running spider "${row._id.$oid}" has been scheduled`)
|
||||
})
|
||||
})
|
||||
},
|
||||
onView (row) {
|
||||
this.$router.push(`/spiders/${row._id.$oid}`)
|
||||
@@ -257,9 +267,10 @@ export default {
|
||||
this.$refs.importForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.importLoading = true
|
||||
// TODO: switch between github / gitlab / svn
|
||||
this.$store.dispatch('spider/importGithub')
|
||||
.then(response => {
|
||||
this.$message.success('Import repo sucessfully')
|
||||
this.$message.success('Import repo successfully')
|
||||
this.$store.dispatch('spider/getSpiderList')
|
||||
})
|
||||
.catch(response => {
|
||||
@@ -274,6 +285,19 @@ export default {
|
||||
},
|
||||
openImportDialog () {
|
||||
this.dialogVisible = true
|
||||
},
|
||||
onDeployAll () {
|
||||
this.$confirm('Are you sure to deploy all spiders to active nodes?', 'Notice', {
|
||||
confirmButtonText: 'Confirm',
|
||||
cancelButtonText: 'Cancel',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.dispatch('spider/deployAll')
|
||||
.then(() => {
|
||||
this.$message.success('Deployed all spiders successfully')
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
||||
Reference in New Issue
Block a user