No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

100 líneas
3.0 KiB

  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { IonSlides } from '@ionic/angular';
  3. import { Router } from '@angular/router';
  4. import { NewsService, IMAGE_BASE_URL } from '../services/news.service';
  5. import { ToastService } from '../services/toast.service';
  6. import { DomSanitizer } from '@angular/platform-browser';
  7. import { Uptime } from '@ionic-native/uptime/ngx';
  8. import { SocialSharing } from '@ionic-native/social-sharing/ngx';
  9. @Component({
  10. selector: 'app-home',
  11. templateUrl: './home.page.html',
  12. styleUrls: ['./home.page.scss'],
  13. })
  14. export class HomePage implements OnInit {
  15. @ViewChild('slides') slides: IonSlides;
  16. selectedTab: 'news' | 'videos' | 'gallery' = 'news';
  17. slideOpts = {
  18. slidesPerView: 1.5,
  19. spaceBetween: 15,
  20. initialSlide: 0,
  21. centeredSlides: true,
  22. // simulateTouch: false,
  23. // followFinger: false,
  24. };
  25. newsData = [];
  26. videoData = [];
  27. galleryData = [];
  28. showChat: boolean = false;
  29. image_url = IMAGE_BASE_URL;
  30. myuptime: string;
  31. constructor(
  32. private router: Router,
  33. private newsService: NewsService,
  34. private toastService: ToastService,
  35. private dom: DomSanitizer,
  36. private uptime: Uptime,
  37. private socialSharing: SocialSharing
  38. ) { }
  39. transformYourHtml(htmlTextWithStyle) {
  40. return this.dom.bypassSecurityTrustHtml(htmlTextWithStyle += '<style type="text/css">p{ margin: 0px; }</style>');
  41. }
  42. share(message: string, image?: string, url?: string) {
  43. this.socialSharing.share(message, '', image ? image : '', url? url : '');
  44. }
  45. ngOnInit() {
  46. this.uptime.getUptime(true)
  47. .then(uptime => this.myuptime = uptime)
  48. .catch(error => console.log(error));
  49. this.newsService.getArticles().then((data: any) => {
  50. // alert(JSON.stringify());
  51. this.newsData = JSON.parse(data.data)['content'].items;
  52. }, (err) => {
  53. console.log(err);
  54. this.toastService.presentToastWithOptions("Failed to get News data", "danger");
  55. });
  56. this.newsService.getVideos().then((data: any) => {
  57. this.videoData = JSON.parse(data.data)['content'].items;
  58. }, (err) => {
  59. this.toastService.presentToastWithOptions("Failed to get Videos data", "danger");
  60. });
  61. this.newsService.getGalleries().then((data: any) => {
  62. this.galleryData = JSON.parse(data.data)['content'].items;
  63. }, (err) => {
  64. console.log(err);
  65. this.toastService.presentToastWithOptions("Failed to get Gallery data", "danger");
  66. });
  67. }
  68. ionViewDidEnter() {
  69. if (localStorage.isPartyChatOn === 'yes') {
  70. this.showChat = true;
  71. }
  72. }
  73. getIndex(e: any) {
  74. console.log(this.slides);
  75. }
  76. showNewsDetails(alias_title: string) {
  77. this.router.navigate(['/home-details', { alias_title: alias_title, type: this.selectedTab }]);
  78. }
  79. }