aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-01-30 14:20:14 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-01-30 14:21:06 +0200
commit69dc1caca6a3f4ff7bbb5c01dfe23ffdc27f20fc (patch)
treee295f295e4669a7724edb6f85a07e47f4ee7b31a
parentc8083d23e6f0483ce569845ddb7187c41f7a6e1f (diff)
downloadDevHive-69dc1caca6a3f4ff7bbb5c01dfe23ffdc27f20fc.tar
DevHive-69dc1caca6a3f4ff7bbb5c01dfe23ffdc27f20fc.tar.gz
DevHive-69dc1caca6a3f4ff7bbb5c01dfe23ffdc27f20fc.zip
Made post component slightly more dynamic (postId, message and time
created are dynamic)
-rw-r--r--src/DevHive.Angular/src/app/app-constants.module.ts2
-rw-r--r--src/DevHive.Angular/src/app/components/post/post.component.html6
-rw-r--r--src/DevHive.Angular/src/app/components/post/post.component.ts18
-rw-r--r--src/DevHive.Angular/src/app/services/post.service.ts25
-rw-r--r--src/DevHive.Angular/src/models/post.ts37
5 files changed, 83 insertions, 5 deletions
diff --git a/src/DevHive.Angular/src/app/app-constants.module.ts b/src/DevHive.Angular/src/app/app-constants.module.ts
index 7552a5e..8a63651 100644
--- a/src/DevHive.Angular/src/app/app-constants.module.ts
+++ b/src/DevHive.Angular/src/app/app-constants.module.ts
@@ -8,5 +8,7 @@ export class AppConstants {
public static API_LANGUAGE_URL = AppConstants.BASE_API_URL + '/Language';
public static API_TECHNOLOGY_URL = AppConstants.BASE_API_URL + '/Technology';
+ public static API_POST_URL = AppConstants.BASE_API_URL + '/Post';
+
public static FALLBACK_PROFILE_ICON = 'assets/images/feed/profile-pic.png';
}
diff --git a/src/DevHive.Angular/src/app/components/post/post.component.html b/src/DevHive.Angular/src/app/components/post/post.component.html
index 487b785..4dec754 100644
--- a/src/DevHive.Angular/src/app/components/post/post.component.html
+++ b/src/DevHive.Angular/src/app/components/post/post.component.html
@@ -1,4 +1,4 @@
-<div class="post rounded-border">
+<div class="post rounded-border" *ngIf="loaded">
<div class="content">
<div class="author">
<img class="round-image" [src]="user.imageUrl">
@@ -12,10 +12,10 @@
</div>
</div>
<div class="message">
- Your opinion on my idea?
+ {{ post.message }}
</div>
<div class="timestamp">
- 17:41 - 27 Dec 2020
+ {{ post.timeCreated }}
</div>
</div>
<div class="rating">
diff --git a/src/DevHive.Angular/src/app/components/post/post.component.ts b/src/DevHive.Angular/src/app/components/post/post.component.ts
index 76a4873..ab894d1 100644
--- a/src/DevHive.Angular/src/app/components/post/post.component.ts
+++ b/src/DevHive.Angular/src/app/components/post/post.component.ts
@@ -1,7 +1,10 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, Input, OnInit } from '@angular/core';
import { Guid } from 'guid-typescript';
import {AppConstants} from 'src/app/app-constants.module';
+import {FeedService} from 'src/app/services/feed.service';
+import {PostService} from 'src/app/services/post.service';
import { User } from 'src/models/identity/user';
+import {Post} from 'src/models/post';
@Component({
selector: 'app-post',
@@ -10,11 +13,16 @@ import { User } from 'src/models/identity/user';
})
export class PostComponent implements OnInit {
public user: User;
+ public post: Post;
public votesNumber: number;
+ public loaded = false;
+ @Input() paramId: string;
- constructor() {}
+ constructor(private _postService: PostService)
+ {}
ngOnInit(): void {
+ this.post = this._postService.getDefaultPost();
// Fetch data in post service
this.user = new User(
Guid.create(),
@@ -27,6 +35,12 @@ export class PostComponent implements OnInit {
new Array()
);
+ this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe(
+ (result: object) => {
+ Object.assign(this.post, result);
+ this.loaded = true;
+ }
+ );
this.votesNumber = 23;
}
}
diff --git a/src/DevHive.Angular/src/app/services/post.service.ts b/src/DevHive.Angular/src/app/services/post.service.ts
new file mode 100644
index 0000000..74105b3
--- /dev/null
+++ b/src/DevHive.Angular/src/app/services/post.service.ts
@@ -0,0 +1,25 @@
+import {HttpClient, HttpParams} from '@angular/common/http';
+import {Injectable} from '@angular/core';
+import {Guid} from 'guid-typescript';
+import {Observable} from 'rxjs';
+import {Post} from 'src/models/post';
+import {AppConstants} from '../app-constants.module';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class PostService {
+ constructor(private http: HttpClient) { }
+
+ getDefaultPost(): Post {
+ return new Post(Guid.createEmpty(), '', new Date());
+ }
+
+ getPostRequest(id: Guid): Observable<object> {
+ const options = {
+ params: new HttpParams().set('Id', id.toString())
+ };
+ return this.http.get(AppConstants.API_POST_URL, options);
+ }
+}
+
diff --git a/src/DevHive.Angular/src/models/post.ts b/src/DevHive.Angular/src/models/post.ts
new file mode 100644
index 0000000..aed1005
--- /dev/null
+++ b/src/DevHive.Angular/src/models/post.ts
@@ -0,0 +1,37 @@
+import {Guid} from 'guid-typescript';
+
+export class Post {
+ private _postId: Guid;
+ // _creatorId
+ private _message: string;
+ private _timeCreated: Date;
+ // _comments
+ // _files
+
+ constructor(postId: Guid, message: string, timeCreated: Date) {
+ this.postId = postId;
+ this.message = message;
+ this.timeCreated = timeCreated;
+ }
+
+ public get postId(): Guid {
+ return this._postId;
+ }
+ public set postId(v: Guid) {
+ this._postId = v;
+ }
+
+ public get message(): string {
+ return this._message;
+ }
+ public set message(v: string) {
+ this._message = v;
+ }
+
+ public get timeCreated(): Date {
+ return this._timeCreated;
+ }
+ public set timeCreated(v: Date) {
+ this._timeCreated = v;
+ }
+}