be5a107080e297269586935421cf1f89cf178fd9
[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 (urlquery) {
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 : '/icons/',
17                         avatar: 'images/avatars/',
18                         audio : 'images/audio/',
19                         appli : 'images/appli/'
20                     },
21                                         
22                     session: { // Those data are updated by session service
23                        initial : urlquery.token || '123456789',  // typical dev initial token
24                        timeout : 3600,         // timeout is updated client sessin context creation
25                        pingrate: 15,           // Ping rate to check if server is still alive
26                        uuid    : '',           // uuid map with cookie or long term session access key
27                        token   : ''            // will be returned from authentication    
28                     }
29                 };
30
31                 return myConfig;
32             })
33
34             // Factory is a singleton and share its context within all instances.
35             .factory('AppCall', function ($http, AppConfig, $log) {
36                 var myCalls = {
37                     get : function(plugin, action, query, callback) {
38                         if (!query.token) query.token = AppConfig.session.token; // add token to provided query
39                         $http.get('/api/' + plugin + '/' + action , {params: query}).then (callback, callback);
40                     }
41
42                 };
43                 return myCalls;
44             });
45     
46  
47 })();