16c05b536e8b425d7a403b0db2ab13e7af59afe4
[src/app-framework-demo.git] / afm-client / app / Frontend / etc / AppConfig.js
1 (function () {
2     'use strict';
3
4     // _all modules only reference dependencies
5     angular.module('AppConfig', [])
6     
7             // Factory is a singleton and share its context within all instances.
8             .factory('AppConfig', function () {
9
10                 // console.log ("URL="+ $location.url() + " Query=" + location.href+ " window=" + document.referrer);
11
12                 var myConfig = {
13                     
14                     paths: { // Warning paths should end with /
15                         image : 'images/',
16                         icons : 'images/icons/',
17                         avatar: 'images/avatars/',
18                         audio : 'images/audio/',
19                         appli : 'images/appli/'
20                     },
21                     
22                     myapi: { // Warning paths should end with /
23                        token : '/api/myplugin/xxxx'
24                     },
25                     
26                     session: { // Those data are updated by session service
27                        create  : '/api/token/create',
28                        refresh : '/api/token/refresh',
29                        check   : '/api/token/check',
30                        reset   : '/api/token/reset',
31                        ping    : '/api/token/check',
32                        initial : '123456789',  // typical dev initial token
33                        timeout : 3600,         // timeout is updated client sessin context creation
34                        pingrate: 60,           // Ping rate to check if server is still alive
35                        uuid    : '',           // uuid map with cookie or long term session access key
36                        token   : ''            // will be returned from authentication    
37                     }
38                 };
39
40                 return myConfig;
41             })
42
43             // Factory is a singleton and share its context within all instances.
44             .factory('AppCall', function ($http, AppConfig) {
45                 var myCalls = {
46                     get : function(plugin, action, query, callback) {
47                         query.token = AppConfig.session.token; // add token to provided query                        
48                         $http.get('/api/' + plugin + '/' + action , {params: query}).then (callback, callback);
49                     }
50
51                 };
52                 return myCalls;
53             });
54     
55  
56 })();