Skip to content
Snippets Groups Projects
Commit 1742bf2b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

user color functions refactored

common implementation is used when color for user is not defined and
system value must be used
parent cb06890b
No related branches found
No related tags found
2 merge requests!115Resolve "admin panel should use API",!114Resolve "admin panel should use API"
......@@ -58,55 +58,38 @@ ServerConnector.init();
ServerConnector.getMinOverlayColorInt = function() {
var self = this;
var userColor;
return self.getLoggedUser().then(function(user) {
userColor = user.getMinColor();
return self.getConfigurationParam(ConfigurationType.MIN_COLOR_VAL);
}).then(function(systemMinColor) {
var userColor = user.getMinColor();
return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.MIN_COLOR_VAL));
});
};
ServerConnector.returnUserOrSystemColor = function(userColor, systemPromisedColor) {
return systemPromisedColor.then(function(systemColor) {
var color = userColor;
if (userColor === null || userColor === undefined || userColor === "") {
color = systemMinColor;
color = systemColor;
}
color = parseInt(color, 16);
/* jslint bitwise: true */
color = (color & 0xFFFFFF);
return color;
});
};
}
ServerConnector.getSimpleOverlayColorInt = function() {
var self = this;
var userColor;
return self.getLoggedUser().then(function(user) {
userColor = user.getSimpleColor();
return self.getConfigurationParam(ConfigurationType.SIMPLE_COLOR_VAL);
}).then(function(systemSimpleColor) {
var color = userColor;
if (userColor === null || userColor === undefined || userColor === "") {
color = systemSimpleColor;
}
color = parseInt(color, 16);
/* jslint bitwise: true */
color = (color & 0xFFFFFF);
return color;
var userColor = user.getSimpleColor();
return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.SIMPLE_COLOR_VAL));
});
};
ServerConnector.getMaxOverlayColorInt = function() {
var self = this;
var userColor;
return self.getLoggedUser().then(function(user) {
userColor = user.getMaxColor();
return self.getConfigurationParam(ConfigurationType.MAX_COLOR_VAL);
}).then(function(systemMaxColor) {
var color = userColor;
if (userColor === null || userColor === undefined || userColor === "") {
color = systemMaxColor;
}
color = parseInt(color, 16);
/* jslint bitwise: true */
color = (color & 0xFFFFFF);
return color;
var userColor = user.getMaxColor();
return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.MAX_COLOR_VAL));
});
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment