From e112023dc378a809cd60e7e250661b9410d1b763 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 27 Jan 2020 15:59:28 +0100 Subject: [PATCH] Add post reporting function --- .../feed/postlist/postlist.component.html | 32 ++++-- .../feed/postlist/postlist.component.ts | 29 ++++- src/app/components/group/group.component.html | 2 +- src/app/models/reportReason.ts | 11 ++ src/app/services/activity/activity.service.ts | 71 +++++++++--- src/app/services/feed/feed.service.ts | 108 +++++++++++------- src/app/services/group/group.service.ts | 3 + 7 files changed, 178 insertions(+), 78 deletions(-) create mode 100644 src/app/models/reportReason.ts diff --git a/src/app/components/feed/postlist/postlist.component.html b/src/app/components/feed/postlist/postlist.component.html index f07a137..f74d789 100644 --- a/src/app/components/feed/postlist/postlist.component.html +++ b/src/app/components/feed/postlist/postlist.component.html @@ -1,16 +1,23 @@
- +
- - + + + +
@@ -22,10 +29,11 @@
- +
- post image + post image
{{post.upvotes}}
{{post.downvotes}}
@@ -57,4 +69,4 @@ -
+ \ No newline at end of file diff --git a/src/app/components/feed/postlist/postlist.component.ts b/src/app/components/feed/postlist/postlist.component.ts index 84e2044..fee24fa 100644 --- a/src/app/components/feed/postlist/postlist.component.ts +++ b/src/app/components/feed/postlist/postlist.component.ts @@ -1,7 +1,10 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {Post} from 'src/app/models/post'; -import {FeedService} from 'src/app/services/feed/feed.service'; -import {Router} from '@angular/router'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Post } from 'src/app/models/post'; +import { FeedService } from 'src/app/services/feed/feed.service'; +import { Router } from '@angular/router'; +import { DatasharingService } from 'src/app/services/datasharing.service'; +import { ActivityService } from 'src/app/services/activity/activity.service'; +import { ReportReason } from 'src/app/models/reportReason'; @Component({ selector: 'feed-postlist', @@ -13,11 +16,23 @@ export class PostlistComponent implements OnInit { @Input() childPostList: Post[]; @Output() voteEvent = new EventEmitter(); selectedPost: Post; + loggedIn = false; + reportReasons: ReportReason[] = new Array(); - constructor(private feedService: FeedService, private router: Router) { + constructor(private feedService: FeedService, + private data: DatasharingService, + private router: Router, + private activityService: ActivityService) { } ngOnInit() { + this.data.currentUser.subscribe(user => { + this.loggedIn = user.loggedIn; + }); + this.activityService.getReportReasons(); + this.activityService.reportReasonList.subscribe(response => { + this.reportReasons = response; + }); } voteUp(pPost: Post) { @@ -49,6 +64,10 @@ export class PostlistComponent implements OnInit { }); } + reportPost(reason: ReportReason, post: Post) { + this.feedService.reportPost(reason.id, post.id).subscribe(); + } + onLoad(post: Post) { post.mediaLoading = false; } diff --git a/src/app/components/group/group.component.html b/src/app/components/group/group.component.html index 132e5b1..5b80133 100644 --- a/src/app/components/group/group.component.html +++ b/src/app/components/group/group.component.html @@ -134,7 +134,7 @@ {{user.username}} {{user.handle}} - [admin] +