diff --git a/src/app/api/black-connect.service.ts b/src/app/api/black-connect.service.ts index ba0c308..bae9da5 100644 --- a/src/app/api/black-connect.service.ts +++ b/src/app/api/black-connect.service.ts @@ -1,27 +1,54 @@ -import { Injectable, Injector } from '@angular/core'; -import { HTTP } from '@ionic-native/http/ngx'; -//import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' -//import 'rxjs/add/operator/map' -//import { Observable, from } from 'rxjs' +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable,from } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { resolve } from 'dns'; -/* -import { FloatSessionProvider } from '../float-session/float-session' -import { LocationTrackerProvider } from '../location-tracker/location-tracker' -import { FloatEventsService } from '../float-events/float-events'; -import { CONFIG } from '../app-config' -*/ - @Injectable({ providedIn: 'root' }) export class BlackConnectService { - // data source - https://www.theblackfaces.com/feed/ + // data source - https://www.chiefsoft.net/INTGR/API/theblackfaces/ + + url = 'https://www.chiefsoft.net/INTGR/API/theblackfaces/'; + apiKey = ''; // <-- Enter your own key here! + constructor( - public http: HTTP + private http: HttpClient ) { - } + } + + + + getResult: any; + blogData(title: string) { + // blogData(title: string): Observable { + var end_url = this.url + "?s=" + encodeURI(title) + "&apikey=" + this.apiKey; + // return this.http.get(`${this.url}?s=${encodeURI(title)}&apikey=${this.apiKey}`).pipe( + + /* return this.http.get(this.url+"?s="+encodeURI(title)+"&apikey="+this.apiKey).pipe( + map(results => results['internal_return']) + */ +return from ( + new Promise((resolve)=>{ + + this.http.get(end_url).subscribe( + (data) => { + this.getResult = data; + // console.log(this.getResult); + resolve(data); + } + ) + + }) +) + + //console.log(results); + // ); + } + } diff --git a/src/app/blog/blog.page.html b/src/app/blog/blog.page.html index 270cceb..cddd275 100644 --- a/src/app/blog/blog.page.html +++ b/src/app/blog/blog.page.html @@ -1,18 +1,18 @@ - + - Card Subtitle - Card Title + + {{type.post_title}} - + Keep close to Nature's heart... and break clear away, once in awhile, and climb a mountain or spend a week in the woods. Wash your spirit clean. - + - - - - Card Link Item 1 activated - + Refresh - - - Card Link Item 2 - - - - Card Button Item 1 activated - - - - - Card Button Item 2 - - \ No newline at end of file diff --git a/src/app/blog/blog.page.ts b/src/app/blog/blog.page.ts index 4956927..e6e870b 100644 --- a/src/app/blog/blog.page.ts +++ b/src/app/blog/blog.page.ts @@ -1,4 +1,6 @@ +import { BlackConnectService } from './../api/black-connect.service'; import { Component, OnInit } from '@angular/core'; +import { Observable } from 'rxjs'; @Component({ selector: 'app-blog', @@ -6,10 +8,74 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./blog.page.scss'], }) export class BlogPage implements OnInit { - - constructor() { } - + blogData: any; + constructor(private blackConnectService: BlackConnectService) { + this. getBlog(); + } + image_url = "https://blog.chiefsoft.com/wp-content/uploads/"; ngOnInit() { + this. getBlog(); } + blog_list: any; + getBlog() { + this.blackConnectService.blogData("blackblog").subscribe((retBlogData) => { + this.blogData = retBlogData; + //console.log(this.blogData); + //console.log(this.blogData["internal_return"]["result_list"]); + + this.blog_list = this.blogData["internal_return"]["result_list"]; + console.log(this.blog_list); + }) + + } + + // ---- + userPointData: { + sessionid: string + member_id: number + limit: number + } + + refreshBlog() { + this.userPointData = { + sessionid: "", + member_id: 1, + limit: 10, + } + + try { + this.floatServiceProvider + .genericService('pointsdetail', this.userPointData) + .subscribe((pointsDetailData) => { + // console.log("getslidecarddata:"); + if ( + pointsDetailData.hasOwnProperty('result_list') && + Array.isArray(pointsDetailData['result_list']) + ) { + this.pointsDetailData = pointsDetailData['result_list'] + + for (const i in this.pointsDetailData) { + if (this.pointsDetailData.hasOwnProperty(i)) { + // model the date string to be parsable by the browser + let strDate = this.pointsDetailData[i]['added'].replace( + /-/g, + '/' + ) + strDate = strDate.split(' ')[0] + const dateObj = new Date(strDate) + this.pointsDetailData[i]['formated_date'] = this.formatDate( + dateObj + ) + } + } + // console.log("points detail data: ", this.pointsDetailData); + } + }) + } catch (e) { + console.log(e) + } + } + + } diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 398d344..2681210 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -8,14 +8,14 @@ import { Router } from '@angular/router'; }) export class HomePage implements OnInit { - constructor(private router:Router) { } + constructor(private router: Router) { } ngOnInit() { } -public goTabPages(){ - // alert("You called me"); - this.router.navigateByUrl("blog"); + public goTabPages() { + // alert("You called me"); + this.router.navigateByUrl("blog"); -} + } }