Commit 92cfee09 authored by dbulatovicx32's avatar dbulatovicx32
Browse files

implemented save method for monitoring

parent 6a9a8566
......@@ -2,121 +2,141 @@
<Card class="p-m-2">
<template #content>
<form class="p-fluid p-formgrid p-grid">
<div class="p-field p-col-6">
<div class="p-field p-col-4">
<Button :label="$t('managers.datasetManagement.monitoring')" class="kn-button kn-button--primary" @click="showMonitoringDialog = true" />
</div>
<div class="p-field p-col-6">
<div class="p-field p-col-4">
<Button :label="$t('managers.datasetManagement.openDP')" class="kn-button kn-button--primary" @click="prepareForDataPreparation" />
</div>
</form>
</template>
</Card>
<MonitoringDialog :visibility="showMonitoringDialog" :dataset="selectedDataset" @close="showMonitoringDialog = false" />
<MonitoringDialog :visibility="showMonitoringDialog" :dataset="selectedDataset" @close="showMonitoringDialog = false" @save="updateDatasetAndSave" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { AxiosResponse } from 'axios'
import descriptor from './DatasetManagementPreparedDataset.json'
import Card from 'primevue/card'
import MonitoringDialog from '@/modules/workspace/dataPreparation/DataPreparationMonitoring/DataPreparationMonitoringDialog.vue'
import { defineComponent } from 'vue'
import { AxiosResponse } from 'axios'
import descriptor from './DatasetManagementPreparedDataset.json'
import Card from 'primevue/card'
import MonitoringDialog from '@/modules/workspace/dataPreparation/DataPreparationMonitoring/DataPreparationMonitoringDialog.vue'
export default defineComponent({
components: { Card, MonitoringDialog },
props: { selectedDataset: { type: Object as any }, dataSources: { type: Array as any } },
emits: ['touched'],
data() {
return {
descriptor,
dataset: {} as any,
availableDatasets: [] as any,
avroDatasets: [] as any,
showMonitoringDialog: false
}
},
created() {
export default defineComponent({
components: { Card, MonitoringDialog },
props: { selectedDataset: { type: Object as any }, dataSources: { type: Array as any } },
emits: ['touched'],
data() {
return {
descriptor,
dataset: {} as any,
availableDatasets: [] as any,
avroDatasets: [] as any,
showMonitoringDialog: false
}
},
created() {
this.dataset = this.selectedDataset
},
watch: {
selectedDataset() {
this.dataset = this.selectedDataset
}
},
methods: {
async loadDataset(datasetId: Number) {
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `1.0/datasets/dataset/id/${datasetId}`)
.then((response: AxiosResponse<any>) => {
this.dataset = response.data[0]
})
.catch(() => {})
},
watch: {
selectedDataset() {
this.dataset = this.selectedDataset
}
routeToDataPreparation() {
let path = ''
this.$confirm.require({
header: this.$t('managers.datasetManagement.openDP'),
message: this.$t('managers.datasetManagement.confirmMsg'),
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.$router.push(path)
}
})
},
methods: {
routeToDataPreparation() {
let path = ''
this.$confirm.require({
header: this.$t('managers.datasetManagement.openDP'),
message: this.$t('managers.datasetManagement.confirmMsg'),
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.$router.push(path)
}
})
},
async getAllAvroDataSets() {
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `3.0/datasets/avro`)
.then((response: AxiosResponse<any>) => {
this.avroDatasets = response.data
})
.catch(() => {})
},
async getAllAvroDataSets() {
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `3.0/datasets/avro`)
.then((response: AxiosResponse<any>) => {
this.avroDatasets = response.data
})
.catch(() => {})
},
async prepareForDataPreparation() {
await this.getAllAvroDataSets()
await this.openDataPreparation(this.selectedDataset)
},
async prepareForDataPreparation() {
await this.getAllAvroDataSets()
await this.openDataPreparation(this.selectedDataset)
},
isAvroReady(dsId: Number) {
if (this.avroDatasets.indexOf(dsId) >= 0 || (dsId && this.avroDatasets.indexOf(dsId.toString())) >= 0) return true
else return false
},
isAvroReady(dsId: Number) {
if (this.avroDatasets.indexOf(dsId) >= 0 || (dsId && this.avroDatasets.indexOf(dsId.toString())) >= 0) return true
else return false
},
openDataPreparation(dataset: any) {
if (dataset.dsTypeCd == 'Prepared') {
//edit existing data prep
this.$http.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `3.0/datasets/advanced/${dataset.id}`).then(
(response: AxiosResponse<any>) => {
let instanceId = response.data.configuration.dataPrepInstanceId
this.$http.get(process.env.VUE_APP_DATA_PREPARATION_PATH + `1.0/process/by-instance-id/${instanceId}`).then(
(response: AxiosResponse<any>) => {
let transformations = response.data.definition
let processId = response.data.id
let datasetId = response.data.instance.dataSetId
if (this.isAvroReady(datasetId))
// check if Avro file has been deleted or not
this.$router.push({ name: 'data-preparation', params: { id: datasetId, transformations: JSON.stringify(transformations), processId: processId, instanceId: instanceId, dataset: JSON.stringify(dataset) } })
else {
this.$store.commit('setInfo', {
title: 'Avro file is missing',
msg: 'Generate it again and then retry'
})
}
},
() => {
this.$store.commit('setError', { title: 'Save error', msg: 'Cannot create process' })
openDataPreparation(dataset: any) {
if (dataset.dsTypeCd == 'Prepared') {
//edit existing data prep
this.$http.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `3.0/datasets/advanced/${dataset.id}`).then(
(response: AxiosResponse<any>) => {
let instanceId = response.data.configuration.dataPrepInstanceId
this.$http.get(process.env.VUE_APP_DATA_PREPARATION_PATH + `1.0/process/by-instance-id/${instanceId}`).then(
(response: AxiosResponse<any>) => {
let transformations = response.data.definition
let processId = response.data.id
let datasetId = response.data.instance.dataSetId
if (this.isAvroReady(datasetId))
// check if Avro file has been deleted or not
this.$router.push({ name: 'data-preparation', params: { id: datasetId, transformations: JSON.stringify(transformations), processId: processId, instanceId: instanceId, dataset: JSON.stringify(dataset) } })
else {
this.$store.commit('setInfo', {
title: 'Avro file is missing',
msg: 'Generate it again and then retry'
})
}
)
},
() => {
this.$store.commit('setError', {
title: 'Cannot open data preparation'
})
}
)
} else if (this.isAvroReady(dataset.id)) {
// original dataset already exported in Avro
this.$router.push({ name: 'data-preparation', params: { id: dataset.id } })
} else {
this.$store.commit('setInfo', {
title: 'Avro file is missing',
msg: 'Generate it again and then retry'
})
}
},
() => {
this.$store.commit('setError', { title: 'Save error', msg: 'Cannot create process' })
}
)
},
() => {
this.$store.commit('setError', {
title: 'Cannot open data preparation'
})
}
)
} else if (this.isAvroReady(dataset.id)) {
// original dataset already exported in Avro
this.$router.push({ name: 'data-preparation', params: { id: dataset.id } })
} else {
this.$store.commit('setInfo', {
title: 'Avro file is missing',
msg: 'Generate it again and then retry'
})
}
},
async updateDatasetAndSave(newConfig) {
this.showMonitoringDialog = false
await this.$http.patch(process.env.VUE_APP_DATA_PREPARATION_PATH + '1.0/instance/' + newConfig.instanceId, { config: newConfig.config }, { headers: { Accept: 'application/json, */*' } }).then(
() => {
this.loadDataset(this.selectedDataset.id)
},
() => {
this.$store.commit('setError', { title: this.$t('common.error.saving'), msg: this.$t('managers.workspaceManagement.dataPreparation.errors.updatingSchedulation') })
}
)
}
})
}
})
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment