-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabs.ts
108 lines (94 loc) · 2.66 KB
/
tabs.ts
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { Component } from '@angular/core';
import { Events, NavParams } from 'ionic-angular';
import { ReposPage } from '../repos/repos';
import { CameraPage } from '../camera/camera';
import { UploadPage } from '../upload/upload';
import { AboutPage } from '../about/about';
import { AuthService } from '../../providers/auth-service';
export interface TabsInterface {
title: string;
root: any;
icon: string;
}
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
public tabs = [];
public tabId: number;
public selectTabIndex: number;
roleOneTabs: TabsInterface[] = [
{ title: 'About', root: AboutPage, icon: 'home' },
{ title: 'Repos', root: ReposPage, icon: 'copy' },
{ title: 'Camera', root: CameraPage, icon: 'camera' },
{ title: 'Upload', root: UploadPage, icon: 'cloud-upload' }
];
roleTwoTabs: TabsInterface[] = [
{ title: 'About', root: AboutPage, icon: 'home' },
{ title: 'Repos', root: ReposPage, icon: 'copy' },
{ title: 'Camera', root: CameraPage, icon: 'camera' }
];
roleThreeTabs: TabsInterface[] = [
{ title: 'About', root: AboutPage, icon: 'home' },
{ title: 'Repos', root: ReposPage, icon: 'copy' }
];
constructor(
public events: Events,
public authService: AuthService,
public params: NavParams
) {
this.tabId = params.get('tabId');
if (this.tabId !== undefined || this.tabId !== null) this.selectTabIndex = this.tabId;
}
/*
* http://ionicframework.com/docs/v2/api/navigation/NavController/
* Lifecycle events
*/
ionViewCanEnter(): boolean{
let role = this.authService.getUserRole();
console.log('TabsView Can Enter.');
if (role) {
switch (role) {
case 'super_admin':
this.tabs = this.roleOneTabs;
break;
case 'reseller_admin':
this.tabs = this.roleTwoTabs;
break;
case 'customer_admin':
this.tabs = this.roleThreeTabs;
break;
case 'user_admin':
this.tabs = this.roleThreeTabs;
break;
default:
this.tabs = this.roleThreeTabs;
break;
}
return true;
}
return false;
}
ionViewDidLoad(): void{
console.log('TabsView Did Load.');
}
ionViewWillEnter(): void{
console.log('TabsView Will Enter.');
}
ionViewDidEnter(): void{
console.log('TabsView Did Enter.');
}
ionViewCanLeave(): boolean{
console.log('TabsView Can Leave.');
return true;
}
ionViewWillUnload(): void{
console.log('TabsView Will Unload.');
}
ionViewWillLeave(): void{
console.log('TabsView Will Leave.');
}
ionViewDidLeave(): void{
console.log('TabsView Did Leave.');
}
}