|
|
@ -6,7 +6,40 @@ import { RequestService } from 'src/app/services/request/request.service';
|
|
|
|
import { DatasharingService } from '../../services/datasharing.service';
|
|
|
|
import { DatasharingService } from '../../services/datasharing.service';
|
|
|
|
import { GroupService } from 'src/app/services/group/group.service';
|
|
|
|
import { GroupService } from 'src/app/services/group/group.service';
|
|
|
|
import { Group } from 'src/app/models/group';
|
|
|
|
import { Group } from 'src/app/models/group';
|
|
|
|
|
|
|
|
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DIALOG COMPONENT to create events
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
|
|
|
selector: 'dialog-overview-example-dialog',
|
|
|
|
|
|
|
|
templateUrl: 'dialog.html',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
export class DialogCreateEventComponent {
|
|
|
|
|
|
|
|
groupId: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
|
|
|
public dialogRef: MatDialogRef<DialogCreateEventComponent>,
|
|
|
|
|
|
|
|
private group: GroupService,
|
|
|
|
|
|
|
|
private router: Router) {
|
|
|
|
|
|
|
|
this.groupId = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onNoClick(): void {
|
|
|
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createEvent(name: string, date: string) {
|
|
|
|
|
|
|
|
name = name.trim();
|
|
|
|
|
|
|
|
if (name && date) {
|
|
|
|
|
|
|
|
this.group.createEvent(name, (new Date(date)).getTime().toString(), this.groupId).subscribe(response => {
|
|
|
|
|
|
|
|
console.log(response);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GROUP COMPONENT
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-profile',
|
|
|
|
selector: 'app-profile',
|
|
|
|
templateUrl: './group.component.html',
|
|
|
|
templateUrl: './group.component.html',
|
|
|
@ -17,12 +50,14 @@ export class GroupComponent implements OnInit {
|
|
|
|
groupProfile: Group = new Group();
|
|
|
|
groupProfile: Group = new Group();
|
|
|
|
self: User;
|
|
|
|
self: User;
|
|
|
|
id: string;
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
isAdmin = false;
|
|
|
|
groupNotFound = false;
|
|
|
|
groupNotFound = false;
|
|
|
|
|
|
|
|
|
|
|
|
loading = false;
|
|
|
|
loading = false;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private router: Router,
|
|
|
|
|
|
|
|
public dialog: MatDialog,
|
|
|
|
private requestService: RequestService,
|
|
|
|
private requestService: RequestService,
|
|
|
|
private data: DatasharingService,
|
|
|
|
private data: DatasharingService,
|
|
|
|
private groupService: GroupService) {
|
|
|
|
private groupService: GroupService) {
|
|
|
@ -48,15 +83,27 @@ export class GroupComponent implements OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.groupService.getGroupData(this.id);
|
|
|
|
this.groupService.getGroupData(this.id);
|
|
|
|
this.groupService.group.subscribe(response => {
|
|
|
|
this.groupService.group.subscribe(response => {
|
|
|
|
|
|
|
|
this.isAdmin = false;
|
|
|
|
if (response) {
|
|
|
|
if (response) {
|
|
|
|
this.groupProfile = response;
|
|
|
|
this.groupProfile = response;
|
|
|
|
// tslint:disable-next-line:max-line-length
|
|
|
|
// tslint:disable-next-line:max-line-length
|
|
|
|
this.groupProfile.allowedToJoinGroup = this.requestService.isAllowedToJoinGroup(this.groupProfile.id, this.self);
|
|
|
|
this.groupProfile.allowedToJoinGroup = this.requestService.isAllowedToJoinGroup(this.groupProfile.id, this.self);
|
|
|
|
|
|
|
|
for (const admin of this.groupProfile.admins) {
|
|
|
|
|
|
|
|
if (admin.userID === this.self.userID) {
|
|
|
|
|
|
|
|
this.isAdmin = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else { this.groupNotFound = true; }
|
|
|
|
} else { this.groupNotFound = true; }
|
|
|
|
this.loading = false;
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openDialog(): void {
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(DialogCreateEventComponent, {
|
|
|
|
|
|
|
|
width: '250px'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public joinGroup(group: Group) {
|
|
|
|
public joinGroup(group: Group) {
|
|
|
|
group.allowedToJoinGroup = false;
|
|
|
|
group.allowedToJoinGroup = false;
|
|
|
|
this.requestService.joinGroup(group);
|
|
|
|
this.requestService.joinGroup(group);
|
|
|
|