my app.js is:
// framework stuff
import {App, IonicApp,Config,Events} from 'ionic/ionic';
import {Http, HTTP_BINDINGS} from "angular2/http";
// pages
import {TabsPage} from './pages/tabs/tabs';
import {MyRoomBookingsPage} from './pages/rooms/myRoomBookings';
import {MyParkingBookingsPage} from './pages/parking/myParkingBookings';
import {KudosPage} from './pages/kudos/kudos';
import {LoginPage} from './pages/login/login';
import {SettingsPage} from './pages/settings/settings'
// providers
import {UserData} from './providers/userData';
import {RoomsData} from './providers/rooms';
import {MyRoomsData} from './providers/myRooms';
import {ParkingData} from './providers/parking';
import {KudosData} from './providers/kudos';
import {MyParkingData} from './providers/myParking';
import {HolidaysData} from './providers/holidays';
import {HolidayNamesData} from './providers/holidayNames';
import {HolidaysByNameData} from './providers/holidaysByName';
import {HolidaysMineData} from './providers/holidaysMine';
import {HolidayEntitlementData} from './providers/holidayEntitlement';
@App({
templateUrl: 'build/app.html',
providers: [UserData,KudosData,RoomsData,MyRoomsData,ParkingData,MyParkingData,HolidaysData,HolidayNamesData,HolidaysByNameData,HolidaysMineData,HolidayEntitlementData,Http,HTTP_BINDINGS],
config: {}
})
class MyApp {
constructor(app: IonicApp,events: Events, userData: UserData
) {
this.app = app;
this.events = events;
this.userData = userData;
this.root=LoginPage;
// set the side menu options
this.pages = [
{ title: 'Home', component: TabsPage, icon: 'home', hide: false },
{ title: 'My Room Bookings', component: MyRoomBookingsPage, icon: 'people', hide: false },
{ title: 'My Parking', component: MyParkingBookingsPage, icon: 'car', hide: false },
{ title: 'Kudos Leaderboard', component: KudosPage, icon: 'trophy', hide: false },
{ title: 'Team Connect', component: null, icon: 'contacts', hide: false },
{ title: 'Feedback & Issues', component: null, icon: 'chatboxes', hide: false },
{ title: 'Set Location', component: SettingsPage, icon: 'settings', hide: false},
{ title: 'Logout', component: LoginPage, icon: 'log-out', hide: false }
];
// get current location and if it's not Bracknell, hide the
// parking option
this.userData.getLocation().then((value) => {
if (value !== "Bracknell") {
this.findMenuItemByTitle('My Parking').hide = true;
}
});
})
// subscribe to events we want to listen for
this.subscribeToEvents();
}
subscribeToEvents() {
// if the user:timeout event occurs, re-open the Login Page
this.events.subscribe('user:timeout', () => {
this.openPage({ title: 'Logout', component: LoginPage, icon: 'log-out' });
});
}
openPage(page) {
// Team Connect and Feedback & Issues options are special as they are opening
// an external web page
if(page.title == "Team Connect") {
this.app.getComponent('leftMenu').close();
window.open("https://myserver.com/mobile/homepage/Launcher", "_blank", "location=no");
} else if (page.title == "Feedback & Issues") {
this.app.getComponent('leftMenu').close();
window.open("https://myserver.com/mobile/forums/Forum?uid=e762f2ed-d469-4ce9-a612-df3efcdc201b", "_blank", "location=no");
} else {
// all other pages, set the root to the new page
// we wouldn't want a back button appearing here
let nav = this.app.getComponent('nav');
nav.setRoot(page.component).then(() => {
// wait for the root page to be completely loaded
// then close the menu
this.app.getComponent('leftMenu').close();
});
}
}
// find a menu option
findMenuItemByTitle(title) {
return this.pages.find((menuItem) => {
return menuItem.title === title
})
}
}