Merge "Always set login to default theme"

This commit is contained in:
Jenkins 2015-06-19 13:25:13 +00:00 committed by Gerrit Code Review
commit f82d8e18f9
2 changed files with 8 additions and 5 deletions

View File

@ -9,7 +9,9 @@ angular.module('bansho.authentication', [])
});
}])
.controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', 'configManager', function ($scope, $rootScope, $location, authService, configManager) {
.controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', 'configManager', 'themeManager', function ($scope, $rootScope, $location, authService, configManager, themeManager) {
themeManager.setTheme(themeManager.THEMES.DEFAULT);
var login = function (credentials) {
authService.login(credentials);
};
@ -66,7 +68,7 @@ angular.module('bansho.authentication', [])
$http.defaults.headers.common['X-Auth-Token'] = session.sessionId;
configManager.fetchConfig(configManager.getDevelopmentConfig().useStoredConfig).then(function () {
themeManager.setTheme();
themeManager.setTheme(configManager.getTheme());
$location.path('/view');
}, function (message) {
throw new Error(message);

View File

@ -5,11 +5,13 @@
angular.module('bansho.config', [])
.service('themeManager', ['$rootScope', 'configManager',
function ($rootScope, configManager) {
// Constants for theme colors
var THEMES = {
DARK: "dark",
LIGHT: "light",
DEFAULT: "dark"
};
this.THEMES = THEMES;
var setThemeClass = function (theme, saveConfig) {
$rootScope.themeClass = 'color-scheme--' + theme;
@ -25,12 +27,11 @@ angular.module('bansho.config', [])
*
* If configManager isn't loaded this will set default.
*/
this.setTheme = function () {
var theme = configManager.getTheme();
this.setTheme = function (theme) {
if (theme) {
setThemeClass(theme, false);
} else {
setThemeClass(THEMES.DARK, false);
setThemeClass(THEMES.DEFAULT, false);
}
};