added color feedback on userVote

master
Max 5 years ago
parent 4f9bd3c8e6
commit fec332b2de

@ -27,6 +27,7 @@ export class FeedComponent implements OnInit {
this.feedNew = this.feedService.renderAllPosts(response.json()) this.feedNew = this.feedService.renderAllPosts(response.json())
this.parentSelectedPostList = this.feedNew this.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew this.feedMostLiked = this.feedNew
console.log(this.feedNew)
}) })
} }

@ -35,9 +35,15 @@
<p [innerHTML]="post.htmlContent"></p> <p [innerHTML]="post.htmlContent"></p>
</mat-card-content> </mat-card-content>
<mat-card-actions> <mat-card-actions>
<button mat-button><mat-icon aria-hidden="false" aria-label="Example home icon">keyboard_arrow_up</mat-icon></button> <button mat-button>
<mat-icon aria-hidden="false" color="primary" *ngIf="post.userVote == 'UPVOTE'">keyboard_arrow_up</mat-icon>
<mat-icon aria-hidden="false" *ngIf="!post.userVote || post.userVote == 'DOWNVOTE'">keyboard_arrow_up</mat-icon>
</button>
{{post.upvotes}} {{post.upvotes}}
<button mat-button><mat-icon aria-hidden="false" aria-label="Example home icon">keyboard_arrow_down</mat-icon></button> <button mat-button>
<mat-icon aria-hidden="false" color="primary" *ngIf="post.userVote == 'DOWNVOTE'">keyboard_arrow_down</mat-icon>
<mat-icon aria-hidden="false" *ngIf="!post.userVote || post.userVote == 'UPVOTE'">keyboard_arrow_down</mat-icon>
</button>
{{post.downvotes}} {{post.downvotes}}
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>

@ -7,14 +7,16 @@ export class Post {
date: string date: string
upvotes: number upvotes: number
downvotes: number downvotes: number
userVote: string
author: Author author: Author
constructor(pId: number, pContent: string, pHtmlContent: string, pUpvotes: number, pDownvotes: number, pDate: string, pAuthor: Author) { constructor(pId: number, pContent: string, pHtmlContent: string, pUpvotes: number, pDownvotes: number, pUserVote: string, pDate: string, pAuthor: Author) {
this.id = pId this.id = pId
this.content = pContent this.content = pContent
this.htmlContent = pHtmlContent this.htmlContent = pHtmlContent
this.upvotes = pUpvotes this.upvotes = pUpvotes
this.downvotes = pDownvotes this.downvotes = pDownvotes
this.userVote = pUserVote
this.date = pDate this.date = pDate
this.author = pAuthor this.author = pAuthor
} }

@ -97,7 +97,7 @@ export class FeedService {
getBodyForGetAllPosts() { getBodyForGetAllPosts() {
const body = {query: `query { const body = {query: `query {
getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, author{name, handle, id}, createdAt} getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, userVote, author{name, handle, id}, createdAt}
}` }`
} }
@ -113,11 +113,12 @@ export class FeedService {
let htmlContent: string = post.htmlContent let htmlContent: string = post.htmlContent
let upvotes: number = post.upvotes let upvotes: number = post.upvotes
let downvotes: number = post.downvotes let downvotes: number = post.downvotes
let userVote: string = post.userVote
let author = new Author(post.author.id, post.author.name, post.author.handle) let author = new Author(post.author.id, post.author.name, post.author.handle)
let temp = new Date(Number(post.createdAt)) let temp = new Date(Number(post.createdAt))
let date = temp.toLocaleString("en-GB") let date = temp.toLocaleString("en-GB")
posts.push(new Post(id, content, htmlContent, upvotes, downvotes, date, author)) posts.push(new Post(id, content, htmlContent, upvotes, downvotes, userVote, date, author))
} }
return posts return posts
} }

Loading…
Cancel
Save