This repository has been archived by the owner on Feb 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
61 lines (51 loc) · 1.97 KB
/
app.js
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
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic','ionic.service.core', 'starter.controllers', 'starter.services', 'angular-storage', 'ionic-color-picker'])
.run(function($ionicPlatform, $rootScope, store, $state) {
// route all requests to login screen if necessary, i.e. no Particle API access token has been stored
$rootScope.$on('$stateChangeStart', function(e, toState) {
if ('login' !== toState.name) {
// get the access token for the particle API
var token = store.get('particle_access_token');
if (null === token) {
e.preventDefault();
$state.go('login');
}
}
});
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'templates/login.html',
controller: 'AuthController'
})
.state('devices', {
url: '/devices',
templateUrl: 'templates/devices.html',
controller: 'DevicesController'
})
.state('device', {
url: '/devices/:id',
templateUrl: 'templates/device.html',
controller: 'DeviceController'
});
$urlRouterProvider.otherwise('/devices');
});