diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8e3001a4..dde91e65 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core'; +import { AfterViewInit, Component, Inject, OnDestroy, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { Subscription } from 'rxjs'; @@ -15,6 +15,8 @@ import { Poll } from './core/models/poll.model'; import { PollDTO } from './core/models/poll.DTO.model'; import { PrimeNGConfig } from 'primeng/api'; import { Language } from './core/enums/language.enum'; +import { ApiService } from './core/services/api.service'; +import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-root', @@ -39,7 +41,9 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { private titleService: Title, private themeService: ThemeService, private pollService: PollService, + private apiService: ApiService, private config: PrimeNGConfig, + @Inject(DOCUMENT) private document: any, private languageService: LanguageService // private mockingService: MockingService ) {} @@ -63,7 +67,10 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { if (!(evt instanceof NavigationEnd)) { return; } - window.scrollTo(0, 0); + + let mainelem = this.document.querySelector('#big_container main'); + console.log('mainelem', mainelem); + window.scrollTo(0, mainelem.offsetTop); }); if (!environment.production) { @@ -92,10 +99,12 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { this.themeClass = 'theme-light-watermelon'; } }); + + // debug cors + this.apiService.getAllAvailablePolls(); } ngAfterViewInit(): void { - console.log('this.shortcuts', this.shortcuts); this.shortcuts.push( { key: '?', @@ -118,7 +127,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { preventDefault: true, } ); - console.log('this.shortcuts', this.shortcuts); } ngOnDestroy(): void { @@ -127,10 +135,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { } } - public toggleSidebar(status: boolean): void { - this.isSidebarOpened = status === true; - } - prepareRoute(outlet: RouterOutlet) { return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation; } diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index 7ee51523..4b72865d 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -38,16 +38,17 @@ export class ApiService { this.axiosInstance = axios.create({ baseURL: apiBaseHref }); this.axiosInstance.defaults.timeout = 2500; - this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json'; - this.axiosInstance.defaults.headers.post['Accept'] = 'application/json'; - this.axiosInstance.defaults.headers.post['Charset'] = 'UTF-8'; + // this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json'; + // this.axiosInstance.defaults.headers.post['Accept'] = 'application/json'; + // this.axiosInstance.defaults.headers.post['Charset'] = 'UTF-8'; // this.axiosInstance.defaults.headers.post['Accept-Charset'] = 'UTF-8'; - this.axiosInstance.defaults.headers.post['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; - this.axiosInstance.defaults.headers.post['Referrer-Policy'] = 'origin-when-cross-origin'; - this.axiosInstance.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; - this.axiosInstance.defaults.headers.post['Allow-Origin'] = '*'; - this.axiosInstance.defaults.headers.post['Access-Control-Allow-Headers'] = - 'Origin, X-Requested-With, Content-Type, Accept'; + // this.axiosInstance.defaults.headers.post['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; + // this.axiosInstance.defaults.headers.post['Referrer-Policy'] = 'origin-when-cross-origin'; + // this.axiosInstance.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; + // this.axiosInstance.defaults.headers.post['Control-Allow-Origin'] = '*'; + // this.axiosInstance.defaults.headers.post['Allow-Origin'] = '*'; + // this.axiosInstance.defaults.headers.post['Access-Control-Allow-Headers'] = + // 'Origin, X-Requested-With, Content-Type, Accept'; console.log('this.axiosInstance.defaults.headers', this.axiosInstance.defaults.headers); } @@ -68,16 +69,16 @@ export class ApiService { // Accept: 'application/json', 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', - mode: 'no-cors', + // mode: 'no-cors', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', 'Access-Control-Allow-Headers': 'Accept,Accept-Language,Content-Language,Content-Type', - // 'Access-Control-Allow-Origin': '*', }; - - return { + const headersAxios = { headers: headerDict, body: bodyContent, }; + console.log('headersAxios', headersAxios); + return headersAxios; } /** @@ -89,8 +90,8 @@ export class ApiService { console.log('apiservice createPoll config', poll); return this.axiosInstance.post( `${this.baseHref}${currentApiRoutes['api_new_poll']}`, - poll, - ApiService.makeHeaders() + poll + // ApiService.makeHeaders() ); } @@ -146,6 +147,8 @@ export class ApiService { public async getAllAvailablePolls(): Promise { // TODO: used for facilities in DEV, should be removed in production try { + this.axiosInstance.options(this.pollsEndpoint); + const response: AxiosResponse = await this.axiosInstance.get(`${this.pollsEndpoint}`); return response?.data; } catch (error) { diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 3ee901dc..d8ed77f7 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -85,7 +85,7 @@ export class PollService implements Resolve { */ setDemoValues(): void { this.form.patchValue({ - title: 'mon titre de sondage du ' + this.DateUtilitiesService.formateDateToInputStringNg(new Date()), + title: 'Mon titre de sondage du ' + this.DateUtilitiesService.formateDateToInputStringNg(new Date()), description: 'répondez SVP <3 ! *-* ', custom_url: this.uuidService.getUUID(), creatorPseudo: 'Chuck Norris', @@ -390,7 +390,6 @@ export class PollService implements Resolve { */ public createPoll(): Promise { this.toastService.display('sending...'); - console.log('createPoll this.form', this.form); const newpoll = this.newPollFromForm(); return this.apiService.createPoll(newpoll).then( (resp: any) => { @@ -689,7 +688,7 @@ export class PollService implements Resolve { const field = form.value[pk]; newpoll[pk] = field; } else { - console.log('manque pollKey', pk); + // console.log('manque pollKey', pk); } } diff --git a/src/app/core/services/poll.utilities.service.ts b/src/app/core/services/poll.utilities.service.ts index 0b6471fe..4b669c40 100644 --- a/src/app/core/services/poll.utilities.service.ts +++ b/src/app/core/services/poll.utilities.service.ts @@ -65,16 +65,16 @@ export class PollUtilitiesService { * @param bodyContent */ makeHeaders(bodyContent?: any) { - const headerDict = { - Charset: 'UTF-8', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', - 'Access-Control-Allow-Origin': '*', - }; + // const headerDict = { + // Charset: 'UTF-8', + // 'Content-Type': 'application/json', + // Accept: 'application/json', + // 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + // 'Access-Control-Allow-Origin': '*', + // }; return { - headers: headerDict, + headers: [], body: bodyContent, }; } diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index b63a41e6..9f23a16a 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -1,10 +1,5 @@
-
-

- {{ 'creation.title' | translate }} -

-
-
+
diff --git a/src/app/features/administration/form/steps/step-five/step-five.component.ts b/src/app/features/administration/form/steps/step-five/step-five.component.ts index cfd6c4fb..c7e8fd33 100644 --- a/src/app/features/administration/form/steps/step-five/step-five.component.ts +++ b/src/app/features/administration/form/steps/step-five/step-five.component.ts @@ -12,7 +12,9 @@ export class StepFiveComponent implements OnInit { @Input() step_max: any; @Input() public form: FormGroup; poll: any; - constructor(public pollService: PollService) {} + constructor(public pollService: PollService) { + this.pollService.step_current = 5; + } ngOnInit(): void {} askInitFormDefault() { diff --git a/src/app/features/administration/form/steps/step-four/step-four.component.ts b/src/app/features/administration/form/steps/step-four/step-four.component.ts index 3c589228..127e9a62 100644 --- a/src/app/features/administration/form/steps/step-four/step-four.component.ts +++ b/src/app/features/administration/form/steps/step-four/step-four.component.ts @@ -1,6 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; import { PollService } from '../../../../../core/services/poll.service'; -import { ApiService } from '../../../../../core/services/api.service'; import { environment } from '../../../../../../environments/environment'; import { Router } from '@angular/router'; @@ -16,7 +15,10 @@ export class StepFourComponent implements OnInit { step_max: any; @Input() form: any; - constructor(private router: Router, public pollService: PollService, private apiService: ApiService) {} + + constructor(private router: Router, public pollService: PollService) { + this.pollService.step_current = 4; + } ngOnInit(): void {} diff --git a/src/app/features/administration/form/steps/step-one/step-one.component.html b/src/app/features/administration/form/steps/step-one/step-one.component.html index be65462f..f133ba0b 100644 --- a/src/app/features/administration/form/steps/step-one/step-one.component.html +++ b/src/app/features/administration/form/steps/step-one/step-one.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/features/administration/form/steps/step-one/step-one.component.ts b/src/app/features/administration/form/steps/step-one/step-one.component.ts index 0107efb2..24414959 100644 --- a/src/app/features/administration/form/steps/step-one/step-one.component.ts +++ b/src/app/features/administration/form/steps/step-one/step-one.component.ts @@ -17,6 +17,7 @@ export class StepOneComponent implements OnInit { form: FormGroup; ngOnInit(): void { + this.pollService.step_current = 1; const selector = '#title'; const firstField = this.document.querySelector(selector); if (firstField) { diff --git a/src/app/features/administration/form/steps/step-three/step-three.component.html b/src/app/features/administration/form/steps/step-three/step-three.component.html index 46acb886..3e3da6d6 100644 --- a/src/app/features/administration/form/steps/step-three/step-three.component.html +++ b/src/app/features/administration/form/steps/step-three/step-three.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/features/administration/form/steps/step-three/step-three.component.ts b/src/app/features/administration/form/steps/step-three/step-three.component.ts index 621b2737..1a6da11b 100644 --- a/src/app/features/administration/form/steps/step-three/step-three.component.ts +++ b/src/app/features/administration/form/steps/step-three/step-three.component.ts @@ -13,7 +13,9 @@ export class StepThreeComponent implements OnInit { @Input() form: any; - constructor(public pollService: PollService) {} + constructor(public pollService: PollService) { + this.pollService.step_current = 3; + } ngOnInit(): void {} diff --git a/src/app/features/administration/form/steps/step-two/step-two.component.html b/src/app/features/administration/form/steps/step-two/step-two.component.html index 102c242a..92d2289d 100644 --- a/src/app/features/administration/form/steps/step-two/step-two.component.html +++ b/src/app/features/administration/form/steps/step-two/step-two.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/features/administration/form/steps/step-two/step-two.component.ts b/src/app/features/administration/form/steps/step-two/step-two.component.ts index 2a030ff0..728c04aa 100644 --- a/src/app/features/administration/form/steps/step-two/step-two.component.ts +++ b/src/app/features/administration/form/steps/step-two/step-two.component.ts @@ -39,6 +39,7 @@ export class StepTwoComponent implements OnInit { @Inject(DOCUMENT) private document: any ) { this.form = this.pollService.form; + this.pollService.step_current = 2; } addIntervalOfDates() {} diff --git a/src/app/features/administration/stepper/stepper.component.html b/src/app/features/administration/stepper/stepper.component.html index 9fb6739a..499ce974 100644 --- a/src/app/features/administration/stepper/stepper.component.html +++ b/src/app/features/administration/stepper/stepper.component.html @@ -1,12 +1,17 @@
-

- Étape {{ step_current }} / - {{ step_max }} +

+ {{ 'creation.title' | translate }} +

+

{{ pollService.form.value.title }}

+

+ Étape {{ step_current }} / + {{ step_max }} +

diff --git a/src/app/features/administration/success/success.component.html b/src/app/features/administration/success/success.component.html index 61b70b97..00834474 100644 --- a/src/app/features/administration/success/success.component.html +++ b/src/app/features/administration/success/success.component.html @@ -1,14 +1,30 @@ -
+
-

🎉 {{ 'resume.title' | translate }}

+

🎉 {{ 'resume.title' | translate }}

- Votre sondage « + Votre sondage +
+ « {{ pollService.form.value.title }} - » a bien été créé ! + » + + n'a pas été créé :( + +
+ +
+ + a bien été créé ! +

@@ -20,19 +36,20 @@
-

- - {{ 'resume.admins' | translate }} -

-

- Voici les liens d’accès au sondage, conservez-les soigneusement ! (Si vous les perdez vous - pourrez toujours les recevoir par email) -

-
+
Pas de clé d'administration, l'enregistrement du sondage a échoué. vérifiez vos paramètres réseau.
+

+ + {{ 'resume.admins' | translate }} +

+ +

+ Voici les liens d’accès au sondage, conservez-les soigneusement ! (Si vous les perdez + vous pourrez toujours les recevoir par email) +

Pour accéder au sondage et à tous ses paramètres :
@@ -68,7 +85,7 @@
-
+

{{ 'resume.users' | translate }} @@ -86,8 +103,6 @@

- -
diff --git a/src/app/features/consultation/consultation.module.ts b/src/app/features/consultation/consultation.module.ts index 7771ab14..7b5cfcb8 100644 --- a/src/app/features/consultation/consultation.module.ts +++ b/src/app/features/consultation/consultation.module.ts @@ -9,6 +9,8 @@ import { PollResultsCompactComponent } from './poll-results-compact/poll-results import { PollResultsDetailedComponent } from './poll-results-detailed/poll-results-detailed.component'; import { ChoiceButtonComponent } from '../../shared/components/choice-item/choice-button.component'; import { PasswordPromptComponent } from './password/password-prompt/password-prompt.component'; +import { ChoiceDetailsComponent } from '../../shared/components/choice-details/choice-details.component'; +import { CoreModule } from '../../core/core.module'; @NgModule({ declarations: [ diff --git a/src/environments/endpoints.ts b/src/environments/endpoints.ts index 2a3201c1..01f50335 100644 --- a/src/environments/endpoints.ts +++ b/src/environments/endpoints.ts @@ -1,15 +1,15 @@ export const backendApiUrlsInDev = { // local: 'http://tktest.lan/api/v1', // remote: 'http://tktest.lan/api/v1', - local: 'https://localhost:8000/api/v1', + local: 'http://localhost:8000/api/v1', // local: 'https://framadate-api.cipherbliss.com/api/v1', - remote: 'https://localhost:8000/api/v1', + remote: 'http://localhost:8000/api/v1', // remote: 'https://framadate-api.cipherbliss.com/api/v1', }; export const apiV1 = { - // baseHref: 'https://localhost:8000/api/v1', + baseHref: 'http://localhost:8000/api/v1', // baseHref: 'http://tktest.lan/api/v1', - baseHref: 'https://framadate-api.cipherbliss.com/api/v1', + // baseHref: 'https://framadate-api.cipherbliss.com/api/v1', api_new_poll: '/poll/', api_get_poll: '/poll/{id}', api_new_vote_stack: '/vote-stack', diff --git a/src/styles/partials/_forms.scss b/src/styles/partials/_forms.scss index 2c6a0453..d6b2f05c 100644 --- a/src/styles/partials/_forms.scss +++ b/src/styles/partials/_forms.scss @@ -320,3 +320,7 @@ mat-checkbox { color: $light; } } + +.step-container { + @extend .container, .is-widescreen; +}