📖 add mocks from updated backend

This commit is contained in:
Baptiste Lemoine 2020-01-21 12:04:14 +01:00
parent 96709c9bc7
commit a68cbdcc0a
12 changed files with 714 additions and 39 deletions

View File

@ -6,6 +6,7 @@
"start": "ng serve",
"serve": "ng serve",
"build": "ng build",
"build:demo": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --aot=true --progress=true --statsJson=true",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",

View File

@ -19,7 +19,7 @@ export class AppComponent {
age: 42
};
menuVisible: boolean = true;
private step: string;
step: string;
constructor(private translate: TranslateService,
@Inject(DOCUMENT) private document,

View File

@ -0,0 +1,4 @@
{
"message": "anti flood déclenché",
"details": "votre deriner commentaire a exactement le même contenu que celui ci, il n'a donc pas été créé"
}

View File

@ -0,0 +1,4 @@
{
"message": "anti flood déclenché",
"details": "votre deriner commentaire a été envoyé il y a moins de 5 secondes"
}

View File

@ -0,0 +1,565 @@
{
"message": "your poll config v2",
"data": {
"id": 3,
"title": "dessin animé préféré",
"customUrl": null,
"description": "choisissez votre animé préféré",
"creationDate": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"expiracyDate": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"owner": {
"__initializer__": null,
"__cloner__": null,
"__isInitialized__": true,
"pseudo": "tk_TEST",
"email": "tktest@tktest.com"
},
"kind": "text",
"allowedAnswers": [
"yes"
],
"modificationPolicy": "self",
"mailOnComment": null,
"mailOnVote": null,
"hideResults": null,
"showResultEvenIfPasswords": null,
"votes": {},
"stacksOfVotes": {},
"choices": {},
"comments": {},
"defaultExpiracyDaysFromNow": 60
},
"stacks_count": 10,
"stacks": {
"3": {
"id": 3,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"4": {
"id": 3,
"vote_id": 4,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
},
"5": {
"id": 3,
"vote_id": 5,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
}
}
},
"4": {
"id": 4,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"6": {
"id": 4,
"vote_id": 6,
"value": "yes",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"7": {
"id": 4,
"vote_id": 7,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
},
"8": {
"id": 4,
"vote_id": 8,
"value": "no",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"5": {
"id": 5,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:33:26.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"9": {
"id": 5,
"vote_id": 9,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"10": {
"id": 5,
"vote_id": 10,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"11": {
"id": 5,
"vote_id": 11,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"6": {
"id": 6,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:36:58.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"12": {
"id": 6,
"vote_id": 12,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"13": {
"id": 6,
"vote_id": 13,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"14": {
"id": 6,
"vote_id": 14,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"7": {
"id": 7,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:39:12.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"15": {
"id": 7,
"vote_id": 15,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"16": {
"id": 7,
"vote_id": 16,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"17": {
"id": 7,
"vote_id": 17,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"8": {
"id": 8,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:39:13.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"18": {
"id": 8,
"vote_id": 18,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"19": {
"id": 8,
"vote_id": 19,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"20": {
"id": 8,
"vote_id": 20,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"9": {
"id": 9,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:42:19.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"21": {
"id": 9,
"vote_id": 21,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"22": {
"id": 9,
"vote_id": 22,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"23": {
"id": 9,
"vote_id": 23,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"10": {
"id": 10,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:42:32.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"24": {
"id": 10,
"vote_id": 24,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"25": {
"id": 10,
"vote_id": 25,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"26": {
"id": 10,
"vote_id": 26,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"11": {
"id": 11,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:43:46.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"27": {
"id": 11,
"vote_id": 27,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"28": {
"id": 11,
"vote_id": 28,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"29": {
"id": 11,
"vote_id": 29,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
},
"12": {
"id": 12,
"pseudo": "voting_people_TEST",
"creation_date": {
"date": "2020-01-21 10:44:35.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": {
"30": {
"id": 12,
"vote_id": 30,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"31": {
"id": 12,
"vote_id": 31,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"32": {
"id": 12,
"vote_id": 32,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
}
}
},
"choices_count": 7,
"choices": {
"5": {
"id": 5,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Vic le viking"
},
"6": {
"id": 6,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Boumbo petite automobile"
},
"7": {
"id": 7,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Les mystérieuses cités d'or"
},
"8": {
"id": 8,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Les mondes engloutis"
},
"9": {
"id": 9,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Foot 2 rue"
},
"10": {
"id": 10,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Le chat, la vache, et l'océan"
},
"11": {
"id": 11,
"date": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"text": "Digimon"
}
},
"comments": {
"3": {
"id": 3,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-20 16:58:56.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"4": {
"id": 4,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-20 16:59:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"5": {
"id": 5,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:12:02.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"6": {
"id": 6,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:12:34.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"7": {
"id": 7,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:14:20.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"8": {
"id": 8,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:15:09.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"9": {
"id": 9,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:15:10.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"10": {
"id": 10,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:15:35.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"11": {
"id": 11,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:26:58.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"12": {
"id": 12,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:27:03.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"13": {
"id": 13,
"text": "wouah trop bien framadate!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:27:10.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"14": {
"id": 14,
"text": "wouah trop bien framadate wouhouuu!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:34:04.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"15": {
"id": 15,
"text": "wouah trop bien framadate wouhouucghfdghu!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:36:33.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
"16": {
"id": 16,
"text": "wouah trop bien framadate woudghdghhouucghfdghu!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-21 10:50:43.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
}
},
"comments_count": 14
}

View File

@ -0,0 +1,48 @@
{
"message": "you created a comment",
"data": {
"your_comment": {
"id": 14,
"poll": {
"id": 3,
"title": "dessin animé préféré",
"customUrl": null,
"description": "choisissez votre animé préféré",
"creationDate": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"expiracyDate": {
"date": "2020-01-20 16:45:48.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"owner": {
"__initializer__": null,
"__cloner__": null,
"__isInitialized__": true,
"pseudo": "tk_TEST",
"email": "tktest@tktest.com"
},
"kind": "text",
"allowedAnswers": [
"yes"
],
"modificationPolicy": "self",
"mailOnComment": null,
"mailOnVote": null,
"hideResults": null,
"showResultEvenIfPasswords": null,
"votes": {},
"stacksOfVotes": {},
"choices": {},
"comments": {},
"defaultExpiracyDaysFromNow": 60
},
"text": "wouah trop bien framadate wouhouuu!",
"token": "5e25cb2c6e533"
},
"poll_comments": {}
}
}

View File

@ -0,0 +1,43 @@
{
"message": "you created a vote stack from an existing owner : testing_vote_people@tktest.com",
"vote_stack": {
"30": {
"id": 30,
"value": "no",
"choice_id": 5,
"text": "Vic le viking"
},
"31": {
"id": 31,
"value": "maybe",
"choice_id": 6,
"text": "Boumbo petite automobile"
},
"32": {
"id": 32,
"value": "yes",
"choice_id": 7,
"text": "Les mystérieuses cités d'or"
}
},
"vote_count": 10,
"owner_modifier_token": "rc7fgzdb6D8bUdgwl7H065eYMMeqOcL31JrS11MpRs08az8ed43aZLKsFd81cr50uq23D9b1w068E57U39omaBcygfebm7m252YI430b332UZ4tkC76",
"json_you_sent": {
"pseudo": "tktest",
"email": "testing_vote_people@tktest.com",
"votes": [
{
"choice_id": 5,
"value": "no"
},
{
"choice_id": 6,
"value": "maybe"
},
{
"choice_id": 7,
"value": "yes"
}
]
}
}

View File

@ -1,7 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {BaseComponent} from "../base-page/base.component";
import {ConfigService} from "../../services/config.service";
import {mockPoll3} from "../../config/mocks/mock-poll3";
import {mockComments} from "../../config/mocks/mock-comments";
import {ActivatedRoute} from "@angular/router";
@ -12,8 +11,8 @@ import {ActivatedRoute} from "@angular/router";
})
export class PollDisplayComponent extends BaseComponent implements OnInit {
private pollConfigFetched;
private comments = mockComments;
pollConfigFetched;
comments = mockComments;
constructor(public config: ConfigService,
public activeRoute: ActivatedRoute) {

View File

@ -120,7 +120,7 @@ export class ConfigService extends PollConfig {
'Charset': 'UTF-8',
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Origin': '*'
};
@ -136,6 +136,8 @@ export class ConfigService extends PollConfig {
this.customUrlIsUnique = null;
this.loading = true;
// TODO
this.todo('check slug is unique');
this.http.get(`${this.baseHref}/check-slug-is-uniq`,
this.makeHeaders({slug: this.customUrl}),
)
@ -198,7 +200,6 @@ export class ConfigService extends PollConfig {
if (localStorage) {
console.log('localStorage', localStorage)
}
}
@ -207,13 +208,15 @@ export class ConfigService extends PollConfig {
* @param url
*/
getPollByURL(url: string) {
this.http.get(`${this.baseHref}/poll/${url}`, this.makeHeaders()).subscribe(
(res: any) => {
this.myPolls = res.data;
}, (e) => {
this.handleError(e)
}
);
this.todo();
// this.http.get(`${this.baseHref}/poll/${url}`, this.makeHeaders()).subscribe(
// (res: any) => {
// this.myPolls = res.data;
// }, (e) => {
// this.handleError(e)
// }
// );
}
/**
@ -501,9 +504,9 @@ export class ConfigService extends PollConfig {
alert('TODO');
}
todo() {
todo(message = '') {
this.messageService.add({
severity: 'info',
severity: 'info' + message,
detail: "cette fonctionnalité n'est pas encore disponible. Venez en discuter sur framateam.org / Ux et design libre / Framasoft",
summary: "Work in progress",
});

View File

@ -1,94 +1,96 @@
<nav class="choices">
<nav class="choices" >
<a
[routerLink]="'home'"
[ngClass]="{'active': step == 'home'}"
[ngClass]="{'active': step === 'home'}"
i18n
>
<i class="fa fa-home"></i>
</a>
<i class="fa fa-home" ></i >
</a >
<a
[routerLink]="'/step/creation'"
[ngClass]="{'active': step == 'creation'}"
i18n
>
Création
</a>
</a >
<a
[routerLink]="'/step/date'"
[ngClass]="{'active': step == 'date'}"
i18n
>
Les Dates
</a>
</a >
<a
[routerLink]="'/step/answers'"
[ngClass]="{'active': step == 'answers'}"
i18
>
Réponses
</a>
</a >
<a
[routerLink]="'/step/visibility'"
[ngClass]="{'active': step == 'visibility'}"
i18n
>
Visibilité
</a>
</a >
<a
[routerLink]="'/step/base'"
[ngClass]="{'active': step == 'base'}"
i18n
>
Base
</a>
</a >
<a
[routerLink]="'/step/pictures'"
[ngClass]="{'active': step == 'pictures'}"
i18n
>
Images
</a>
</a >
<a
[routerLink]="'/step/resume'"
[ngClass]="{'active': step == 'resume'}"
i18n
>
Résumé
</a>
</a >
<a
[routerLink]="'/step/end'"
[ngClass]="{'active': step == 'end'}"
i18n
>
Confirmation
</a>
</a >
<a
[routerLink]="'/step/kind'"
[ngClass]="{'active': step == 'kind'}"
i18n
>
Page démo
</a>
<a [routerLink]="'/vote/poll/id/3'" i18n>
</a >
<a
[routerLink]="'/vote/poll/id/3'"
i18n >
Sondage dessins animés
</a>
</a >
<a
[routerLink]="'/graphic/toto'"
[ngClass]="{'active': step == 'graphic'}"
i18n
>
Graphique
</a>
</a >
<a
[routerLink]="'/step/admin'"
i18n
>
Administration
</a>
</a >
<a
[routerLink]="'/home'"
i18n
>
Accueil
</a>
</nav>
</a >
</nav >

View File

@ -25,7 +25,7 @@ interface VoteChoice {
})
export class VoteChoiceComponent {
@Input() private choice: any;
@Input() public choice: any;
constructor(private el: ElementRef) {

View File

@ -1,12 +1,18 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
let baseURL = "http://localhost:8000/";
const baseURLProd = "https://framadate.org/";
const baseURLDemo = "https://framadate-api.cipherbliss.com/";
const apiVersion = 1;
const testOnDemo = 0;
if (testOnDemo) {
baseURL = baseURLDemo;
}
export const environment = {
production: false,
baseHref: "https://framadate-api.cipherbliss.com/",
baseApiHref: "https://framadate-api.cipherbliss.com/api/v1"
// baseApiHref: "http://localhost:8000/api/v1"
baseHref: baseURL,
baseApiHref: baseURL + "api/v" + apiVersion
};
/*