cropper & imageservice

This commit is contained in:
2024-03-23 22:35:47 +01:00
parent d5210d3df4
commit a2c613c38f
11 changed files with 651 additions and 49 deletions

View File

@@ -0,0 +1,23 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ImageService {
private uploadUrl = 'http://localhost:3000/bizmatch/image/uploadPropertyPicture/1a4b800e-793c-4c47-b987-7bf634060a4e';
constructor(private http: HttpClient) { }
uploadImage(imageBlob: Blob) {
const formData = new FormData();
formData.append('file', imageBlob, 'image.png');
return this.http.post(this.uploadUrl, formData,{
// headers: this.headers,
reportProgress: true,
observe: 'events',
});
}
}

View File

@@ -12,15 +12,15 @@ export class LoadingService {
public isLoading$ = this.loading$.asObservable().pipe(
map((loading) => loading.length > 0),
debounceTime(200),
debounceTime(100),
distinctUntilChanged(),
shareReplay(1)
);
public startLoading(type: string,request:string): void {
public startLoading(type: string,request?:string): void {
if (!this.loading$.value.includes(type)) {
this.loading$.next(this.loading$.value.concat(type));
if (request.includes('uploadPropertyPicture')) {
if (type==='uploadImage' || request?.includes('uploadPropertyPicture')) {
this.loadingTextSubject.next("Please wait - we're processing your image...");
} else {
this.loadingTextSubject.next(null);