|
|
|
@ -28,6 +28,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
super();
|
|
|
|
|
// fill in mock values if we are not in production environment
|
|
|
|
|
if (!environment.production) {
|
|
|
|
|
console.info(' ######### framadate ######### we are not in production env, filling with mock values');
|
|
|
|
|
this.currentPoll = mockPoll3;
|
|
|
|
|
this.myPolls = mockMyPolls;
|
|
|
|
|
this.dateList = defaultDates;
|
|
|
|
@ -44,6 +45,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
this.messageService.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// utils functions
|
|
|
|
|
/**
|
|
|
|
|
* generate unique id to have a default url for future poll
|
|
|
|
|
*/
|
|
|
|
@ -54,6 +56,10 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* make a uniq slug for the current poll creation
|
|
|
|
|
* @param str
|
|
|
|
|
*/
|
|
|
|
|
makeSlug(str?: string) {
|
|
|
|
|
if (!str) {
|
|
|
|
|
str = this.creationDate.getFullYear() + '_' + (this.creationDate.getMonth() + 1) + '_' + this.creationDate.getDate() + '_' + this.myName + '_' + this.title;
|
|
|
|
@ -96,29 +102,25 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
*/
|
|
|
|
|
getPollConfig() {
|
|
|
|
|
const jsonConfig = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
|
|
owner: {
|
|
|
|
|
email: this.myEmail,
|
|
|
|
|
pseudo: this.myName,
|
|
|
|
|
},
|
|
|
|
|
title: this.title,
|
|
|
|
|
description: this.description,
|
|
|
|
|
type: this.pollType,
|
|
|
|
|
visibility: this.visibility,
|
|
|
|
|
voteChoices: this.voteChoices,
|
|
|
|
|
allowSeveralHours: this.allowSeveralHours,
|
|
|
|
|
expirationDate: this.expirationDate,
|
|
|
|
|
passwordAccess: this.passwordAccess,
|
|
|
|
|
password: this.password,
|
|
|
|
|
customUrl: this.customUrl,
|
|
|
|
|
canModifyAnswers: this.canModifyAnswers,
|
|
|
|
|
whoModifiesAnswers: this.whoModifiesAnswers,
|
|
|
|
|
dateList: this.dateList,
|
|
|
|
|
timeList: this.timeList,
|
|
|
|
|
answers: this.answers,
|
|
|
|
|
}
|
|
|
|
|
owner: {
|
|
|
|
|
email: this.myEmail,
|
|
|
|
|
pseudo: this.myName,
|
|
|
|
|
},
|
|
|
|
|
title: this.title,
|
|
|
|
|
description: this.description,
|
|
|
|
|
type: this.pollType,
|
|
|
|
|
visibility: this.visibility,
|
|
|
|
|
voteChoices: this.voteChoices,
|
|
|
|
|
allowSeveralHours: this.allowSeveralHours,
|
|
|
|
|
expirationDate: this.expirationDate,
|
|
|
|
|
passwordAccess: this.passwordAccess,
|
|
|
|
|
password: this.password,
|
|
|
|
|
customUrl: this.customUrl,
|
|
|
|
|
canModifyAnswers: this.canModifyAnswers,
|
|
|
|
|
whoModifiesAnswers: this.whoModifiesAnswers,
|
|
|
|
|
dateList: this.dateList,
|
|
|
|
|
timeList: this.timeList,
|
|
|
|
|
answers: this.answers,
|
|
|
|
|
};
|
|
|
|
|
return jsonConfig
|
|
|
|
|
}
|
|
|
|
@ -226,13 +228,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
getPollByURL(url: string) {
|
|
|
|
|
|
|
|
|
|
this.todo();
|
|
|
|
|
// this.http.get(`${this.baseHref}/poll/${url}`, this.makeHeaders()).subscribe(
|
|
|
|
|
// (res: any) => {
|
|
|
|
|
// this.myPolls = res.data;
|
|
|
|
|
// }, (e) => {
|
|
|
|
|
// this.handleError(e)
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
return this.http.get(`${this.baseHref}/poll/slug/${url}`, this.makeHeaders())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|