Merge branch 'max_dev' of Software_Engineering_I/greenvironment-frontend into master

master
Max_ES 4 years ago committed by Gitea
commit 742e9196bf

@ -106,36 +106,46 @@ export class GroupComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.loading = true; this.loading = true;
this.id = this.router.url.substr(this.router.url.lastIndexOf('/') + 1); this.id = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
this.loading = true;
this.data.currentUser.subscribe(user => { this.data.currentUser.subscribe(user => {
this.self = user; this.self = user;
this.checkSelfStats();
}); });
this.groupService.getGroupData(this.id).subscribe(); this.groupService.getGroupData(this.id).subscribe();
this.groupService.group.subscribe(response => { this.groupService.group.subscribe(response => {
if (response) { if (response) {
this.isAdmin = false; if (response.id) {
this.groupProfile = response; if(response.id.toString() === this.id){
// tslint:disable-next-line:max-line-length this.loading = false;
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;
} }
} }
if (this.groupProfile.creator.userID === this.self.userID) { this.groupProfile = response;
this.isCreator = true; this.checkSelfStats();
} else {
this.isCreator = false;
}
for (const member of this.groupProfile.members) { for (const member of this.groupProfile.members) {
member.allowedToSendRequest = this.requestService.isAllowedToSendRequest(member.userID, this.self); member.allowedToSendRequest = this.requestService.isAllowedToSendRequest(member.userID, this.self);
} }
} else { } else {
this.groupNotFound = true; this.groupNotFound = true;
} }
this.loading = false;
}); });
} }
checkSelfStats() {
this.isAdmin = false;
// tslint:disable-next-line:max-line-length
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;
}
}
if (this.groupProfile.creator.userID === this.self.userID) {
this.isCreator = true;
} else {
this.isCreator = false;
}
}
openDialog(): void { openDialog(): void {
const dialogRef = this.dialog.open(DialogCreateEventComponent, { const dialogRef = this.dialog.open(DialogCreateEventComponent, {
width: '250px' width: '250px'

Loading…
Cancel
Save