{{ translate('Finished') }}
{{ translate('Failed records') }}
@@ -123,7 +121,7 @@ import { checkmarkOutline, codeWorkingOutline, cloudDownloadOutline, documentTex import { IonBackButton, IonBadge, IonButton, IonChip, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonPage, IonSpinner, IonTitle, IonToolbar, popoverController } from "@ionic/vue"; import { defineComponent } from 'vue' import { mapGetters, useStore } from 'vuex' -import { responseFileType } from '@/utils'; +import { saveDataFile, hasError } from '@/utils'; import { translate } from '@hotwax/dxp-components' import { DateTime } from 'luxon' import DownloadLogsFilePopover from "@/components/DownloadLogsFilePopover.vue"; @@ -151,59 +149,60 @@ export default defineComponent ({ data() { return { configDetails: {}, - selectedChip: 'All', - chips: [ - { label: 'All' }, - { label: 'Failed logs' }, - { label: 'Failed records' } + selectedFilter: 'All', + dataManagerLogFilters: [ + { id: 'ALL', label: 'All' }, + { id: 'FAILED_LOGS', label: 'Failed logs' }, + { id: 'FAILED_RECORDS', label: 'Failed records' } ], - filteredLogs: [], + dataManagerLogList: [], isLoading: true, } }, computed: { ...mapGetters({ currentJob: 'job/getCurrentJob', - getDataLogs: 'job/getDataLogs', + getDataManagerLogs: 'job/getDataManagerLogs', getJob: 'job/getJob', - getDataResourceId: 'job/getDataResourceIds' + getStatusDesc: 'util/getStatusDesc', }), }, async mounted() { await this.fetchJobs(); const job = await this.getJob(this.$route.params.jobId) await this.store.dispatch('job/updateCurrentJob', { job }); - this.filteredLogs = await this.store.dispatch('job/fetchDataManagerLogs', job.runtimeData?.configId) - this.configDetails = await this.store.dispatch('job/fetchDataManagerConfig', job.runtimeData?.configId) - this.updateLogs('All'); + await this.fetchDataManagerConfig(job.runtimeData?.configId) + await this.store.dispatch('job/fetchDataManagerLogs', job.runtimeData?.configId) + await this.store.dispatch('job/fetchDataResource', this.getDataManagerLogs) + this.filterDataManagerLogs('ALL'); this.isLoading = false; }, methods : { - updateLogs(label) { - this.selectedChip = label - if (label === 'All') { - this.filteredLogs = this.getDataLogs - } else if (label === 'Failed logs') { - this.filteredLogs = this.getDataLogs.filter(log => log.statusId === 'SERVICE_FAILED') - } else if (label === 'Failed records') { - this.filteredLogs = this.getDataLogs.filter(log => log.errorRecordContentId !== null) + filterDataManagerLogs(id) { + this.selectedFilter = id + if (id === 'ALL') { + this.dataManagerLogList = this.getDataManagerLogs + } else if (id === 'FAILED_LOGS') { + this.dataManagerLogList = this.getDataManagerLogs.filter(log => log.statusId === 'SERVICE_FAILED') + } else if (id === 'FAILED_RECORDS') { + this.dataManagerLogList = this.getDataManagerLogs.filter(log => log.errorRecordContentId !== null) } }, getDateTime(time) { return DateTime.fromMillis(time).toFormat("dd/MM/yyyy H:mm a") }, getProcessedFileCount() { - return this.getDataLogs.filter((log) => log.statusId === "SERVICE_FINISHED").length + return this.getDataManagerLogs.filter((log) => log.statusId === "SERVICE_FINISHED").length }, getErrorFileCount() { - return this.getDataLogs.filter((log) => log.errorRecordContentId !== null).length + return this.getDataManagerLogs.filter((log) => log.errorRecordContentId !== null).length }, - async openDownloadLogsFilePopover(log, event) { + async openDownloadLogsFilePopover(dataManagerLog, event) { const popover = await popoverController.create({ component: DownloadLogsFilePopover, showBackdrop: false, event: event, - componentProps: { log } + componentProps: { dataManagerLog } }); return popover.present() }, @@ -212,14 +211,36 @@ export default defineComponent ({ "inputFields": this.$route.params.jobId }); }, - async downloadCsv(id) { + async fetchDataManagerConfig(configId) { + let resp = {} + const payload = { + "inputFields": { + "configId": configId + }, + "fieldList": ["importPath", "multiThreading", "description", "executionModeId"], + "noConditionFind": "Y", + "viewSize": 1, + "entityName": "DataManagerConfig", + } + + try { + resp = await JobService.fetchDataManagerConfig(payload); + if (resp.status === 200 && resp.data.docs?.length > 0 && !hasError(resp)) { + this.configDetails = resp.data.docs[0]; + } else { + throw resp.data + } + } catch (err) { + logger.error(err); + } + }, + async downloadErrorRecordFile(dataManagerLog) { try { - const dataResource = this.getDataResourceId(id); - if (dataResource) { - const response = await JobService.downloadCsv({ - dataResourceId: dataResource.dataResourceId + if (dataManagerLog?.errorRecordDataResourceId) { + const response = await JobService.fetchFileData({ + dataResourceId: dataManagerLog.errorRecordDataResourceId }); - responseFileType(response.data, dataResource.name); + saveDataFile(response.data, dataManagerLog?.errorRecordContentName); } } catch (error) { logger.error(error); diff --git a/src/components/JobConfiguration.vue b/src/components/JobConfiguration.vue index 292d4b9a..5e39c2fd 100644 --- a/src/components/JobConfiguration.vue +++ b/src/components/JobConfiguration.vue @@ -113,17 +113,17 @@