File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/pages/club-content/club-content.page.ts
import { PublicationClubService } from './../../services/publication-club.service';
import { Component, OnInit } from '@angular/core';
import { UtilsService } from '../../services/utils.service';
import { TranslateService } from '@ngx-translate/core';
import { ModalController } from '@ionic/angular';
@Component({
selector: 'app-club-content',
templateUrl: './club-content.page.html',
styleUrls: ['./club-content.page.scss'],
})
export class ClubContentPage implements OnInit {
typeContent = 'photo';
photoClub: any = [];
videos: any = [];
podcast: any = [];
news: any = [];
time: number;
timeScroll: number;
constructor(
public utilsService: UtilsService,
public translateService: TranslateService,
public modalCtrl: ModalController,
private publicationClubService: PublicationClubService
) { }
ngOnInit() {
this.loadInit();
}
loadInit(time = 0) {
this.time = new Date().getTime();
setTimeout(() => {
return new Promise((resolve, reject) => {
this.utilsService.presentLoading(this.translateService.instant("all.loading")).then(() => {
Promise.all([
this.getPhotos()
]).then(() => {
this.utilsService.closeAllAlerts();
this.utilsService.loadingPage = false;
resolve(false);
}).catch((error) => {
this.utilsService.closeAllAlerts();
this.utilsService.loadingPage = false;
console.log('Error loadInit HomeSc', error);
reject(error);
});
});
});
}, time);
}
getPhotos() {
this.publicationClubService.get('photo', 50).then((items) => {
this.photoClub = items;
});
}
getVideos() {
this.publicationClubService.get('video', 50).then((items) => {
this.timeScroll = null;
this.videos = items;
});
}
getPodcast() {
this.publicationClubService.get('podcast', 50).then((items) => {
this.podcast = items;
});
}
getNews() {
this.publicationClubService.get('news', 50).then((items) => {
this.news = items;
});
}
changedTypeOrder(e) {
this.typeContent = e.detail.value;
switch (this.typeContent) {
case 'photo':
this.getPhotos();
break;
case 'video':
this.getVideos();
break;
case 'podcast':
this.getPodcast();
break;
case 'news':
this.getNews();
break;
}
}
doRefresh(event) {
this.loadInit(500);
event.target.complete();
}
onScroll(event) {
this.timeScroll = new Date().getTime();
}
}