WIP: Rearrange code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UtilityService} from '../../book/service/utility.service';
|
||||
import {UtilityService} from './utility.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-directory-picker-v2',
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UtilityService {
|
||||
|
||||
private pathUrl = 'http://localhost:8080/v1/path';
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getFolders(path: string): Observable<string[]> {
|
||||
const params = new HttpParams().set('path', path);
|
||||
return this.http.get<string[]>(this.pathUrl, { params });
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {FileUploadService} from '../../book/service/file-upload.service';
|
||||
import {FileUploadService} from './file-upload.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {DropdownModule} from 'primeng/dropdown';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {ToastService} from '../../book/service/toast.service';
|
||||
import {ToastService} from '../../core/service/toast.service';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryService} from '../../book/service/library.service';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FileUploadService {
|
||||
|
||||
private uploadUrl = 'http://localhost:8080/api/v1/files/upload';
|
||||
|
||||
constructor(private http: 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(
|
||||
catchError((error) => {
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user