Moved preference resolution into its own resolver.

Preferences aren't strictly part of the session, so I've moved the
resolution thereof into the services package.

Change-Id: I3233e43f38ed553af78fd53c03cf033e9db9c004
This commit is contained in:
Michael Krotscheck 2015-03-11 11:28:44 -07:00
parent 3430f7ffec
commit e78ae03805
3 changed files with 32 additions and 10 deletions

View File

@ -110,14 +110,6 @@ angular.module('sb.auth').constant('SessionResolver',
requireCurrentUser: function ($q, $log, CurrentUser) {
$log.debug('Resolving current user...');
return CurrentUser.resolve();
},
/**
* This function resolves the preferences.
*/
resolvePreferences: function ($q, $log, Preference) {
$log.debug('Resolving user preferences...');
return Preference.refresh();
}
};
})());

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* A preference resolver that allows route-level preloading of preferences.
*/
angular.module('sb.services').constant('PreferenceResolver',
{
/**
* Resolves all preferences.
*/
resolvePreferences: function (Preference) {
'use strict';
return Preference.refresh();
}
});

View File

@ -33,7 +33,8 @@ angular.module('storyboard',
timezone: 'UTC'
})
.config(function ($urlRouterProvider, $locationProvider, $httpProvider,
msdElasticConfig, $stateProvider, SessionResolver) {
msdElasticConfig, $stateProvider, SessionResolver,
PreferenceResolver) {
'use strict';
// Default URL hashbang route
@ -58,7 +59,7 @@ angular.module('storyboard',
template: '<div ui-view></div>',
resolve: {
sessionState: SessionResolver.resolveSessionState,
preferences: SessionResolver.resolvePreferences
preferences: PreferenceResolver.resolvePreferences
}
});
})