summaryrefslogtreecommitdiffstats
path: root/afb-client/app/Frontend/etc/AppConfig.js
diff options
context:
space:
mode:
Diffstat (limited to 'afb-client/app/Frontend/etc/AppConfig.js')
-rw-r--r--afb-client/app/Frontend/etc/AppConfig.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/afb-client/app/Frontend/etc/AppConfig.js b/afb-client/app/Frontend/etc/AppConfig.js
index bd1aae0..5c9283e 100644
--- a/afb-client/app/Frontend/etc/AppConfig.js
+++ b/afb-client/app/Frontend/etc/AppConfig.js
@@ -23,7 +23,7 @@
ping : '/api/token/check',
initial : urlquery.token || '123456789', // typical dev initial token
timeout : 3600, // timeout is updated client sessin context creation
- pingrate: 60, // Ping rate to check if server is still alive
+ pingrate: 30, // Ping rate to check if server is still alive
uuid : '', // uuid map with cookie or long term session access key
token : '' // will be returned from authentication
}
@@ -33,16 +33,28 @@
})
// Factory is a singleton and share its context within all instances.
- .factory('AppCall', function ($http, AppConfig) {
+ .factory('AppCall', function ($http, AppConfig, $log) {
var myCalls = {
- get : function(plugin, action, query, callback) {
- if (!query.token) query.token = AppConfig.session.token; // add token to provided query
- $http.get('/api/' + plugin + '/' + action , {params: query}).then (callback, callback);
+ get : function(plugin, action, query, cbresponse, cberror) {
+ if (!query.token) query.token = AppConfig.session.token; // add token to provided query
+ var handle= $http.get('/api/' + plugin + '/' + action , {params: query}).then (onsuccess, onerror);
+
+ handle.onsuccess (function(data, errcode, headers, config) {
+ // if token was updated keep it within application cache
+ if (data.request.token) AppConfig.session.token = data.request.token;
+ if (data.request.uuid) AppConfig.session.uuid = data.request.uuid;
+ if (data.request.timeout) AppConfig.session.timeout = data.request.timeout;
+
+ cbresponse(data, errcode, headers, config);
+ });
+
+ handle.onerror (function(data, errcode, headers, config) {
+ if (cberror) cberror(data, errcode, headers, config);
+ else cbresponse(data, errcode, headers, config);
+ });
}
-
};
return myCalls;
});
-
})(); \ No newline at end of file