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

View File

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