+
{
+ const currentPagination$ = this.getCurrentPagination();
+ const currentSort$ = this.getCurrentSort();
+ const searchTerm$ = new BehaviorSubject(this.searchQuery);
+
+ combineLatest([currentPagination$, currentSort$, searchTerm$]).pipe(
+ scan((prevState, [currentPagination, currentSort, searchTerm]) => {
+ // If search term has changed, reset to page 1; otherwise, keep current page
+ const currentPage = prevState.searchTerm !== searchTerm ? 1 : currentPagination.currentPage;
+ return { currentPage, currentPagination, currentSort, searchTerm };
+ }, { searchTerm: '', currentPage: 1, currentPagination: this.getCurrentPagination(),
+ currentSort: this.getCurrentSort() }),
+ switchMap(({ currentPage, currentPagination, currentSort, searchTerm }) => {
return this.handleDataService.findAll({
- currentPage: currentPagination.currentPage,
+ currentPage: currentPage,
elementsPerPage: currentPagination.pageSize,
sort: {field: currentSort.field, direction: currentSort.direction}
}, false
@@ -351,29 +353,6 @@ export class HandleTableComponent implements OnInit {
}, 250 );
}
- /**
- * If the user is typing the searchQuery is changing.
- */
- setSearchQuery() {
- if (isEmpty(this.searchOption)) {
- return;
- }
-
- fromEvent(this.searchInput.nativeElement,'keyup')
- .pipe(
- debounceTime(300),
- distinctUntilChanged()
- )
- .subscribe( cc => {
- this.searchHandles(this.searchInput.nativeElement.value);
- setTimeout(() => {
- // click to refresh table data because without click it still shows wrong data
- document.getElementById('clarin-dc-search-box').click();
- }, 25);
- });
-
- }
-
/**
* The search option is selected from the dropdown menu.
* @param event with the selected value
@@ -386,7 +365,7 @@ export class HandleTableComponent implements OnInit {
* Update the sortConfiguration based on the `searchOption` and the `searchQuery` but parse that attributes at first.
* @param searchQuery
*/
- searchHandles(searchQuery = '') {
+ searchHandles() {
if (isEmpty(this.searchOption)) {
return;
}
@@ -394,7 +373,7 @@ export class HandleTableComponent implements OnInit {
// parse searchQuery for the server request
// the new sorting query is in the format e.g. `handle:123456`, `resourceTypeId:2`, `url:internal`
let parsedSearchOption = '';
- let parsedSearchQuery = searchQuery;
+ let parsedSearchQuery = this.searchQuery;
switch (this.searchOption) {
case this.handleOption:
parsedSearchOption = HANDLE_SEARCH_OPTION;
@@ -402,16 +381,16 @@ export class HandleTableComponent implements OnInit {
case this.internalOption:
// if the handle doesn't have the URL - is internal, if it does - is external
parsedSearchOption = URL_SEARCH_OPTION;
- if (searchQuery === 'Yes' || searchQuery === 'yes') {
+ if (this.searchQuery.toLowerCase() === 'yes') {
parsedSearchQuery = 'internal';
- } else if (searchQuery === 'No' || searchQuery === 'no') {
+ } else if (this.searchQuery.toLowerCase() === 'no') {
parsedSearchQuery = 'external';
}
break;
case this.resourceTypeOption:
parsedSearchOption = RESOURCE_TYPE_SEARCH_OPTION;
// parse resourceType from string to the number because the resourceType is integer on the server
- switch (searchQuery) {
+ switch (this.searchQuery) {
case ITEM:
parsedSearchQuery = '' + 2;
break;
@@ -441,4 +420,18 @@ export class HandleTableComponent implements OnInit {
private initializeSortingOptions() {
this.sortConfiguration = defaultSortConfiguration;
}
+
+ /**
+ * Get the current pagination options.
+ */
+ private getCurrentPagination() {
+ return this.paginationService.getCurrentPagination(this.options.id, defaultPagination);
+ }
+
+ /**
+ * Get the current sorting options.
+ */
+ private getCurrentSort() {
+ return this.paginationService.getCurrentSort(this.options.id, defaultSortConfiguration);
+ }
}
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..510010b6de9 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 { 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..f094c948079 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 @@
+
+
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",