fix
This commit is contained in:
@@ -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<any> {
|
||||
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);
|
||||
// );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<ion-content fullscreen>
|
||||
<ion-card>
|
||||
<ion-card *ngFor="let type of blog_list">
|
||||
|
||||
<ion-card-header>
|
||||
<ion-card-subtitle>Card Subtitle</ion-card-subtitle>
|
||||
<ion-card-title>Card Title</ion-card-title>
|
||||
<!-- ion-card-subtitle>{{type.post_title}}</!-->
|
||||
<ion-card-title>{{type.post_title}}</ion-card-title>
|
||||
</ion-card-header>
|
||||
<img src="./assets/imgs/madison.jpg" />
|
||||
<img src="{{image_url}}{{type.meta_value}}" />
|
||||
<ion-card-content>
|
||||
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.
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<!-- ion-card>
|
||||
<ion-item>
|
||||
<ion-icon name="pin" slot="start"></ion-icon>
|
||||
<ion-label>ion-item in a card, icon left, button right</ion-label>
|
||||
@@ -23,27 +23,9 @@
|
||||
This is content, without any paragraph or header tags,
|
||||
within an ion-card-content element.
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
</!-->
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
<ion-button fill="outline" (click)="getBlog()">Refresh</ion-button>
|
||||
|
||||
<ion-item href="#">
|
||||
<ion-icon name="wine" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-icon name="walk" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 2</ion-label>
|
||||
</ion-item>
|
||||
</ion-card>
|
||||
</ion-content>
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user