diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-01 15:00:39 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-01 15:08:52 +0200 |
| commit | aa342542789b22f24ce3ecbfcb7888d4ff12d30c (patch) | |
| tree | 2ce0d4c49986bdf6c0ab56059f8434e63e283fca /src | |
| parent | b0d06d43552840cf8352cf22486f3438267677f5 (diff) | |
| download | DevHive-aa342542789b22f24ce3ecbfcb7888d4ff12d30c.tar DevHive-aa342542789b22f24ce3ecbfcb7888d4ff12d30c.tar.gz DevHive-aa342542789b22f24ce3ecbfcb7888d4ff12d30c.zip | |
Implemented comment deletion in admin panel; Fixed some missing imports
Diffstat (limited to 'src')
5 files changed, 25 insertions, 6 deletions
diff --git a/src/DevHive.Angular/src/app/components/admin-panel-page/admin-panel-page.component.ts b/src/DevHive.Angular/src/app/components/admin-panel-page/admin-panel-page.component.ts index bb0af21..99c0721 100644 --- a/src/DevHive.Angular/src/app/components/admin-panel-page/admin-panel-page.component.ts +++ b/src/DevHive.Angular/src/app/components/admin-panel-page/admin-panel-page.component.ts @@ -1,11 +1,13 @@ import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { Title } from '@angular/platform-browser'; import { Router } from '@angular/router'; -import {Guid} from 'guid-typescript'; +import { Guid } from 'guid-typescript'; import { AppConstants } from 'src/app/app-constants.module'; +import { CommentService } from 'src/app/services/comment.service'; import { LanguageService } from 'src/app/services/language.service'; -import {PostService} from 'src/app/services/post.service'; +import { PostService } from 'src/app/services/post.service'; import { TechnologyService } from 'src/app/services/technology.service'; import { TokenService } from 'src/app/services/token.service'; import { UserService } from 'src/app/services/user.service'; @@ -34,7 +36,7 @@ export class AdminPanelPageComponent implements OnInit { public technologyForm: FormGroup; public deleteForm: FormGroup; - constructor(private _titleService: Title, private _router: Router, private _fb: FormBuilder, private _userService: UserService, private _languageService: LanguageService, private _technologyService: TechnologyService, private _tokenService: TokenService, private _postService: PostService) { + constructor(private _titleService: Title, private _router: Router, private _fb: FormBuilder, private _userService: UserService, private _languageService: LanguageService, private _technologyService: TechnologyService, private _tokenService: TokenService, private _postService: PostService, private _commentService: CommentService) { this._titleService.setTitle(this._title); } @@ -309,6 +311,20 @@ export class AdminPanelPageComponent implements OnInit { } private tryDeleteComment(): void { + const deleteComment: string = this.deleteForm.get('deleteComment')?.value; + + if (deleteComment !== '' && deleteComment !== null) { + const commentId: Guid = Guid.parse(deleteComment); + + this._commentService.deleteCommentWithSessionStorage(commentId).subscribe( + (result: object) => { + this.deletionSuccess('Successfully deleted comment!'); + }, + (err: HttpErrorResponse) => { + this._errorBar.showError(err); + } + ); + } } private deletionSuccess(successMsg: string): void { diff --git a/src/DevHive.Angular/src/app/components/not-found/not-found.component.ts b/src/DevHive.Angular/src/app/components/not-found/not-found.component.ts index d269a76..b1f8cc1 100644 --- a/src/DevHive.Angular/src/app/components/not-found/not-found.component.ts +++ b/src/DevHive.Angular/src/app/components/not-found/not-found.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { Title } from '@angular/platform-browser'; import { Router } from '@angular/router'; @Component({ @@ -9,7 +10,7 @@ import { Router } from '@angular/router'; export class NotFoundComponent implements OnInit { private _title = 'Not Found!'; - constructor(private _titleService: Title,private _router: Router) { + constructor(private _titleService: Title, private _router: Router) { this._titleService.setTitle(this._title); } diff --git a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts index cd9fd28..9974d90 100644 --- a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts +++ b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts @@ -1,9 +1,10 @@ import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { Title } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { Guid } from 'guid-typescript'; -import {CommentService} from 'src/app/services/comment.service'; +import { CommentService } from 'src/app/services/comment.service'; import { PostService } from 'src/app/services/post.service'; import { TokenService } from 'src/app/services/token.service'; import { Post } from 'src/models/post'; @@ -79,7 +80,6 @@ export class PostPageComponent implements OnInit { addComment(): void { const newComment = this.addCommentFormGroup.get('newComment')?.value; if (newComment !== '' && newComment !== null) { - console.log(newComment); this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe( (result: object) => { this.editPostFormGroup.reset(); diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts index fac8dee..4a401ef 100644 --- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts @@ -12,6 +12,7 @@ import { SuccessBarComponent } from '../success-bar/success-bar.component'; import { Language } from 'src/models/language'; import { Technology } from 'src/models/technology'; import { TokenService } from 'src/app/services/token.service'; +import { Title } from '@angular/platform-browser'; @Component({ selector: 'app-profile-settings', diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.ts b/src/DevHive.Angular/src/app/components/profile/profile.component.ts index 47098f7..bb80346 100644 --- a/src/DevHive.Angular/src/app/components/profile/profile.component.ts +++ b/src/DevHive.Angular/src/app/components/profile/profile.component.ts @@ -10,6 +10,7 @@ import { TechnologyService } from 'src/app/services/technology.service'; import { Post } from 'src/models/post'; import { FeedService } from 'src/app/services/feed.service'; import { TokenService } from 'src/app/services/token.service'; +import { Title } from '@angular/platform-browser'; @Component({ selector: 'app-profile', |
