| @@ -6,6 +6,9 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; | |||||
| import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | ||||
| import { StatusBar } from '@ionic-native/status-bar/ngx'; | import { StatusBar } from '@ionic-native/status-bar/ngx'; | ||||
| import { CameraPreview } from '@ionic-native/camera-preview/ngx'; | import { CameraPreview } from '@ionic-native/camera-preview/ngx'; | ||||
| import { Uptime } from '@ionic-native/uptime/ngx'; | |||||
| import { HTTP } from '@ionic-native/http/ngx'; | |||||
| import { AppRoutingModule } from './app-routing.module'; | import { AppRoutingModule } from './app-routing.module'; | ||||
| import { AppComponent } from './app.component'; | import { AppComponent } from './app.component'; | ||||
| @@ -35,6 +38,8 @@ import { ToastService } from './services/toast.service'; | |||||
| NewsService, | NewsService, | ||||
| MatchService, | MatchService, | ||||
| ToastService, | ToastService, | ||||
| Uptime, | |||||
| HTTP, | |||||
| { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, | ||||
| { provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig }, | { provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig }, | ||||
| ], | ], | ||||
| @@ -39,16 +39,7 @@ export class ArFanCamPage implements OnInit { | |||||
| private modalController: ModalController, | private modalController: ModalController, | ||||
| private cameraPreview: CameraPreview | private cameraPreview: CameraPreview | ||||
| ) { | ) { | ||||
| this.sourceImageElement.nativeElement.onload = () => { | |||||
| const context = this.sourceCanvasElement.nativeElement.getContext('2d'); | |||||
| context.drawImage( | |||||
| this.sourceImageElement.nativeElement, | |||||
| 0, | |||||
| 0, | |||||
| this.sourceCanvasElement.nativeElement.width, | |||||
| this.sourceCanvasElement.nativeElement.height | |||||
| ); | |||||
| } | |||||
| } | } | ||||
| loadNeuralNetModels = async () => { | loadNeuralNetModels = async () => { | ||||
| @@ -203,6 +194,18 @@ export class ArFanCamPage implements OnInit { | |||||
| } | } | ||||
| ngAfterViewInit() { | ngAfterViewInit() { | ||||
| this.sourceImageElement.nativeElement.onload = () => { | |||||
| const context = this.sourceCanvasElement.nativeElement.getContext('2d'); | |||||
| context.drawImage( | |||||
| this.sourceImageElement.nativeElement, | |||||
| 0, | |||||
| 0, | |||||
| this.sourceCanvasElement.nativeElement.width, | |||||
| this.sourceCanvasElement.nativeElement.height | |||||
| ); | |||||
| } | |||||
| this.loadNeuralNetModels(); | this.loadNeuralNetModels(); | ||||
| this.getCameraStream().then(() => this.detectAndDrawFace(), (err) => console.log(err)); | this.getCameraStream().then(() => this.detectAndDrawFace(), (err) => console.log(err)); | ||||
| } | } | ||||
| @@ -42,12 +42,7 @@ export class HomeDetailsPage implements OnInit { | |||||
| if (type === 'news') { | if (type === 'news') { | ||||
| this.newsService.getArticleDetails(alias_title).then((data: any) => { | this.newsService.getArticleDetails(alias_title).then((data: any) => { | ||||
| if (data && data.content && data.content.data) { | |||||
| this.newsDetails = data.content.data; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No News available"); | |||||
| } | |||||
| this.newsDetails = JSON.parse(data.data)['content'].data; | |||||
| }, (err) => { | }, (err) => { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -58,11 +53,7 @@ export class HomeDetailsPage implements OnInit { | |||||
| if (type === 'videos') { | if (type === 'videos') { | ||||
| this.newsService.getVideoDetails(alias_title).then((data: any) => { | this.newsService.getVideoDetails(alias_title).then((data: any) => { | ||||
| if (data && data.content && data.content.data) { | |||||
| this.newsDetails = data.content.data; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No Video available"); | |||||
| } | |||||
| this.newsDetails = JSON.parse(data.data)['content'].data; | |||||
| }, (err) => { | }, (err) => { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -73,11 +64,7 @@ export class HomeDetailsPage implements OnInit { | |||||
| if (type === 'gallery') { | if (type === 'gallery') { | ||||
| this.newsService.getGalleryDetails(alias_title).then((data: any) => { | this.newsService.getGalleryDetails(alias_title).then((data: any) => { | ||||
| if (data && data.content && data.content.data) { | |||||
| this.newsDetails = data.content.data; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No Photos available"); | |||||
| } | |||||
| this.newsDetails = JSON.parse(data.data)['content'].data; | |||||
| }, (err) => { | }, (err) => { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -4,6 +4,8 @@ import { Router } from '@angular/router'; | |||||
| import { NewsService, IMAGE_BASE_URL } from '../services/news.service'; | import { NewsService, IMAGE_BASE_URL } from '../services/news.service'; | ||||
| import { ToastService } from '../services/toast.service'; | import { ToastService } from '../services/toast.service'; | ||||
| import { DomSanitizer } from '@angular/platform-browser'; | import { DomSanitizer } from '@angular/platform-browser'; | ||||
| import { Uptime } from '@ionic-native/uptime/ngx'; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-home', | selector: 'app-home', | ||||
| @@ -32,12 +34,14 @@ export class HomePage implements OnInit { | |||||
| showChat: boolean = false; | showChat: boolean = false; | ||||
| image_url = IMAGE_BASE_URL; | image_url = IMAGE_BASE_URL; | ||||
| myuptime: string; | |||||
| constructor( | constructor( | ||||
| private router: Router, | private router: Router, | ||||
| private newsService: NewsService, | private newsService: NewsService, | ||||
| private toastService: ToastService, | private toastService: ToastService, | ||||
| private dom: DomSanitizer, | private dom: DomSanitizer, | ||||
| private uptime: Uptime | |||||
| ) { } | ) { } | ||||
| transformYourHtml(htmlTextWithStyle) { | transformYourHtml(htmlTextWithStyle) { | ||||
| @@ -45,36 +49,27 @@ export class HomePage implements OnInit { | |||||
| } | } | ||||
| ngOnInit() { | ngOnInit() { | ||||
| this.newsService.getArticles().then((data: any) => { | |||||
| if (data && data.content && data.content.items) { | |||||
| this.newsData = data.content.items; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No News available"); | |||||
| } | |||||
| this.uptime.getUptime(true) | |||||
| .then(uptime => this.myuptime = uptime) | |||||
| .catch(error => console.log(error)); | |||||
| this.newsService.getArticles().then((data: any) => { | |||||
| // alert(JSON.stringify()); | |||||
| this.newsData = JSON.parse(data.data)['content'].items; | |||||
| }, (err) => { | }, (err) => { | ||||
| console.log(err); | console.log(err); | ||||
| this.toastService.presentToastWithOptions("Failed to get News data", "danger"); | this.toastService.presentToastWithOptions("Failed to get News data", "danger"); | ||||
| }); | }); | ||||
| this.newsService.getVideos().then((data: any) => { | this.newsService.getVideos().then((data: any) => { | ||||
| if (data && data.content && data.content.items) { | |||||
| this.videoData = data.content.items; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No Videos available"); | |||||
| } | |||||
| this.videoData = JSON.parse(data.data)['content'].items; | |||||
| }, (err) => { | }, (err) => { | ||||
| this.toastService.presentToastWithOptions("Failed to get Videos data", "danger"); | this.toastService.presentToastWithOptions("Failed to get Videos data", "danger"); | ||||
| }); | }); | ||||
| this.newsService.getGalleries().then((data: any) => { | this.newsService.getGalleries().then((data: any) => { | ||||
| if (data && data.content && data.content.items) { | |||||
| this.galleryData = data.content.items; | |||||
| } else { | |||||
| this.toastService.presentToastWithOptions("No Albums available"); | |||||
| } | |||||
| this.galleryData = JSON.parse(data.data)['content'].items; | |||||
| }, (err) => { | }, (err) => { | ||||
| console.log(err); | console.log(err); | ||||
| this.toastService.presentToastWithOptions("Failed to get Gallery data", "danger"); | this.toastService.presentToastWithOptions("Failed to get Gallery data", "danger"); | ||||
| @@ -1,5 +1,5 @@ | |||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||
| import { HttpClient } from '@angular/common/http'; | |||||
| import { HTTP } from '@ionic-native/http/ngx'; | |||||
| export const IMAGE_BASE_URL: string = 'https://www.punjabkingsipl.in/static-assets/waf-images/'; | export const IMAGE_BASE_URL: string = 'https://www.punjabkingsipl.in/static-assets/waf-images/'; | ||||
| @@ -8,30 +8,30 @@ export const IMAGE_BASE_URL: string = 'https://www.punjabkingsipl.in/static-asse | |||||
| }) | }) | ||||
| export class NewsService { | export class NewsService { | ||||
| constructor( | constructor( | ||||
| private http: HttpClient | |||||
| private http: HTTP | |||||
| ) { } | ) { } | ||||
| getArticles() { | getArticles() { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=4&otherent=1,8021&pgnum=1&inum=10&pgsize=10').toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=4&otherent=1,8021&pgnum=1&inum=10&pgsize=10', {}, {}); | |||||
| } | } | ||||
| getArticleDetails(title_alias_from_listing_api: string) { | getArticleDetails(title_alias_from_listing_api: string) { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/article/' + title_alias_from_listing_api + '?is_app=1').toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/article/' + title_alias_from_listing_api + '?is_app=1', {}, {}); | |||||
| } | } | ||||
| getVideos() { | getVideos() { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=3,4&otherent=&pgnum=1&inum=10&pgsize=10').toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=3,4&otherent=&pgnum=1&inum=10&pgsize=10', {}, {}); | |||||
| } | } | ||||
| getVideoDetails(title_alias_from_listing_api: string) { | getVideoDetails(title_alias_from_listing_api: string) { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/video/' + title_alias_from_listing_api).toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/video/' + title_alias_from_listing_api, {}, {}); | |||||
| } | } | ||||
| getGalleries() { | getGalleries() { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=2,4&otherent=&pgnum=1&inum=10&pgsize=10').toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=2,4&otherent=&pgnum=1&inum=10&pgsize=10', {}, {}); | |||||
| } | } | ||||
| getGalleryDetails(title_alias_from_listing_api: string) { | getGalleryDetails(title_alias_from_listing_api: string) { | ||||
| return this.http.get('https://www.punjabkingsipl.in/api/photo/' + title_alias_from_listing_api).toPromise(); | |||||
| return this.http.get('https://www.punjabkingsipl.in/api/photo/' + title_alias_from_listing_api, {}, {}); | |||||
| } | } | ||||
| } | } | ||||