Skip to content

Commit

Permalink
FE-#153: Add leave event call
Browse files Browse the repository at this point in the history
  • Loading branch information
Drumber committed May 24, 2024
1 parent aed9292 commit ad6086f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<mat-icon>edit</mat-icon>
Bearbeiten
</button>
<button mat-menu-item>
<button mat-menu-item (click)="leaveEvent()">
<mat-icon>logout</mat-icon>
Verlassen
</button>
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/app/eventpage/event-banner/event-banner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {MatDialog} from "@angular/material/dialog";
import {EventService} from "../../../services/event.service";
import {CreateEventDialogComponent} from "../../create-event/create-event-dialog.component";
import {InvitationDialogComponent} from "../invitation-dialog/invitation-dialog.component";
import {Router} from "@angular/router";


@Component({
Expand All @@ -19,6 +20,9 @@ export class EventBannerComponent implements OnInit {
@Output()
onEventUpdated = new EventEmitter<Event>();

@Output()
onEventLeft = new EventEmitter();

@Output()
showParticipantsClicked = new EventEmitter();

Expand All @@ -27,7 +31,8 @@ export class EventBannerComponent implements OnInit {
constructor(
private breakpointObserver: BreakpointObserver,
private dialog: MatDialog,
private service: EventService
private service: EventService,
private router: Router
) {
}

Expand All @@ -47,7 +52,7 @@ export class EventBannerComponent implements OnInit {
dialogRef.afterClosed().subscribe(updateCommand => {
if (!updateCommand) return;
this.service.updateEvent(this.eventData.id, updateCommand).subscribe((event) => {
//TODO: Update Eventpage and navbar
this.onEventUpdated.emit(event);
}
);
});
Expand All @@ -63,4 +68,11 @@ export class EventBannerComponent implements OnInit {
});
dialogRef.afterClosed().subscribe(() => subscription.unsubscribe());
}

leaveEvent() {
this.service.leaveEvent(this.eventData.id).subscribe(() => {
this.router.navigateByUrl("/");
this.onEventLeft.emit();
});
}
}
1 change: 1 addition & 0 deletions frontend/src/app/eventpage/eventpage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<app-event-banner
[eventData]="eventData"
(onEventUpdated)="onEventUpdated($event)"
(onEventLeft)="updateEventList()"
(showParticipantsClicked)="drawer.toggle()"
></app-event-banner>
<br>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/eventpage/eventpage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export class EventpageComponent implements OnInit, OnDestroy {

onEventUpdated(event: Event) {
this.eventData = event;
this.updateEventList();
}

updateEventList() {
// TODO: trigger an update for the event list in the sidebar
}

private loadEventData(eventId: string) {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export class EventService {
generateInvitationLink(eventId: string): Observable<Event> {
return this.http.get<Event>(`${environment.api}/event/${eventId}/generateInvitationLink`, {withCredentials: true});
}

leaveEvent(eventId: string): Observable<any> {
return this.http.get(`${environment.api}/event/${eventId}/leave`, {withCredentials: true});
}
}

0 comments on commit ad6086f

Please sign in to comment.