funky-framadate-front/src/app/core/components/home/home.component.ts

82 lines
2.3 KiB
TypeScript
Raw Normal View History

2022-02-08 14:46:13 +01:00
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
2020-11-06 11:32:58 +01:00
import { environment } from '../../../../environments/environment';
2021-05-03 10:06:10 +02:00
import { StorageService } from '../../services/storage.service';
2021-05-03 11:32:03 +02:00
import { ApiService } from '../../services/api.service';
import { ToastService } from '../../services/toast.service';
import { DOCUMENT } from '@angular/common';
2021-11-08 11:27:35 +01:00
import { Title } from '@angular/platform-browser';
import { PollService } from '../../services/poll.service';
import { TranslateService } from '@ngx-translate/core';
2020-05-01 19:10:17 +02:00
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
2022-02-08 14:46:13 +01:00
export class HomeComponent implements OnInit {
2021-05-03 10:06:10 +02:00
public environment = environment;
2022-02-03 14:08:03 +01:00
public AppTitle = environment.appTitle;
public nonexistent_email = '';
2021-05-21 13:11:54 +02:00
public email_sent = false;
display_poll_search_dialog: any = false;
2022-02-03 14:08:03 +01:00
constructor(
@Inject(DOCUMENT) private document: any,
public storageService: StorageService,
public toastService: ToastService,
2021-11-08 11:27:35 +01:00
public titleService: Title,
private api: ApiService,
private pollService: PollService,
private translate: TranslateService,
private cd: ChangeDetectorRef
) {}
2022-02-08 14:46:13 +01:00
ngOnInit() {
2022-02-09 14:47:51 +01:00
// this.openModalFindPoll();
this.pollService.step_current = null;
this.pollService.updateTitle();
2021-11-08 11:27:35 +01:00
}
2021-05-03 10:06:10 +02:00
2021-05-03 11:32:03 +02:00
searchMyPolls() {
const email = this.storageService.vote_stack.owner.email;
this.email_sent = false;
this.api.findMyPollsByEmail(email).then(
(resp) => {
console.log('resp', resp);
if (resp) {
if (resp.data && resp.data.mail_sent == '1') {
this.toastService.display("C'est bon, vérifiez votre boite mail");
this.email_sent = true;
}
}
},
(error) => {
if (error.response.status == '404') {
this.toastService.display('Aucun sondage géré par cet email : ' + email);
this.nonexistent_email = email;
this.document.querySelector('#search_email').select();
}
console.log('error', error);
}
);
2021-05-03 11:32:03 +02:00
}
openModalFindPoll() {
this.display_poll_search_dialog = true;
this.cd.detectChanges();
let buttonClose = this.document.querySelector('#close_dialog');
if (buttonClose) {
buttonClose.focus();
}
}
focusOnCancelButton() {
this.display_poll_search_dialog = false;
let buttonClose = this.document.querySelector('#open_popup_button');
if (buttonClose) {
buttonClose.focus();
}
}
2020-05-01 19:10:17 +02:00
}