Commit b776f926 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '311-admin-panel-configuration-items-should-be-grouped' into 'master'

Resolve "Admin panel: Configuration items should be grouped"

Closes #311

See merge request piotr.gawron/minerva!255
parents f8a7e613 bfc1ec51
Pipeline #4318 passed with stage
in 1 minute and 4 seconds
......@@ -13,10 +13,12 @@ function ConfigurationOption(data) {
self.setType(data.getType());
self.setCommonName(data.getCommonName());
self.setValue(data.getValue());
self.setGroup(data.getGroup());
self.setValueType(data.getValueType());
} else {
self.setType(data.type);
self.setCommonName(data.commonName);
self.setGroup(data.group);
self.setValue(data.value);
self.setValueType(data.valueType);
}
......@@ -57,4 +59,13 @@ ConfigurationOption.prototype.getCommonName = function () {
return this._commonName;
};
ConfigurationOption.prototype.setGroup = function (group) {
this._group = group;
};
ConfigurationOption.prototype.getGroup = function () {
return this._group;
};
module.exports = ConfigurationOption;
......@@ -35,6 +35,16 @@ ConfigurationAdminPanel.prototype._createGui = function () {
});
self.getElement().appendChild(configurationDiv);
configurationDiv.appendChild(Functions.createElement({
type: "h3",
content: 'Configuration category: <select name="categorySelect"></select>',
xss: false
}));
configurationDiv.appendChild(Functions.createElement({
type: "br"
}));
var configurationTable = Functions.createElement({
type: "table",
name: "configurationTable",
......@@ -45,16 +55,17 @@ ConfigurationAdminPanel.prototype._createGui = function () {
// noinspection JSUnusedGlobalSymbols
$(configurationTable).DataTable({
fnRowCallback: function (nRow, aData) {
nRow.setAttribute('id', aData[0]);
},
columns: [{
title: 'Category'
}, {
title: 'Name'
}, {
title: 'Value'
}, {
title: 'Save'
}]
title: 'Save',
orderable: false
}],
order: [[1, "asc"]]
});
$(configurationTable).on("click", "[name='saveOption']", function () {
var button = this;
......@@ -73,7 +84,6 @@ ConfigurationAdminPanel.prototype._createGui = function () {
var button = this;
var value = $(button).css("background-color");
var type = $(button).attr("data");
logger.debug(type);
var colorPicker = $(button).parent().spectrum({
color: value,
move: function (color) {
......@@ -106,13 +116,30 @@ ConfigurationAdminPanel.prototype.init = function () {
ConfigurationAdminPanel.prototype.setOptions = function (options, editable) {
var self = this;
var dataTable = $($("[name='configurationTable']", self.getElement())[0]).DataTable();
var dataTable = $("[name='configurationTable']", self.getElement()).DataTable();
var data = [];
var categoryDropDown = $("[name='categorySelect']", self.getElement());
categoryDropDown.empty();
var categories = {"": true};
categoryDropDown.append('<option value=""></option>');
for (var i = 0; i < options.length; i++) {
var option = options[i];
var rowData = self.optionToTableRow(option, editable);
data.push(rowData);
var group = option.getGroup();
if (categories[group] === undefined && group !== undefined) {
categories[group] = true;
categoryDropDown.append('<option value="' + group + '">' + group + '</option>')
}
}
categoryDropDown.change(function () {
logger.warn($(this).val());
dataTable.column(0).search($(this).val()).draw();
});
dataTable.clear().rows.add(data).draw();
};
......@@ -149,9 +176,14 @@ ConfigurationAdminPanel.prototype.optionToTableRow = function (option, editable)
logger.warn("Don't know how to handle: " + option.getValueType());
editOption = "<input name='edit-" + option.getType() + "' value='" + value + "'readonly/>";
}
row[0] = option.getCommonName();
row[1] = editOption;
row[2] = "<button name='saveOption' data='" + option.getType() + "' " + disabled + "><i class='fa fa-save' style='font-size:17px'></i></button>";
var group = option.getGroup();
if (group === undefined) {
group = "";
}
row[0] = group;
row[1] = option.getCommonName();
row[2] = editOption;
row[3] = "<button name='saveOption' data='" + option.getType() + "' " + disabled + "><i class='fa fa-save' style='font-size:17px'></i></button>";
return row;
};
......
[{"id":345331,"modelId":16728,"type":"ALIAS"},{"id":345330,"modelId":16729,"type":"ALIAS"},{"id":345337,"modelId":16731,"type":"ALIAS"}]
\ No newline at end of file
[{"id":345331,"modelId":16728,"type":"ALIAS"},{"id":345337,"modelId":16731,"type":"ALIAS"},{"id":345330,"modelId":16729,"type":"ALIAS"}]
\ No newline at end of file
package lcsb.mapviewer.model.user;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* This class represents one configureable parameter of the system.
*
* @author Piotr Gawron
*
*/
@Entity
@Table(name = "configuration_table")
public class Configuration implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Unique identifier in the database.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private int id;
/**
* Type of the configuration element.
*/
private ConfigurationElementType type;
/**
* What is the value of the configuration parameter.
*/
private String value;
/**
* @return the id
* @see #id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
* @see #id
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the type
* @see #type
*/
public ConfigurationElementType getType() {
return type;
}
/**
* @param type
* the type to set
* @see #type
*/
public void setType(ConfigurationElementType type) {
this.type = type;
}
/**
* @return the value
* @see #value
*/
public String getValue() {
return value;
}
/**
* @param value
* the value to set
* @see #value
*/
public void setValue(String value) {
this.value = value;
}
}
......@@ -12,64 +12,75 @@ public enum ConfigurationElementType {
/**
* Email address used for sending email from the system.
*/
EMAIL_ADDRESS("E-mail address", "your.account@domain.com", ConfigurationElementEditType.EMAIL, true), //
EMAIL_ADDRESS("E-mail address", "your.account@domain.com", ConfigurationElementEditType.EMAIL, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Login for the email account.
*/
EMAIL_LOGIN("E-mail server login", "your@login", ConfigurationElementEditType.STRING, true), //
EMAIL_LOGIN("E-mail server login", "your@login", ConfigurationElementEditType.STRING, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Password for the email account.
*/
EMAIL_PASSWORD("E-mail server password", "email.secret.password", ConfigurationElementEditType.PASSWORD, true), //
EMAIL_PASSWORD("E-mail server password", "email.secret.password", ConfigurationElementEditType.PASSWORD, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Address of the IMAP server.
*/
EMAIL_IMAP_SERVER("IMAP server", "your.imap.domain.com", ConfigurationElementEditType.STRING, true), //
EMAIL_IMAP_SERVER("IMAP server", "your.imap.domain.com", ConfigurationElementEditType.STRING, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Address of the SMTP server.
*/
EMAIL_SMTP_SERVER("SMTP server", "your.smtp.domain.com", ConfigurationElementEditType.STRING, true), //
EMAIL_SMTP_SERVER("SMTP server", "your.smtp.domain.com", ConfigurationElementEditType.STRING, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Port used for SMTP connection (sending e-mails).
*/
EMAIL_SMTP_PORT("SMTP port", "25", ConfigurationElementEditType.INTEGER, true), //
EMAIL_SMTP_PORT("SMTP port", "25", ConfigurationElementEditType.INTEGER, true,
ConfigurationElementTypeGroup.EMAIL_NOTIFICATION), //
/**
* Default map that should be presented if no map is selected by user side.
*/
DEFAULT_MAP("Default Project Id", "empty", ConfigurationElementEditType.STRING, false), //
DEFAULT_MAP("Default Project Id", "empty", ConfigurationElementEditType.STRING, false,
ConfigurationElementTypeGroup.SERVER_CONFIGURATION), //
/**
* Logo presented in the system.
*/
LOGO_IMG("Logo icon", "udl.png", ConfigurationElementEditType.URL, false), //
LOGO_IMG("Logo icon", "udl.png", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO), //
/**
* Address connected to the logo.
*/
LOGO_LINK("Logo link (after click)", "http://wwwen.uni.lu/", ConfigurationElementEditType.URL, false), //
LOGO_LINK("Logo link (after click)", "http://wwwen.uni.lu/", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO), //
/**
* Maximum distance (in pixels) that is allowed during finding closest element
* on the map.
*/
SEARCH_DISTANCE("Max distance for clicking on element (px)", "10", ConfigurationElementEditType.DOUBLE, false),
SEARCH_DISTANCE("Max distance for clicking on element (px)", "10", ConfigurationElementEditType.DOUBLE, false,
ConfigurationElementTypeGroup.POINT_AND_CLICK),
/**
* Email used for requesting an account (in client side).
*/
REQUEST_ACCOUNT_EMAIL("Email used for requesting an account", "your.email@domain.com",
ConfigurationElementEditType.EMAIL, false),
ConfigurationElementEditType.EMAIL, false, ConfigurationElementTypeGroup.EMAIL_NOTIFICATION),
/**
* Max number of results in search box.
*/
SEARCH_RESULT_NUMBER("Max number of results in search box. ", "100", ConfigurationElementEditType.INTEGER, false),
SEARCH_RESULT_NUMBER("Max number of results in search box. ", "100", ConfigurationElementEditType.INTEGER, false,
ConfigurationElementTypeGroup.POINT_AND_CLICK),
/**
* Google Analytics tracking ID used for statistics. This tracking ID should
......@@ -78,89 +89,101 @@ public enum ConfigurationElementType {
* </a>.
*/
GOOGLE_ANALYTICS_IDENTIFIER("Google Analytics tracking ID used for statistics", "",
ConfigurationElementEditType.STRING, false),
ConfigurationElementEditType.STRING, false, ConfigurationElementTypeGroup.SERVER_CONFIGURATION),
/**
* Description of the logo presented in the system.
*/
LOGO_TEXT("Logo description", "University of Luxembourg", ConfigurationElementEditType.STRING, false),
LOGO_TEXT("Logo description", "University of Luxembourg", ConfigurationElementEditType.STRING, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* Domain allowed to connect via x-frame technology.
*/
X_FRAME_DOMAIN("Domain allowed to connect via x-frame technology", "", ConfigurationElementEditType.URL, false),
X_FRAME_DOMAIN("Domain allowed to connect via x-frame technology", "", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.SERVER_CONFIGURATION),
/**
* Relative directory (in webapps folder) where big files will be stored.
*/
BIG_FILE_STORAGE_DIR("Path to store big files", "minerva-big/", ConfigurationElementEditType.STRING, false),
BIG_FILE_STORAGE_DIR("Path to store big files", "minerva-big/", ConfigurationElementEditType.STRING, false,
ConfigurationElementTypeGroup.SERVER_CONFIGURATION),
/**
* File where legend 1/4 is stored.
*/
LEGEND_FILE_1("Legend 1 image file", "resources/images/legend_a.png", ConfigurationElementEditType.URL, false),
LEGEND_FILE_1("Legend 1 image file", "resources/images/legend_a.png", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* File where legend 2/4 is stored.
*/
LEGEND_FILE_2("Legend 2 image file", "resources/images/legend_b.png", ConfigurationElementEditType.URL, false),
LEGEND_FILE_2("Legend 2 image file", "resources/images/legend_b.png", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* File where legend 3/4 is stored.
*/
LEGEND_FILE_3("Legend 3 image file", "resources/images/legend_c.png", ConfigurationElementEditType.URL, false),
LEGEND_FILE_3("Legend 3 image file", "resources/images/legend_c.png", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* File where legend 4/4 is stored.
*/
LEGEND_FILE_4("Legend 4 image file", "resources/images/legend_d.png", ConfigurationElementEditType.URL, false),
LEGEND_FILE_4("Legend 4 image file", "resources/images/legend_d.png", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* File where legend 4/4 is stored.
*/
USER_MANUAL_FILE("User manual file", "resources/other/user_guide.pdf", ConfigurationElementEditType.URL, false),
USER_MANUAL_FILE("User manual file", "resources/other/user_guide.pdf", ConfigurationElementEditType.URL, false,
ConfigurationElementTypeGroup.LEGEND_AND_LOGO),
/**
* Color used for negative overlay values.
*/
MIN_COLOR_VAL("Overlay color for negative values", "FF0000", ConfigurationElementEditType.COLOR, false),
MIN_COLOR_VAL("Overlay color for negative values", "FF0000", ConfigurationElementEditType.COLOR, false,
ConfigurationElementTypeGroup.OVERLAYS),
/**
* Color used for positive overlay values.
*/
MAX_COLOR_VAL("Overlay color for postive values", "0000FF", ConfigurationElementEditType.COLOR, false),
MAX_COLOR_VAL("Overlay color for postive values", "0000FF", ConfigurationElementEditType.COLOR, false,
ConfigurationElementTypeGroup.OVERLAYS),
/**
* Color used for undefined overlay values.
*/
SIMPLE_COLOR_VAL("Overlay color when no values are defined", "00FF00", ConfigurationElementEditType.COLOR, false),
SIMPLE_COLOR_VAL("Overlay color when no values are defined", "00FF00", ConfigurationElementEditType.COLOR, false,
ConfigurationElementTypeGroup.OVERLAYS),
/**
* Color used for 0 overlay value.
*/
NEUTRAL_COLOR_VAL("Overlay color for value=0", "FFFFFF", ConfigurationElementEditType.COLOR, false),
NEUTRAL_COLOR_VAL("Overlay color for value=0", "FFFFFF", ConfigurationElementEditType.COLOR, false,
ConfigurationElementTypeGroup.OVERLAYS),
/**
* Opacity of data overlay objects in the frontend.
*/
OVERLAY_OPACITY("Opacity used when drwaing data overlays (value between 0.0-1.0)", "0.8",
ConfigurationElementEditType.DOUBLE, false),
ConfigurationElementEditType.DOUBLE, false, ConfigurationElementTypeGroup.OVERLAYS),
/**
* Default content of the email when requesting for an account in the system.
*/
REQUEST_ACCOUNT_DEFAULT_CONTENT("Email content used for requesting an account",
"Dear Disease map team,\nI would like to request an account in the system.\nKind regards",
ConfigurationElementEditType.TEXT, false),
ConfigurationElementEditType.TEXT, false, ConfigurationElementTypeGroup.EMAIL_NOTIFICATION),
DEFAULT_VIEW_PROJECT("Default user privilege for: " + PrivilegeType.VIEW_PROJECT.getCommonName(), "true",
ConfigurationElementEditType.BOOLEAN, true),
ConfigurationElementEditType.BOOLEAN, true, ConfigurationElementTypeGroup.DEFAULT_USER_PRIVILEGES),
DEFAULT_EDIT_COMMENTS_PROJECT("Default user privilege for: " + PrivilegeType.EDIT_COMMENTS_PROJECT.getCommonName(),
"false", ConfigurationElementEditType.BOOLEAN, true),
"false", ConfigurationElementEditType.BOOLEAN, true, ConfigurationElementTypeGroup.DEFAULT_USER_PRIVILEGES),
DEFAULT_LAYOUT_MANAGEMENT("Default user privilege for: " + PrivilegeType.LAYOUT_MANAGEMENT.getCommonName(), "false",
ConfigurationElementEditType.BOOLEAN, true),
ConfigurationElementEditType.BOOLEAN, true, ConfigurationElementTypeGroup.DEFAULT_USER_PRIVILEGES),
;
......@@ -181,6 +204,7 @@ public enum ConfigurationElementType {
private ConfigurationElementEditType editType = null;
private boolean serverSide = true;
private ConfigurationElementTypeGroup group = null;
/**
* Default constructor.
......@@ -193,11 +217,12 @@ public enum ConfigurationElementType {
* default value assigned to this parameter
*/
ConfigurationElementType(String commonName, String defaultVal, ConfigurationElementEditType editType,
boolean serverSide) {
boolean serverSide, ConfigurationElementTypeGroup group) {
this.defaultValue = defaultVal;
this.commonName = commonName;
this.editType = editType;
this.serverSide = serverSide;
this.group = group;
}
/**
......@@ -232,13 +257,7 @@ public enum ConfigurationElementType {
return serverSide;
}
/**
* @param serverSide
* the serverSide to set
* @see #serverSide
*/
public void setServerSide(boolean serverSide) {
this.serverSide = serverSide;
public ConfigurationElementTypeGroup getGroup() {
return group;
}
}
package lcsb.mapviewer.model.user;
public enum ConfigurationElementTypeGroup {
EMAIL_NOTIFICATION("Email notification details"), //
DEFAULT_USER_PRIVILEGES("Default user privileges"), //
LEGEND_AND_LOGO("Legend and logo"), //
OVERLAYS("Overlays"), //
POINT_AND_CLICK("Point and click"), //
SERVER_CONFIGURATION("Server configuration"),//
;
private String commonName;
ConfigurationElementTypeGroup(String commonName) {
this.commonName = commonName;
}
public String getCommonName() {
return commonName;
}
public void setCommonName(String commonName) {
this.commonName = commonName;
}
}
package lcsb.mapviewer.services.view;
package lcsb.mapviewer.model.user;
import java.io.Serializable;
import lcsb.mapviewer.model.user.Configuration;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* View representation of the Configuration element.
* This class represents one configurable parameter of the system.
*
* @author Piotr Gawron
*
* @see Configuration
*
*/
public class ConfigurationView extends AbstractView<Configuration> implements Serializable {
@Entity
@Table(name = "configuration_table")
public class ConfigurationOption implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Unique identifier in the database.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private int id;
/**
* Type of the configuration element.
*/
private ConfigurationElementType type;
/**
* Value of the configuration parameter.
* What is the value of the configuration parameter.
*/
private String value;
private String valueType;
private String commonName;
/**
* Default constructor which creates View for the object given in the parameter.
*
* @param configuration
* object for which we are interested in the view
* @return the id
* @see #id
*/
protected ConfigurationView(Configuration configuration) {
super(configuration);
public int getId() {
return id;
}
/**
* Default constructor. Should be used only for deserialization.
* @param id
* the id to set