Blame view

app/js/app.js 17.6 KB
feacde5ff   Rishav   setup acuefuel in...
1
  'use strict';
9aea92263   Kuldeep Arora   Added local and U...
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','ds.clock'])
4bb02bb84   Rishav   new integration w...
3
4
5
6
7
8
  
      .config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.withCredentials = true;
        $httpProvider.interceptors.push('myCSRF');
        $httpProvider.interceptors.push('httpRequestInterceptor');
      }])
9aea92263   Kuldeep Arora   Added local and U...
9
       
4bb02bb84   Rishav   new integration w...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
      .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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
       
       .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...
42
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
      
      .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...
69
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
  
    .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...
96
97
98
99
                controller: "customersController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
100
              })
3a9f4472b   Rishav   Implement contact...
101
102
103
104
  
              .state("app.accountSetting", {
                url: "/accountSetting",
                templateUrl: "partials/accountSetting/accountSetting.html",
dd378d69f   Mr. Hot Foods   changes in flight...
105
106
107
108
                controller: "AccountSettingController",
                data: {
                    authorizedRoles: ["FBO"],
                }
3a9f4472b   Rishav   Implement contact...
109
              })
4bb02bb84   Rishav   new integration w...
110
111
112
              .state("app.ContactView", {
                url: "/ContactView",
                templateUrl: "partials/ContactView/ContactView.html",
dd378d69f   Mr. Hot Foods   changes in flight...
113
114
115
116
                controller: "ContactViewController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
117
118
119
120
              })
              .state("app.FuelVendors", {
                url: "/FuelVendors",
                templateUrl: "partials/FuelVendors/FuelVendors.html",
dd378d69f   Mr. Hot Foods   changes in flight...
121
122
123
124
                controller: "FuelVendorsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
125
              })
feacde5ff   Rishav   setup acuefuel in...
126
127
128
129
  
              .state("app.analytics", {
                url: "/analytics",
                templateUrl: "partials/analytics/analytics.html",
dd378d69f   Mr. Hot Foods   changes in flight...
130
131
132
133
                controller: "analyticsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
134
135
136
              })
  
              .state("app.account", {
3604ba8cb   Kuldeep Arora   updates
137
138
139
                url: "/vendors",
                templateUrl: "partials/FuelVendors/FuelVendors.html",
                controller: "FuelVendorsController",
dd378d69f   Mr. Hot Foods   changes in flight...
140
141
142
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
143
144
              })
              
3a9f4472b   Rishav   Implement contact...
145
              .state("app.dashboard", {
feacde5ff   Rishav   setup acuefuel in...
146
147
                url: "/dashboard",
                templateUrl: "partials/dashboard/dashboard.html",
dd378d69f   Mr. Hot Foods   changes in flight...
148
149
                controller: "dashboardController",
                data: {
671643c9f   Kuldeep Arora   additional user
150
                    authorizedRoles: ["FBO","ADDITIONAL"],
dd378d69f   Mr. Hot Foods   changes in flight...
151
                }
feacde5ff   Rishav   setup acuefuel in...
152
              })
feacde5ff   Rishav   setup acuefuel in...
153
154
155
              .state("app.elements", {
                url: "/elements",
                templateUrl: "partials/elements/elements.html",
dd378d69f   Mr. Hot Foods   changes in flight...
156
157
158
159
                controller: "elementsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
160
              })
feacde5ff   Rishav   setup acuefuel in...
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
              .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...
176
177
178
179
                controller: "formsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
180
181
182
183
184
              })
  
              .state("app.fuelManager", {
                url: "/fuelManager",
                templateUrl: "partials/fuelManager/fuelManager.html",
dd378d69f   Mr. Hot Foods   changes in flight...
185
186
187
188
                controller: "fuelManagerController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
189
              })
feacde5ff   Rishav   setup acuefuel in...
190
191
192
              .state("app.pricing", {
                url: "/pricing",
                templateUrl: "partials/pricing/pricing.html",
dd378d69f   Mr. Hot Foods   changes in flight...
193
194
195
196
                controller: "pricingController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
197
198
199
200
201
              })
  
              .state("app.reports", {
                url: "/reports",
                templateUrl: "partials/reports/reports.html",
dd378d69f   Mr. Hot Foods   changes in flight...
202
203
204
205
                controller: "reportsController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
206
207
208
209
210
              })
  
              .state("app.scheduler", {
                url: "/scheduler",
                templateUrl: "partials/scheduler/scheduler.html",
dd378d69f   Mr. Hot Foods   changes in flight...
211
212
213
214
                controller: "schedulerController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
215
              })
e196b9b74   Anchit Jindal   new changes added
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
              
              .state("app.flightTracking", {
                url: "/flightTracking",
                templateUrl: "partials/flightTracking/flightTracking.html",
                controller: "flightTrackingController",
                data: {
                    authorizedRoles: ["FBO"],
                }
              })
              
              .state("app.taxes", {
                url: "/taxes",
                templateUrl: "partials/taxes/taxes.html",
                controller: "taxesController",
                data: {
                    authorizedRoles: ["FBO"],
                }
              })
              
feacde5ff   Rishav   setup acuefuel in...
235
236
237
238
239
240
241
242
243
              .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...
244
                controller: "updateFuelManagerController",
dd378d69f   Mr. Hot Foods   changes in flight...
245
246
247
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
248
              })
cd330b5ee   Rishav   fuel vendor and v...
249
              .state("app.viewCompany", {
55e075d7e   Rishav   add contact, add ...
250
                url: "/viewCompany/:id",
feacde5ff   Rishav   setup acuefuel in...
251
                templateUrl: "partials/viewCompany/viewCompany.html",
dd378d69f   Mr. Hot Foods   changes in flight...
252
253
254
255
                controller: "viewCompanyController",
                data: {
                    authorizedRoles: ["FBO"],
                }
feacde5ff   Rishav   setup acuefuel in...
256
              }) 
ea15674c8   Rishav   minor changes for...
257
258
259
              .state("app.viewFuelVendor", {
                url: "/viewFuelVendor/:id",
                templateUrl: "partials/viewFuelVendor/viewFuelVendor.html",
dd378d69f   Mr. Hot Foods   changes in flight...
260
261
262
263
                controller: "ViewFuelVendorController",
                data: {
                    authorizedRoles: ["FBO"],
                }
cd330b5ee   Rishav   fuel vendor and v...
264
              }) 
88dad9efc   Rishav   remove unused fil...
265
              .state("app.fuelOrders", {
4bb02bb84   Rishav   new integration w...
266
267
                url: "/fuelOrders",
                templateUrl: "partials/fuelOrders/fuelOrders.html",
dd378d69f   Mr. Hot Foods   changes in flight...
268
269
270
271
                controller: "fuelOrdersController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
272
273
274
275
276
              })
  
               .state("app.DispatchFuel", {
                url: "/DispatchFuel",
                templateUrl: "partials/DispatchFuel/DispatchFuel.html",
dd378d69f   Mr. Hot Foods   changes in flight...
277
278
279
280
                controller: "DispatchFuelController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
281
              })
3a9f4472b   Rishav   Implement contact...
282
              .state("app.searchDispatchFuel", {
4bb02bb84   Rishav   new integration w...
283
284
                url: "/searchDispatchFuel",
                templateUrl: "partials/searchDispatchFuel/searchDispatchFuel.html",
dd378d69f   Mr. Hot Foods   changes in flight...
285
286
287
288
                controller: "searchDispatchFuelController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
289
              })
3a9f4472b   Rishav   Implement contact...
290
              .state("app.Accept", {
4bb02bb84   Rishav   new integration w...
291
292
                url: "/Accept",
                templateUrl: "partials/Accept/Accept.html",
dd378d69f   Mr. Hot Foods   changes in flight...
293
294
295
296
                controller: "AcceptController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
297
              })
3a9f4472b   Rishav   Implement contact...
298
299
  
              .state("app.delselected", {
4bb02bb84   Rishav   new integration w...
300
301
                url: "/delselected",
                templateUrl: "partials/delselected/delselected.html",
dd378d69f   Mr. Hot Foods   changes in flight...
302
303
304
305
                controller: "delselectedController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
306
307
308
309
310
              })
              
              .state("app.pricingcontact", {
                url: "/pricingcontact",
                templateUrl: "partials/pricingcontact/pricingcontact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
311
312
313
314
                controller: "pricingcontactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
315
              })
3a9f4472b   Rishav   Implement contact...
316
              .state("app.viewContact", {
3cab9e8a3   Rishav   implement view co...
317
318
                url: "/viewContact/:id",
                templateUrl: "partials/viewcontact/viewcontact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
319
320
321
322
                controller: "viewcontactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
4bb02bb84   Rishav   new integration w...
323
              })
d1fe89776   Rishav Singla   view fuel vendor ...
324
325
326
327
  
              .state("app.viewVendorContact", {
                url: "/viewVendorContact/:id",
                templateUrl: "partials/viewVendorContact/viewVendorContact.html",
dd378d69f   Mr. Hot Foods   changes in flight...
328
329
330
331
                controller: "viewVendorContactController",
                data: {
                    authorizedRoles: ["FBO"],
                }
d1fe89776   Rishav Singla   view fuel vendor ...
332
333
              })
              
8f7dbe97c   Swarn Singh   fuel order comple...
334
335
336
              .state("app.enterFuelOrder", {
                url: "/enterFuelOrder",
                templateUrl: "partials/enterFuelOrder/enterFuelOrder.html",
dd378d69f   Mr. Hot Foods   changes in flight...
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
                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...
353
              })
d121d5539   Kuldeep Arora   UI Changes
354
355
356
357
358
              .state("forgetPassword", {
               url: "/forgetPassword",
               templateUrl: "partials/forgetPassword/forgetPassword.html",
               controller: "forgetPasswordController"
             })
5fd0d0f40   Kuldeep Arora   forget pwd UI
359
360
361
362
363
364
365
  
              .state("resetPassword", {
                url : "/resetPassword",
                templateUrl : "partials/resetpwd/resetPassword.html",
                controller : "resetPasswordController"
                  
              })
feacde5ff   Rishav   setup acuefuel in...
366
          }
4bb02bb84   Rishav   new integration w...
367
368
369
370
    ])
  
    .run(['$rootScope', '$state', 'LoginService', 'AUTH_EVENTS', function($rootScope, $state, LoginService, AUTH_EVENTS) {
        $rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) {
5ff103048   Kuldeep Arora   updates
371
            //console.log("from",from, "fromState",fromState)
f62f8940f   Kuldeep Arora   UI changes
372
373
            $rootScope.isShowEmail = false;
            $rootScope.isShowFMA = false;
5ff103048   Kuldeep Arora   updates
374
            $rootScope.previousState = fromState.name;
4bb02bb84   Rishav   new integration w...
375
            $rootScope.currentUser = JSON.parse(window.localStorage.getItem('currentUser'));
f62f8940f   Kuldeep Arora   UI changes
376
377
378
379
380
381
382
383
384
            var EPDAccess = JSON.parse(window.localStorage.getItem('EPDAccess'));
            var FMAAccess = JSON.parse(window.localStorage.getItem('FMAAccess'));
            if(EPDAccess === true || EPDAccess == null){
              $rootScope.isShowEmail = true;
            }
            if(FMAAccess === true || FMAAccess == null){
              $rootScope.isShowFMA = true;
            }
            
565570086   Kuldeep Arora   highcharts(MFS,CS...
385
           // console.log("nextParams",nextParams)
5fd0d0f40   Kuldeep Arora   forget pwd UI
386
            /*LoginService.isAuthorized = function (authorizedRoles) {
4bb02bb84   Rishav   new integration w...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
                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...
412
            }else{
c277275bb   Mr. Hot Foods   login changes
413
414
415
416
417
              // if (next.name == 'login') {
              //   event.preventDefault();
              //   $state.go('app.flightDepDashboard');
              // }
                
dd378d69f   Mr. Hot Foods   changes in flight...
418
              
5fd0d0f40   Kuldeep Arora   forget pwd UI
419
            }*/
4bb02bb84   Rishav   new integration w...
420
421
        });
    }])
feacde5ff   Rishav   setup acuefuel in...
422

d121d5539   Kuldeep Arora   UI Changes
423
       
325c8ff31   Swarn Singh   date issue fixed
424
425
426
427
428
429
430
431
      .directive("datepicker",function(){
        return {
          restrict:"A",
          link:function(scope,el,attr){
            el.datepicker();
          }
        };
      })
325c8ff31   Swarn Singh   date issue fixed
432
    
cf8827d2e   Kuldeep Arora   decimal points fixed
433
    /* Valid number for upto 4 decimal points-Input type */
32ea0c476   Swarn Singh   working on fuel m...
434

cf8827d2e   Kuldeep Arora   decimal points fixed
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
      .directive('validNumber', function() {
        return {
          require: '?ngModel',
          link: function(scope, element, attrs, ngModelCtrl) {
            if(!ngModelCtrl) {
              return; 
            }
  
            ngModelCtrl.$parsers.push(function(val) {
              if (angular.isUndefined(val)) {
                  var val = '';
              }
              
              var clean = val.replace(/[^-0-9\.]/g, '');
              var negativeCheck = clean.split('-');
        var decimalCheck = clean.split('.');
              if(!angular.isUndefined(negativeCheck[1])) {
                  negativeCheck[1] = negativeCheck[1].slice(0, negativeCheck[1].length);
                  clean =negativeCheck[0] + '-' + negativeCheck[1];
                  if(negativeCheck[0].length > 0) {
                    clean =negativeCheck[0];
                  }
                  
              }
                
              if(!angular.isUndefined(decimalCheck[1])) {
                  decimalCheck[1] = decimalCheck[1].slice(0,4);
                  clean =decimalCheck[0] + '.' + decimalCheck[1];
              }
  
              if (val !== clean) {
                ngModelCtrl.$setViewValue(clean);
                ngModelCtrl.$render();
              }
              return clean;
            });
  
            element.bind('keypress', function(event) {
              if(event.keyCode === 32) {
                event.preventDefault();
              }
            });
          }
        };
      })
   /* Valid number for upto 2 decimal points-Input type */
      .directive('decimalNumber', function() {
            return {
              require: '?ngModel',
              link: function(scope, element, attrs, ngModelCtrl) {
                if(!ngModelCtrl) {
                  return; 
                }
  
                ngModelCtrl.$parsers.push(function(val) {
                  if (angular.isUndefined(val)) {
                      var val = '';
                  }
                  
                  var clean = val.replace(/[^-0-9\.]/g, '');
                  var negativeCheck = clean.split('-');
                  var decimalCheck = clean.split('.');
                  if(!angular.isUndefined(negativeCheck[1])) {
                      negativeCheck[1] = negativeCheck[1].slice(0, negativeCheck[1].length);
                      clean =negativeCheck[0] + '-' + negativeCheck[1];
                      if(negativeCheck[0].length > 0) {
                        clean =negativeCheck[0];
                      }
                      
                  }
                    
                  if(!angular.isUndefined(decimalCheck[1])) {
                      decimalCheck[1] = decimalCheck[1].slice(0,2);
                      clean =decimalCheck[0] + '.' + decimalCheck[1];
                  }
  
                  if (val !== clean) {
                    ngModelCtrl.$setViewValue(clean);
                    ngModelCtrl.$render();
                  }
                  return clean;
                });
  
                element.bind('keypress', function(event) {
                  if(event.keyCode === 32) {
                    event.preventDefault();
                  }
                });
              }
            };
          });
feacde5ff   Rishav   setup acuefuel in...
526