HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
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();
  }
}