File tree 6 files changed +33
-16
lines changed
6 files changed +33
-16
lines changed Original file line number Diff line number Diff line change @@ -131,14 +131,20 @@ export default Ember.ObjectController.extend({
131
131
}
132
132
data . push ( row ) ;
133
133
}
134
- data = google . visualization . arrayToDataTable ( data ) ;
135
-
136
- var fmt = new google . visualization . DateFormat ( {
137
- pattern : 'LLL d, yyyy' ,
138
- } ) ;
139
- fmt . format ( data , 0 ) ;
140
134
141
135
var drawChart = function ( ) {
136
+ if ( ! window . google || ! window . googleChartsLoaded ) {
137
+ Ember . $ ( '.graph' ) . hide ( ) ;
138
+ return ;
139
+ } else {
140
+ Ember . $ ( '.graph' ) . show ( ) ;
141
+ }
142
+ data = google . visualization . arrayToDataTable ( data ) ;
143
+
144
+ var fmt = new google . visualization . DateFormat ( {
145
+ pattern : 'LLL d, yyyy' ,
146
+ } ) ;
147
+ fmt . format ( data , 0 ) ;
142
148
var el = document . getElementById ( 'graph-data' ) ;
143
149
if ( ! el ) {
144
150
return ;
@@ -159,6 +165,8 @@ export default Ember.ObjectController.extend({
159
165
Ember . run . scheduleOnce ( 'afterRender' , this , drawChart ) ;
160
166
Ember . $ ( window ) . off ( 'resize.chart' ) ;
161
167
Ember . $ ( window ) . on ( 'resize.chart' , drawChart ) ;
168
+ Ember . $ ( document ) . off ( 'googleChartsLoaded' ) ;
169
+ Ember . $ ( document ) . on ( 'googleChartsLoaded' , drawChart ) ;
162
170
} ,
163
171
} ,
164
172
} ) ;
Original file line number Diff line number Diff line change 19
19
window . EmberENV = { { EMBER_ENV } } ;
20
20
</ script >
21
21
< script src ="assets/vendor.js "> </ script >
22
- < script type ="text/javascript " src ="https://www.google.com/jsapi "> </ script >
23
22
< script src ="assets/cargo.js "> </ script >
24
23
< script >
25
- google . load ( 'visualization' , '1.0' , { 'packages' :[ 'corechart' ] } ) ;
26
24
window . Cargo = require ( 'cargo/app' ) [ 'default' ] . create ( { { APP_CONFIG } } ) ;
27
25
</ script >
28
26
</ body >
Original file line number Diff line number Diff line change
1
+ import Ember from 'ember' ;
2
+
3
+ export var initialize = function ( ) {
4
+ Ember . $ . getScript ( 'https://www.google.com/jsapi' , function ( ) {
5
+ google . load ( 'visualization' , '1.0' , {
6
+ 'packages' : [ 'corechart' ] ,
7
+ 'callback' : function ( ) {
8
+ window . googleChartsLoaded = true ;
9
+ Ember . $ ( document ) . trigger ( 'googleChartsLoaded' ) ;
10
+ }
11
+ } ) ;
12
+ } ) ;
13
+ } ;
14
+
15
+ export default {
16
+ name : 'google' ,
17
+
18
+ initialize : initialize
19
+ } ;
Original file line number Diff line number Diff line change @@ -4,18 +4,14 @@ import ajax from 'ic-ajax';
4
4
export default Ember . Route . extend ( {
5
5
beforeModel : function ( ) {
6
6
var self = this ;
7
- console . log ( 'index route' , this . session . get ( 'isLoggedIn' ) ,
8
- this . session . get ( 'currentUser' ) ) ;
9
7
if ( this . session . get ( 'isLoggedIn' ) &&
10
8
this . session . get ( 'currentUser' ) === null )
11
9
{
12
10
return ajax ( '/me' ) . then ( function ( response ) {
13
- console . log ( 'good' , response ) ;
14
11
var user = self . store . push ( 'user' , response . user ) ;
15
12
user . set ( 'api_token' , response . api_token ) ;
16
13
self . session . set ( 'currentUser' , user ) ;
17
14
} ) . catch ( function ( ) {
18
- console . log ( 'bad' ) ;
19
15
self . session . logoutUser ( ) ;
20
16
} ) ;
21
17
}
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ export default Ember.Route.extend({
15
15
if ( ! win . closed ) { return ; }
16
16
window . clearInterval ( oauthInterval ) ;
17
17
var response = JSON . parse ( localStorage . github_response ) ;
18
- console . log ( 'loging response' , response ) ;
19
18
20
19
if ( ! response . ok ) {
21
20
self . controllerFor ( 'application' ) . set ( 'flashError' ,
Original file line number Diff line number Diff line change @@ -8,21 +8,18 @@ export default Ember.Object.extend({
8
8
init : function ( ) {
9
9
this . set ( 'isLoggedIn' , localStorage . getItem ( 'isLoggedIn' ) === '1' ) ;
10
10
this . set ( 'currentUser' , null ) ;
11
- console . log ( 'session-init' , this . get ( 'isLoggedIn' ) ) ;
12
11
} ,
13
12
14
13
loginUser : function ( user ) {
15
14
this . set ( 'isLoggedIn' , true ) ;
16
15
this . set ( 'currentUser' , user ) ;
17
16
localStorage . setItem ( 'isLoggedIn' , '1' ) ;
18
- console . log ( 'session-login' , this . get ( 'isLoggedIn' ) ) ;
19
17
} ,
20
18
21
19
logoutUser : function ( ) {
22
20
this . set ( 'savedTransition' , null ) ;
23
21
this . set ( 'isLoggedIn' , null ) ;
24
22
this . set ( 'currentUser' , null ) ;
25
23
localStorage . removeItem ( 'isLoggedIn' ) ;
26
- console . log ( 'session-logout' , this . get ( 'isLoggedIn' ) ) ;
27
24
} ,
28
25
} ) ;
You can’t perform that action at this time.
0 commit comments