Skip to content

Commit 595769d

Browse files
UFAL/Updated the no file preview message and refactored some code (#837)
* Updated the no file preview message and refactored some code. * Added a non null check when accessing the object properties and the message is refactored.
1 parent eeed640 commit 595769d

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@
6161
</div>
6262
<div [style]="'max-height: 500px; padding: 0px; overflow: scroll'" class="panel-body">
6363
<ul class="treeview collapse show">
64-
<!-- Loading Spinner -->
65-
<div *ngIf="fileInput.fileInfo.length === 0" class="d-flex justify-content-center align-items-center my-3">
66-
<div>{{'item.preview.no-preview' | translate}}
64+
<div *ngIf="hasNoPreview()" class="d-flex justify-content-center align-items-center my-3">
65+
<div>{{ 'item.preview.no-preview' | translate }}
6766
<a *ngIf="emailToContact" [href]="'mailto:' + emailToContact" class="email-text">{{ emailToContact }}</a>
6867
</div>
6968
</div>

src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MetadataBitstream } from 'src/app/core/metadata/metadata-bitstream.mode
33
import { HALEndpointService } from '../../../../../core/shared/hal-endpoint.service';
44
import { Router } from '@angular/router';
55
import { ConfigurationDataService } from '../../../../../core/data/configuration-data.service';
6+
import { getFirstSucceededRemoteData } from '../../../../../core/shared/operators';
67

78
const allowedPreviewFormats = ['text/plain', 'text/html', 'application/zip', 'application/x-tar'];
89
@Component({
@@ -24,8 +25,10 @@ export class FileDescriptionComponent implements OnInit {
2425
private configService: ConfigurationDataService) { }
2526

2627
ngOnInit(): void {
27-
this.configService.findByPropertyName('lr.help.mail').subscribe(remoteData => {
28-
this.emailToContact = remoteData.payload.values[0];
28+
this.configService.findByPropertyName('lr.help.mail')
29+
.pipe(getFirstSucceededRemoteData())
30+
.subscribe(remoteData => {
31+
this.emailToContact = remoteData?.payload?.values?.[0];
2932
});
3033
}
3134

@@ -61,4 +64,8 @@ export class FileDescriptionComponent implements OnInit {
6164
return format === 'application/zip' || format === 'application/x-tar';
6265
}
6366

67+
hasNoPreview() {
68+
// this.fileInput.fileInfo.length === 0 means that the file has no preview
69+
return this.fileInput?.fileInfo?.length === 0;
70+
}
6471
}

src/app/item-page/simple/field-components/preview-section/preview-section.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class PreviewSectionComponent implements OnInit {
2828
this.listOfFiles.next(data);
2929
});
3030
this.configService.findByPropertyName('lr.help.mail')?.subscribe(remoteData => {
31-
this.emailToContact = remoteData.payload.values[0];
31+
this.emailToContact = remoteData.payload?.values?.[0];
3232
});
3333
}
3434

src/assets/i18n/cs.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,8 +3382,8 @@
33823382
"item.preview.authors.et.al": "; et al.",
33833383
// "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",
33843384
"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",
3385-
// "item.preview.no-preview": "The file preview wasn't successfully generated, please contact the system administrator",
3386-
"item.preview.no-preview": "Náhled souboru nebyl úspěšně vygenerován, kontaktujte prosím správce systému",
3385+
// "item.preview.no-preview": "The file preview has not been generated yet. Please try again later or contact the system administrator",
3386+
"item.preview.no-preview": "Náhled souboru zatím nebyl vygenerován. Zkuste to prosím znovu později, nebo kontaktujte správce systému",
33873387
// "item.refbox.modal.copy.instruction": ["Press", "ctrl + c", "to copy"],
33883388
"item.refbox.modal.copy.instruction": ["Stiskněte", "ctrl + c", "pro kopírování"],
33893389
// "item.refbox.modal.submit": "Ok",

src/assets/i18n/en.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2834,7 +2834,7 @@
28342834

28352835
"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",
28362836

2837-
"item.preview.no-preview": "The file preview wasn't successfully generated, please contact the system administrator",
2837+
"item.preview.no-preview": "The file preview has not been generated yet. Please try again later or contact the system administrator",
28382838

28392839
"item.refbox.modal.copy.instruction": ["Press", "ctrl + c", "to copy"],
28402840

0 commit comments

Comments
 (0)