Revision 62554
Added by John Balasis about 1 year ago
register-existing-datasource.component.ts | ||
---|---|---|
347 | 347 |
} |
348 | 348 |
|
349 | 349 |
saveNewInterfaces() { |
350 |
if (this.repoInterfaces && (this.repoInterfaces.length > 0)) { |
|
351 |
from(this.repoInterfaces).pipe( |
|
352 |
concatMap(intrf => { |
|
353 |
if (intrf.id) { |
|
354 |
let req; |
|
355 |
if (this.interfacesToDelete.some(id => id === intrf.id)) { |
|
356 |
req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby); |
|
357 |
} else { |
|
358 |
// console.log('comments', intrf.comments); |
|
359 |
req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf); |
|
360 |
} |
|
361 |
return req; |
|
362 |
} else { |
|
363 |
// console.log('comments', intrf.comments); |
|
364 |
return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf); |
|
365 |
} |
|
366 |
}) |
|
367 |
).subscribe( |
|
368 |
res => console.log('after save interfaces', JSON.stringify(res)), |
|
369 |
er => { |
|
370 |
console.log(er); |
|
371 |
this.loadingMessage = ''; |
|
372 |
this.errorMessage = 'Not all changes were saved. Please try again'; |
|
373 |
window.scrollTo(1, 1); |
|
374 |
}, |
|
375 |
() => { |
|
376 |
this.loadingMessage = ''; |
|
377 |
this.datasourceId = null; |
|
378 |
this.repo = null; |
|
379 |
this.repoInterfaces = []; |
|
380 |
this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`); |
|
381 |
} |
|
382 |
); |
|
350 |
console.log('saving Interfaces'); |
|
351 |
for (let i = 0; i < this.interfacesArray.length; i++) { |
|
352 |
console.log(i); |
|
353 |
this.interfacesArray[i].saveInterface(); |
|
383 | 354 |
} |
355 |
this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`); |
|
356 |
// if (this.repoInterfaces && (this.repoInterfaces.length > 0)) { |
|
357 |
// from(this.repoInterfaces).pipe( |
|
358 |
// concatMap(intrf => { |
|
359 |
// if (intrf.id) { |
|
360 |
// let req; |
|
361 |
// if (this.interfacesToDelete.some(id => id === intrf.id)) { |
|
362 |
// req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby); |
|
363 |
// } else { |
|
364 |
// // console.log('comments', intrf.comments); |
|
365 |
// req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf); |
|
366 |
// } |
|
367 |
// return req; |
|
368 |
// } else { |
|
369 |
// // console.log('comments', intrf.comments); |
|
370 |
// return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf); |
|
371 |
// } |
|
372 |
// }) |
|
373 |
// ).subscribe( |
|
374 |
// res => console.log('after save interfaces', JSON.stringify(res)), |
|
375 |
// er => { |
|
376 |
// console.log(er); |
|
377 |
// this.loadingMessage = ''; |
|
378 |
// this.errorMessage = 'Not all changes were saved. Please try again'; |
|
379 |
// window.scrollTo(1, 1); |
|
380 |
// }, |
|
381 |
// () => { |
|
382 |
// this.loadingMessage = ''; |
|
383 |
// this.datasourceId = null; |
|
384 |
// this.repo = null; |
|
385 |
// this.repoInterfaces = []; |
|
386 |
// this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`); |
|
387 |
// } |
|
388 |
// ); |
|
389 |
// } |
|
384 | 390 |
} |
385 | 391 |
} |
Also available in: Unified diff
removed probably unnecessary subscription