app controller MainController scope UserService CachedObjectsService F

 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
app.controller('MainController', [
'$scope', 'UserService', 'CachedObjectsServiceFactory',
function($scope, UserService, CachedObjectsServiceFactory) {
var organizationResources = {
serviceType: 'organization_related',
array: []
};
var matterTypeResources = {
serviceType: 'matter_type_related',
array: ['Definings', 'SubMatterStatuses', 'ReferenceTypes']
};
var dependentResources = {
serviceType: 'dependency_related',
array: ['SubMatterTypes', 'SubMatterSubTypes']
};
[organizationResources, matterTypeResources, dependentResources].forEach(function(cachedResources) {
cachedResources.array.forEach(function(resourceName) {
CachedObjectsServiceFactory.get(resourceName, cachedResources.serviceType).init();
});
});
$scope.user = UserService.getCurrent();
$scope.logout = function() {
$scope.user.$promise.then(function() {
UserService.logout(function() {
window.location = '/';
});
})
};
}]);