From c1b1cb2a272039c8afc38727f02702b2b841edc5 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Fri, 25 Jun 2021 17:29:18 +0200 Subject: [PATCH] 80369: Remove deprecated front-end thumbnail methods --- .../publication/publication.component.html | 2 +- .../item-types/shared/item.component.ts | 17 +--- .../untyped-item/untyped-item.component.html | 2 +- src/app/core/data/bitstream-data.service.ts | 86 ------------------- ...-search-result-grid-element.component.html | 4 +- ...-search-result-grid-element.component.html | 4 +- ...-search-result-grid-element.component.html | 4 +- .../journal-issue.component.html | 2 +- .../journal-volume.component.html | 2 +- .../item-pages/journal/journal.component.html | 2 +- ...-search-result-grid-element.component.html | 4 +- ...-search-result-grid-element.component.html | 4 +- ...-search-result-grid-element.component.html | 4 +- .../org-unit/org-unit.component.html | 2 +- .../item-pages/person/person.component.html | 2 +- .../item-pages/project/project.component.html | 2 +- ...ult-list-submission-element.component.html | 2 +- ...esult-list-submission-element.component.ts | 10 --- ...esult-list-submission-element.component.ts | 10 --- .../item-detail-preview.component.html | 2 +- .../item-detail-preview.component.spec.ts | 7 -- .../item-detail-preview.component.ts | 17 +--- ...-search-result-grid-element.component.html | 5 +- .../search-result-grid-element.component.ts | 9 -- 24 files changed, 27 insertions(+), 178 deletions(-) diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index a5282bfa7f..9e61f00e48 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -10,7 +10,7 @@
- + diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 130f67edc7..7f437acfbb 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -7,6 +7,7 @@ import { takeUntilCompletedRemoteData } from '../../../../core/shared/operators' import { getItemPageRoute } from '../../../item-page-routing-paths'; import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; import { RemoteData } from '../../../../core/data/remote-data'; +import { Observable } from 'rxjs/internal/Observable'; @Component({ selector: 'ds-item', @@ -18,28 +19,14 @@ import { RemoteData } from '../../../../core/data/remote-data'; export class ItemComponent implements OnInit { @Input() object: Item; - /** - * The Item's thumbnail - */ - thumbnail$: BehaviorSubject>; - /** * Route to the item page */ itemPageRoute: string; - mediaViewer = environment.mediaViewer; - constructor(protected bitstreamDataService: BitstreamDataService) { - } + mediaViewer = environment.mediaViewer; ngOnInit(): void { this.itemPageRoute = getItemPageRoute(this.object); - - this.thumbnail$ = new BehaviorSubject>(undefined); - this.bitstreamDataService.getThumbnailFor(this.object).pipe( - takeUntilCompletedRemoteData(), - ).subscribe((rd: RemoteData) => { - this.thumbnail$.next(rd); - }); } } diff --git a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html index bacffbf526..b0157dcfee 100644 --- a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html +++ b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html @@ -10,7 +10,7 @@
- + diff --git a/src/app/core/data/bitstream-data.service.ts b/src/app/core/data/bitstream-data.service.ts index 1a16abc47f..a29854d9b3 100644 --- a/src/app/core/data/bitstream-data.service.ts +++ b/src/app/core/data/bitstream-data.service.ts @@ -75,92 +75,6 @@ export class BitstreamDataService extends DataService { return this.findAllByHref(bundle._links.bitstreams.href, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - /** - * Retrieves the thumbnail for the given item - * @returns {Observable>} the first bitstream in the THUMBNAIL bundle - */ - // TODO should be implemented rest side. {@link Item} should get a thumbnail link - public getThumbnailFor(item: Item): Observable> { - return this.bundleService.findByItemAndName(item, 'THUMBNAIL').pipe( - switchMap((bundleRD: RemoteData) => { - if (isNotEmpty(bundleRD.payload)) { - return this.findAllByBundle(bundleRD.payload, { elementsPerPage: 1 }).pipe( - map((bitstreamRD: RemoteData>) => { - if (hasValue(bitstreamRD.payload) && hasValue(bitstreamRD.payload.page)) { - return new RemoteData( - bitstreamRD.timeCompleted, - bitstreamRD.msToLive, - bitstreamRD.lastUpdated, - bitstreamRD.state, - bitstreamRD.errorMessage, - bitstreamRD.payload.page[0], - bitstreamRD.statusCode - ); - } else { - return bitstreamRD as any; - } - }) - ); - } else { - return [bundleRD as any]; - } - }) - ); - } - - /** - * Retrieve the matching thumbnail for a {@link Bitstream}. - * - * The {@link Item} is technically redundant, but is available - * in all current use cases, and having it simplifies this method - * - * @param item The {@link Item} the {@link Bitstream} and its thumbnail are a part of - * @param bitstreamInOriginal The original {@link Bitstream} to find the thumbnail for - */ - // TODO should be implemented rest side - public getMatchingThumbnail(item: Item, bitstreamInOriginal: Bitstream): Observable> { - return this.bundleService.findByItemAndName(item, 'THUMBNAIL').pipe( - switchMap((bundleRD: RemoteData) => { - if (isNotEmpty(bundleRD.payload)) { - return this.findAllByBundle(bundleRD.payload, { elementsPerPage: 9999 }).pipe( - map((bitstreamRD: RemoteData>) => { - if (hasValue(bitstreamRD.payload) && hasValue(bitstreamRD.payload.page)) { - const matchingThumbnail = bitstreamRD.payload.page.find((thumbnail: Bitstream) => - thumbnail.name.startsWith(bitstreamInOriginal.name) - ); - if (hasValue(matchingThumbnail)) { - return new RemoteData( - bitstreamRD.timeCompleted, - bitstreamRD.msToLive, - bitstreamRD.lastUpdated, - bitstreamRD.state, - bitstreamRD.errorMessage, - matchingThumbnail, - bitstreamRD.statusCode - ); - } else { - return new RemoteData( - bitstreamRD.timeCompleted, - bitstreamRD.msToLive, - bitstreamRD.lastUpdated, - RequestEntryState.Error, - 'No matching thumbnail found', - undefined, - 404 - ); - } - } else { - return bitstreamRD as any; - } - }) - ); - } else { - return [bundleRD as any]; - } - }) - ); - } - /** * Retrieve all {@link Bitstream}s in a certain {@link Bundle}. * diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html index feb282d3a7..028876b3d0 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -8,13 +8,13 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- +
- +
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html index aa2352b284..65ff75a731 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -8,13 +8,13 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- +
- +
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html index 8fdad59827..0c5824c6d6 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -8,13 +8,13 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- +
- +
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index 8e357140d8..5847be7dd2 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -9,7 +9,7 @@
- +
- +
- +
- +
- +
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html index 23de8b134f..680a9909bc 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -8,13 +8,13 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- +
- +
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html index 88498a4d67..204f8fc8cb 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -8,13 +8,13 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- +
- +
diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index d328e93b15..c9ea8fb549 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -9,7 +9,7 @@
-
- diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 181a8dc44e..8f2ff6adcd 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -10,7 +10,7 @@
diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.html b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.html index 063e1393cc..13787bb925 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.html +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.html @@ -1,6 +1,6 @@
- +
{ - return this.bitstreamDataService.getThumbnailFor(this.dso).pipe( - getFirstSucceededRemoteDataPayload() - ); - } } diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts index 64cf73cfb9..13de40e015 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts @@ -1,8 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service'; -import { Bitstream } from '../../../../../core/shared/bitstream.model'; -import { getFirstSucceededRemoteDataPayload } from '../../../../../core/shared/operators'; import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; @@ -108,11 +105,4 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu modalComp.value = value; return modalRef.result; } - - // TODO refactor to return RemoteData, and thumbnail template to deal with loading - getThumbnail(): Observable { - return this.bitstreamDataService.getThumbnailFor(this.dso).pipe( - getFirstSucceededRemoteDataPayload() - ); - } } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html index e4d2526eb2..61e2955deb 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html @@ -10,7 +10,7 @@
- + diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts index 2b38b58598..07acf3ea75 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts @@ -126,13 +126,6 @@ describe('ItemDetailPreviewComponent', () => { })); - it('should get item thumbnail', (done) => { - component.getThumbnail().subscribe((thumbnail) => { - expect(thumbnail).toBeDefined(); - done(); - }); - }); - it('should get item bitstreams', (done) => { component.getFiles().subscribe((bitstreams) => { expect(bitstreams).toBeDefined(); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts index a4dc0a1d3d..92c1afcb59 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts @@ -5,10 +5,7 @@ import { first } from 'rxjs/operators'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.service'; import { Item } from '../../../../core/shared/item.model'; -import { - getFirstSucceededRemoteDataPayload, - getFirstSucceededRemoteListPayload -} from '../../../../core/shared/operators'; +import { getFirstSucceededRemoteListPayload } from '../../../../core/shared/operators'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { fadeInOut } from '../../../animations/fade'; import { Bitstream } from '../../../../core/shared/bitstream.model'; @@ -57,11 +54,6 @@ export class ItemDetailPreviewComponent { */ public separator = ', '; - /** - * The item's thumbnail - */ - public thumbnail$: Observable; - /** * Initialize instance variables * @@ -86,13 +78,6 @@ export class ItemDetailPreviewComponent { }); } - // TODO refactor this method to return RemoteData, and the template to deal with loading and errors - public getThumbnail(): Observable { - return this.bitstreamDataService.getThumbnailFor(this.item).pipe( - getFirstSucceededRemoteDataPayload() - ); - } - // TODO refactor this method to return RemoteData, and the template to deal with loading and errors public getFiles(): Observable { return this.bitstreamDataService diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html index bc16853721..d2454b28e6 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html @@ -6,13 +6,13 @@
- +
- +
@@ -43,4 +43,3 @@
- diff --git a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts index 7436d2922e..da1f0ea11b 100644 --- a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts @@ -3,13 +3,11 @@ import { Observable } from 'rxjs'; import { SearchResult } from '../../search/search-result.model'; import { BitstreamDataService } from '../../../core/data/bitstream-data.service'; -import { Bitstream } from '../../../core/shared/bitstream.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { Metadata } from '../../../core/shared/metadata.utils'; import { hasValue } from '../../empty.util'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { TruncatableService } from '../../truncatable/truncatable.service'; -import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators'; @Component({ selector: 'ds-search-result-grid-element', @@ -66,11 +64,4 @@ export class SearchResultGridElementComponent, K exten private isCollapsed(): Observable { return this.truncatableService.isCollapsed(this.dso.id); } - - // TODO refactor to return RemoteData, and thumbnail template to deal with loading - getThumbnail(): Observable { - return this.bitstreamDataService.getThumbnailFor(this.dso as any).pipe( - getFirstSucceededRemoteDataPayload() - ); - } }