From e7ba37af2ad49498043edac26afa38e6c3128c9f Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 30 Oct 2023 10:24:25 +0100 Subject: [PATCH] The user is redirected to the right download page after clicking on `Download file` button. --- .../file-description/file-description.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 68dd27f4dab..0c7662e991d 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,6 +1,7 @@ import { Component, Input } 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'; const allowedPreviewFormats = ['text/plain', 'text/html', 'application/zip']; @Component({ @@ -12,11 +13,20 @@ export class FileDescriptionComponent { @Input() fileInput: MetadataBitstream; - constructor(protected halService: HALEndpointService) { } + constructor(protected halService: HALEndpointService, private router: Router) { } public downloadFiles() { console.log('${this.fileInput.href}', `${this.fileInput.href}`); - window.location.href = this.halService.getRootHref().replace('/server/api', '') + `${this.fileInput.href}`; + console.log('gile', this.fileInput); + // console.log('this.halService.getRootHref()', ); + // const href$ = this.halService.getEndpoint('bitstreams'); + this.router.navigateByUrl('bitstreams/' + this.fileInput.id + '/download'); + // href$.pipe( + // find((href: string) => hasValue(href)), + // ).subscribe((endpoint: string) => { + // console.log('endpoint', endpoint + '/' + this.fileInput.id + '/download'); + // }); + // window.location.href = this.halService.getRootHref() } public isTxt() {