Merge branch 'master' of Software_Engineering_I/greenvironment-frontend into max_dev

master
Max_ES 5 years ago committed by Gitea
commit afe9b773a5

@ -6,7 +6,7 @@
<button id="tab-login" routerLink="/login" *ngIf="loggedIn != true">Login</button> <button id="tab-login" routerLink="/login" *ngIf="loggedIn != true">Login</button>
<div id="dropdown" *ngIf="loggedIn"> <div id="dropdown" *ngIf="loggedIn">
<div> <div>
<span (click)="showDropdown()"><i class="fa fa-caret-down" aria-hidden="true"></i></span> <span id="symbol" (click)="showDropdown()"><i class="fa fa-caret-down" aria-hidden="true"></i></span>
<span>{{username}}</span> <span>{{username}}</span>
</div> </div>
<div id="dropdown-content" *ngIf="dropdownShown"> <div id="dropdown-content" *ngIf="dropdownShown">

@ -46,6 +46,10 @@ h1
margin-left: 2em margin-left: 2em
span span
margin-left: 1em margin-left: 1em
#symbol
span:hover
background-color: lighten($cHeadPrimaryBackground, 10%)
cursor: pointer
#dropdown-content #dropdown-content
position: absolute position: absolute
background-color: $cHeadPrimaryBackground background-color: $cHeadPrimaryBackground
@ -54,11 +58,6 @@ h1
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2) box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2)
padding: 12px 16px padding: 12px 16px
z-index: 1 z-index: 1
div:hover
background-color: lighten($cHeadPrimaryBackground, 10%)
cursor: pointer
#dropdown-content
//display: block
#logoutbutton #logoutbutton
@include gridPosition(1, 2, 8, 9) @include gridPosition(1, 2, 8, 9)

@ -4,7 +4,7 @@
<button id="newchat" (click)="newChat()"><span><i class="fa fa-plus fa-3x" aria-hidden="true"></i></span></button> <button id="newchat" (click)="newChat()"><span><i class="fa fa-plus fa-3x" aria-hidden="true"></i></span></button>
</div> </div>
<div id="chats"> <div id="chats">
<div class="chatitem" *ngFor="let chat of chatService.chats" <div class="chatitem" *ngFor="let chat of chats"
[class.selected]="chat === selectedChat" (click)="showChat(chat)"> [class.selected]="chat === selectedChat" (click)="showChat(chat)">
<div class="picture">Pic</div> <div class="picture">Pic</div>
<div class="name"><span>{{chat.id}}</span></div> <div class="name"><span>{{chat.id}}</span></div>

@ -1,7 +1,7 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { Chatinfo } from 'src/app/models/chatinfo'; import { Chatinfo } from 'src/app/models/chatinfo';
import { ChatService } from 'src/app/services/chat/chat.service';
import { Chat } from 'src/app/models/chat'; import { Chat } from 'src/app/models/chat';
import { ChatService } from 'src/app/services/chat/chat.service';
@Component({ @Component({
selector: 'chatmanager-chatlist', selector: 'chatmanager-chatlist',
@ -13,11 +13,12 @@ export class ChatlistComponent implements OnInit {
@Output() showChatEvent = new EventEmitter<Chat>(); @Output() showChatEvent = new EventEmitter<Chat>();
@Output() showCreateChatEvent = new EventEmitter<boolean>(); @Output() showCreateChatEvent = new EventEmitter<boolean>();
selectedChat: Chat; selectedChat: Chat;
chats: Array<Chat>
constructor(private chatService: ChatService) { } constructor(private chatService: ChatService) { }
ngOnInit() { ngOnInit() {
this.chats = this.chatService.chats
} }
showNewChat() { showNewChat() {

@ -1,7 +1,7 @@
<div id="postinput"> <div id="postinput">
<textarea #content id='input' placeholder="Post something ..." rows='3' wrap="soft"></textarea> <textarea #content id='input' placeholder="Post something ..." rows='3' wrap="soft"></textarea>
<button id="attach" type='submit'><span><i class="fa fa-paperclip fa-2x" aria-hidden="true"></i></span></button> <button id="attach" type='submit'><span><i class="fa fa-paperclip fa-2x" aria-hidden="true"></i></span></button>
<button id="submit" type='submit' (click)=createPost(content.value)><span><i class="fa fa-send-o fa-2x" aria-hidden="true"></i></span></button> <button id="submit" type='submit' (click)=createPost(content)><span><i class="fa fa-send-o fa-2x" aria-hidden="true"></i></span></button>
</div> </div>
<div id='completeFeed'> <div id='completeFeed'>
<div id='feedchooser'> <div id='feedchooser'>
@ -10,31 +10,10 @@
</div> </div>
<div id="feedlist"> <div id="feedlist">
<div *ngIf = "viewNew"> <div *ngIf = "viewNew">
<feed-postlist [childPostList]="parentSelectedPostList"></feed-postlist> <feed-postlist (voteEvent)="refresh($event)" [childPostList]="parentSelectedPostList"></feed-postlist>
</div> </div>
<div *ngIf = "viewMostLiked"> <div *ngIf = "viewMostLiked">
<feed-postlist [childPostList]="parentSelectedPostList"></feed-postlist> <feed-postlist (voteEvent)="refresh($event)" [childPostList]="parentSelectedPostList"></feed-postlist>
</div> </div>
<!--
<div class="feeditem">
<div class="itemhead">
<div class="usertag">
<span class="title">post.username</span>
<span class="handle"><a href="#">post.handle</a></span>
</div>
<span class="date">post.date</span>
</div>
<div class="itembody">
<div class='text'>
<p>post.message</p>
</div>
<div class="vote">
<button id="down" type='submit'><span><i class="fa fa-thumbs-o-down fa-2x" aria-hidden="true"></i></span></button>
<button id="up" type='submit'><span><i class="fa fa-thumbs-o-up fa-2x" aria-hidden="true"></i></span></button>
<span id="votecounter">post.votes</span>
</div>
</div>
</div>
-->
</div> </div>
</div> </div>

@ -22,29 +22,42 @@ export class FeedComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.feedService.getAllPostsRaw().subscribe(response => { this.feedService.getAllPostsRaw().subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json()) this.feedNew = this.feedService.renderAllPosts(response.json())
console.log(response)
this.parentSelectedPostList = this.feedNew this.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew this.feedMostLiked = this.feedNew
}) })
} }
createPost(pContent: string){ createPost(pElement){
this.feedService.createPost(pContent) this.feedService.createPost(pElement.value)
console.log(pContent) pElement.value = ""
this.feedService.getAllPostsRaw().subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json())
this.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew})
} }
showNew() { showNew() {
this.feedNew = this.feedService.getAllPosts() this.feedService.getAllPostsRaw().subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json())
this.parentSelectedPostList = this.feedNew})
this.viewNew = true this.viewNew = true
this.viewMostLiked = false this.viewMostLiked = false
this.parentSelectedPostList = this.feedNew
} }
showMostLiked() { showMostLiked() {
this.feedMostLiked = this.feedService.getAllPosts() this.feedService.getAllPostsRaw().subscribe(response => {
this.feedMostLiked = this.feedService.renderAllPosts(response.json())
this.parentSelectedPostList = this.feedMostLiked})
this.viewNew = false this.viewNew = false
this.viewMostLiked = true this.viewMostLiked = true
this.parentSelectedPostList = this.feedMostLiked }
refresh($event) {
this.feedService.getAllPostsRaw().subscribe(response => {
this.parentSelectedPostList = this.feedService.renderAllPosts(response.json())
console.log("Refresh")
})
} }
} }

@ -8,7 +8,7 @@
</div> </div>
<div class="itembody"> <div class="itembody">
<div class='text'> <div class='text'>
<p>{{post.content}}</p> <p [innerHTML]="post.htmlContent" id="content"></p>
</div> </div>
<div class="vote"> <div class="vote">
<button id="down" type='submit'><span><i class="fa fa-thumbs-o-down fa-2x" aria-hidden="true" (click)="voteDown(post)"></i></span></button> <button id="down" type='submit'><span><i class="fa fa-thumbs-o-down fa-2x" aria-hidden="true" (click)="voteDown(post)"></i></span></button>

@ -34,6 +34,11 @@
grid-template: 100% /85% 15% grid-template: 100% /85% 15%
.text .text
@include gridPosition(1, 2, 1, 2) @include gridPosition(1, 2, 1, 2)
overflow-x: hidden
::ng-deep img
max-width: 100%
height: auto
.vote .vote
@include gridPosition(1, 2, 2, 3) @include gridPosition(1, 2, 2, 3)
display: grid display: grid

@ -1,4 +1,4 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Post } from 'src/app/models/post'; import { Post } from 'src/app/models/post';
import { FeedService } from 'src/app/services/feed/feed.service'; import { FeedService } from 'src/app/services/feed/feed.service';
@ -10,6 +10,7 @@ import { FeedService } from 'src/app/services/feed/feed.service';
export class PostlistComponent implements OnInit { export class PostlistComponent implements OnInit {
@Input() childPostList: Array<Post> @Input() childPostList: Array<Post>
@Output() voteEvent = new EventEmitter<boolean>()
selectedPost: Post selectedPost: Post
constructor(private feedService: FeedService) { } constructor(private feedService: FeedService) { }
@ -19,11 +20,12 @@ export class PostlistComponent implements OnInit {
voteUp(pPost: Post){ voteUp(pPost: Post){
this.feedService.upvote(pPost.id) this.feedService.upvote(pPost.id)
console.log("UPVOTE", pPost.id) this.voteEvent.emit(true)
} }
voteDown(pPost: Post){ voteDown(pPost: Post){
this.feedService.downvote(pPost.id) this.feedService.downvote(pPost.id)
this.voteEvent.emit(true)
} }
} }

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

@ -99,7 +99,7 @@ export class FeedService {
getBodyForGetAllChats() { getBodyForGetAllChats() {
const body = {query: `query { const body = {query: `query {
getPosts (first: 1000, offset: 0) {id, content, upvotes, downvotes, author{name, handle, id}, createdAt} getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, author{name, handle, id}, createdAt}
}` }`
} }
@ -111,12 +111,13 @@ export class FeedService {
for(let post of pResponse.data.getPosts) { for(let post of pResponse.data.getPosts) {
let id: number = post.id let id: number = post.id
let content: string = post.content let content: string = post.content
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 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 date = post.createdAt let date = post.createdAt
posts.push(new Post(id, content, upvotes, downvotes, date, author)) posts.push(new Post(id, content, htmlContent, upvotes, downvotes, date, author))
} }
return posts return posts
} }

Loading…
Cancel
Save