From 70ace4263c9e694e50156b16104133096015241b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Tue, 21 May 2024 15:29:40 +0200 Subject: [PATCH] document thumbnailUrl should be the sipi baseUrl --- .../representation/upload/upload.component.ts | 41 +++++++++---------- .../src/lib/upload-file.service.ts | 5 ++- .../src/lib/upload2.component.ts | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/apps/dsp-app/src/app/workspace/resource/representation/upload/upload.component.ts b/apps/dsp-app/src/app/workspace/resource/representation/upload/upload.component.ts index 0fbda5a6b5..95281ad212 100644 --- a/apps/dsp-app/src/app/workspace/resource/representation/upload/upload.component.ts +++ b/apps/dsp-app/src/app/workspace/resource/representation/upload/upload.component.ts @@ -2,26 +2,26 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { - CreateArchiveFileValue, - CreateAudioFileValue, - CreateDocumentFileValue, - CreateFileValue, - CreateMovingImageFileValue, - CreateStillImageFileValue, - CreateTextFileValue, - UpdateArchiveFileValue, - UpdateAudioFileValue, - UpdateDocumentFileValue, - UpdateFileValue, - UpdateMovingImageFileValue, - UpdateStillImageFileValue, - UpdateTextFileValue, + CreateArchiveFileValue, + CreateAudioFileValue, + CreateDocumentFileValue, + CreateFileValue, + CreateMovingImageFileValue, + CreateStillImageFileValue, + CreateTextFileValue, + UpdateArchiveFileValue, + UpdateAudioFileValue, + UpdateDocumentFileValue, + UpdateFileValue, + UpdateMovingImageFileValue, + UpdateStillImageFileValue, + UpdateTextFileValue, } from '@dasch-swiss/dsp-js'; import { NotificationService } from '@dasch-swiss/vre/shared/app-notification'; import { UploadedFile, UploadFileService } from '@dasch-swiss/vre/shared/app-resource-properties'; -import {Store} from "@ngxs/store"; -import {ProjectsSelectors} from "@dasch-swiss/vre/shared/app-state"; -import {filter, map, mergeMap} from "rxjs/operators"; +import { Store } from '@ngxs/store'; +import { ProjectsSelectors } from '@dasch-swiss/vre/shared/app-state'; +import { filter, map, mergeMap } from 'rxjs/operators'; import { AppConfigService } from '@dasch-swiss/vre/shared/app-config'; // https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror @@ -104,14 +104,13 @@ export class UploadComponent implements OnInit { ).subscribe( (res: UploadedFile) => { // prepare thumbnail url to display something after upload - const thumbnailUri = res.thumbnailUrl; switch (this.representation) { case 'stillImage': - this.thumbnailUrl = this._sanitizer.bypassSecurityTrustUrl( thumbnailUri); + this.thumbnailUrl = this._sanitizer.bypassSecurityTrustUrl( res.thumbnailUrl); break; case 'document': - this.thumbnailUrl = thumbnailUri; + this.thumbnailUrl = res.baseUrl; break; default: @@ -119,7 +118,7 @@ export class UploadComponent implements OnInit { break; } - this.fileControl.setValue(res.internalFilename); + this.fileControl.setValue(res); const fileValue = this.getNewValue(); if (fileValue) { diff --git a/libs/vre/shared/app-resource-properties/src/lib/upload-file.service.ts b/libs/vre/shared/app-resource-properties/src/lib/upload-file.service.ts index e76c46a64e..0b75342f38 100644 --- a/libs/vre/shared/app-resource-properties/src/lib/upload-file.service.ts +++ b/libs/vre/shared/app-resource-properties/src/lib/upload-file.service.ts @@ -12,6 +12,7 @@ interface UploadedFileResponse { export interface UploadedFile { internalFilename: string; thumbnailUrl: string; + baseUrl: string; } @Injectable({ @@ -47,9 +48,11 @@ export class UploadFileService { const url = `${this._acs.dspIngestConfig.url}/projects/${shortcode}/assets/ingest/${file.name}`; return this._http.post(url, file, options).pipe( map((res: UploadedFileResponse) => { + let baseUrl = `${this._acs.dspIiifConfig.iiifUrl}/${shortcode}/${res.internalFilename}`; return { internalFilename: res.internalFilename, - thumbnailUrl: `${this._acs.dspIiifConfig.iiifUrl}/${shortcode}/${res.internalFilename}/full/256,/0/default.jpg`, + thumbnailUrl: `${baseUrl}/full/256,/0/default.jpg`, + baseUrl: baseUrl, }; }), ); diff --git a/libs/vre/shared/app-resource-properties/src/lib/upload2.component.ts b/libs/vre/shared/app-resource-properties/src/lib/upload2.component.ts index b1c0601ea2..f7f1e9ef59 100644 --- a/libs/vre/shared/app-resource-properties/src/lib/upload2.component.ts +++ b/libs/vre/shared/app-resource-properties/src/lib/upload2.component.ts @@ -131,7 +131,7 @@ export class Upload2Component implements ControlValueAccessor { this.previewUrl = this._sanitizer.bypassSecurityTrustUrl( res.thumbnailUrl ); break; case Constants.HasDocumentFileValue: - this.previewUrl = res.thumbnailUrl; + this.previewUrl = res.baseUrl; break; }