From 078f63f742d29e5c1cb7426560047830f165ea97 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 26 Apr 2021 10:32:42 +0200 Subject: [PATCH] add comment on display --- proxy.conf.json | 11 --- src/app/core/models/poll.model.ts | 2 + .../consultation/consultation.component.html | 28 ++++--- .../consultation/consultation.component.ts | 19 ++--- .../comments/comments.component.html | 81 +++++++++++++++++-- .../components/comments/comments.component.ts | 27 +++++-- src/proxy.conf.json | 2 +- 7 files changed, 120 insertions(+), 50 deletions(-) delete mode 100644 proxy.conf.json diff --git a/proxy.conf.json b/proxy.conf.json deleted file mode 100644 index 220da25b..00000000 --- a/proxy.conf.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "/api/v1/*": { - "target": "http://localhost:8000", - "secure": false, - "pathRewrite": { - "^/api/v1": "" - }, - "changeOrigin": false, - "logLevel": "debug" - } -} diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index 4c6d64fa..61f75ca2 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -11,6 +11,8 @@ export class Poll { public slug: string = '', public title: string = 'mon titre', public description?: string, + public expiracy_date?: string, + public creation_date?: string, public creatorPseudo?: string, public creatorEmail?: string, public allowSeveralHours?: boolean, diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index f34b1f5b..87b7cd45 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -1,9 +1,18 @@
-
- aucun vote pour le moment -
+ +
+
+ ⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires +
+
+
+
+ aucun vote pour le moment +
+
+
@@ -30,18 +39,13 @@ Detailed
- - + + +
TODO links - - - - - -
@@ -49,7 +53,7 @@
- +
diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 7f7b2566..fcb116f6 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -4,6 +4,7 @@ import { Subscription } from 'rxjs'; import { Poll } from '../../core/models/poll.model'; import { ModalService } from '../../core/services/modal.service'; import { PollService } from '../../core/services/poll.service'; +import { DateService } from '../../core/services/date.service'; @Component({ selector: 'app-consultation', @@ -15,7 +16,7 @@ export class ConsultationComponent implements OnInit, OnDestroy { public poll: Poll; public pollSlug: string; public passHash: string; - public fetching: boolean = true; + public fetching = true; public isArchived: boolean; private routeSubscription: Subscription; @@ -23,6 +24,7 @@ export class ConsultationComponent implements OnInit, OnDestroy { private router: Router, private _Activatedroute: ActivatedRoute, public pollService: PollService, + public dateService: DateService, private modalService: ModalService ) {} @@ -30,6 +32,9 @@ export class ConsultationComponent implements OnInit, OnDestroy { console.log('constultation de poll'); this.pollService.poll.subscribe((newpoll: Poll) => { this.poll = newpoll; + if (newpoll) { + this.isArchived = new Date(newpoll.expiracy_date) < new Date(); + } }); this._Activatedroute.paramMap.subscribe((params) => { @@ -46,18 +51,6 @@ export class ConsultationComponent implements OnInit, OnDestroy { }); } }); - - // if (!this.userService.isCurrentUserIdentifiable()) { - // this.modalService.openModal(SettingsComponent); - // } - // this.routeSubscription = this.activatedRoute.data.subscribe((data: { poll: Poll }) => { - // if (data.poll) { - // this.poll = data.poll; - // this.isArchived = PollConfiguration.isArchived(data.poll.configuration); - // } else { - // this.router.navigate(['/page-not-found']); - // } - // }); } ngOnDestroy(): void { diff --git a/src/app/shared/components/comments/comments.component.html b/src/app/shared/components/comments/comments.component.html index d8f9e576..5104bb02 100644 --- a/src/app/shared/components/comments/comments.component.html +++ b/src/app/shared/components/comments/comments.component.html @@ -1,9 +1,74 @@ -
-
-

{{ comment.author }}

- {{ comment.dateCreated | date: 'medium' }} +
+

Laisser un commentaire

+
+
+
+ + + + + + + + + + + + +
+ + + + +
+
+ +
+ + + +
+
+ +
+

{{ poll.comments.length }} Commentaires

+ +
+
+

+ {{ comment.pseudo }} , le + + il y a + {{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le {{ comment.owner.created_at }} +

+
+
+

+ {{ comment.text }} +

+
+
-
- {{ comment.content }} -
-
+ diff --git a/src/app/shared/components/comments/comments.component.ts b/src/app/shared/components/comments/comments.component.ts index a05feb7d..7de1c384 100644 --- a/src/app/shared/components/comments/comments.component.ts +++ b/src/app/shared/components/comments/comments.component.ts @@ -1,8 +1,6 @@ -import { Component } from '@angular/core'; -import { Observable } from 'rxjs'; - -import { Poll } from '../../../core/models/poll.model'; +import { Component, Input } from '@angular/core'; import { PollService } from '../../../core/services/poll.service'; +import * as moment from 'moment'; @Component({ selector: 'app-comments', @@ -10,7 +8,26 @@ import { PollService } from '../../../core/services/poll.service'; styleUrls: ['./comments.component.scss'], }) export class CommentsComponent { - public _poll: Observable = this.pollService.poll; + @Input() public poll: any; + + public config: any = { + myName: '', + myEmail: '', + myComment: '', + }; constructor(private pollService: PollService) {} + calculateDaysAgoOfComment(dateAsString) { + let numberOfDays = 0; + + if (dateAsString && dateAsString) { + numberOfDays = moment(new Date()).diff(moment(new Date(dateAsString)), 'days'); + } + + return numberOfDays; + } + + addComment() { + alert('TODO'); + } } diff --git a/src/proxy.conf.json b/src/proxy.conf.json index 5b9f3ff5..244c8195 100644 --- a/src/proxy.conf.json +++ b/src/proxy.conf.json @@ -1,6 +1,6 @@ { "/api/*": { - "target": "http://localhost:3001", + "target": "http://localhost:8000/api", "secure": false, "logLevel": "debug" }