|
|
@ -7,12 +7,12 @@ |
|
|
|
</v-overlay> |
|
|
|
<config-header :step="step.count" /> |
|
|
|
<config-template-name |
|
|
|
v-model="templateConfig" |
|
|
|
v-model="fields" |
|
|
|
@next="step.next()" |
|
|
|
/> |
|
|
|
<config-parameters |
|
|
|
v-if="templateConfig.model_attrs !== undefined" |
|
|
|
v-model="templateConfig.model_attrs" |
|
|
|
v-if="fields.modelAttrs !== undefined" |
|
|
|
v-model="fields.modelAttrs" |
|
|
|
:is-passed="passTesting.parameter" |
|
|
|
:error-messages="errors" |
|
|
|
:response="response.parameter" |
|
|
@ -22,7 +22,7 @@ |
|
|
|
/> |
|
|
|
|
|
|
|
<config-template |
|
|
|
v-model="templateConfig.template" |
|
|
|
v-model="fields.template" |
|
|
|
:is-passed="passTesting.template" |
|
|
|
:error-messages="errors" |
|
|
|
:response="response.parameter" |
|
|
@ -33,9 +33,11 @@ |
|
|
|
/> |
|
|
|
|
|
|
|
<config-label-mapping |
|
|
|
v-model="labelMapping" |
|
|
|
:error-messages="errors" |
|
|
|
v-model="fields.labelMapping" |
|
|
|
:is-passed="passTesting.mapping" |
|
|
|
:error-messages="errors" |
|
|
|
:response="response.template" |
|
|
|
:result="response.mapping" |
|
|
|
@prev="step.prev()" |
|
|
|
@next="saveConfig" |
|
|
|
@onTest="testMapping" |
|
|
@ -47,7 +49,7 @@ |
|
|
|
import Vue from 'vue' |
|
|
|
import { FromApiConfigItemListRepository } from '@/repositories/config/api' |
|
|
|
import { ConfigApplicationService } from '@/services/application/config.service' |
|
|
|
import { ConfigItem, Parameters } from '@/models/config/config-item-list' |
|
|
|
import { ConfigItem, Fields } from '@/models/config/config-item-list' |
|
|
|
import { StepCounter } from '@/models/stepper' |
|
|
|
import ConfigHeader from './form/ConfigHeader.vue' |
|
|
|
import ConfigTemplateName from './form/ConfigTemplateName.vue' |
|
|
@ -58,24 +60,24 @@ import ConfigLabelMapping from './form/ConfigLabelMapping.vue' |
|
|
|
export default Vue.extend({ |
|
|
|
components: { |
|
|
|
ConfigHeader, |
|
|
|
ConfigTemplate, |
|
|
|
ConfigTemplateName, |
|
|
|
ConfigLabelMapping, |
|
|
|
ConfigParameters, |
|
|
|
ConfigLabelMapping |
|
|
|
ConfigTemplate, |
|
|
|
ConfigTemplateName |
|
|
|
}, |
|
|
|
|
|
|
|
data() { |
|
|
|
return { |
|
|
|
config: {} as ConfigItem, |
|
|
|
errors: [] as string[], |
|
|
|
fields: {} as Fields, |
|
|
|
isLoading: false, |
|
|
|
step: new StepCounter(), |
|
|
|
passTesting: { |
|
|
|
parameter: false, |
|
|
|
template: false, |
|
|
|
mapping: false |
|
|
|
}, |
|
|
|
step: new StepCounter(1, 4), |
|
|
|
templateConfig: {}, |
|
|
|
labelMapping: [], |
|
|
|
response: { |
|
|
|
parameter: [], |
|
|
|
template: [], |
|
|
@ -93,87 +95,63 @@ export default Vue.extend({ |
|
|
|
}, |
|
|
|
|
|
|
|
watch: { |
|
|
|
templateConfig: { |
|
|
|
handler() { |
|
|
|
// this.passTesting = false |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
} |
|
|
|
'fields.modelName'() { |
|
|
|
this.passTesting = {parameter: false, template: false, mapping: false} |
|
|
|
}, |
|
|
|
'fields.modelAttrs': { |
|
|
|
handler() { |
|
|
|
this.passTesting = {parameter: false, template: false, mapping: false} |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
}, |
|
|
|
'fields.template'() { |
|
|
|
this.passTesting = {parameter: true, template: false, mapping: false} |
|
|
|
}, |
|
|
|
'fields.labelMapping': { |
|
|
|
handler() { |
|
|
|
this.passTesting = {parameter: true, template: true, mapping: false} |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
createConfig() { |
|
|
|
const payload = { |
|
|
|
// @ts-ignore |
|
|
|
modelName: this.templateConfig.model_name, |
|
|
|
// @ts-ignore |
|
|
|
modelAttrs: this.templateConfig.model_attrs, |
|
|
|
// @ts-ignore |
|
|
|
template: this.templateConfig.template, |
|
|
|
// @ts-ignore |
|
|
|
labelMapping: this.labelMapping |
|
|
|
} |
|
|
|
return ConfigItem.parseFromUI(payload) |
|
|
|
}, |
|
|
|
testMapping() { |
|
|
|
const projectId = this.$route.params.id |
|
|
|
const item = this.createConfig() |
|
|
|
testConfig(promise: Promise<any>, key: 'parameter'|'template'|'mapping') { |
|
|
|
this.isLoading = true |
|
|
|
this.configService.testMapping(projectId, item, this.response.template) |
|
|
|
.then((value) => { |
|
|
|
this.passTesting.mapping = true |
|
|
|
// @ts-ignore |
|
|
|
this.response.mapping = value |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
this.errors = [error.message] |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.isLoading = false |
|
|
|
}) |
|
|
|
promise.then((value) => { |
|
|
|
this.response[key] = value |
|
|
|
this.passTesting[key] = true |
|
|
|
this.errors = [] |
|
|
|
}).catch((error) => { |
|
|
|
this.errors = [error.message] |
|
|
|
}).finally(() => { |
|
|
|
this.isLoading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
testParameters(text: string) { |
|
|
|
// @ts-ignore |
|
|
|
const item = Parameters.parse(this.templateConfig.model_attrs) |
|
|
|
this.isLoading = true |
|
|
|
// @ts-ignore |
|
|
|
this.configService.testParameters(this.templateConfig.model_name, item, text) |
|
|
|
.then((value) => { |
|
|
|
// @ts-ignore |
|
|
|
this.response.parameter = value |
|
|
|
this.passTesting.parameter = true |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
this.errors = [error.message] |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.isLoading = false |
|
|
|
}) |
|
|
|
const item = ConfigItem.parseFromUI(this.fields) |
|
|
|
const promise = this.configService.testParameters(item, text) |
|
|
|
this.testConfig(promise, 'parameter') |
|
|
|
}, |
|
|
|
testTemplate() { |
|
|
|
const projectId = this.$route.params.id |
|
|
|
this.isLoading = true |
|
|
|
this.errors = [] |
|
|
|
// @ts-ignore |
|
|
|
this.configService.testTemplate(projectId, this.response.parameter, this.templateConfig.template) |
|
|
|
.then((value) => { |
|
|
|
// @ts-ignore |
|
|
|
this.response.template = value |
|
|
|
this.passTesting.template = true |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
this.errors = [error.message] |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.isLoading = false |
|
|
|
}) |
|
|
|
const item = ConfigItem.parseFromUI(this.fields) |
|
|
|
const promise = this.configService.testTemplate(projectId, this.response.parameter, item) |
|
|
|
this.testConfig(promise, 'template') |
|
|
|
}, |
|
|
|
testMapping() { |
|
|
|
const projectId = this.$route.params.id |
|
|
|
const item = ConfigItem.parseFromUI(this.fields) |
|
|
|
const promise = this.configService.testMapping(projectId, item, this.response.template) |
|
|
|
this.testConfig(promise, 'mapping') |
|
|
|
}, |
|
|
|
saveConfig() { |
|
|
|
const projectId = this.$route.params.id |
|
|
|
const item = this.createConfig() |
|
|
|
const item = ConfigItem.parseFromUI(this.fields) |
|
|
|
this.isLoading = true |
|
|
|
this.configService.save(projectId, item) |
|
|
|
.then(() => { |
|
|
|
this.step.first() |
|
|
|
this.$emit('onCreate') |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|