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