Skip to content
Snippets Groups Projects
Commit e51c4774 authored by Albert Bruns's avatar Albert Bruns
Browse files

OZG-6223 typisierung fehlt

parent 3328b544
No related branches found
No related tags found
1 merge request!13OZG-6223-bug-bei-langsamer-verbindung
...@@ -135,7 +135,7 @@ describe('BinaryFileService', () => { ...@@ -135,7 +135,7 @@ describe('BinaryFileService', () => {
}); });
it('should return empty state resource', () => { it('should return empty state resource', () => {
const result = service.handleDownloadError(); const result: Observable<StateResource<Blob>> = service.handleDownloadError();
expect(result).toBeObservable(cold('(a|)', { a: createEmptyStateResource() })); expect(result).toBeObservable(cold('(a|)', { a: createEmptyStateResource() }));
}); });
......
...@@ -84,17 +84,17 @@ export class BinaryFileService { ...@@ -84,17 +84,17 @@ export class BinaryFileService {
} }
} }
public downloadFile(file: BinaryFileResource, fileNamePrefix: string): Observable<StateResource<any>> { public downloadFile(file: BinaryFileResource, fileNamePrefix: string): Observable<StateResource<Blob>> {
return this.repository.download(file).pipe( return this.repository.download(file).pipe(
map((data) => this.saveBinaryFile(data, file, fileNamePrefix)), map((data) => this.saveBinaryFile(data, file, fileNamePrefix)),
startWith(createEmptyStateResource(true)), startWith(createEmptyStateResource<Blob>(true)),
catchError(() => this.handleDownloadError()), catchError(() => this.handleDownloadError()),
); );
} }
handleDownloadError(): Observable<StateResource<unknown>> { handleDownloadError(): Observable<StateResource<Blob>> {
this.snackbarService.showError('Die Datei konnte nicht heruntergeladen werden.'); this.snackbarService.showError('Die Datei konnte nicht heruntergeladen werden.');
return of(createEmptyStateResource()); return of(createEmptyStateResource<Blob>());
} }
saveBinaryFile(data: any, file: BinaryFileResource, fileNamePrefix: string): StateResource<Blob> { saveBinaryFile(data: any, file: BinaryFileResource, fileNamePrefix: string): StateResource<Blob> {
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ApiDownloadToken, ApiRootService } from '@alfa-client/api-root-shared'; import { ApiDownloadToken, ApiRootService } from '@alfa-client/api-root-shared';
import { BinaryFileResource, BinaryFileService } from '@alfa-client/binary-file-shared'; import { BinaryFileResource, BinaryFileService } from '@alfa-client/binary-file-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@Component({ @Component({
...@@ -39,7 +39,7 @@ export class BinaryFileContainerComponent { ...@@ -39,7 +39,7 @@ export class BinaryFileContainerComponent {
@Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter(); @Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter();
fileStateResource$: Observable<StateResource<any>>; fileStateResource$: Observable<StateResource<Blob>>;
downloadToken$: Observable<ApiDownloadToken>; downloadToken$: Observable<ApiDownloadToken>;
constructor( constructor(
...@@ -48,10 +48,7 @@ export class BinaryFileContainerComponent { ...@@ -48,10 +48,7 @@ export class BinaryFileContainerComponent {
) {} ) {}
startDownload(file: BinaryFileResource): void { startDownload(file: BinaryFileResource): void {
this.fileStateResource$ = this.binaryFileService.downloadFile( this.fileStateResource$ = this.binaryFileService.downloadFile(file, this.downloadFileNamePrefix);
file,
this.downloadFileNamePrefix,
);
} }
getDownloadToken(): void { getDownloadToken(): void {
......
...@@ -38,7 +38,7 @@ export class BinaryFile2ContainerComponent { ...@@ -38,7 +38,7 @@ export class BinaryFile2ContainerComponent {
@Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter(); @Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter();
fileStateResource$: Observable<StateResource<any>>; fileStateResource$: Observable<StateResource<Blob>>;
downloadToken$: Observable<ApiDownloadToken>; downloadToken$: Observable<ApiDownloadToken>;
constructor( constructor(
...@@ -47,10 +47,7 @@ export class BinaryFile2ContainerComponent { ...@@ -47,10 +47,7 @@ export class BinaryFile2ContainerComponent {
) {} ) {}
startDownload(file: BinaryFileResource): void { startDownload(file: BinaryFileResource): void {
this.fileStateResource$ = this.binaryFileService.downloadFile( this.fileStateResource$ = this.binaryFileService.downloadFile(file, this.downloadFileNamePrefix);
file,
this.downloadFileNamePrefix,
);
} }
getDownloadToken(): void { getDownloadToken(): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment