Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

113 rindas
3.4 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 { SocialSharing } from '@ionic-native/social-sharing/ngx';
  8. import { Platform } from '@ionic/angular';
  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 socialSharing: SocialSharing,
  37. private platform: Platform,
  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.newsService.getArticles().then((data: any) => {
  47. // alert(JSON.stringify());
  48. if (this.platform.is('android') || this.platform.is('capacitor')) {
  49. this.newsData = JSON.parse(data.data)['content'].items;
  50. } else {
  51. this.newsData = data.content.items;
  52. }
  53. }, (err) => {
  54. console.log(err);
  55. this.toastService.presentToastWithOptions("Failed to get News data", "danger");
  56. });
  57. this.newsService.getVideos().then((data: any) => {
  58. if (this.platform.is('android') || this.platform.is('capacitor')) {
  59. this.videoData = JSON.parse(data.data)['content'].items;
  60. } else {
  61. this.videoData = data.content.items;
  62. }
  63. }, (err) => {
  64. this.toastService.presentToastWithOptions("Failed to get Videos data", "danger");
  65. });
  66. this.newsService.getGalleries().then((data: any) => {
  67. if (this.platform.is('android') || this.platform.is('capacitor')) {
  68. this.galleryData = JSON.parse(data.data)['content'].items;
  69. } else {
  70. this.galleryData = data.content.items;
  71. }
  72. }, (err) => {
  73. console.log(err);
  74. this.toastService.presentToastWithOptions("Failed to get Gallery data", "danger");
  75. });
  76. }
  77. ionViewDidEnter() {
  78. if (localStorage.isPartyChatOn === 'yes') {
  79. this.showChat = true;
  80. }
  81. }
  82. getIndex(e: any) {
  83. console.log(this.slides);
  84. }
  85. showNewsDetails(alias_title: string) {
  86. this.router.navigate(['/home-details', { alias_title: alias_title, type: this.selectedTab }]);
  87. }
  88. }