Add Config model

* Add ability to configurably cache API responses per model
* Fix general error display on credentials
* Add current version from API to the documentation link
This commit is contained in:
gconsidine
2017-07-31 17:07:25 -04:00
parent 59157565bd
commit bdb2bbbd41
9 changed files with 171 additions and 24 deletions

View File

@@ -0,0 +1,37 @@
function CacheService ($cacheFactory, $q) {
let cache = $cacheFactory('api');
this.put = (key, data) => {
return cache.put(key, data);
};
this.get = (key) => {
return $q.resolve(cache.get(key));
};
this.remove = (key) => {
if (!key) {
return cache.removeAll();
}
return cache.remove(key);
};
this.createKey = (method, path, resource) => {
let key = `${method.toUpperCase()}.${path}`;
if (resource) {
if (resource.id) {
key += `${resource.id}/`;
} else if (Number(resource)) {
key += `${resource}/`;
}
}
return key;
}
}
CacheService.$inject = ['$cacheFactory', '$q'];
export default CacheService;

View File

@@ -1,3 +1,4 @@
import CacheService from './cache.service';
import EventService from './event.service';
import PathService from './path.service';
import BaseStringService from './base-string.service';
@@ -5,7 +6,8 @@ import AppStrings from './app.strings';
angular
.module('at.lib.services', [])
.service('EventService', EventService)
.service('PathService', PathService)
.service('AppStrings', AppStrings)
.service('BaseStringService', BaseStringService)
.service('AppStrings', AppStrings);
.service('CacheService', CacheService)
.service('EventService', EventService)
.service('PathService', PathService);