import { SITES } from './../../../../../core/mocks/data'; import { Site } from 'src/app/core/interfaces/site/site'; import { environment } from './../../../../../../environments/environment'; import { QueryService } from './../../../../../core/services/query/query.service'; import { Component, Input, OnInit, EventEmitter, Output } from '@angular/core'; import { faBorderAll } from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'app-sites', templateUrl: './sites.component.html', styleUrls: ['./sites.component.scss'] }) export class SitesComponent implements OnInit { @Output() emitAllyId = new EventEmitter(); @Input() is_slide_mode: boolean = true; icon_border_all = faBorderAll; url = environment.BASE_URL_API; sites: Site[] = SITES; nextPage: string | null = null; previousPage: string | null = null; actualPage = environment.BASE_URL_API+'/allys/'; constructor(private queryService: QueryService) { } ngOnInit() { this.getSites(); } changeModeList(){ this.is_slide_mode=true; } changeModeSlide(){ this.is_slide_mode=false; } handlePatternAllyId($event: any) { this.emitAllyId.emit($event); } getSites(){ this.queryService.query(this.actualPage, 'GET')?.subscribe( (data: any) => { console.log("This is data",data) this.sites = data.results; this.nextPage = data.nextPage; this.previousPage = data.previousPage; }, (error) => { console.log(error) } ) } handleNextPage(){ if (this.nextPage) this.actualPage = this.nextPage; this.getSites(); } handlePreviousPage(){ if (this.previousPage) this.actualPage = this.previousPage; this.getSites(); } }