-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp-config.service.ts
More file actions
75 lines (69 loc) · 1.72 KB
/
app-config.service.ts
File metadata and controls
75 lines (69 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Injectable } from '@angular/core';
// Pages
import { EventsListPage } from '../../pages/events/list/list.page';
import { GalleryPage } from '../../pages/gallery/gallery.page';
import { LevelsPage } from '../../pages/levels/list/list.page';
import { RankingsPage } from '../../pages/rankings/list/rankings.page';
import { SettingsPage } from '../../pages/settings/settings.page';
import { TeamPage } from '../../pages/team/team.page';
// Others
import * as _ from 'lodash';
@Injectable()
export class AppConfigService {
// Mapping page to name,
// use for changing page in tab menu
pagesMap: any = {
events: EventsListPage,
rankings: RankingsPage,
settings: SettingsPage,
gallery: GalleryPage,
team: TeamPage
}
// JSON format sent back from server
appConfigContent: any = {
app: {
name: 'ISDK'
},
tabs: {
events: {
name: 'events',
title: 'Events',
icon: 'md-calendar',
order: 1
},
rankings: {
name: 'rankings',
title: 'Rankings',
icon: 'md-medal',
order: 2
},
settings: {
name: 'settings',
title: 'Settings',
icon: 'md-person',
order: 3
}
}
};
/**
* @description Get raw configure data from server
*/
get(): Promise<any> {
return new Promise((resolve, reject) => {
resolve(this.appConfigContent);
});
}
/**
* @description Get only configure for tabs
*/
getTabs(): Promise<any> {
return this.get().then((data: any) => {
return _.sortBy(data.tabs, [(o) => o.order]);
}).then((data: any) => {
return _.map(data, (o) => {
o.root = this.pagesMap[o.name];
return o;
});
});
}
}