support multi-node log view

This commit is contained in:
Marvin Zhang
2019-03-06 15:43:14 +08:00
parent a9f555d9b9
commit 1fb09e4d1f
8 changed files with 102 additions and 59 deletions

View File

@@ -133,10 +133,7 @@ export default {
this.$store.commit('dialogView/SET_DIALOG_VISIBLE', false)
})
} else if (this.dialogType === 'spiderRun') {
this.$store.dispatch('spider/crawlSpider', {
id: this.spiderForm._id.$oid,
nodeId: this.activeNode._id
})
this.$store.dispatch('spider/crawlSpider', this.spiderForm._id.$oid)
.then(() => {
this.$message.success(`Spider "${this.spiderForm.name}" started to run on node "${this.activeNode._id}"`)
})

View File

@@ -42,7 +42,7 @@
</el-row>
<el-row class="button-container" v-if="!isView">
<el-button type="danger" @click="onRun">Run</el-button>
<!--<el-button type="primary" @click="onDeploy">Deploy</el-button>-->
<el-button type="primary" @click="onDeploy">Deploy</el-button>
<el-button type="success" @click="onSave">Save</el-button>
</el-row>
</div>
@@ -78,12 +78,12 @@ export default {
const row = this.spiderForm
this.$refs['spiderForm'].validate(res => {
if (res) {
this.$confirm('Are you sure to run this spider', 'Notice', {
this.$confirm('Are you sure to run this spider?', 'Notice', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel'
})
.then(() => {
this.$store.dispatch('spider/crawlSpider', { id: row._id.$oid })
this.$store.dispatch('spider/crawlSpider', row._id.$oid)
.then(() => {
this.$message.success(`Running spider "${row._id.$oid}" has been scheduled`)
})
@@ -92,8 +92,21 @@ export default {
})
},
onDeploy () {
this.$store.commit('dialogView/SET_DIALOG_VISIBLE', true)
this.$store.commit('dialogView/SET_DIALOG_TYPE', 'spiderDeploy')
const row = this.spiderForm
this.$refs['spiderForm'].validate(res => {
if (res) {
this.$confirm('Are you sure to deploy this spider?', 'Notice', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel'
})
.then(() => {
this.$store.dispatch('spider/crawlSpider', row._id.$oid)
.then(() => {
this.$message.success(`Spider "${row._id.$oid}" has been deployed`)
})
})
}
})
},
onSave () {
this.$refs['spiderForm'].validate(res => {

View File

@@ -166,8 +166,19 @@ export const constantRouterMap = [
{ path: '*', redirect: '/404', hidden: true }
]
export default new Router({
const router = new Router({
// mode: 'history', //后端支持可开
scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap
})
router.beforeEach((to, from, next) => {
if (to.meta && to.meta.title) {
window.document.title = `Crawlab - ${to.meta.title}`
} else {
window.document.title = 'Crawlab'
}
next()
})
export default router

View File

@@ -79,16 +79,13 @@ const actions = {
commit('SET_SPIDER_FORM', response.data)
})
},
deploySpider ({ state, dispatch }, { id, nodeId }) {
return request.post(`/spiders/${id}/deploy`, {
node_id: nodeId
})
deploySpider ({ state, dispatch }, id) {
return request.post(`/spiders/${id}/deploy`)
.then(response => {
console.log(response.data)
})
},
crawlSpider ({ state, dispatch }, payload) {
const { id } = payload
crawlSpider ({ state, dispatch }, id) {
return request.post(`/spiders/${id}/on_crawl`)
.then(response => {
console.log(response.data)

View File

@@ -241,9 +241,19 @@ export default {
})
},
onDeploy (row) {
this.$store.dispatch('spider/getSpiderData', row._id.$oid)
this.$store.commit('dialogView/SET_DIALOG_VISIBLE', true)
this.$store.commit('dialogView/SET_DIALOG_TYPE', 'spiderDeploy')
this.$confirm('Are you sure to deploy this spider?', 'Notification', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
this.$store.dispatch('spider/deploySpider', row._id.$oid)
.then(() => {
this.$message({
type: 'success',
message: 'Deployed successfully'
})
})
})
},
onCrawl (row) {
this.$confirm('Are you sure to run this spider', 'Notice', {
@@ -251,7 +261,7 @@ export default {
cancelButtonText: 'Cancel'
})
.then(() => {
this.$store.dispatch('spider/crawlSpider', { id: row._id.$oid })
this.$store.dispatch('spider/crawlSpider', row._id.$oid)
.then(() => {
this.$message.success(`Running spider "${row._id.$oid}" has been scheduled`)
})