|
|
|
@ -4,6 +4,7 @@ import {HttpClient, HttpHeaders} from "@angular/common/http";
|
|
|
|
|
import {environment} from "../../environments/environment";
|
|
|
|
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
|
|
|
|
import {Router} from "@angular/router";
|
|
|
|
|
import {mockPoll3} from "../config/mocks/mock-poll3";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
|
|
|
|
@ -13,6 +14,7 @@ import {Router} from "@angular/router";
|
|
|
|
|
})
|
|
|
|
|
export class ConfigService extends PollConfig {
|
|
|
|
|
|
|
|
|
|
currentPoll: any = mockPoll3;
|
|
|
|
|
loading: boolean = false;
|
|
|
|
|
baseHref: any = environment.baseApiHref;
|
|
|
|
|
|
|
|
|
@ -307,8 +309,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
.subscribe((res: any) => {
|
|
|
|
|
|
|
|
|
|
this.messageService.add({severity: 'success', summary: 'Vote ajouté'});
|
|
|
|
|
alert("succès!");
|
|
|
|
|
this.myPolls = res;
|
|
|
|
|
this.currentPoll = res;
|
|
|
|
|
}, (e) => {
|
|
|
|
|
this.handleError(e)
|
|
|
|
|
}
|
|
|
|
@ -327,7 +328,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
this.makeHeaders())
|
|
|
|
|
.subscribe((res: any) => {
|
|
|
|
|
this.messageService.add({severity: 'success', summary: 'Vote mis à jour'});
|
|
|
|
|
this.myPolls = res;
|
|
|
|
|
this.currentPoll = res;
|
|
|
|
|
}, (e) => {
|
|
|
|
|
this.handleError(e)
|
|
|
|
|
}
|
|
|
|
@ -340,10 +341,11 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
* @param comment
|
|
|
|
|
*/
|
|
|
|
|
addComment(comment?: any) {
|
|
|
|
|
if (!comment) {
|
|
|
|
|
if (!comment && this.myComment) {
|
|
|
|
|
comment = {
|
|
|
|
|
pseudo: this.myName,
|
|
|
|
|
comment: this.myComment,
|
|
|
|
|
name: this.myName,
|
|
|
|
|
date: new Date(),
|
|
|
|
|
text: this.myComment,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.http.post(
|
|
|
|
@ -358,8 +360,10 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
});
|
|
|
|
|
// empty comment after success
|
|
|
|
|
this.myComment = '';
|
|
|
|
|
this.currentPoll.comments.push(comment);
|
|
|
|
|
}, (e) => {
|
|
|
|
|
this.handleError(e)
|
|
|
|
|
this.handleError(e);
|
|
|
|
|
this.currentPoll.comments.push(comment);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -463,7 +467,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
severity: 'success',
|
|
|
|
|
summary: 'Sondage mis à jour',
|
|
|
|
|
});
|
|
|
|
|
this.myPolls = res;
|
|
|
|
|
this.currentPoll = res;
|
|
|
|
|
}, (e) => {
|
|
|
|
|
this.handleError(e)
|
|
|
|
|
}
|
|
|
|
|