|
|
@ -1,5 +1,5 @@
|
|
|
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
|
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
|
|
import {NavigationEnd, Router} from '@angular/router';
|
|
|
|
import {Data, NavigationEnd, Router} from '@angular/router';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {MatSort} from '@angular/material/sort';
|
|
|
|
import {MatSort} from '@angular/material/sort';
|
|
|
|
import {RequestService} from 'src/app/services/request/request.service';
|
|
|
|
import {RequestService} from 'src/app/services/request/request.service';
|
|
|
@ -17,11 +17,14 @@ import {DialogGroupFileUploadComponent} from './fileUpload/fileUpload.component'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class DialogCreateEventComponent {
|
|
|
|
export class DialogCreateEventComponent {
|
|
|
|
groupId: string;
|
|
|
|
groupId: string;
|
|
|
|
|
|
|
|
private errorMessage: string;
|
|
|
|
|
|
|
|
errorOccurred: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
public dialogRef: MatDialogRef<DialogCreateEventComponent>,
|
|
|
|
public dialogRef: MatDialogRef<DialogCreateEventComponent>,
|
|
|
|
private group: GroupService,
|
|
|
|
private group: GroupService,
|
|
|
|
private router: Router) {
|
|
|
|
private router: Router,
|
|
|
|
|
|
|
|
private datasharingService: DatasharingService) {
|
|
|
|
this.groupId = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
|
|
|
|
this.groupId = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -29,15 +32,36 @@ export class DialogCreateEventComponent {
|
|
|
|
this.dialogRef.close();
|
|
|
|
this.dialogRef.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Creates a new event
|
|
|
|
|
|
|
|
* @param name
|
|
|
|
|
|
|
|
* @param date
|
|
|
|
|
|
|
|
* @param time
|
|
|
|
|
|
|
|
*/
|
|
|
|
createEvent(name: string, date: string, time: string) {
|
|
|
|
createEvent(name: string, date: string, time: string) {
|
|
|
|
name = name.trim();
|
|
|
|
name = name.trim();
|
|
|
|
|
|
|
|
this.errorOccurred = false;
|
|
|
|
if (name && date && time) {
|
|
|
|
if (name && date && time) {
|
|
|
|
date = date + ' ' + time;
|
|
|
|
date = date + ' ' + time;
|
|
|
|
this.group.createEvent(name, (new Date(date)).getTime().toString(), this.groupId);
|
|
|
|
this.group.createEvent(name, (new Date(date)).getTime().toString(), this.groupId)
|
|
|
|
this.dialogRef.close();
|
|
|
|
.subscribe(() => {
|
|
|
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
|
|
|
}, (error) => {
|
|
|
|
|
|
|
|
if (error.error) {
|
|
|
|
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns the error message
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getErrorMessage(): string {
|
|
|
|
|
|
|
|
return this.errorMessage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GROUP COMPONENT
|
|
|
|
// GROUP COMPONENT
|
|
|
@ -132,14 +156,14 @@ export class GroupComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
public joinEvent(event: Event) {
|
|
|
|
public joinEvent(event: Event) {
|
|
|
|
this.groupService.joinEvent(event.id).subscribe(response => {
|
|
|
|
this.groupService.joinEvent(event.id).subscribe(response => {
|
|
|
|
const pEvent = response.json().data.joinEvent;
|
|
|
|
const pEvent = response.data.joinEvent;
|
|
|
|
event.joined = pEvent.joined;
|
|
|
|
event.joined = pEvent.joined;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public leaveEvent(event: Event) {
|
|
|
|
public leaveEvent(event: Event) {
|
|
|
|
this.groupService.leaveEvent(event.id).subscribe(response => {
|
|
|
|
this.groupService.leaveEvent(event.id).subscribe(response => {
|
|
|
|
const pEvent = response.json().data.leaveEvent;
|
|
|
|
const pEvent = response.data.leaveEvent;
|
|
|
|
event.joined = pEvent.joined;
|
|
|
|
event.joined = pEvent.joined;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|