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.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew
console.log(this.feedNew)
})
}

@ -35,9 +35,15 @@
<p [innerHTML]="post.htmlContent"></p>
</mat-card-content>
<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}}
<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}}
</mat-card-actions>
</mat-card>

@ -7,14 +7,16 @@ export class Post {
date: string
upvotes: number
downvotes: number
userVote: string
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.content = pContent
this.htmlContent = pHtmlContent
this.upvotes = pUpvotes
this.downvotes = pDownvotes
this.userVote = pUserVote
this.date = pDate
this.author = pAuthor
}

@ -97,7 +97,7 @@ export class FeedService {
getBodyForGetAllPosts() {
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 upvotes: number = post.upvotes
let downvotes: number = post.downvotes
let userVote: string = post.userVote
let author = new Author(post.author.id, post.author.name, post.author.handle)
let temp = new Date(Number(post.createdAt))
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
}

Loading…
Cancel
Save