Move files
This commit is contained in:
@@ -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;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { RxStompConfig } from '@stomp/rx-stomp';
|
||||
|
||||
export const myRxStompConfig: RxStompConfig = {
|
||||
// Which server?
|
||||
brokerURL: 'ws://localhost:8080/ws',
|
||||
|
||||
// Headers
|
||||
// Typical keys: login, passcode, host
|
||||
connectHeaders: {
|
||||
login: 'guest',
|
||||
passcode: 'guest',
|
||||
},
|
||||
|
||||
// How often to heartbeat?
|
||||
// Interval in milliseconds, set to 0 to disable
|
||||
heartbeatIncoming: 0, // Typical value 0 - disabled
|
||||
heartbeatOutgoing: 20000, // Typical value 20000 - every 20 seconds
|
||||
|
||||
// Wait in milliseconds before attempting auto reconnect
|
||||
// Set to 0 to disable
|
||||
// Typical value 500 (500 milli seconds)
|
||||
reconnectDelay: 200,
|
||||
|
||||
// Will log diagnostics on console
|
||||
// It can be quite verbose, not recommended in production
|
||||
// Skip this key to stop logging to console
|
||||
debug: (msg: string): void => {
|
||||
//console.log(new Date(), msg);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { RxStompService } from './rx-stomp.service';
|
||||
import { myRxStompConfig } from './my-rx-stomp.config';
|
||||
|
||||
export function rxStompServiceFactory() {
|
||||
const rxStomp = new RxStompService();
|
||||
rxStomp.configure(myRxStompConfig);
|
||||
rxStomp.activate();
|
||||
return rxStomp;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RxStomp } from '@stomp/rx-stomp';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RxStompService extends RxStomp {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ToastService {
|
||||
|
||||
constructor(private messageService: MessageService) {}
|
||||
|
||||
showSuccess(summary: string, detail: string) {
|
||||
this.messageService.add({ severity: 'success', summary, detail });
|
||||
}
|
||||
|
||||
showError(summary: string, detail: string) {
|
||||
this.messageService.add({ severity: 'error', summary, detail });
|
||||
}
|
||||
|
||||
showInfo(summary: string, detail: string) {
|
||||
this.messageService.add({ severity: 'info', summary, detail });
|
||||
}
|
||||
|
||||
showWarning(summary: string, detail: string) {
|
||||
this.messageService.add({ severity: 'warn', summary, detail });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user