Implemented URL query parsing for initial token /opa/?token=abcde
[src/app-framework-demo.git] / afm-client / app / Frontend / app.js
1 (function() {
2   'use strict';
3     function ParseQueryString () {
4       var qd = {};
5       location.search.substr(1).split("&").forEach(function(item) {
6           var k = item.split("=")[0], v = decodeURIComponent(item.split("=")[1]); (k in qd) ? qd[k].push(v) : qd[k] = [v];
7       });
8       return qd;
9   }
10
11   angular.module('@@APPNAME@@', [ // Warning: Appname should fit with gulpfile.js & index.html
12     'ui.router',
13     'ngAnimate',
14
15     //foundation
16     'foundation',
17     'foundation.dynamicRouting',
18     'foundation.dynamicRouting.animations',
19     
20     // external components
21     'ui-notification',
22     
23     // Application Components
24     'AppConfig',
25     'JQueryEmu',
26     'DashboardModule',
27     'UploadFiles',
28     'LinkButton',
29     'TokenRefresh',
30     'RangeSlider',
31     'ModalNotification'
32   ])
33     .value ('urlquery', ParseQueryString())
34     .config(config)
35     .run(run)
36   ;
37
38   config.$inject = ['$urlRouterProvider', '$locationProvider'];
39   
40   function config($urlProvider, $locationProvider, AppConfig) {
41     $urlProvider.otherwise('/dashboard');
42
43     // https://docs.angularjs.org/error/$location/nobase
44     $locationProvider.html5Mode(true).hashPrefix('!');
45     
46   }
47
48   function run() {
49     FastClick.attach(document.body);
50   }
51   
52 // Fondation-app.template is not included correctly by gulp 
53 // Include here missing templates from foundation-apps/dist/js/foundation-apps-templates.js
54 angular.module('foundation').run(['$templateCache', function($templateCache) {
55   $templateCache.put('components/modal/modal.html',
56     '<div\n' +
57     '  class="modal-overlay"\n' +
58     '  ng-click="hideOverlay()">\n' +
59     '  <aside\n' +
60     '    class="modal"\n' +
61     '    ng-click="$event.stopPropagation();"\n' +
62     '    ng-transclude>\n' +
63     '  </aside>\n' +
64     '</div>\n' +
65     '');
66 }]);
67
68 console.log ("opa=@@APPNAME@@ Loaded");
69 })();