Просмотр исходного кода

Native HTTP for new service integrated

master
kj1352 4 лет назад
Родитель
Сommit
0aa1f43b4b
5 измененных файлов: 42 добавлений и 52 удалений
  1. +5
    -0
      src/app/app.module.ts
  2. +13
    -10
      src/app/ar-fan-cam/ar-fan-cam.page.ts
  3. +3
    -16
      src/app/home-details/home-details.page.ts
  4. +13
    -18
      src/app/home/home.page.ts
  5. +8
    -8
      src/app/services/news.service.ts

+ 5
- 0
src/app/app.module.ts Просмотреть файл

@@ -6,6 +6,9 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/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 { AppComponent } from './app.component';
@@ -35,6 +38,8 @@ import { ToastService } from './services/toast.service';
NewsService,
MatchService,
ToastService,
Uptime,
HTTP,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
{ provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig },
],


+ 13
- 10
src/app/ar-fan-cam/ar-fan-cam.page.ts Просмотреть файл

@@ -39,16 +39,7 @@ export class ArFanCamPage implements OnInit {
private modalController: ModalController,
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 () => {
@@ -203,6 +194,18 @@ export class ArFanCamPage implements OnInit {
}

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.getCameraStream().then(() => this.detectAndDrawFace(), (err) => console.log(err));
}


+ 3
- 16
src/app/home-details/home-details.page.ts Просмотреть файл

@@ -42,12 +42,7 @@ export class HomeDetailsPage implements OnInit {

if (type === 'news') {
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) => {
console.log(err);
@@ -58,11 +53,7 @@ export class HomeDetailsPage implements OnInit {
if (type === 'videos') {
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) => {
console.log(err);
@@ -73,11 +64,7 @@ export class HomeDetailsPage implements OnInit {
if (type === 'gallery') {
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) => {
console.log(err);


+ 13
- 18
src/app/home/home.page.ts Просмотреть файл

@@ -4,6 +4,8 @@ import { Router } from '@angular/router';
import { NewsService, IMAGE_BASE_URL } from '../services/news.service';
import { ToastService } from '../services/toast.service';
import { DomSanitizer } from '@angular/platform-browser';
import { Uptime } from '@ionic-native/uptime/ngx';


@Component({
selector: 'app-home',
@@ -32,12 +34,14 @@ export class HomePage implements OnInit {
showChat: boolean = false;

image_url = IMAGE_BASE_URL;
myuptime: string;

constructor(
private router: Router,
private newsService: NewsService,
private toastService: ToastService,
private dom: DomSanitizer,
private uptime: Uptime
) { }

transformYourHtml(htmlTextWithStyle) {
@@ -45,36 +49,27 @@ export class HomePage implements OnInit {
}

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) => {
console.log(err);
this.toastService.presentToastWithOptions("Failed to get News data", "danger");
});

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) => {
this.toastService.presentToastWithOptions("Failed to get Videos data", "danger");
});

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) => {
console.log(err);
this.toastService.presentToastWithOptions("Failed to get Gallery data", "danger");


+ 8
- 8
src/app/services/news.service.ts Просмотреть файл

@@ -1,5 +1,5 @@
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/';

@@ -8,30 +8,30 @@ export const IMAGE_BASE_URL: string = 'https://www.punjabkingsipl.in/static-asse
})
export class NewsService {
constructor(
private http: HttpClient
private http: HTTP
) { }

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) {
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() {
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) {
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() {
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) {
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, {}, {});
}
}

Загрузка…
Отмена
Сохранить