From ea43430e1b7acf3f6250215fc9966cca5e6422a5 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Wed, 22 Jan 2020 11:18:55 +0100 Subject: [PATCH] :zap: build for production, :bug: fix publicy of vars in templates --- package.json | 7 +- src/app/config/PollConfig.ts | 11 +- .../mocks/config-poll-dessins-animes.json | 174 ++--- src/app/config/mocks/mock-comments.ts | 4 +- src/app/config/mocks/mock-poll3.ts | 603 ++++++++++++++---- src/app/debugger/debugger.component.html | 2 +- src/app/pages/admin/admin.component.ts | 17 +- src/app/pages/answers/answers.component.ts | 8 +- .../poll-display/poll-display.component.html | 26 +- .../visibility/visibility.component.html | 2 +- .../voting-comment.component.html | 12 +- .../voting-comment.component.ts | 2 +- .../voting-summary.component.ts | 22 +- src/app/services/config.service.ts | 29 +- .../erasable-input.component.ts | 1 + .../ui/navigation/navigation.component.html | 2 +- src/app/ui/navigation/navigation.component.ts | 2 +- .../ui/vote-choice/vote-choice.component.html | 12 +- .../ui/vote-choice/vote-choice.component.ts | 5 +- update-demo.sh | 2 +- 20 files changed, 656 insertions(+), 287 deletions(-) diff --git a/package.json b/package.json index 831de722..fb7e8283 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,19 @@ { "name": "framadate-funky-frontend", - "version": "0.1.0", + "version": "1.0.0", "scripts": { "ng": "ng", "start": "ng serve", "serve": "ng serve", "build": "ng build --crossOrigin=anonymous --aot=false", - "build:demo": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --aot=true --progress=true --statsJson=true", + "package": " cat dist/framadate/{polyfills,runtime,main}.js > ./package.js", + "build:demo": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --progress=true --output-hashing=none --prod && npm run package", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "trans": "ng xi18n --output-path=src/locale --i18n-locale=fr" }, - "private": true, + "private": false, "dependencies": { "@angular/animations": "^8.2.14", "@angular/cdk": "^8.2.3", diff --git a/src/app/config/PollConfig.ts b/src/app/config/PollConfig.ts index 1a3828ba..2acacd01 100644 --- a/src/app/config/PollConfig.ts +++ b/src/app/config/PollConfig.ts @@ -2,8 +2,7 @@ * une option de date dans les sondages spéciaux */ import {environment} from "../../environments/environment"; -import {mockMyPolls} from "./mocks/mockmypolls"; -import {defaultAnswers, defaultDates, timeOfDay} from "./defaultConfigs"; +import {defaultAnswers} from "./defaultConfigs"; export interface DateOption { timeList: any; @@ -33,7 +32,7 @@ export class PollConfig { myComment: string = 'wouah trop bien framadate!'; isAdmin: boolean = true; myEmail: string = "tktest@tktest.com"; - myPolls: any = mockMyPolls;// list of retrieved polls from the backend api + myPolls: any;// list of retrieved polls from the backend api // date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates allowSeveralHours = 'false'; // access @@ -42,7 +41,7 @@ export class PollConfig { creationDate = new Date(); expirationDate = ''; // expiracy date pollId = null; // id of the current poll when created. data given by the backend api - selectedPoll = null; // current poll selected with createPoll or getPoll of ConfigService + currentPoll; // current poll selected with createPoll or getPoll of ConfigService passwordAccess = 0; password = ''; customUrl = ''; // custom slug in the url, must be unique @@ -52,8 +51,8 @@ export class PollConfig { canModifyAnswers = 1;// everybody, self, nobody (= just admin) whoModifiesAnswers = "self";// everybody, self, nobody (= just admin) whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin) - dateList: DateOption[] = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll - timeList: DateOption[] = timeOfDay; // ranges of time expressed as strings + dateList: DateOption[]; // sets of days as strings, config to set identical time for days in a special days poll + timeList: DateOption[]; // ranges of time expressed as strings answers: any = defaultAnswers; diff --git a/src/app/config/mocks/config-poll-dessins-animes.json b/src/app/config/mocks/config-poll-dessins-animes.json index 983a4952..512a5cfe 100644 --- a/src/app/config/mocks/config-poll-dessins-animes.json +++ b/src/app/config/mocks/config-poll-dessins-animes.json @@ -1,5 +1,5 @@ { - "message": "your poll config v2", + "message": "your poll config", "data": { "id": 3, "title": "dessin animé préféré", @@ -38,8 +38,8 @@ "defaultExpiracyDaysFromNow": 60 }, "stacks_count": 10, - "stacks": { - "3": { + "stacks": [ + { "id": 3, "pseudo": "voting_people_TEST", "creation_date": { @@ -47,24 +47,24 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "4": { + "votes": [ + { "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": { @@ -72,31 +72,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "6": { + "votes": [ + { "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": { @@ -104,31 +104,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "9": { + "votes": [ + { "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": { @@ -136,31 +136,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "12": { + "votes": [ + { "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": { @@ -168,31 +168,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "15": { + "votes": [ + { "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": { @@ -200,31 +200,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "18": { + "votes": [ + { "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": { @@ -232,31 +232,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "21": { + "votes": [ + { "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": { @@ -264,31 +264,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "24": { + "votes": [ + { "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": { @@ -296,31 +296,31 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "27": { + "votes": [ + { "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": { @@ -328,34 +328,34 @@ "timezone_type": 3, "timezone": "Europe/Berlin" }, - "votes": { - "30": { + "votes": [ + { "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": { + "choices": [ + { "id": 5, "date": { "date": "2020-01-20 16:45:48.000000", @@ -364,7 +364,7 @@ }, "text": "Vic le viking" }, - "6": { + { "id": 6, "date": { "date": "2020-01-20 16:45:48.000000", @@ -373,7 +373,7 @@ }, "text": "Boumbo petite automobile" }, - "7": { + { "id": 7, "date": { "date": "2020-01-20 16:45:48.000000", @@ -382,7 +382,7 @@ }, "text": "Les mystérieuses cités d'or" }, - "8": { + { "id": 8, "date": { "date": "2020-01-20 16:45:48.000000", @@ -391,7 +391,7 @@ }, "text": "Les mondes engloutis" }, - "9": { + { "id": 9, "date": { "date": "2020-01-20 16:45:48.000000", @@ -400,7 +400,7 @@ }, "text": "Foot 2 rue" }, - "10": { + { "id": 10, "date": { "date": "2020-01-20 16:45:48.000000", @@ -409,7 +409,7 @@ }, "text": "Le chat, la vache, et l'océan" }, - "11": { + { "id": 11, "date": { "date": "2020-01-20 16:45:48.000000", @@ -418,9 +418,9 @@ }, "text": "Digimon" } - }, - "comments": { - "3": { + ], + "comments": [ + { "id": 3, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -430,7 +430,7 @@ "timezone": "Europe/Berlin" } }, - "4": { + { "id": 4, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -440,7 +440,7 @@ "timezone": "Europe/Berlin" } }, - "5": { + { "id": 5, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -450,7 +450,7 @@ "timezone": "Europe/Berlin" } }, - "6": { + { "id": 6, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -460,7 +460,7 @@ "timezone": "Europe/Berlin" } }, - "7": { + { "id": 7, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -470,7 +470,7 @@ "timezone": "Europe/Berlin" } }, - "8": { + { "id": 8, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -480,7 +480,7 @@ "timezone": "Europe/Berlin" } }, - "9": { + { "id": 9, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -490,7 +490,7 @@ "timezone": "Europe/Berlin" } }, - "10": { + { "id": 10, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -500,7 +500,7 @@ "timezone": "Europe/Berlin" } }, - "11": { + { "id": 11, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -510,7 +510,7 @@ "timezone": "Europe/Berlin" } }, - "12": { + { "id": 12, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -520,7 +520,7 @@ "timezone": "Europe/Berlin" } }, - "13": { + { "id": 13, "text": "wouah trop bien framadate!", "pseudo": "tk_TEST", @@ -530,7 +530,7 @@ "timezone": "Europe/Berlin" } }, - "14": { + { "id": 14, "text": "wouah trop bien framadate wouhouuu!", "pseudo": "tk_TEST", @@ -540,7 +540,7 @@ "timezone": "Europe/Berlin" } }, - "15": { + { "id": 15, "text": "wouah trop bien framadate wouhouucghfdghu!", "pseudo": "tk_TEST", @@ -550,7 +550,7 @@ "timezone": "Europe/Berlin" } }, - "16": { + { "id": 16, "text": "wouah trop bien framadate woudghdghhouucghfdghu!", "pseudo": "tk_TEST", @@ -560,6 +560,6 @@ "timezone": "Europe/Berlin" } } - }, + ], "comments_count": 14 } diff --git a/src/app/config/mocks/mock-comments.ts b/src/app/config/mocks/mock-comments.ts index 293c1f92..17c73beb 100644 --- a/src/app/config/mocks/mock-comments.ts +++ b/src/app/config/mocks/mock-comments.ts @@ -1,12 +1,12 @@ export const mockComments = [ { - name: "Bulbizarre", + pseudo: "Bulbizarre", date: "23 décembre 2019", text: "Pokem ipsum dolor sit amet Electric Cottonee Scratch Leech Life Ice Berry Ducklett. Leaf Green Durant Zoroark\n" + " Skitty Rock Luxio Surskit. Glacier Badge", }, { - name: "Marylin", + pseudo: "Marylin", date: "5 Janvier 2020", text: "j'ai vu de la lumière o_o", }, diff --git a/src/app/config/mocks/mock-poll3.ts b/src/app/config/mocks/mock-poll3.ts index b518e87d..4e3dee84 100644 --- a/src/app/config/mocks/mock-poll3.ts +++ b/src/app/config/mocks/mock-poll3.ts @@ -1,5 +1,3 @@ -import {mockComments} from "./mock-comments"; - export const mockPoll3 = { "message": "your poll config", "data": { @@ -8,19 +6,21 @@ export const mockPoll3 = { "customUrl": null, "description": "choisissez votre animé préféré", "creationDate": { - "date": "2020-01-15 15:07:53.000000", + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, "expiracyDate": { - "date": "2020-03-17 15:07:53.000000", + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, "owner": { - "__initializer__": {}, - "__cloner__": {}, - "__isInitialized__": false + "__initializer__": null, + "__cloner__": null, + "__isInitialized__": true, + "pseudo": "tk_TEST", + "email": "tktest@tktest.com" }, "kind": "text", "allowedAnswers": [ @@ -37,65 +37,318 @@ export const mockPoll3 = { "comments": {}, "defaultExpiracyDaysFromNow": 60 }, - "stacks_count": 4, + "stacks_count": 10, "stacks": [ { - "pseudo": "Wulfila", + "id": 3, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 3, + "vote_id": 4, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + }, + { + "id": 3, + "vote_id": 5, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + } + ] + }, + { + "id": 4, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 4, + "vote_id": 6, + "value": "yes", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 4, + "vote_id": 7, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + }, + { + "id": 4, + "vote_id": 8, + "value": "no", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 5, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:33:26.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, "votes": [ { "id": 5, - "answer": "yes", + "vote_id": 9, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + { + "id": 5, + "vote_id": 10, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 5, + "vote_id": 11, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 6, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:36:58.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 6, + "vote_id": 12, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" }, { "id": 6, - "answer": "maybe", + "vote_id": 13, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 6, + "vote_id": 14, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 7, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:39:12.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 7, + "vote_id": 15, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" }, { "id": 7, - "answer": "no", + "vote_id": 16, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" }, + { + "id": 7, + "vote_id": 17, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } ] }, { - "pseudo": "Tykayn", + "id": 8, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:39:13.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, "votes": [ { - "id": 5, - "answer": "yes", + "id": 8, + "vote_id": 18, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" }, { "id": 8, - "answer": "maybe", - }, - { - "id": 9, - "answer": "no", - }, - ] - }, - { - "pseudo": "CopyCat", - "votes": [ - { - "id": 5, - "answer": "yes", + "vote_id": 19, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" }, { "id": 8, - "answer": "maybe", - }, - { - "id": 9, - "answer": "no", - }, + "vote_id": 20, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } ] }, { - "pseudo": "Marylin", + "id": 9, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:42:19.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, "votes": [ { - "id": 5, - "answer": "yes", + "id": 9, + "vote_id": 21, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + { + "id": 9, + "vote_id": 22, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 9, + "vote_id": 23, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 10, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:42:32.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 10, + "vote_id": 24, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + { + "id": 10, + "vote_id": 25, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 10, + "vote_id": 26, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 11, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:43:46.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 11, + "vote_id": 27, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + { + "id": 11, + "vote_id": 28, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 11, + "vote_id": 29, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" + } + ] + }, + { + "id": 12, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:44:35.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": [ + { + "id": 12, + "vote_id": 30, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + { + "id": 12, + "vote_id": 31, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + { + "id": 12, + "vote_id": 32, + "value": "yes", + "choice_id": 7, + "text": "Les mystérieuses cités d'or" } ] } @@ -104,137 +357,209 @@ export const mockPoll3 = { "choices": [ { "id": 5, - "name": "Vic le viking", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Vic le viking" }, { "id": 6, - "name": "Boumbo petite automobile", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Boumbo petite automobile" }, { "id": 7, - "name": "Les mystérieuses cités d'or", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Les mystérieuses cités d'or" }, { "id": 8, - "name": "Les mondes engloutis", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Les mondes engloutis" }, { "id": 9, - "name": "Foot 2 rue", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Foot 2 rue" }, { "id": 10, - "name": "Le chat, la vache, et l'océan", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Le chat, la vache, et l'océan" }, { "id": 11, - "name": "Digimon", - "dateTime": { - "date": "2020-01-15 15:07:53.000000", + "date": { + "date": "2020-01-20 16:45:48.000000", "timezone_type": 3, - "timezone": "Europe/Paris" + "timezone": "Europe/Berlin" }, - "votes": { - "count": { - "yes": 0, - "no": 0, - "maybe": 0, - "null": 0, - } - }, - simpleAnswer: true, - "answer": null + "text": "Digimon" } ], - "comments": mockComments + "comments": [ + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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" + } + }, + { + "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 }; diff --git a/src/app/debugger/debugger.component.html b/src/app/debugger/debugger.component.html index 8c518989..b964cd72 100644 --- a/src/app/debugger/debugger.component.html +++ b/src/app/debugger/debugger.component.html @@ -28,7 +28,7 @@ diff --git a/src/app/pages/admin/admin.component.ts b/src/app/pages/admin/admin.component.ts index cf0bc3fa..a99c9db7 100644 --- a/src/app/pages/admin/admin.component.ts +++ b/src/app/pages/admin/admin.component.ts @@ -1,16 +1,17 @@ -import { Component, OnInit } from '@angular/core'; -import {BaseComponent} from '../base-page/base.component'; +import {Component, OnInit} from '@angular/core'; import {ConfigService} from '../../services/config.service'; + @Component({ - selector: 'framadate-admin', - templateUrl: './admin.component.html', - styleUrls: ['./admin.component.scss'] + selector: 'framadate-admin', + templateUrl: './admin.component.html', + styleUrls: ['./admin.component.scss'] }) export class AdminComponent implements OnInit { - constructor(private config : ConfigService) { } + constructor(public config: ConfigService) { + } - ngOnInit() { - } + ngOnInit() { + } } diff --git a/src/app/pages/answers/answers.component.ts b/src/app/pages/answers/answers.component.ts index ab769f02..cd891418 100644 --- a/src/app/pages/answers/answers.component.ts +++ b/src/app/pages/answers/answers.component.ts @@ -11,11 +11,11 @@ import {DOCUMENT} from '@angular/common'; }) export class AnswersComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges { - private allAnswersAreValid = false; + allAnswersAreValid = false; - private answerList = []; - private currentHeader: any = ""; - private display: boolean; + answerList = []; + currentHeader: any = ""; + display: boolean; constructor(public config: ConfigService, @Inject(DOCUMENT) private document: any, diff --git a/src/app/pages/poll-display/poll-display.component.html b/src/app/pages/poll-display/poll-display.component.html index eec65087..0794a3ba 100644 --- a/src/app/pages/poll-display/poll-display.component.html +++ b/src/app/pages/poll-display/poll-display.component.html @@ -1,8 +1,22 @@
@@ -94,11 +109,14 @@ (click)='config.addVote()' > Envoyer +
- +
+ +
diff --git a/src/app/pages/visibility/visibility.component.html b/src/app/pages/visibility/visibility.component.html index f84ca772..e1c81b7c 100644 --- a/src/app/pages/visibility/visibility.component.html +++ b/src/app/pages/visibility/visibility.component.html @@ -134,7 +134,7 @@
+ *ngIf="config.passwordAccess == 1" > - {{comment.name}} , le - {{comment.date}} -

+

+ {{comment.pseudo}} , le + {{comment.date}} +

{{comment.text}} -

-
+

+
diff --git a/src/app/pages/voting/voting-comment/voting-comment.component.ts b/src/app/pages/voting/voting-comment/voting-comment.component.ts index 6ab3b627..64b36ce4 100644 --- a/src/app/pages/voting/voting-comment/voting-comment.component.ts +++ b/src/app/pages/voting/voting-comment/voting-comment.component.ts @@ -8,7 +8,7 @@ import {mockComments} from "../../../config/mocks/mock-comments"; }) export class VotingCommentComponent implements OnInit { - @Input() private comment = mockComments[0]; + @Input() comment = mockComments[0]; constructor() { } diff --git a/src/app/pages/voting/voting-summary/voting-summary.component.ts b/src/app/pages/voting/voting-summary/voting-summary.component.ts index ddfc4650..3e2ff185 100644 --- a/src/app/pages/voting/voting-summary/voting-summary.component.ts +++ b/src/app/pages/voting/voting-summary/voting-summary.component.ts @@ -9,10 +9,10 @@ import {mockPoll3} from "../../../config/mocks/mock-poll3"; }) export class VotingSummaryComponent implements OnInit { - private preferred: string = 'rien'; - private counters: any = {}; + preferred: string = 'rien'; + counters: any = {}; - @Input() private pollconfig = mockPoll3; + @Input() pollconfig = mockPoll3; constructor(private config: ConfigService) { @@ -30,11 +30,11 @@ export class VotingSummaryComponent implements OnInit { let maximumYesCount = 0; let choice_id_max = 0; let winners_id = []; - this.pollconfig.stacks.map(stack => { + this.pollconfig.stacks.forEach(stack => { stack.votes.map(vote => { - let choice_id = vote.id; - let answer = vote.answer; + let choice_id = vote.choice_id; + let answer = vote.text; if (!this.counters["choice_" + choice_id]) { this.counters["choice_" + choice_id] = { yes: 0, @@ -50,12 +50,14 @@ export class VotingSummaryComponent implements OnInit { // find the favourite - }) - console.log('this.counters', this.counters); + }); + console.log('choice_id_max', choice_id_max); + console.log(' this.pollconfig.choices', this.pollconfig.choices); let choiceTitleFound = this.pollconfig.choices.find(elem => { + console.log('elem', elem); return elem.id == choice_id_max - }) - this.preferred = choiceTitleFound.name; + }); + this.preferred = choiceTitleFound.text; console.log('choiceTitleFound', choiceTitleFound) } diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts index 9cd73378..67416433 100644 --- a/src/app/services/config.service.ts +++ b/src/app/services/config.service.ts @@ -5,6 +5,8 @@ import {environment} from "../../environments/environment"; import {ConfirmationService, MessageService} from 'primeng/api'; import {Router} from "@angular/router"; import {mockPoll3} from "../config/mocks/mock-poll3"; +import {mockMyPolls} from "../config/mocks/mockmypolls"; +import {defaultAnswers, defaultDates, timeOfDay} from "../config/defaultConfigs"; /** * le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée @@ -14,7 +16,6 @@ import {mockPoll3} from "../config/mocks/mock-poll3"; }) export class ConfigService extends PollConfig { - currentPoll: any = mockPoll3; loading: boolean = false; baseHref: any = environment.baseApiHref; @@ -25,6 +26,14 @@ export class ConfigService extends PollConfig { private confirmationService: ConfirmationService, ) { super(); + // fill in mock values if we are not in production environment + if (!environment.production) { + this.currentPoll = mockPoll3; + this.myPolls = mockMyPolls; + this.dateList = defaultDates; + this.timeList = timeOfDay; + this.answers = defaultAnswers; + } } set(key, val) { @@ -114,6 +123,10 @@ export class ConfigService extends PollConfig { return jsonConfig } + /** + * prepare headers like the charset and json type for any call to the backend + * @param bodyContent + */ makeHeaders(bodyContent?: any) { const headerDict = { @@ -132,13 +145,16 @@ export class ConfigService extends PollConfig { return requestOptions; } - checkIfSlugIsUniqueInDatabase(slug: string) { + checkIfSlugIsUniqueInDatabase(slug: string = '') { this.customUrlIsUnique = null; + if (!slug) { + slug = this.makeSlug(); + } this.loading = true; // TODO this.todo('check slug is unique'); - this.http.get(`${this.baseHref}/check-slug-is-uniq`, + this.http.get(`${this.baseHref}/check-slug-is-uniq/${slug}`, this.makeHeaders({slug: this.customUrl}), ) .subscribe((res: any) => { @@ -282,11 +298,14 @@ export class ConfigService extends PollConfig { .subscribe((res: any) => { // redirect to the page to administrate the new poll this.messageService.add({severity: 'success', summary: 'Sondage Créé',}); - this.selectedPoll = res; + this.currentPoll = res; this.pollId = res.pollId; this.loading = false; this.myPolls.push(config); this.router.navigate(['step/end']); + // TODO save new poll to localstorage + // reset all fields in current config + this.resetConfig(); }, (e) => { this.handleError(e) } @@ -401,7 +420,7 @@ export class ConfigService extends PollConfig { } deleteVotes() { -// prompt for confirmation + // prompt for confirmation this.confirmationService.confirm({ message: 'Are you sure that you want to completely delete the votes of this poll (' + this.title + ') permanentely?', accept: () => { diff --git a/src/app/ui/erasable-input/erasable-input.component.ts b/src/app/ui/erasable-input/erasable-input.component.ts index b11a5fbd..147a1c01 100644 --- a/src/app/ui/erasable-input/erasable-input.component.ts +++ b/src/app/ui/erasable-input/erasable-input.component.ts @@ -19,6 +19,7 @@ export class ErasableInputComponent implements OnInit { eraseInput() { // this.inputModelChange.emit(''); + // TODO focus on other element } } diff --git a/src/app/ui/navigation/navigation.component.html b/src/app/ui/navigation/navigation.component.html index 304bcb25..aedc5b7f 100644 --- a/src/app/ui/navigation/navigation.component.html +++ b/src/app/ui/navigation/navigation.component.html @@ -1,7 +1,7 @@