First version
[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                     },
20                     
21                     myapi: { // Warning paths should end with /
22                        token : '/api/myplugin/xxxx'
23                     },
24                     
25                     session: { // Those data are updated by session service
26                        create  : '/api/token/create',
27                        refresh : '/api/token/refresh',
28                        check   : '/api/token/check',
29                        reset   : '/api/token/reset',
30                        ping    : '/api/token/check',
31                        initial : '123456789',  // typical dev initial token
32                        timeout : 3600,         // timeout is updated client sessin context creation
33                        pingrate: 60,           // Ping rate to check if server is still alive
34                        uuid    : '',           // uuid map with cookie or long term session access key
35                        token   : ''            // will be returned from authentication    
36                     }
37                 };
38
39                 return myConfig;
40             })
41
42             // Factory is a singleton and share its context within all instances.
43             .factory('AppCall', function ($http, AppConfig) {
44                 var myCalls = {
45                     get : function(plugin, action, query, callback) {
46                         query["token"] = AppConfig.session.token; // add token to provided query                        
47                         $http.get('/api/' + plugin + '/' + action , {params: query}).then (callback, callback);
48                     }
49
50                 };
51                 return myCalls;
52             });
53     
54  
55 })();