Commit 96b3d0c1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '203-test-issues' into 'master'

Resolve "test issues"

Closes #203

See merge request !109
parents 4ecece8f ebfac381
"use strict";
var ConfigurationType = {
DEFAULT_MAP : "DEFAULT_MAP",
GOOGLE_ANALYTICS_IDENTIFIER : "GOOGLE_ANALYTICS_IDENTIFIER",
LOGO_IMG : "LOGO_IMG",
LOGO_LINK : "LOGO_LINK",
LEGEND_FILES : "LEGEND_FILES",
MIN_COLOR_VAL : "MIN_COLOR_VAL",
MAX_COLOR_VAL : "MAX_COLOR_VAL",
SIMPLE_COLOR_VAL : "SIMPLE_COLOR_VAL",
SEARCH_DISTANCE : "SEARCH_DISTANCE",
USER_MANUAL_FILE : "USER_MANUAL_FILE",
DEFAULT_MAP: "DEFAULT_MAP",
GOOGLE_ANALYTICS_IDENTIFIER: "GOOGLE_ANALYTICS_IDENTIFIER",
LOGO_IMG: "LOGO_IMG",
LOGO_LINK: "LOGO_LINK",
LEGEND_FILES: "LEGEND_FILES",
MIN_COLOR_VAL: "MIN_COLOR_VAL",
MAX_COLOR_VAL: "MAX_COLOR_VAL",
REQUEST_ACCOUNT_EMAIL: "REQUEST_ACCOUNT_EMAIL",
SIMPLE_COLOR_VAL: "SIMPLE_COLOR_VAL",
SEARCH_DISTANCE: "SEARCH_DISTANCE",
USER_MANUAL_FILE: "USER_MANUAL_FILE",
};
module.exports = ConfigurationType;
This diff is collapsed.
......@@ -85,6 +85,8 @@ CommentDialog.prototype._createGui = function() {
pinnedLabel.innerHTML = "Pinned";
var pinnedCheckbox = document.createElement('input');
pinnedCheckbox.type = "checkbox";
pinnedCheckbox.checked = "checked";
table.appendChild(createRow([ pinnedLabel, pinnedCheckbox ]));
this.setPinnedCheckbox(pinnedCheckbox);
......
......@@ -6,6 +6,7 @@ var AbstractGuiElement = require('./AbstractGuiElement');
var GuiConnector = require('../GuiConnector');
var InvalidCredentialsError = require('../InvalidCredentialsError');
var PanelControlElementType = require('./PanelControlElementType');
var ConfigurationType = require("../ConfigurationType");
var Functions = require('../Functions');
var logger = require('../logger');
......@@ -15,18 +16,18 @@ function LoginDialog(params) {
var self = this;
self._createLoginTab();
$(self.getElement()).dialog({
autoOpen : false,
resizable : false,
autoOpen: false,
resizable: false,
});
var loginButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON);
loginButton.onclick = function() {
loginButton.onclick = function () {
var login = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT).value;
var password = self.getControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT).value;
return ServerConnector.login(login, password).then(function() {
return ServerConnector.login(login, password).then(function () {
window.location.reload(false);
}).then(null, function(error) {
}).then(null, function (error) {
if (error instanceof InvalidCredentialsError) {
GuiConnector.alert("invalid credentials");
} else {
......@@ -40,16 +41,16 @@ function LoginDialog(params) {
LoginDialog.prototype = Object.create(AbstractGuiElement.prototype);
LoginDialog.prototype.constructor = LoginDialog;
LoginDialog.prototype.createTableRow = function(elements) {
LoginDialog.prototype.createTableRow = function (elements) {
var row = Functions.createElement({
type : "div",
style : "display: table-row;"
type: "div",
style: "display: table-row;"
});
for (var i = 0; i < elements.length; i++) {
var cell = Functions.createElement({
type : "div",
style : "display: table-cell;"
type: "div",
style: "display: table-cell;"
});
cell.appendChild(elements[i]);
row.appendChild(cell);
......@@ -57,65 +58,81 @@ LoginDialog.prototype.createTableRow = function(elements) {
return row;
};
LoginDialog.prototype._createLoginTab = function() {
LoginDialog.prototype._createLoginTab = function () {
var self = this;
var authorizationFormTab = Functions.createElement({
type : "div",
style : "width:100%;display: table;border-spacing: 10px;"
type: "div",
style: "width:100%;display: table;border-spacing: 10px;"
});
this.getElement().appendChild(authorizationFormTab);
var loginLabel = Functions.createElement({
type : "div",
content : "LOGIN:"
type: "div",
content: "LOGIN:"
});
var loginInput = Functions.createElement({
type : "input",
inputType : "text",
style : "width:100%",
name : "loginText"
type: "input",
inputType: "text",
style: "width:100%",
name: "loginText"
});
this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT, loginInput);
authorizationFormTab.appendChild(self.createTableRow([ loginLabel, loginInput ]));
authorizationFormTab.appendChild(self.createTableRow([loginLabel, loginInput]));
var passwordLabel = Functions.createElement({
type : "div",
content : "PASSWORD:"
type: "div",
content: "PASSWORD:"
});
var passwordInput = Functions.createElement({
type : "input",
inputType : "password",
style : "width:100%",
name : "passwordText"
type: "input",
inputType: "password",
style: "width:100%",
name: "passwordText"
});
this.setControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT, passwordInput);
authorizationFormTab.appendChild(self.createTableRow([ passwordLabel, passwordInput ]));
authorizationFormTab.appendChild(self.createTableRow([passwordLabel, passwordInput]));
var centerTag = Functions.createElement({
type : "center"
type: "center"
});
this.getElement().appendChild(centerTag);
var loginButton = Functions.createElement({
type : "button",
name : "loginButton",
content : "LOGIN"
type: "button",
name: "loginButton",
content: "LOGIN"
});
centerTag.appendChild(loginButton);
this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON, loginButton);
this.getElement().appendChild(Functions.createElement({type: "br"}));
this.getElement().appendChild(Functions.createElement({
type: "a",
name: "requestAccount",
content: "Request an account",
href: "#",
}));
};
LoginDialog.prototype.init = function () {
var self = this;
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (value) {
var link = $("[name=requestAccount]", self.getElement());
link.attr("href", "mailto:" + value + "?subject=MINERVA account request");
});
};
LoginDialog.prototype.open = function() {
LoginDialog.prototype.open = function () {
var self = this;
$(self.getElement()).dialog('option', 'title', 'AUTHORIZATION FORM');
$(self.getElement()).dialog("open");
};
LoginDialog.prototype.destroy = function() {
LoginDialog.prototype.destroy = function () {
$(this.getElement()).dialog("destroy");
};
......
......@@ -151,6 +151,7 @@ LeftPanel.prototype.init = function() {
resolve();
});
promises.push(initEvents);
promises.push(self.getLoginDialog().init());
return Promise.all(promises);
};
......@@ -185,7 +186,8 @@ LeftPanel.prototype.showElementDetails = function(element) {
if (element !== undefined && (openTabName.indexOf("SEARCH") === -1 || searchTabName !== "GENERIC")) {
var model = self.getMap().getSubmapById(element.getModelId()).getModel();
return model.getByIdentifiedElement(element, true).then(function(bioEntity) {
div.innerHTML = self.prepareElementDetailsContent(bioEntity).innerHTML;
div.innerHTML ="";
div.appendChild(self.prepareElementDetailsContent(bioEntity));
$(div).dialog("open");
$(div).dialog("option", "title", self.getElementTitle(bioEntity));
$(div).scrollTop(0);
......
......@@ -27,7 +27,7 @@ MiRnaPanel.prototype.createPreamble = function(miRna) {
result.appendChild(guiUtils.createLabel("NOT FOUND"));
} else {
var line = document.createElement("div");
line.appendChild(guiUtils.createLabel("&mu;Rna: "));
line.appendChild(guiUtils.createLabel("MiRNA: "));
line.appendChild(guiUtils.createLink("http://www.mirbase.org/cgi-bin/mirna_entry.pl?acc=" + miRna.getName(), miRna
.getName()));
line.appendChild(guiUtils.createNewLine());
......
......@@ -16,8 +16,8 @@ function OverlayPanel(params) {
params.panelName = "overlays";
params.scrollable = true;
params.helpTip = "<p>Overlays tab allows to display or generate custom coloring of elements and interactions in the map.</p>"
+ "<p>General overlays are overlays accessible for every user viewing the content.</p>"
+ "<p>Custom overlays are user-provided overlays, this menu becomes available upon login (see below).</p>";
+ "<p>General overlays are overlays accessible for every user viewing the content.</p>"
+ "<p>Custom overlays are user-provided overlays, this menu becomes available upon login (see below).</p>";
Panel.call(this, params);
var self = this;
......@@ -26,7 +26,7 @@ function OverlayPanel(params) {
var addButton = this.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON);
addButton.onclick = function() {
addButton.onclick = function () {
self.openAddOverlayDialog();
};
......@@ -38,70 +38,70 @@ function OverlayPanel(params) {
OverlayPanel.prototype = Object.create(Panel.prototype);
OverlayPanel.prototype.constructor = OverlayPanel;
OverlayPanel.prototype._createOverlayPanelGui = function() {
OverlayPanel.prototype._createOverlayPanelGui = function () {
var generalOverlaysDiv = Functions.createElement({
type : "div",
name : "generalOverlays",
className : "searchPanel"
type: "div",
name: "generalOverlays",
className: "searchPanel"
});
this.getElement().appendChild(generalOverlaysDiv);
this.setControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_DIV, generalOverlaysDiv);
var generalOverlaysTitle = Functions.createElement({
type : "h5",
content : "GENERAL OVERLAYS:"
type: "h5",
content: "GENERAL OVERLAYS:"
});
generalOverlaysDiv.appendChild(generalOverlaysTitle);
var generalOverlaysTableDiv = Functions.createElement({
type : "table",
name : "generalOverlaysTab",
className : "table table-bordered",
style : "width:100%"
type: "table",
name: "generalOverlaysTab",
className: "table table-bordered",
style: "width:100%"
});
generalOverlaysDiv.appendChild(generalOverlaysTableDiv);
this.setControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE, generalOverlaysTableDiv);
var customOverlaysDiv = Functions.createElement({
type : "div",
name : "customOverlays",
className : "searchPanel"
type: "div",
name: "customOverlays",
className: "searchPanel"
});
this.getElement().appendChild(customOverlaysDiv);
this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_DIV, customOverlaysDiv);
var customOverlaysTitle = Functions.createElement({
type : "h5",
name : "customOverlaysTitle",
content : "USER-PROVIDED OVERLAYS:"
type: "h5",
name: "customOverlaysTitle",
content: "USER-PROVIDED OVERLAYS:"
});
customOverlaysDiv.appendChild(customOverlaysTitle);
this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE, customOverlaysTitle);
var customOverlaysTableDiv = Functions.createElement({
type : "table",
name : "customOverlaysTab",
className : "table table-bordered",
style : "width:100%"
type: "table",
name: "customOverlaysTab",
className: "table table-bordered",
style: "width:100%"
});
customOverlaysDiv.appendChild(customOverlaysTableDiv);
this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE, customOverlaysTableDiv);
var centerTag = Functions.createElement({
type : "center"
type: "center"
});
customOverlaysDiv.appendChild(centerTag);
var addOverlayButton = Functions.createElement({
type : "button",
name : "addOverlay",
content : "Add overlay"
type: "button",
name: "addOverlay",
content: "Add overlay"
});
centerTag.appendChild(addOverlayButton);
this.setControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON, addOverlayButton);
};
OverlayPanel.prototype.clear = function() {
OverlayPanel.prototype.clear = function () {
var table = this.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
while (table.firstChild) {
table.removeChild(table.firstChild);
......@@ -114,7 +114,7 @@ OverlayPanel.prototype.clear = function() {
};
OverlayPanel.prototype.createTableHeader = function(edit) {
OverlayPanel.prototype.createTableHeader = function (edit) {
var result = document.createElement("thead");
var row = document.createElement("tr");
......@@ -141,7 +141,7 @@ OverlayPanel.prototype.createTableHeader = function(edit) {
return result;
};
OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
OverlayPanel.prototype.createOverlayRow = function (overlay, checked) {
var self = this;
var guiUtils = self.getGuiUtils();
var result = document.createElement("tr");
......@@ -159,7 +159,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
var checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = checked;
checkbox.onclick = function() {
checkbox.onclick = function () {
if (this.checked) {
return self.getMap().openDataOverlay(overlay.getId()).then(null, GuiConnector.alert);
} else {
......@@ -171,7 +171,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
var img = guiUtils.createIcon("icons/search.png");
var link = document.createElement("a");
link.href = "#";
link.onclick = function() {
link.onclick = function () {
self.getMap().openDataOverlay(overlay.getId());
$(result).addClass('active').siblings().removeClass('active');
};
......@@ -184,10 +184,10 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
if (overlay.getInputDataAvailable()) {
var button = document.createElement("button");
button.setAttribute("name", "download-overlay-" + overlay.getId());
button.onclick = function() {
button.onclick = function () {
return ServerConnector.getOverlaySourceDownloadUrl({
overlayId : overlay.getId()
}).then(function(url) {
overlayId: overlay.getId()
}).then(function (url) {
return self.downloadFile(url);
}).then(null, GuiConnector.alert);
};
......@@ -201,7 +201,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
var editTd = document.createElement("td");
var editButton = document.createElement("button");
editButton.setAttribute("name", "editButton");
editButton.onclick = function() {
editButton.onclick = function () {
self.openEditOverlayDialog(overlay);
};
editButton.innerHTML = "<span class='ui-icon ui-icon-document'></span>";
......@@ -212,147 +212,147 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) {
return result;
};
OverlayPanel.prototype.openEditOverlayDialog = function(overlay) {
OverlayPanel.prototype.openEditOverlayDialog = function (overlay) {
var self = this;
var guiUtils = self.getGuiUtils();
var content = document.createElement("fieldset");
var nameInput = guiUtils.createInputText(overlay.getName());
var row = guiUtils.createTableRow([ guiUtils.createLabel("Name: "), nameInput ]);
var row = guiUtils.createTableRow([guiUtils.createLabel("Name: "), nameInput]);
content.appendChild(row);
var descriptionInput = guiUtils.createTextArea(overlay.getDescription());
row = guiUtils.createTableRow([ guiUtils.createLabel("Description: "), descriptionInput ]);
row = guiUtils.createTableRow([guiUtils.createLabel("Description: "), descriptionInput]);
content.appendChild(row);
var buttons = [ {
text : "SAVE",
click : function() {
var buttons = [{
text: "SAVE",
click: function () {
var windowSelf = this;
return ServerConnector.updateOverlay({
overlayId : overlay.id,
name : nameInput.value,
description : descriptionInput.value
}).then(function() {
overlayId: overlay.id,
name: nameInput.value,
description: descriptionInput.value
}).then(function () {
return self.refresh();
}).then(function() {
}).then(function () {
$(windowSelf).dialog("close");
}).then(null, GuiConnector.alert);
}
}, {
text : "REMOVE",
click : function() {
text: "REMOVE",
click: function () {
self.getMap().removeSelectedLayout(overlay.getId());
var windowSelf = this;
return ServerConnector.removeOverlay({
overlayId : overlay.getId()
}).then(function() {
overlayId: overlay.getId()
}).then(function () {
return self.refresh();
}).then(function() {
}).then(function () {
$(windowSelf).dialog("close");
}).then(null, GuiConnector.alert);
}
}, {
text : "CANCEL",
click : function() {
text: "CANCEL",
click: function () {
$(this).dialog("close");
}
} ];
}];
self.openDialog(content, {
id : overlay.getId(),
buttons : buttons,
title : "Data overlay: " + overlay.getName(),
className : "minerva-overlay-dialog",
id: overlay.getId(),
buttons: buttons,
title: "Data overlay: " + overlay.getName(),
className: "minerva-overlay-dialog",
});
};
OverlayPanel.prototype.refresh = function() {
OverlayPanel.prototype.refresh = function () {
var self = this;
var user = null;
var overlayTypes = [];
var selectedOverlay = [];
return ServerConnector.getOverlayTypes().then(function(types) {
return ServerConnector.getOverlayTypes().then(function (types) {
overlayTypes = types;
return ServerConnector.getLoggedUser();
}).then(function(loggedUser) {
}).then(function (loggedUser) {
user = loggedUser;
return self.getMap().getVisibleDataOverlays();
}).then(function(visibleDataOverlays) {
}).then(function (visibleDataOverlays) {
for (var j = 0; j < visibleDataOverlays.length; j++) {
selectedOverlay[visibleDataOverlays[j].getId()] = true;
}
return ServerConnector.getOverlays();
}).then(
function(customOverlays) {
function (customOverlays) {
var id = self.getMap().getGoogleMap().getMapTypeId().substring(2);
selectedOverlay[id] = true;
var id = self.getMap().getGoogleMap().getMapTypeId().substring(2);
selectedOverlay[id] = true;
self.clear();
self.clear();
var generalOverlays = [];
var overlay;
var generalOverlays = [];
var overlay;
var overlays = self.getMap().getLayouts();
for (var i = 0; i < overlays.length; i++) {
overlay = overlays[i];
if (overlay.getCreator() === undefined || overlay.getCreator() === "") {
generalOverlays.push(overlay);
}
var overlays = self.getMap().getLayouts();
for (var i = 0; i < overlays.length; i++) {
overlay = overlays[i];
if (overlay.getCreator() === undefined || overlay.getCreator() === "") {
generalOverlays.push(overlay);
}
}
var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
table.appendChild(self.createTableHeader());
var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
table.appendChild(self.createTableHeader());
var body = document.createElement("tbody");
table.appendChild(body);
for (i = 0; i < generalOverlays.length; i++) {
overlay = generalOverlays[i];
body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()]));
}
var body = document.createElement("tbody");
table.appendChild(body);
for (i = 0; i < generalOverlays.length; i++) {
overlay = generalOverlays[i];
body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()]));
}
var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE);
var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON);
if (user.getLogin() === "anonymous") {
title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>'
+ 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>';
var openLoginDialog = function() {
return self.getParent().getLoginDialog().open();
};
$(title).find("a")[0].onclick = openLoginDialog;
$(title).find("button")[0].onclick = openLoginDialog;
addButton.style.display = "none";
} else {
title.innerHTML = self.getCustomOverlaysMessage();
addButton.style.display = "block";
var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE);
var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON);
if (user.getLogin() === "anonymous") {
title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>'
+ 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>';
var openLoginDialog = function () {
return self.getParent().getLoginDialog().open();
};
$(title).find("a")[0].onclick = openLoginDialog;
$(title).find("button")[0].onclick = openLoginDialog;
addButton.style.display = "none";