diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 72982d943bf08690c098691b5246f1198c776225..c40405f3e423aa84402c07145aee5800dc9b0c8d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -96,7 +96,7 @@ import { DatasetsDialogComponent } from './datasets/datasets-dialog/datasets-dia NbToastrModule.forRoot(), NbDialogModule.forRoot(), ], - entryComponents: [DatasetsDialogComponent], + entryComponents: [DatasetsDialogComponent, FeedbackDialogComponent], providers: [ AppConfiguration, ParseXmlService, diff --git a/src/app/datasets/datasets.component.ts b/src/app/datasets/datasets.component.ts index f80db3dc76d9ea9eb84f546c6fb3d98a77aefcaf..f7db5d4bd21a71d1b3d53007cd34a46c2d880634 100644 --- a/src/app/datasets/datasets.component.ts +++ b/src/app/datasets/datasets.component.ts @@ -56,7 +56,7 @@ export class DatasetsComponent implements OnInit, OnChanges { } ngOnInit() { - this.dataSetService.itemsDataset = []; + this.dataSetService.resetDataset() } @@ -315,7 +315,7 @@ export class DatasetsComponent implements OnInit, OnChanges { for (const id of datasetId) { const requestPromise = this.launchRequest(datasetRequestPathName, datasetRequestHttpMethod, false, id) .then((dataset) => { - this.dataSetService.saveDatasets(dataset); + this.dataSetService.saveDatasets(dataset, id); }); requestPromises.push(requestPromise); } diff --git a/src/app/datasets/services/dataset-crud.service.ts b/src/app/datasets/services/dataset-crud.service.ts index 0199c6eb7dbbf31601e1136f9456867983a54341..8bf3cae906927101046dfedf3248d386ec84af9b 100644 --- a/src/app/datasets/services/dataset-crud.service.ts +++ b/src/app/datasets/services/dataset-crud.service.ts @@ -15,6 +15,7 @@ export class DatasetCrudService { fds2Token: string = this.sessionStorage.getFDPToken(); public results: string[] = []; itemsDataset: Object[] = []; + ids: number[] = []; constructor(private http: HttpClient, private appConfig: AppConfiguration, private parserService: ParseXmlService, private sessionStorage: TokenStorageService) { } @@ -104,12 +105,16 @@ export class DatasetCrudService { getLocally<T = any>(path: string): Observable<T> { return this.http.get<T>(`${path}`); } - saveDatasets(obj: Object) { + saveDatasets(obj: Object, id: number) { this.itemsDataset.push(obj); + this.ids.push(id); } resetDataset() { this.itemsDataset = []; + this.ids = []; } + + } diff --git a/src/app/mapping/mapping.component.ts b/src/app/mapping/mapping.component.ts index 77c68742f8503bb970e751532010abf9afcca37f..b274ed694229ddc3fa32861ffd349c2274fcee98 100644 --- a/src/app/mapping/mapping.component.ts +++ b/src/app/mapping/mapping.component.ts @@ -32,8 +32,8 @@ export class MappingComponent implements OnInit { first: boolean = true; loading: boolean = false; FDP_URL = environment.fdpUrl; - postedDatastes: string[]; - notPostedDatasets: string[]; + + ids: number []; @ViewChild('autoInput') input; @Input() catalogId: any; @@ -58,6 +58,8 @@ export class MappingComponent implements OnInit { populatecatalogue() { this.itemsdataset = this.dataSetService.itemsDataset; + this.ids = this.dataSetService.ids; + this.ids this.keys = []; for (let i = 0; i < this.itemsdataset.length; i++) { if (i === 0) { @@ -82,8 +84,8 @@ export class MappingComponent implements OnInit { publishDataset() { let data: string = ''; let properties: string = ''; - this.postedDatastes = []; - this.notPostedDatasets = []; + let postedDatastes = []; + let notPostedDatasets = []; this.loading = true; for (let i = 0; i < this.mappedMetadatas.length; i++) { let title = ""; @@ -126,21 +128,27 @@ export class MappingComponent implements OnInit { this.dataSetService.createDataset(data).subscribe( (error: Error) => { - this.notPostedDatasets.push(title); + notPostedDatasets.push(this.ids[i]); if (i === this.mappedMetadatas.length - 1) { this.loading = false; + this.dialog.open(FeedbackDialogComponent, { + data: { + postedMetadatas: postedDatastes, + notPostedMetadatas: notPostedDatasets + } + }).afterClosed().subscribe(() => this.route.navigateByUrl('/dashboard')); } }, () => { - this.postedDatastes.push(title); + postedDatastes.push(this.ids[i]); if (i === this.mappedMetadatas.length - 1) { this.loading = false; this.dialog.open(FeedbackDialogComponent, { data: { - postedMetadatas: this.postedDatastes, - notPostedMetadatas: this.notPostedDatasets + postedMetadatas: postedDatastes, + notPostedMetadatas: notPostedDatasets } - }).afterClosed().subscribe(() => this.route.navigateByUrl('/dashboard')) + }).afterClosed().subscribe(() => this.route.navigateByUrl('/dashboard')); }