2019-08-10 16:20:59 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
2019-08-10 17:21:40 +02:00
|
|
|
import {PollConfig} from './config/PollConfig';
|
2019-11-19 11:19:21 +01:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
import {environment} from "../environments/environment";
|
2019-08-10 16:20:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
|
|
|
|
*/
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
2019-08-10 17:21:40 +02:00
|
|
|
export class ConfigService extends PollConfig {
|
2019-11-19 11:19:21 +01:00
|
|
|
myEmail: string;
|
|
|
|
myPolls: any;// list of retrieved polls from the backend api
|
2019-08-10 17:21:40 +02:00
|
|
|
|
2019-08-10 16:20:59 +02:00
|
|
|
|
2019-11-19 11:19:21 +01:00
|
|
|
constructor(public http: HttpClient) {
|
2019-08-10 17:21:40 +02:00
|
|
|
super();
|
2019-08-10 16:20:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
set(key, val) {
|
|
|
|
this[key] = val;
|
|
|
|
}
|
|
|
|
|
2019-11-19 11:19:21 +01:00
|
|
|
createPoll() {
|
2019-08-10 16:20:59 +02:00
|
|
|
// todo
|
|
|
|
console.log('sends the form');
|
2019-11-19 11:19:21 +01:00
|
|
|
alert('envoi de formulaire pour création de sondage en XHR à faire');
|
|
|
|
const payload = this;
|
|
|
|
this.http.post(`${environment.baseApiHref}/poll`, payload)
|
|
|
|
.subscribe(res => {
|
|
|
|
console.log('res', res)
|
|
|
|
},
|
|
|
|
err => console.error('err', err))
|
2019-08-10 16:20:59 +02:00
|
|
|
}
|
|
|
|
}
|