From 18db8cda99eb87daf470350a2b6dc2548c8238f9 Mon Sep 17 00:00:00 2001 From: Cecilia Krum Date: Mon, 8 Jun 2026 14:16:44 -0500 Subject: [PATCH] PER-10621: Show Archivematica thumbnail Map the 256 size thumbnail from the stela response to the record. Also check for it in the data service when deciding whether or not to refresh an item. I wanted to add a test, but I'm not sure this one is useful. --- src/app/shared/services/api/base.ts | 1 + .../shared/services/api/record.repo.spec.ts | 45 ++++++++++++++++++- src/app/shared/services/api/record.repo.ts | 20 +++++---- src/app/shared/services/data/data.service.ts | 1 + 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/app/shared/services/api/base.ts b/src/app/shared/services/api/base.ts index 429eeef8c..eb4210214 100644 --- a/src/app/shared/services/api/base.ts +++ b/src/app/shared/services/api/base.ts @@ -105,6 +105,7 @@ export const LeanWhitelist = [ 'thumbURL500', 'thumbURL1000', 'thumbURL2000', + 'thumbnail256', 'thumbDT', 'refArchiveNbr', 'folder_linkId', diff --git a/src/app/shared/services/api/record.repo.spec.ts b/src/app/shared/services/api/record.repo.spec.ts index b027956b1..0cffe98e8 100644 --- a/src/app/shared/services/api/record.repo.spec.ts +++ b/src/app/shared/services/api/record.repo.spec.ts @@ -6,7 +6,12 @@ import { import { of } from 'rxjs'; import { environment } from '@root/environments/environment'; import { HttpService } from '@shared/services/http/http.service'; -import { RecordRepo, RecordResponse } from '@shared/services/api/record.repo'; +import { + convertStelaRecordToRecordVO, + RecordRepo, + RecordResponse, + StelaRecord, +} from '@shared/services/api/record.repo'; import { RecordVO } from '@root/app/models'; import { provideHttpClient, @@ -15,6 +20,44 @@ import { import { ShareLink } from '@root/app/share-links/models/share-link'; import { HttpV2Service } from '../http-v2/http-v2.service'; +describe('convertStelaRecordToRecordVO', () => { + it('maps thumbnailUrls to all thumb fields', () => { + const stelaRecord = { + recordId: 1, + displayName: 'Test', + archiveNumber: 'arch-1', + displayDate: '2025-01-01', + folderLinkId: '1', + folderLinkType: 'type.folder_link.private', + parentFolderLinkId: '2', + thumbnailUrls: { + '200': 'https://example.com/200', + '256': 'https://example.com/256', + '500': 'https://example.com/500', + '1000': 'https://example.com/1000', + '2000': 'https://example.com/2000', + }, + location: null, + files: [], + createdAt: '2025-01-01', + updatedAt: '2025-01-01', + archive: { id: '1', name: 'Archive', thumbURL200: '' }, + shares: null, + tags: null, + }; + + const result = convertStelaRecordToRecordVO( + stelaRecord as unknown as StelaRecord, + ); + + expect(result.thumbURL200).toBe('https://example.com/200'); + expect(result.thumbURL500).toBe('https://example.com/500'); + expect(result.thumbURL1000).toBe('https://example.com/1000'); + expect(result.thumbURL2000).toBe('https://example.com/2000'); + expect(result.thumbnail256).toBe('https://example.com/256'); + }); +}); + describe('RecordRepo', () => { let repo: RecordRepo; let httpMock: HttpTestingController; diff --git a/src/app/shared/services/api/record.repo.ts b/src/app/shared/services/api/record.repo.ts index b39dfb2cd..eb98be7cf 100644 --- a/src/app/shared/services/api/record.repo.ts +++ b/src/app/shared/services/api/record.repo.ts @@ -104,10 +104,13 @@ export type StelaRecord = Omit & { folderLinkId: string; folderLinkType: FolderLinkType; parentFolderLinkId: string; - thumbUrl200: string; - thumbUrl500: string; - thumbUrl1000: string; - thumbUrl2000: string; + thumbnailUrls: { + '200': string; + '256': string; + '500': string; + '1000': string; + '2000': string; + }; location: StelaLocation | null; files: Array; createdAt: string; @@ -171,10 +174,11 @@ export const convertStelaRecordToRecordVO = ( ): RecordVO => new RecordVO({ ...stelaRecord, - thumbURL200: stelaRecord.thumbUrl200, - thumbURL500: stelaRecord.thumbUrl500, - thumbURL1000: stelaRecord.thumbUrl1000, - thumbURL2000: stelaRecord.thumbUrl2000, + thumbURL200: stelaRecord.thumbnailUrls?.['200'], + thumbURL500: stelaRecord.thumbnailUrls?.['500'], + thumbURL1000: stelaRecord.thumbnailUrls?.['1000'], + thumbURL2000: stelaRecord.thumbnailUrls?.['2000'], + thumbnail256: stelaRecord.thumbnailUrls?.['256'], TagVOs: (stelaRecord.tags ?? []).map((stelaTag) => convertStelaTagToTagVO(stelaTag, stelaRecord.archiveId), ), diff --git a/src/app/shared/services/data/data.service.ts b/src/app/shared/services/data/data.service.ts index cf2385f7b..1ce6c7eb5 100644 --- a/src/app/shared/services/data/data.service.ts +++ b/src/app/shared/services/data/data.service.ts @@ -253,6 +253,7 @@ export class DataService { if ( !item.isFolder && !item.thumbURL200 && + !item.thumbnail256 && item.parentFolderId === this.currentFolder.folderId ) { this.debug('thumbRefreshQueue push %s', item.archiveNbr);