Skip to content

Commit beb554c

Browse files
committed
Added ngCordova support, added about tab and minor tweaks
1 parent e4cc3fc commit beb554c

36 files changed

+28541
-97
lines changed

bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"dependencies": {
55
"lodash": "~2.4.1",
66
"highcharts": "~4.0.4",
7-
"highcharts-ng": "0.0.7"
7+
"highcharts-ng": "0.0.7",
8+
"ngCordova": "~0.1.6-alpha"
89
}
910
}

www/config.xml

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2-
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" android-versionCode="1" id="com.zend.onthego" version="1.0" xmlns:gap= "http://phonegap.com/ns/1.0" >
3-
<name>Zend OnTheGo</name>
4-
<description>A sample Ionic Framework app using Cordova and AngularJS</description>
5-
<author email="[email protected]" href="http://onthego.zend.com">ZendTeam Team</author>
6-
<content src="index.html"/>
7-
<access origin="*"/>
8-
<preference name="fullscreen" value="true"/>
9-
<preference name="webviewbounce" value="false"/>
10-
<preference name="UIWebViewBounce" value="false"/>
11-
<preference name="DisallowOverscroll" value="true"/>
12-
<icon src="www/res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:density="ldpi" />
13-
<icon src="www/res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:density="mdpi" />
14-
<icon src="www/res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:density="hdpi" />
15-
<icon src="www/res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:density="xhdpi" />
16-
</widget>
2+
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
3+
android-versionCode="1" id="com.zend.onthego" version="1.0">
4+
<name>Zend OnTheGo</name>
5+
<description>A sample Ionic Framework app using Cordova and AngularJS
6+
</description>
7+
<author email="[email protected]" href="http://onthego.zend.com">ZendTeam Team</author>
8+
<content src="index.html" />
9+
<access origin="*" />
10+
<preference name="fullscreen" value="true" />
11+
<preference name="webviewbounce" value="false" />
12+
<preference name="UIWebViewBounce" value="false" />
13+
<preference name="DisallowOverscroll" value="true" />
14+
</widget>

www/css/app.css

+42
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,46 @@
55
margin: 15px auto;
66
width: 96px;
77
height: 96px;
8+
}
9+
10+
.bar.bar-status {
11+
display: block;
12+
height: 24px;
13+
14+
/* starts right below a normal header */
15+
top: 44px;
16+
17+
/* make the text centered vertically and horizontally */
18+
text-align: center;
19+
padding: 0;
20+
line-height: 24px;
21+
22+
/* transition 'sliding down' (check below)*/
23+
-webkit-transition: 200ms all;
24+
}
25+
26+
27+
/*
28+
* make the content's top changes animate.
29+
* might not always look good, but looks
30+
* good when our status is added & removed
31+
*/
32+
.has-header {
33+
-webkit-transition: 200ms top;
34+
}
35+
.has-header.has-status {
36+
/* 44px (header) + 24px */
37+
top: 68px;
38+
}
39+
40+
/* make loading bar slide up/down */
41+
.bar-status.ng-enter,
42+
.bar-status.ng-leave.ng-leave-active {
43+
height: 0;
44+
border-width: 0px;
45+
}
46+
.bar-status.ng-enter.ng-enter-active,
47+
.bar-status.ng-leave {
48+
height: 24px;
49+
border-width: 1px;
850
}

www/index.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@
66
<title>OnTheGo App</title>
77

88
<!-- ionic css -->
9-
<link href="lib/css/ionic.css" rel="stylesheet">
9+
<link href="lib/css/ionic.min.css" rel="stylesheet">
1010

1111
<!-- your app's css -->
1212
<link href="css/app.css" rel="stylesheet">
1313

1414
<!-- ionic/angularjs scripts -->
1515
<script src="lib/js/ionic.bundle.js"></script>
16-
16+
1717
<!-- cordova script (this will be a 404 during development) -->
1818
<script src="cordova.js"></script>
19+
20+
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
21+
1922

2023
<!-- your app's script -->
2124
<script src="lib/lodash/dist/lodash.js"></script>
2225
<script src="lib/highcharts/highcharts-all.js"></script>
2326
<script src="lib/highcharts-ng/dist/highcharts-ng.js"></script>
2427
<script src="lib/js/angular-http-auth/http-auth-interceptor.js"></script>
28+
<script src="lib/Toast.js"></script>
2529
<script src="js/main.js"></script>
2630
<script src="js/app.js"></script>
2731
<script src="js/controllers/app.js"></script>
@@ -30,6 +34,7 @@
3034
<script src="js/controllers/monitor-issue.js"></script>
3135
<script src="js/controllers/stat.js"></script>
3236
<script src="js/controllers/login.js"></script>
37+
<script src="js/controllers/about.js"></script>
3338
<script src="js/filters/timestamp.js"></script>
3439
<script src="js/services/hal.js"></script>
3540
<script src="js/services/authentication.js"></script>
@@ -56,7 +61,7 @@
5661
<button class="button button-assertive icon ion-log-out" ng-click="logout()" ng-show="data.loggedIn"></button>
5762
</ion-nav-buttons>
5863
</ion-nav-bar>
59-
64+
6065
<!--
6166
The views will be rendered in the <ion-nav-view> directive below
6267
Templates are in the /templates folder (but you could also

www/js/app.js

+52-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
// Ionic Starter App
2-
3-
// angular.module is a global place for creating, registering and retrieving Angular modules
4-
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
5-
// the 2nd parameter is an array of 'requires'
6-
// 'starter.services' is found in services.js
7-
// 'starter.controllers' is found in controllers.js
8-
angular.module('onthego', ['ionic', 'onthego.services', 'onthego.controllers', 'highcharts-ng'])
1+
angular.module('onthego', ['ionic', 'ngCordova', 'onthego.services', 'onthego.controllers', 'highcharts-ng'])
92

103

114
.config(function($stateProvider, $urlRouterProvider) {
@@ -58,10 +51,61 @@ angular.module('onthego', ['ionic', 'onthego.services', 'onthego.controllers', '
5851
}
5952
}
6053
})
54+
55+
.state('app.about', {
56+
url: '/about',
57+
views: {
58+
'tab-about': {
59+
templateUrl: 'templates/tab-about.html',
60+
controller: 'AboutController'
61+
}
62+
}
63+
});
6164

6265
// if none of the above states are matched, use this as the fallback
6366
$urlRouterProvider.otherwise('/app/home');
6467

68+
}).config(function($httpProvider) {
69+
$httpProvider.interceptors.push(function($rootScope) {
70+
return {
71+
request: function(config) {
72+
$rootScope.$broadcast('loading:show');
73+
return config;
74+
},
75+
response: function(response) {
76+
$rootScope.$broadcast('loading:hide');
77+
return response;
78+
}
79+
}
80+
});
81+
}).run(function($rootScope, $ionicLoading, $ionicPlatform, $cordovaSplashscreen) {
82+
setTimeout(function() {
83+
$cordovaSplashscreen.hide()
84+
}, 3000);
85+
86+
$rootScope.$on('loading:show', function() {
87+
$ionicLoading.show({template: 'Loading...', noBackdrop: false});
88+
});
89+
90+
$rootScope.$on('loading:hide', function() {
91+
$ionicLoading.hide();
92+
});
93+
94+
/*$ionicPlatform.ready(function() {
95+
var networkState = navigator.connection.type;
96+
97+
var states = {};
98+
states[Connection.UNKNOWN] = 'Unknown connection';
99+
states[Connection.ETHERNET] = 'Ethernet connection';
100+
states[Connection.WIFI] = 'WiFi connection';
101+
states[Connection.CELL_2G] = 'Cell 2G connection';
102+
states[Connection.CELL_3G] = 'Cell 3G connection';
103+
states[Connection.CELL_4G] = 'Cell 4G connection';
104+
states[Connection.CELL] = 'Cell generic connection';
105+
states[Connection.NONE] = 'No network connection';
106+
107+
alert('Connection type: ' + states[networkState]);
108+
});*/
65109
});
66110

67111
angular.module('onthego.controllers', []);

www/js/controllers/about.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
angular.module('onthego.controllers')
2+
3+
.controller('AboutController', function($scope) {
4+
5+
});

www/js/controllers/app.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ angular.module('onthego.controllers')
2525
});
2626

2727
};
28+
2829
});

www/js/controllers/home.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
angular.module('onthego.controllers')
22

33
.controller('HomeController', function($scope) {
4-
$scope.contacts = [];
4+
55
});

www/js/controllers/login.js

+44-44
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@ angular.module('onthego.controllers')
22

33
.controller('LoginController', function($rootScope, $scope, $http, $state, $ionicLoading, AuthenticationService) {
44
$rootScope.data = {};
5-
$scope.data = {
6-
//'server': 'http://onthego.zend.com/on-the-go-api',
7-
'server': 'http://54.209.165.66/on-the-go-api',
8-
'user': {
9-
'username': 'demo',
10-
'password': 'zend'
11-
}
12-
}
13-
14-
$scope.login = function() {
15-
window.localStorage.setItem('server', $scope.data.server);
16-
AuthenticationService.login($scope.data.user);
17-
};
18-
19-
$scope.logout = function() {
20-
$rootScope.data.loggedIn = false;
21-
AuthenticationService.logout();
22-
};
23-
24-
$scope.$on('event:auth-loginRequired', function(e, rejection) {
25-
$ionicLoading.hide();
26-
$scope.loginModal.show();
27-
});
28-
29-
$scope.$on('event:auth-loginConfirmed', function() {
30-
$rootScope.data.loggedIn = true;
31-
$scope.data.username = null;
32-
$scope.data.password = null;
33-
$scope.loginModal.hide();
34-
$state.go('app.home');
35-
});
36-
37-
$scope.$on('event:auth-login-failed', function(e, status) {
38-
var error = "Login failed";
39-
40-
if (status == 401) {
41-
error = "Invalid username and/or password";
42-
}
43-
$scope.message = error;
44-
});
45-
46-
$scope.$on('event:auth-logout-complete', function() {
47-
$rootScope.$broadcast('event:auth-loginRequired');
48-
});
5+
$scope.data = {
6+
'server': 'http://onthego.zend.com/on-the-go-api',
7+
//'server': 'http://54.209.165.66/on-the-go-api',
8+
'user': {
9+
'username': 'demo',
10+
'password': 'zend'
11+
}
12+
}
13+
14+
$scope.login = function() {
15+
window.localStorage.setItem('server', $scope.data.server);
16+
AuthenticationService.login($scope.data.user);
17+
};
18+
19+
$scope.logout = function() {
20+
$rootScope.data.loggedIn = false;
21+
AuthenticationService.logout();
22+
};
23+
24+
$scope.$on('event:auth-loginRequired', function(e, rejection) {
25+
$ionicLoading.hide();
26+
$scope.loginModal.show();
27+
});
28+
29+
$scope.$on('event:auth-loginConfirmed', function() {
30+
$rootScope.data.loggedIn = true;
31+
$scope.data.username = null;
32+
$scope.data.password = null;
33+
$scope.loginModal.hide();
34+
$state.go('app.home');
35+
});
36+
37+
$scope.$on('event:auth-login-failed', function(e, status) {
38+
var error = "Login failed";
39+
40+
if (status == 401) {
41+
error = "Invalid username and/or password";
42+
}
43+
$scope.message = error;
44+
});
45+
46+
$scope.$on('event:auth-logout-complete', function() {
47+
$rootScope.$broadcast('event:auth-loginRequired');
48+
});
4949
});

www/js/controllers/monitor-issue.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
angular.module('onthego.controllers')
22

33
.controller('MonitorIssueController', function($scope, $stateParams, $ionicLoading, IssueResource) {
4-
$ionicLoading.show({
5-
template: 'Loading...',
6-
});
74
IssueResource.get($stateParams.issueId).then(function(result) {
85
$scope.issue = result;
96
$ionicLoading.hide();

www/js/controllers/monitor.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ angular.module('onthego.controllers')
44
var issues = IssueResource.getList();
55
issues.then(function(result) {
66
$scope.issues = result;
7-
$ionicLoading.hide();
87
});
98

109
});

www/js/controllers/stat.js

-7
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ angular.module('onthego.controllers')
144144
}
145145

146146
$scope.loading = true;
147-
$ionicLoading.show();
148147
StatResource.getList(specConfig[index].counter, from, to).then(function(result) {
149148
$scope.data.chartConfig.options.title.text = result[0].title;
150149
$scope.data.chartConfig.options.chart.renderTo = specConfig[index].boxid;
@@ -169,12 +168,6 @@ angular.module('onthego.controllers')
169168
return val;
170169
};
171170
$scope.loading = false;
172-
$ionicLoading.hide();
173-
/*$timeout(function() {
174-
$window.resize();
175-
}, 2000);*/
176-
177-
178171
});
179172
};
180173
$scope.changeChart(0);

www/lib/angular/.bower.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "angular",
3+
"version": "1.2.23",
4+
"main": "./angular.js",
5+
"dependencies": {},
6+
"homepage": "https://github.com/angular/bower-angular",
7+
"_release": "1.2.23",
8+
"_resolution": {
9+
"type": "version",
10+
"tag": "v1.2.23",
11+
"commit": "53716560a512e598c32c5dbc70b2e41a793443e9"
12+
},
13+
"_source": "git://github.com/angular/bower-angular.git",
14+
"_target": "1.2.23",
15+
"_originalSource": "angular"
16+
}

0 commit comments

Comments
 (0)