cropper & imageservice
This commit is contained in:
23
bizmatch/src/app/services/image.service.ts
Normal file
23
bizmatch/src/app/services/image.service.ts
Normal 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',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user