Added cruising pages support

This commit is contained in:
2018-03-08 14:41:45 -05:00
parent 9fcaef1068
commit 0cf95d2cd4
18 changed files with 355 additions and 12 deletions

44
src/services/cruises.ts Normal file
View File

@@ -0,0 +1,44 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class CruiseService {
//endpoint: string = '/assets/data/cruises.json';
endpoint: string = 'https://api.fitz.guru/urge/cruises';
idMap: any;
cruises: any;
constructor(private http: Http) {
this.idMap = {};
this.cruises = null;
}
load() {
if (this.cruises) {
return Promise.resolve(this.cruises);
}
return new Promise(resolve => {
this.http.get(this.endpoint)
.map(res => res.json())
.subscribe(data => {
this.cruises = data;
this.cruises.reduce((map, cruise, i) => {
map[cruise._id] = i;
return map;
}, this.idMap);
resolve(this.cruises);
});
});
}
getCruises() {
return this.cruises;
}
getCruiseById(id) {
return this.cruises[this.idMap[id]];
}
}

View File

@@ -5,6 +5,7 @@ import 'rxjs/add/operator/map';
@Injectable()
export class ProfileService {
endpoint: string = 'https://api.fitz.guru/urge/profiles'; //'assets/data/profiles.json';
idMap: any;
profiles: any;
@@ -19,7 +20,7 @@ export class ProfileService {
}
return new Promise(resolve => {
this.http.get('https://api.fitz.guru/urge/profiles')
this.http.get(this.endpoint)
.map(res => res.json())
.subscribe(data => {
this.profiles = data;