@@ -7,7 +7,7 @@ import { ActivatedRoute } from '@angular/router'
77import { AgGridAngular } from 'ag-grid-angular'
88import { catchError , filter , forkJoin , of , Subject , switchMap , take , takeUntil , tap } from 'rxjs'
99import type { Column , ColumnMappingProfile , ColumnMappingProfileType , Cycle , ImportFile , MappingResultsResponse , MappingSuggestionsResponse , Organization , ProgressResponse } from '@seed/api'
10- import { ColumnMappingProfileService , ColumnService , CycleService , DatasetService , MappingService , OrganizationService , UserService } from '@seed/api'
10+ import { CacheService , ColumnMappingProfileService , ColumnService , CycleService , DatasetService , MappingService , OrganizationService , UserService } from '@seed/api'
1111import { PageComponent , ProgressBarComponent } from '@seed/components'
1212import { MaterialImports } from '@seed/materials'
1313import { UploaderService } from '@seed/services/uploader'
@@ -40,6 +40,7 @@ export class DataMappingComponent implements OnDestroy, OnInit {
4040 @ViewChild ( MapDataComponent ) mapDataComponent ! : MapDataComponent
4141 @ViewChild ( MatchMergeComponent ) matchMergeComponent ! : MatchMergeComponent
4242 private readonly _unsubscribeAll$ = new Subject < void > ( )
43+ private _cacheService = inject ( CacheService )
4344 private _columnMappingProfileService = inject ( ColumnMappingProfileService )
4445 private _columnService = inject ( ColumnService )
4546 private _cycleService = inject ( CycleService )
@@ -71,11 +72,12 @@ export class DataMappingComponent implements OnDestroy, OnInit {
7172 matchingTaxLotColumns : string [ ] = [ ]
7273 org : Organization
7374 orgId : number
75+ progressBarObj = this . _uploaderService . defaultProgressBarObj
76+ progressTitle = 'Mapping Data...'
7477 propertyColumns : Column [ ]
7578 rawColumnNames : string [ ] = [ ]
7679 taxlotColumns : Column [ ]
7780
78- progressBarObj = this . _uploaderService . defaultProgressBarObj
7981
8082 ngOnInit ( ) : void {
8183 // this._userService.currentOrganizationId$
@@ -181,7 +183,6 @@ export class DataMappingComponent implements OnDestroy, OnInit {
181183 this . _snackBar . alert ( 'Error starting mapping' )
182184 }
183185 const successFn = ( ) => {
184- this . nextStep ( 2 )
185186 this . getMappingResults ( )
186187 }
187188
@@ -214,10 +215,25 @@ export class DataMappingComponent implements OnDestroy, OnInit {
214215 }
215216
216217 getMappingResults ( ) : void {
217- this . nextStep ( 2 )
218+ this . progressTitle = 'Fetching Mapping Results...'
219+ const successFn = ( { unique_id } : ProgressResponse ) => {
220+ this . _cacheService . getCacheEntry ( this . orgId , unique_id )
221+ . pipe (
222+ tap ( ( response ) => {
223+ this . mappingResultsResponse = response as MappingResultsResponse
224+ this . nextStep ( 2 )
225+ } ) ,
226+ )
227+ . subscribe ( )
228+ }
229+
218230 this . _mappingService . mappingResults ( this . orgId , this . fileId )
219231 . pipe (
220- tap ( ( mappingResultsResponse ) => { this . mappingResultsResponse = mappingResultsResponse } ) ,
232+ switchMap ( ( { progress_key } ) => this . _uploaderService . checkProgressLoop ( {
233+ progressKey : progress_key ,
234+ successFn,
235+ progressBarObj : this . progressBarObj ,
236+ } ) ) ,
221237 )
222238 . subscribe ( )
223239 }
0 commit comments