Initial commit

This commit is contained in:
2018-03-02 02:59:55 -05:00
parent 30518e56d4
commit 33cf657c70
34 changed files with 541 additions and 124 deletions

42
src/services/profiles.ts Normal file
View File

@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class ProfileService {
idMap: any;
profiles: any;
constructor(private http: Http) {
this.idMap = {};
this.profiles = null;
}
load() {
if (this.profiles) {
return Promise.resolve(this.profiles);
}
return new Promise(resolve => {
this.http.get('/assets/data/profiles.json')
.map(res => res.json())
.subscribe(data => {
this.profiles = data;
this.profiles.reduce((map, profile, i) => {
map[profile._id] = i;
return map;
}, this.idMap);
resolve(this.profiles);
});
});
}
getProfiles() {
return this.profiles;
}
getProfileById(id) {
return this.profiles[this.idMap[id]];
}
}