diff options
5 files changed, 47 insertions, 19 deletions
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 4dec754..36783e5 100644 --- a/src/DevHive.Angular/src/app/components/post/post.component.html +++ b/src/DevHive.Angular/src/app/components/post/post.component.html @@ -15,7 +15,7 @@ {{ post.message }} </div> <div class="timestamp"> - {{ post.timeCreated }} + {{ 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 ab894d1..2f5aa81 100644 --- a/src/DevHive.Angular/src/app/components/post/post.component.ts +++ b/src/DevHive.Angular/src/app/components/post/post.component.ts @@ -3,6 +3,7 @@ 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 {UserService} from 'src/app/services/user.service'; import { User } from 'src/models/identity/user'; import {Post} from 'src/models/post'; @@ -15,32 +16,33 @@ export class PostComponent implements OnInit { public user: User; public post: Post; public votesNumber: number; + public timeCreated: string; public loaded = false; @Input() paramId: string; - constructor(private _postService: PostService) + constructor(private _postService: PostService, private _userService: UserService) {} ngOnInit(): void { this.post = this._postService.getDefaultPost(); - // Fetch data in post service - this.user = new User( - Guid.create(), - 'gosho_trapov', - 'Gosho', - 'Trapov', - 'gotra@bg.com', - AppConstants.FALLBACK_PROFILE_ICON, - new Array(), - new Array() - ); + this.user = this._userService.getDefaultUser(); this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe( (result: object) => { Object.assign(this.post, result); - this.loaded = true; + this.timeCreated = new Date(this.post.timeCreated).toLocaleString('en-GB'); + this.loadUser(); } ); this.votesNumber = 23; } + + private loadUser(): void { + this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe( + (result: object) => { + Object.assign(this.user, result); + this.loaded = true; + } + ); + } } diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.html b/src/DevHive.Angular/src/app/components/profile/profile.component.html index 8ac91af..e20f380 100644 --- a/src/DevHive.Angular/src/app/components/profile/profile.component.html +++ b/src/DevHive.Angular/src/app/components/profile/profile.component.html @@ -43,8 +43,8 @@ </div> <hr> <div id="posts" class="scroll-standalone"> - <div *ngFor="let userPost of userPosts" class="post"> - <app-post [paramId]="userPost.postId"></app-post> + <div *ngFor="let userPost of userPosts"> + <app-post [paramId]="userPost.postId.toString()"></app-post> </div> </div> </div> diff --git a/src/DevHive.Angular/src/app/services/post.service.ts b/src/DevHive.Angular/src/app/services/post.service.ts index 74105b3..4cd96bc 100644 --- a/src/DevHive.Angular/src/app/services/post.service.ts +++ b/src/DevHive.Angular/src/app/services/post.service.ts @@ -12,7 +12,7 @@ export class PostService { constructor(private http: HttpClient) { } getDefaultPost(): Post { - return new Post(Guid.createEmpty(), '', new Date()); + return new Post(Guid.createEmpty(), 'Gosho', 'Trapov', 'gosho_trapov', 'Your opinion on my idea?', new Date()); } getPostRequest(id: Guid): Observable<object> { diff --git a/src/DevHive.Angular/src/models/post.ts b/src/DevHive.Angular/src/models/post.ts index aed1005..2d7d79f 100644 --- a/src/DevHive.Angular/src/models/post.ts +++ b/src/DevHive.Angular/src/models/post.ts @@ -2,14 +2,19 @@ import {Guid} from 'guid-typescript'; export class Post { private _postId: Guid; - // _creatorId + private _creatorFirstName: string; + private _creatorLastName: string; + private _creatorUsername: string; private _message: string; private _timeCreated: Date; // _comments // _files - constructor(postId: Guid, message: string, timeCreated: Date) { + constructor(postId: Guid, creatorFirstName: string, creatorLastName: string, creatorUsername: string, message: string, timeCreated: Date) { this.postId = postId; + this.creatorFirstName = creatorFirstName; + this.creatorLastName = creatorLastName; + this.creatorUsername = creatorUsername; this.message = message; this.timeCreated = timeCreated; } @@ -21,6 +26,27 @@ export class Post { this._postId = v; } + public get creatorFirstName(): string { + return this._creatorFirstName; + } + public set creatorFirstName(v: string) { + this._creatorFirstName = v; + } + + public get creatorLastName(): string { + return this._creatorLastName; + } + public set creatorLastName(v: string) { + this._creatorLastName = v; + } + + public get creatorUsername(): string { + return this._creatorUsername; + } + public set creatorUsername(v: string) { + this._creatorUsername = v; + } + public get message(): string { return this._message; } |
