diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html index 2b2f211a316..4778ab0b795 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html @@ -60,18 +60,30 @@
-
diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts index 6a2b69acdce..f8dc723c5a8 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts @@ -1,7 +1,8 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { MetadataBitstream } from 'src/app/core/metadata/metadata-bitstream.model'; import { HALEndpointService } from '../../../../../core/shared/hal-endpoint.service'; -import {Router} from '@angular/router'; +import { Router } from '@angular/router'; +import { ConfigurationDataService } from '../../../../../core/data/configuration-data.service'; const allowedPreviewFormats = ['text/plain', 'text/html', 'application/zip', 'application/x-tar']; @Component({ @@ -9,14 +10,24 @@ const allowedPreviewFormats = ['text/plain', 'text/html', 'application/zip', 'ap templateUrl: './file-description.component.html', styleUrls: ['./file-description.component.scss'], }) -export class FileDescriptionComponent { +export class FileDescriptionComponent implements OnInit { MIME_TYPE_IMAGES_PATH = './assets/images/mime/'; MIME_TYPE_DEFAULT_IMAGE_NAME = 'application-octet-stream.png'; @Input() fileInput: MetadataBitstream; - constructor(protected halService: HALEndpointService, private router: Router) { } + emailToContact: string; + + constructor(protected halService: HALEndpointService, + private router: Router, + private configService: ConfigurationDataService) { } + + ngOnInit(): void { + this.configService.findByPropertyName('lr.help.mail').subscribe(remoteData => { + this.emailToContact = remoteData.payload.values[0]; + }); + } public downloadFile() { void this.router.navigateByUrl('bitstreams/' + this.fileInput.id + '/download'); @@ -45,4 +56,9 @@ export class FileDescriptionComponent { const imgElement = event.target as HTMLImageElement; imgElement.src = this.MIME_TYPE_IMAGES_PATH + this.MIME_TYPE_DEFAULT_IMAGE_NAME; } + + isArchive(format: string): boolean { + return format === 'application/zip' || format === 'application/x-tar'; + } + } diff --git a/src/app/item-page/simple/field-components/preview-section/preview-section.component.html b/src/app/item-page/simple/field-components/preview-section/preview-section.component.html index 8404f491b4f..cd937f7b465 100644 --- a/src/app/item-page/simple/field-components/preview-section/preview-section.component.html +++ b/src/app/item-page/simple/field-components/preview-section/preview-section.component.html @@ -1,3 +1,10 @@ + +
+
+
{{'item.preview.loading-files' | translate}} + +
+
diff --git a/src/app/item-page/simple/field-components/preview-section/preview-section.component.spec.ts b/src/app/item-page/simple/field-components/preview-section/preview-section.component.spec.ts index 7b14feefd87..827b53a4cd6 100644 --- a/src/app/item-page/simple/field-components/preview-section/preview-section.component.spec.ts +++ b/src/app/item-page/simple/field-components/preview-section/preview-section.component.spec.ts @@ -7,20 +7,33 @@ import { PreviewSectionComponent } from './preview-section.component'; import { ResourceType } from 'src/app/core/shared/resource-type'; import { HALLink } from 'src/app/core/shared/hal-link.model'; import { Item } from 'src/app/core/shared/item.model'; +import { ConfigurationDataService } from '../../../../core/data/configuration-data.service'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock'; describe('PreviewSectionComponent', () => { let component: PreviewSectionComponent; let fixture: ComponentFixture; let mockRegistryService: any; + let mockConfigService: any; beforeEach(async () => { + mockConfigService = jasmine.createSpyObj(['findByPropertyName']); mockRegistryService = jasmine.createSpyObj('RegistryService', [ 'getMetadataBitstream', ]); await TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + })], declarations: [PreviewSectionComponent], - providers: [{ provide: RegistryService, useValue: mockRegistryService }], + providers: [ + { provide: RegistryService, useValue: mockRegistryService }, + { provide: ConfigurationDataService, useValue: mockConfigService }], }).compileComponents(); }); diff --git a/src/app/item-page/simple/field-components/preview-section/preview-section.component.ts b/src/app/item-page/simple/field-components/preview-section/preview-section.component.ts index ac8b5df4dd4..efcfcaba609 100644 --- a/src/app/item-page/simple/field-components/preview-section/preview-section.component.ts +++ b/src/app/item-page/simple/field-components/preview-section/preview-section.component.ts @@ -4,6 +4,7 @@ import { MetadataBitstream } from 'src/app/core/metadata/metadata-bitstream.mode import { RegistryService } from 'src/app/core/registry/registry.service'; import { Item } from 'src/app/core/shared/item.model'; import { getAllSucceededRemoteListPayload } from 'src/app/core/shared/operators'; +import { ConfigurationDataService } from '../../../../core/data/configuration-data.service'; @Component({ selector: 'ds-preview-section', @@ -14,8 +15,10 @@ export class PreviewSectionComponent implements OnInit { @Input() item: Item; listOfFiles: BehaviorSubject = new BehaviorSubject([] as any); + emailToContact: string; - constructor(protected registryService: RegistryService) {} // Modified + constructor(protected registryService: RegistryService, + private configService: ConfigurationDataService) {} // Modified ngOnInit(): void { this.registryService @@ -24,5 +27,10 @@ export class PreviewSectionComponent implements OnInit { .subscribe((data: MetadataBitstream[]) => { this.listOfFiles.next(data); }); + this.configService.findByPropertyName('lr.help.mail')?.subscribe(remoteData => { + this.emailToContact = remoteData.payload.values[0]; + }); } + + } diff --git a/src/assets/i18n/cs.json5 b/src/assets/i18n/cs.json5 index 347f7244a8f..cd0da6dccbe 100644 --- a/src/assets/i18n/cs.json5 +++ b/src/assets/i18n/cs.json5 @@ -3380,6 +3380,10 @@ "item.preview.authors.show.everyone": "Zobraz všechny autory", // "item.preview.authors.et.al": " ; et al.", "item.preview.authors.et.al": "; et al.", + // "item.preview.loading-files": "Loading files... This may take a few seconds as file previews are being generated. If the process takes too long, please contact the system administrator", + "item.preview.loading-files": "Načítání souborů... Může to trvat několik sekund, protože se generují náhledy souborů. Pokud proces trvá příliš dlouho, kontaktujte prosím správce systému", + // "item.preview.no-preview": "The file preview wasn't successfully generated, please contact the system administrator", + "item.preview.no-preview": "Náhled souboru nebyl úspěšně vygenerován, kontaktujte prosím správce systému", // "item.refbox.modal.copy.instruction": ["Press", "ctrl + c", "to copy"], "item.refbox.modal.copy.instruction": ["Stiskněte", "ctrl + c", "pro kopírování"], // "item.refbox.modal.submit": "Ok", diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index cdc43133891..7c8a91cfdbd 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -2832,6 +2832,10 @@ "item.preview.authors.et.al": " ; et al.", + "item.preview.loading-files": "Loading files... This may take a few seconds as file previews are being generated. If the process takes too long, please contact the system administrator", + + "item.preview.no-preview": "The file preview wasn't successfully generated, please contact the system administrator", + "item.refbox.modal.copy.instruction": ["Press", "ctrl + c", "to copy"], "item.refbox.modal.submit": "Ok",