-
Notifications
You must be signed in to change notification settings - Fork 0
/
kn-security.ts
51 lines (49 loc) · 1.58 KB
/
kn-security.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { SecurityService } from './$security';
import { TabEventsService } from './$tabEvents';
import 'angular';
import 'ui.router';
import 'angular-cache';
var moduleName = 'kn-security';
var dependencies = [
'ui.router',
'permission',
'angular-cache'
];
angular.module(moduleName, dependencies)
.value('homeRoute', {name: 'app.home', force: false})
.value('loginRoute', {name: 'auth.login', force: false})
.value('logoutRoute', {name: 'auth.logout', force: false})
.config([
'CacheFactoryProvider',
(CacheFactoryProvider: ng.cache.ICacheFactoryProvider) => {
angular.extend(CacheFactoryProvider.defaults, {
// maxAge: 15 * 60 * 1000,
storageMode: 'localStorage'
});
}
])
/* tslint:disable:variable-name */
.factory('cacheGenerator', [
'CacheFactory',
(CacheFactory: ng.cache.ICacheFactory) => {
/* tslint:enable:variable-name */
return (cacheName: string, options?: any) => {
if ( !CacheFactory.get(cacheName) ) {
options = options || {storageMode: 'localStorage'};
CacheFactory.createCache(cacheName, options);
}
return CacheFactory.get(cacheName);
};
}
])
.factory('store', [
'cacheGenerator',
(cacheGenerator: (name: string) => any) => {
return cacheGenerator('store');
}
])
.service({
$security: SecurityService,
$tabEvents: TabEventsService
});
export default moduleName;