Skip to content

Commit

Permalink
Integrated the update for the floor layout image
Browse files Browse the repository at this point in the history
  • Loading branch information
08Arno30 committed Sep 12, 2023
1 parent 414a888 commit 9dd9fd4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
33 changes: 32 additions & 1 deletion libs/app/api/src/lib/app-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ import {
IGetManagedEventsResponse,
IGetUserViewingEventsResponse,
IImage,
IImageUploadRequest,
IImageUploadResponse,
IPosition,
ISendViewRequestResponse,
IUpdateEventDetailsRequest,
IUpdateEventDetailsResponse,
IUpdateEventFloorLayoutImgResponse,
IUpdateFloorlayoutResponse,
} from '@event-participation-trends/api/event/util';
import { firstValueFrom } from 'rxjs';
Expand Down Expand Up @@ -402,6 +402,37 @@ export class AppApiService {
return response.status || Status.FAILURE;
}

async updateFloorplanImages(
eventId: string,
imageId: string,
managerEmail: string,
imgBase64: string,
imageObj: string,
imageScale: number,
imageType: string
): Promise<Status> {
const response = await firstValueFrom(
this.http.post<IUpdateEventFloorLayoutImgResponse>(
'/api/event/updateEventFloorlayoutImage',
{
eventId: eventId,
imageId: imageId,
managerEmail: managerEmail,
imgBase64: imgBase64,
imageObj: imageObj,
imageScale: imageScale,
imageType: imageType
},
{
headers: {
'x-csrf-token': this.cookieService.get('csrf'),
},
}
)
);
return response.status || Status.FAILURE;
}

async getFloorLayoutImages(
eventId: string
): Promise<IImage[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ export class DashboardPageComponent implements OnInit {

// create node from JSON string
this.heatmapLayer = Konva.Node.create(response, 'floormap');
console.log(this.heatmapLayer)
if (this.heatmapLayer) {
this.heatmapLayer?.setAttr('name', 'floorlayoutLayer');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2652,9 +2652,11 @@ export class FloorplanEditorPageComponent implements OnInit, AfterViewInit{
const imageBase64 = image.base64;
const imageObj = JSON.stringify(floorplan);

// this.appApiService.updateFloorplanImages(this.eventId, imageBase64, imageObj, imageScale, imageType).then((res: any) => {
// console.log(res);
// });
this.appApiService.getEmail().then((email) => {
this.appApiService.updateFloorplanImages(this.eventId, image.id, email, imageBase64, imageObj, imageScale, imageType).then((res: any) => {
console.log(res);
});
});
}
});

Expand All @@ -2672,20 +2674,20 @@ export class FloorplanEditorPageComponent implements OnInit, AfterViewInit{
});

// save the JSON data to the database
// this.appApiService.updateFloorLayout(this.eventId, jsonString).then((res: any) => {
// console.log(res);

// setTimeout(() => {
// this.showToastUploading = false;
// res ? this.showToastSuccess = true : this.showToastError = true;

// setTimeout(() => {
// this.showToastSuccess = false;
// this.showToastError = false;
// if (res) this.router.navigate(['details'], { relativeTo: this.route.parent });
// }, 1000)
// }, 2000);
// });
this.appApiService.updateFloorLayout(this.eventId, jsonString).then((res: any) => {
console.log(res);

setTimeout(() => {
this.showToastUploading = false;
res ? this.showToastSuccess = true : this.showToastError = true;

setTimeout(() => {
this.showToastSuccess = false;
this.showToastError = false;
if (res) this.router.navigate(['details'], { relativeTo: this.route.parent });
}, 1000)
}, 2000);
});
}

async presentToastSuccess(position: 'top' | 'middle' | 'bottom', message: string) {
Expand Down

0 comments on commit 9dd9fd4

Please sign in to comment.