import { Component, OnInit } from '@angular/core'; import { Event } from '../../models/event.model'; import { EventsService } from 'src/app/services/events.service'; import { Router } from '@angular/router'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; @Component({ selector: 'app-events', templateUrl: './events.page.html', styleUrls: ['./events.page.scss'], }) export class EventsPage implements OnInit { /* Get current system date */ today = new Date(); months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); /* Setting appropriate greeting according to the time */ grettings = ["Bom dia", "Boa tarde", "Boa noite"]; greetting=''; timeDate = this.today.getHours() + ":" + this.today.getMinutes(); /* Set segment variable */ segment:string; events: Event[]; eventsList: Observable; constructor(private eventService: EventsService, private router: Router, public activatedRoute: ActivatedRoute) { } ngOnInit() { //Inicializar segment this.segment = "combinada"; this.showGreeting(); /* Call Get events method */ this.events = this.eventService.getAllEvents(); this.eventsList = this.eventService.allEvents();/* .subscribe(prods=>console.log(prods)); */ } showGreeting(){ if(this.today.getHours() >= 6 && this.today.getHours() < 12){ console.log(this.grettings[0]+this.today.getHours()); this.greetting = this.grettings[0]; } else if(this.today.getHours() >= 12 && this.today.getHours() < 18){ console.log(this.grettings[1]+this.today.getHours()); this.greetting = this.grettings[1]; } else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */{ console.log(this.grettings[2]+this.today.getHours()); this.greetting = this.grettings[2]; } } gotTo(ev){ this.router.navigate(['/home/events']); } }