mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
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:
37
awx/ui/client/lib/services/cache.service.js
Normal file
37
awx/ui/client/lib/services/cache.service.js
Normal 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;
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user