- Refactor to remove BookMetadataBI
- Use inject everywhere instead of constructor injection
This commit is contained in:
+3
-3
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UtilityService} from './utility.service';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -24,8 +24,8 @@ export class DirectoryPickerComponent implements OnInit {
|
||||
paths: string[] = ['...'];
|
||||
selectedProductName: string = '';
|
||||
|
||||
constructor(private utilityService: UtilityService, private dynamicDialogRef: DynamicDialogRef) {
|
||||
}
|
||||
private utilityService = inject(UtilityService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
|
||||
ngOnInit() {
|
||||
const initialPath = '/';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
|
||||
@@ -9,10 +9,10 @@ export class UtilityService {
|
||||
|
||||
private pathUrl = 'http://localhost:8080/v1/path';
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
private http = inject(HttpClient);
|
||||
|
||||
getFolders(path: string): Observable<string[]> {
|
||||
const params = new HttpParams().set('path', path);
|
||||
return this.http.get<string[]>(this.pathUrl, { params });
|
||||
return this.http.get<string[]>(this.pathUrl, {params});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Library} from '../../../book/model/library.model';
|
||||
import {FileUploadService} from './file-upload.service';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -24,20 +24,19 @@ import {LibraryState} from '../../../book/model/state/library-state.model';
|
||||
],
|
||||
})
|
||||
export class FileUploadComponent {
|
||||
libraryState$: Observable<LibraryState>;
|
||||
|
||||
selectedLibrary: Library | null = null;
|
||||
selectedPath: string = '';
|
||||
selectedFileName: string = '';
|
||||
isUploading: boolean = false;
|
||||
errorMessage: string | null = null;
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private fileUploadService: FileUploadService,
|
||||
private toastService: ToastService,
|
||||
private dynamicDialogRef: DynamicDialogRef) {
|
||||
this.libraryState$ = this.libraryService.libraryState$;
|
||||
}
|
||||
private libraryService = inject(LibraryService);
|
||||
private fileUploadService = inject(FileUploadService);
|
||||
private toastService = inject(ToastService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
|
||||
libraryState$: Observable<LibraryState> = this.libraryService.libraryState$;
|
||||
|
||||
triggerFileInput(fileInput: HTMLInputElement): void {
|
||||
fileInput.click();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
@@ -10,14 +10,14 @@ export class FileUploadService {
|
||||
|
||||
private uploadUrl = 'http://localhost:8080/api/v1/files/upload';
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
private httpClient = inject(HttpClient);
|
||||
|
||||
uploadFile(file: File, libraryId: string, filePath: string): Observable<any> {
|
||||
const formData: FormData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('libraryId', libraryId);
|
||||
formData.append('filePath', filePath);
|
||||
return this.http.post(this.uploadUrl, formData).pipe(
|
||||
return this.httpClient.post(this.uploadUrl, formData).pipe(
|
||||
catchError((error) => {
|
||||
throw error;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user