fixes+improvements
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
import { VoteService } from '../../services/vote.service';
|
||||
import { CommentService } from '../../services/comment.service';
|
||||
import { ModerationService } from '../../services/moderarion.service';
|
||||
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ui-entry',
|
||||
@@ -8,14 +14,24 @@ import { VoteService } from '../../services/vote.service';
|
||||
})
|
||||
export class UiEntry implements OnInit {
|
||||
|
||||
moderator: boolean = false;
|
||||
@Input() entry: any;
|
||||
@Input() index : number;
|
||||
@Input() change : Function;
|
||||
@Input() index: number;
|
||||
@Input() change: Function;
|
||||
|
||||
constructor(private voteService: VoteService) { }
|
||||
constructor(private authService: AuthService, private voteService: VoteService,
|
||||
private moderationService: ModerationService, public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.authService.auth.subscribe((auth: any) => {
|
||||
if (auth && auth.authorities) {
|
||||
for (let role of auth.authorities) {
|
||||
if (role.authority == 'ROLE_ADMIN' || role.authority == 'ROLE_MOD') {
|
||||
this.moderator = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
voteUp() {
|
||||
@@ -26,7 +42,25 @@ export class UiEntry implements OnInit {
|
||||
|
||||
voteDown() {
|
||||
this.voteService.voteEntryDown(this.entry.id).subscribe((result) => {
|
||||
this.change && this.change()
|
||||
this.change && this.change()
|
||||
});
|
||||
}
|
||||
|
||||
deleteEntry(entry: any) {
|
||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||
data: {
|
||||
'label': 'comment.confirmDelete',
|
||||
'args': [ entry.title, entry.author ]
|
||||
}
|
||||
})
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result) {
|
||||
this.moderationService.deleteEntry(entry.id).subscribe((result: any) => {
|
||||
this.entry = null;
|
||||
this.change && this.change();
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user