mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-23 17:31:11 +01:00
加入复制爬虫
This commit is contained in:
@@ -78,8 +78,6 @@
|
||||
<span style="margin-left: 5px">跳转到任务详情页</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template slot="footer">
|
||||
<el-button type="plain" size="small" @click="$emit('close')">{{$t('Cancel')}}</el-button>
|
||||
|
||||
85
frontend/src/components/Spider/CopySpiderDialog.vue
Normal file
85
frontend/src/components/Spider/CopySpiderDialog.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
class="copy-spider-dialog"
|
||||
ref="form"
|
||||
:title="$t('Copy Spider')"
|
||||
:visible="visible"
|
||||
width="580px"
|
||||
:before-close="onClose"
|
||||
>
|
||||
<el-form
|
||||
label-width="160px"
|
||||
:model="form"
|
||||
ref="form"
|
||||
>
|
||||
<el-form-item
|
||||
:label="$t('New Spider Name')"
|
||||
required
|
||||
>
|
||||
<el-input v-model="form.name" :placeholder="$t('New Spider Name')"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template slot="footer">
|
||||
<el-button type="plain" size="small" @click="$emit('close')">{{$t('Cancel')}}</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:icon="isLoading ? 'el-icon-loading' : ''"
|
||||
:disabled="isLoading"
|
||||
@click="onConfirm"
|
||||
>
|
||||
{{$t('Confirm')}}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CopySpiderDialog',
|
||||
props: {
|
||||
spiderId: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
form: {
|
||||
name: ''
|
||||
},
|
||||
isLoading: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClose () {
|
||||
this.$emit('close')
|
||||
},
|
||||
onConfirm () {
|
||||
this.$refs['form'].validate(async valid => {
|
||||
if (!valid) return
|
||||
try {
|
||||
this.isLoading = true
|
||||
const res = await this.$request.post(`/spiders/${this.spiderId}/copy`, this.form)
|
||||
if (!res.data.error) {
|
||||
this.$message.success('Copied successfully')
|
||||
}
|
||||
this.$emit('confirm')
|
||||
this.$emit('close')
|
||||
this.$st.sendEv('爬虫复制', '确认提交')
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -220,6 +220,8 @@ export default {
|
||||
'Item Name': 'Item 名称',
|
||||
'Add Item': '添加 Item',
|
||||
'Add Variable': '添加变量',
|
||||
'Copy Spider': '复制爬虫',
|
||||
'New Spider Name': '新爬虫名称',
|
||||
|
||||
// 爬虫列表
|
||||
'Name': '名称',
|
||||
@@ -564,6 +566,7 @@ docker run -d --restart always --name crawlab_worker \\
|
||||
'Are you sure to delete selected items?': '您是否确认删除所选项?',
|
||||
'Are you sure to stop selected items?': '您是否确认停止所选项?',
|
||||
'Sent signals to cancel selected tasks': '已经向所选任务发送取消任务信号',
|
||||
'Copied successfully': '已成功复制',
|
||||
|
||||
// 其他
|
||||
'Star crawlab-team/crawlab on GitHub': '在 GitHub 上为 Crawlab 加星吧'
|
||||
|
||||
@@ -290,6 +290,15 @@
|
||||
/>
|
||||
<!--./crawl confirm dialog-->
|
||||
|
||||
<!--copy dialog-->
|
||||
<copy-spider-dialog
|
||||
:visible="copyDialogVisible"
|
||||
:spider-id="activeSpiderId"
|
||||
@close="copyDialogVisible = false"
|
||||
@confirm="onCopyConfirm"
|
||||
/>
|
||||
<!--./copy dialog-->
|
||||
|
||||
<el-card style="border-radius: 0">
|
||||
<!--filter-->
|
||||
<div class="filter">
|
||||
@@ -566,7 +575,7 @@
|
||||
>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<el-table-column :label="$t('Action')" align="left" fixed="right" min-width="170px">
|
||||
<el-table-column :label="$t('Action')" align="left" fixed="right" min-width="220px">
|
||||
<template slot-scope="scope">
|
||||
<el-tooltip :content="$t('View')" placement="top">
|
||||
<el-button type="primary" icon="el-icon-search" size="mini"
|
||||
@@ -576,6 +585,14 @@
|
||||
<el-button type="danger" icon="el-icon-delete" size="mini"
|
||||
@click="onRemove(scope.row, $event)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('Copy')" placement="top">
|
||||
<el-button
|
||||
type="info"
|
||||
icon="el-icon-copy-document"
|
||||
size="mini"
|
||||
@click="onCopy(scope.row, $event)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="!isShowRun(scope.row)" :content="$t('No command line')" placement="top">
|
||||
<el-button disabled type="success" icon="fa fa-bug" size="mini"
|
||||
@click="onCrawl(scope.row, $event)"></el-button>
|
||||
@@ -619,10 +636,12 @@ import dayjs from 'dayjs'
|
||||
import CrawlConfirmDialog from '../../components/Common/CrawlConfirmDialog'
|
||||
import StatusTag from '../../components/Status/StatusTag'
|
||||
import StatusLegend from '../../components/Status/StatusLegend'
|
||||
import CopySpiderDialog from '../../components/Spider/CopySpiderDialog'
|
||||
|
||||
export default {
|
||||
name: 'SpiderList',
|
||||
components: {
|
||||
CopySpiderDialog,
|
||||
StatusLegend,
|
||||
CrawlConfirmDialog,
|
||||
StatusTag
|
||||
@@ -784,7 +803,8 @@ export default {
|
||||
selectedSpiders: [],
|
||||
isStopLoading: false,
|
||||
isRemoveLoading: false,
|
||||
isMultiple: false
|
||||
isMultiple: false,
|
||||
copyDialogVisible: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -966,6 +986,17 @@ export default {
|
||||
this.getList()
|
||||
}, 1000)
|
||||
},
|
||||
onCopy (row, ev) {
|
||||
ev.stopPropagation()
|
||||
this.copyDialogVisible = true
|
||||
this.activeSpiderId = row._id
|
||||
this.$st.sendEv('爬虫列表', '点击复制')
|
||||
},
|
||||
onCopyConfirm () {
|
||||
setTimeout(() => {
|
||||
this.getList()
|
||||
}, 1000)
|
||||
},
|
||||
onView (row, ev) {
|
||||
ev.stopPropagation()
|
||||
this.$router.push('/spiders/' + row._id)
|
||||
|
||||
Reference in New Issue
Block a user