diff --git a/frontend/src/components/Config/ConfigList.vue b/frontend/src/components/Config/ConfigList.vue index 5b7e3d3d..b3d4c39d 100644 --- a/frontend/src/components/Config/ConfigList.vue +++ b/frontend/src/components/Config/ConfigList.vue @@ -34,14 +34,14 @@ - + - + @@ -82,7 +82,8 @@
{{$t('Run')}} - {{$t('Extract Fields')}} + {{$t('Extract Fields')}} + {{$t('Preview')}} {{$t('Save')}}
@@ -217,6 +218,24 @@ export default { }) }, onExtractFields () { + this.onSave() + .then(() => { + this.extractFieldsLoading = true + this.$store.dispatch('spider/extractFields') + .then(response => { + if (response.data.item_selector) { + this.$set(this.spiderForm, 'item_selector', response.data.item_selector) + this.$set(this.spiderForm, 'item_selector_type', 'css') + } + + if (response.data.fields && response.data.fields.length) { + this.spiderForm.fields = response.data.fields + } + }) + .finally(() => { + this.extractFieldsLoading = false + }) + }) } }, created () { diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js index 18fcce2a..831c0d0e 100644 --- a/frontend/src/store/modules/spider.js +++ b/frontend/src/store/modules/spider.js @@ -208,6 +208,9 @@ const actions = { .then(response => { commit('SET_PREVIEW_CRAWL_DATA', response.data.items) }) + }, + extractFields ({ state, commit }) { + return request.post(`/spiders/${state.spiderForm._id}/extract_fields`) } }