Blame view

app/js/app.js 12.8 KB
feacde5ff   Rishav   setup acuefuel in...
1
  'use strict';
97f8c67f9   Rishav Singla   ui select impplem...
2
    angular.module('acufuel', ['nvd3', 'ngCookies', 'ngResource', 'ngSanitize', 'ui.router', 'ngAnimate', 'ui.bootstrap', 'xeditable', 'ui.toggle', 'ngTable', 'ui.select2', 'ckeditor', 'ui.calendar', 'ngDragDrop', 'ui.select'])
4bb02bb84   Rishav   new integration w...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  
      .config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.withCredentials = true;
        $httpProvider.interceptors.push('myCSRF');
        $httpProvider.interceptors.push('httpRequestInterceptor');
      }])
  
  
      .factory('httpRequestInterceptor', ['$q', '$rootScope', '$location', function($q, $rootScope, $location) {
         return {
             request: function($config) {
               return $config;
             },
             responseError: function(rejection) {
               if (rejection.status === 401) {
                 if($location.path() != "/login"){
                     localStorage.clear();
                     window.location.reload();
                 }  
               }
               return $q.reject(rejection);
             }
           }
       }])
acc03531d   Anchit Jindal   fixes
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
       
       .directive('fileModel', ['$parse', function ($parse) {
          return {
             restrict: 'A',
             link: function(scope, element, attrs) {
                var model = $parse(attrs.fileModel);
                var modelSetter = model.assign;
                
                element.bind('change', function(){
                   scope.$apply(function(){
                      modelSetter(scope, element[0].files[0]);
                   });
                });
             }
          };
       }])
4bb02bb84   Rishav   new integration w...
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
      
      .provider('myCSRF',[function(){
        var headerName = 'X-CSRFToken';
        var cookieName = 'csrftoken';
        var allowedMethods = ['GET'];
  
        this.setHeaderName = function(n) {
          headerName = n;
        }
        this.setCookieName = function(n) {
          cookieName = n;
        }
        this.setAllowedMethods = function(n) {
          allowedMethods = n;
        }
        this.$get = ['$cookies', function($cookies){
          return {
            'request': function(config) {
              if(allowedMethods.indexOf(config.method) === -1) {
                // do something on success
                config.headers[headerName] = $cookies[cookieName];
              }
              return config;
            }
          }
        }];
      }])
feacde5ff   Rishav   setup acuefuel in...
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
  
    .config(
        ['$locationProvider', '$stateProvider', '$urlRouterProvider',
          function($locationProvider, $stateProvider, $urlRouterProvider) {
            $locationProvider.hashPrefix('!');
            // routes
            $urlRouterProvider
                .otherwise('/login');
  
            $stateProvider
  
              .state("app", {
                url: "",
                templateUrl: "partials/main/main.html",
                controller: "MainController",
                abstract: true
              })
  
              .state("login", {
                url: "/login",
                templateUrl: "partials/login/login.html",
                controller: "LoginController"
              })
              
              .state("app.customers", {
                url: "/customers",
                templateUrl: "partials/customers/customers.html",
dd378d69f   Mr. Hot Foods   changes in flight...
97
98
99
100
                controller: "customersController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
101
              })
3a9f4472b   Rishav   Implement contact...
102
103
104
105
  
              .state("app.accountSetting", {
                url: "/accountSetting",
                templateUrl: "partials/accountSetting/accountSetting.html",
dd378d69f   Mr. Hot Foods   changes in flight...
106
107
108
109
                controller: "AccountSettingController",
                data: {
                    authorizedRoles: ["FBO"],
                }
3a9f4472b   Rishav   Implement contact...
110
              })
4bb02bb84   Rishav   new integration w...
111
112
113
              .state("app.ContactView", {
                url: "/ContactView",
                templateUrl: "partials/ContactView/ContactView.html",
dd378d69f   Mr. Hot Foods   changes in flight...
114
115
116
117
                controller: "ContactViewController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
118
119
120
121
              })
              .state("app.FuelVendors", {
                url: "/FuelVendors",
                templateUrl: "partials/FuelVendors/FuelVendors.html",
dd378d69f   Mr. Hot Foods   changes in flight...
122
123
124
125
                controller: "FuelVendorsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
126
              })
feacde5ff   Rishav   setup acuefuel in...
127
128
129
130
  
              .state("app.analytics", {
                url: "/analytics",
                templateUrl: "partials/analytics/analytics.html",
dd378d69f   Mr. Hot Foods   changes in flight...
131
132
133
134
                controller: "analyticsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
135
136
137
138
139
              })
  
              .state("app.account", {
                url: "/account",
                templateUrl: "partials/account/account.html",
dd378d69f   Mr. Hot Foods   changes in flight...
140
141
142
143
                controller: "accountController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
144
145
              })
              
3a9f4472b   Rishav   Implement contact...
146
              .state("app.dashboard", {
feacde5ff   Rishav   setup acuefuel in...
147
148
                url: "/dashboard",
                templateUrl: "partials/dashboard/dashboard.html",
dd378d69f   Mr. Hot Foods   changes in flight...
149
150
151
152
                controller: "dashboardController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
153
              })
feacde5ff   Rishav   setup acuefuel in...
154
155
156
              .state("app.elements", {
                url: "/elements",
                templateUrl: "partials/elements/elements.html",
dd378d69f   Mr. Hot Foods   changes in flight...
157
158
159
160
                controller: "elementsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
161
              })
feacde5ff   Rishav   setup acuefuel in...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
              .state("app.error", {
                url: "/error",
                templateUrl: "partials/error/error.html",
                controller: "errorController"
              })
  
              .state("app.faq", {
                url: "/faq",
                templateUrl: "partials/faq/faq.html",
                controller: "faqController"
              })
  
              .state("app.forms", {
                url: "/forms",
                templateUrl: "partials/forms/forms.html",
dd378d69f   Mr. Hot Foods   changes in flight...
177
178
179
180
                controller: "formsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
181
182
183
184
185
              })
  
              .state("app.fuelManager", {
                url: "/fuelManager",
                templateUrl: "partials/fuelManager/fuelManager.html",
dd378d69f   Mr. Hot Foods   changes in flight...
186
187
188
189
                controller: "fuelManagerController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
190
              })
feacde5ff   Rishav   setup acuefuel in...
191
192
193
              .state("app.pricing", {
                url: "/pricing",
                templateUrl: "partials/pricing/pricing.html",
dd378d69f   Mr. Hot Foods   changes in flight...
194
195
196
197
                controller: "pricingController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
198
199
200
201
202
              })
  
              .state("app.reports", {
                url: "/reports",
                templateUrl: "partials/reports/reports.html",
dd378d69f   Mr. Hot Foods   changes in flight...
203
204
205
206
                controller: "reportsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
207
208
209
210
211
              })
  
              .state("app.scheduler", {
                url: "/scheduler",
                templateUrl: "partials/scheduler/scheduler.html",
dd378d69f   Mr. Hot Foods   changes in flight...
212
213
214
215
                controller: "schedulerController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
216
217
218
219
220
221
222
223
224
225
              })
              .state("app.signup", {
                url: "/signup",
                templateUrl: "partials/signup/signup.html",
                controller: "signupController"
              })
  
              .state("app.updateFuelManager", {
                url: "/updateFuelManager",
                templateUrl: "partials/updateFuelManager/updateFuelManager.html",
4bb02bb84   Rishav   new integration w...
226
                controller: "updateFuelManagerController",
dd378d69f   Mr. Hot Foods   changes in flight...
227
228
229
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
230
              })
cd330b5ee   Rishav   fuel vendor and v...
231
              .state("app.viewCompany", {
55e075d7e   Rishav   add contact, add ...
232
                url: "/viewCompany/:id",
feacde5ff   Rishav   setup acuefuel in...
233
                templateUrl: "partials/viewCompany/viewCompany.html",
dd378d69f   Mr. Hot Foods   changes in flight...
234
235
236
237
                controller: "viewCompanyController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
238
              }) 
ea15674c8   Rishav   minor changes for...
239
240
241
              .state("app.viewFuelVendor", {
                url: "/viewFuelVendor/:id",
                templateUrl: "partials/viewFuelVendor/viewFuelVendor.html",
dd378d69f   Mr. Hot Foods   changes in flight...
242
243
244
245
                controller: "ViewFuelVendorController",
                data: {
                    authorizedRoles: ["FBO"],
                }
cd330b5ee   Rishav   fuel vendor and v...
246
              }) 
88dad9efc   Rishav   remove unused fil...
247
              .state("app.fuelOrders", {
4bb02bb84   Rishav   new integration w...
248
249
                url: "/fuelOrders",
                templateUrl: "partials/fuelOrders/fuelOrders.html",
dd378d69f   Mr. Hot Foods   changes in flight...
250
251
252
253
                controller: "fuelOrdersController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
254
255
256
257
258
              })
  
               .state("app.DispatchFuel", {
                url: "/DispatchFuel",
                templateUrl: "partials/DispatchFuel/DispatchFuel.html",
dd378d69f   Mr. Hot Foods   changes in flight...
259
260
261
262
                controller: "DispatchFuelController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
263
              })
3a9f4472b   Rishav   Implement contact...
264
              .state("app.searchDispatchFuel", {
4bb02bb84   Rishav   new integration w...
265
266
                url: "/searchDispatchFuel",
                templateUrl: "partials/searchDispatchFuel/searchDispatchFuel.html",
dd378d69f   Mr. Hot Foods   changes in flight...
267
268
269
270
                controller: "searchDispatchFuelController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
271
              })
3a9f4472b   Rishav   Implement contact...
272
              .state("app.Accept", {
4bb02bb84   Rishav   new integration w...
273
274
                url: "/Accept",
                templateUrl: "partials/Accept/Accept.html",
dd378d69f   Mr. Hot Foods   changes in flight...
275
276
277
278
                controller: "AcceptController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
279
              })
3a9f4472b   Rishav   Implement contact...
280
281
  
              .state("app.delselected", {
4bb02bb84   Rishav   new integration w...
282
283
                url: "/delselected",
                templateUrl: "partials/delselected/delselected.html",
dd378d69f   Mr. Hot Foods   changes in flight...
284
285
286
287
                controller: "delselectedController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
288
289
290
291
292
              })
              
              .state("app.pricingcontact", {
                url: "/pricingcontact",
                templateUrl: "partials/pricingcontact/pricingcontact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
293
294
295
296
                controller: "pricingcontactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
297
              })
3a9f4472b   Rishav   Implement contact...
298
              .state("app.viewContact", {
3cab9e8a3   Rishav   implement view co...
299
300
                url: "/viewContact/:id",
                templateUrl: "partials/viewcontact/viewcontact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
301
302
303
304
                controller: "viewcontactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
305
              })
d1fe89776   Rishav Singla   view fuel vendor ...
306
307
308
309
  
              .state("app.viewVendorContact", {
                url: "/viewVendorContact/:id",
                templateUrl: "partials/viewVendorContact/viewVendorContact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
310
311
312
313
                controller: "viewVendorContactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
d1fe89776   Rishav Singla   view fuel vendor ...
314
315
              })
              
8f7dbe97c   Swarn Singh   fuel order comple...
316
317
318
              .state("app.enterFuelOrder", {
                url: "/enterFuelOrder",
                templateUrl: "partials/enterFuelOrder/enterFuelOrder.html",
dd378d69f   Mr. Hot Foods   changes in flight...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
                controller: "enterFuelOrderController",
                data: {
                    authorizedRoles: ["FBO"],
                }
              })
  
              .state("app.flightDepDashboard", {
                url: "/flightDepDashboard",
                templateUrl: "partials/flightDepDashboard/flightDepDashboard.html",
                controller: "flightDepDashboardController"
              })
  
              .state("app.flightDepOrders", {
                url: "/flightDepOrders",
                templateUrl: "partials/flightDepOrders/flightDepOrders.html",
                controller: "flightDepOrdersController"
8f7dbe97c   Swarn Singh   fuel order comple...
335
              })
feacde5ff   Rishav   setup acuefuel in...
336
          }
4bb02bb84   Rishav   new integration w...
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
    ])
  
    .run(['$rootScope', '$state', 'LoginService', 'AUTH_EVENTS', function($rootScope, $state, LoginService, AUTH_EVENTS) {
        $rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) {
            $rootScope.currentUser = JSON.parse(window.localStorage.getItem('currentUser'));
  
            LoginService.isAuthorized = function (authorizedRoles) {
                if (!angular.isArray(authorizedRoles)) {
                    authorizedRoles = [authorizedRoles];
                }
                var userdata = JSON.parse(window.localStorage.getItem('currentUser'));
                return (userdata? (authorizedRoles.indexOf(userdata.type) !== -1): false);
            }
            
            if ('data' in next && 'authorizedRoles' in next.data) {
              var authorizedRoles = next.data.authorizedRoles;
              if (!LoginService.isAuthorized(authorizedRoles)) {
                event.preventDefault();
                if($state.current.name.length == 0) {
                  $state.go('login')
                } else {
                  $state.go($state.current, {}, {reload: true});
                  $rootScope.$broadcast(AUTH_EVENTS.notAuthorized); 
                }
              }
            }
  
            if (LoginService.isAuthenticated()) {
              if (next.name == 'login') {
                event.preventDefault();
                $state.go('app.dashboard');
              }
dd378d69f   Mr. Hot Foods   changes in flight...
369
            }else{
c277275bb   Mr. Hot Foods   login changes
370
371
372
373
374
              // if (next.name == 'login') {
              //   event.preventDefault();
              //   $state.go('app.flightDepDashboard');
              // }
                
dd378d69f   Mr. Hot Foods   changes in flight...
375
              
4bb02bb84   Rishav   new integration w...
376
377
378
            }
        });
    }])
feacde5ff   Rishav   setup acuefuel in...
379

325c8ff31   Swarn Singh   date issue fixed
380
381
382
383
384
385
386
387
388
389
390
    
      .directive("datepicker",function(){
        return {
          restrict:"A",
          link:function(scope,el,attr){
            el.datepicker();
          }
        };
      })
   
    
feacde5ff   Rishav   setup acuefuel in...
391

32ea0c476   Swarn Singh   working on fuel m...
392

feacde5ff   Rishav   setup acuefuel in...
393