upload-bitstream.component.ts (dspace-angular-dspace-7.0) | : | upload-bitstream.component.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; | |||
import { Observable, Subscription } from 'rxjs'; | import { Observable, Subscription } from 'rxjs'; | |||
import { RemoteData } from '../../../core/data/remote-data'; | import { RemoteData } from '../../../core/data/remote-data'; | |||
import { Item } from '../../../core/shared/item.model'; | import { Item } from '../../../core/shared/item.model'; | |||
import { map, switchMap, take } from 'rxjs/operators'; | import { map, take } from 'rxjs/operators'; | |||
import { ActivatedRoute, Router } from '@angular/router'; | import { ActivatedRoute, Router } from '@angular/router'; | |||
import { UploaderOptions } from '../../../shared/uploader/uploader-options.model '; | import { UploaderOptions } from '../../../shared/uploader/uploader-options.model '; | |||
import { hasValue, isEmpty, isNotEmpty } from '../../../shared/empty.util'; | import { hasValue, isEmpty, isNotEmpty } from '../../../shared/empty.util'; | |||
import { ItemDataService } from '../../../core/data/item-data.service'; | import { ItemDataService } from '../../../core/data/item-data.service'; | |||
import { AuthService } from '../../../core/auth/auth.service'; | import { AuthService } from '../../../core/auth/auth.service'; | |||
import { NotificationsService } from '../../../shared/notifications/notification s.service'; | import { NotificationsService } from '../../../shared/notifications/notification s.service'; | |||
import { TranslateService } from '@ngx-translate/core'; | import { TranslateService } from '@ngx-translate/core'; | |||
import { PaginatedList } from '../../../core/data/paginated-list.model'; | import { PaginatedList } from '../../../core/data/paginated-list.model'; | |||
import { Bundle } from '../../../core/shared/bundle.model'; | import { Bundle } from '../../../core/shared/bundle.model'; | |||
import { BundleDataService } from '../../../core/data/bundle-data.service'; | import { BundleDataService } from '../../../core/data/bundle-data.service'; | |||
skipping to change at line 111 | skipping to change at line 111 | |||
* itemRD$ Fetched from the current route data (populated by Bitstrea mPageResolver) | * itemRD$ Fetched from the current route data (populated by Bitstrea mPageResolver) | |||
* bundlesRD$ List of bundles on the item | * bundlesRD$ List of bundles on the item | |||
* selectedBundleId Starts off by checking if the route's queryParams contain a "bundle" parameter. If none is found, | * selectedBundleId Starts off by checking if the route's queryParams contain a "bundle" parameter. If none is found, | |||
* the ID of the first bundle in the list is selected. | * the ID of the first bundle in the list is selected. | |||
* Calls setUploadUrl after setting the selected bundle | * Calls setUploadUrl after setting the selected bundle | |||
*/ | */ | |||
ngOnInit(): void { | ngOnInit(): void { | |||
this.itemId = this.route.snapshot.params.id; | this.itemId = this.route.snapshot.params.id; | |||
this.entityType = this.route.snapshot.params['entity-type']; | this.entityType = this.route.snapshot.params['entity-type']; | |||
this.itemRD$ = this.route.data.pipe(map((data) => data.dso)); | this.itemRD$ = this.route.data.pipe(map((data) => data.dso)); | |||
this.bundlesRD$ = this.itemRD$.pipe( | this.bundlesRD$ = this.itemService.getBundles(this.itemId); | |||
switchMap((itemRD: RemoteData<Item>) => itemRD.payload.bundles) | ||||
); | ||||
this.selectedBundleId = this.route.snapshot.queryParams.bundle; | this.selectedBundleId = this.route.snapshot.queryParams.bundle; | |||
if (isNotEmpty(this.selectedBundleId)) { | if (isNotEmpty(this.selectedBundleId)) { | |||
this.bundleService.findById(this.selectedBundleId).pipe( | this.bundleService.findById(this.selectedBundleId).pipe( | |||
getFirstSucceededRemoteDataPayload() | getFirstSucceededRemoteDataPayload() | |||
).subscribe((bundle: Bundle) => { | ).subscribe((bundle: Bundle) => { | |||
this.selectedBundleName = bundle.name; | this.selectedBundleName = bundle.name; | |||
}); | }); | |||
this.setUploadUrl(); | this.setUploadUrl(); | |||
} | } | |||
} | } | |||
End of changes. 2 change blocks. | ||||
4 lines changed or deleted | 2 lines changed or added |