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

Merge branch '204-uploading-of-data-overlay-fails' into 'master'

uploading of big data overlay gives proper error message

See merge request !110
parents 96b3d0c1 ca1b6c27
package lcsb.mapviewer.converter.graphics;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import lcsb.mapviewer.commands.ColorExtractor;
......@@ -37,4 +45,42 @@ public class ConverterTest {
}
}
@Test
@Ignore("it's just code for generating scale")
public void testX() throws IOException {
BufferedImage tmpBI = new BufferedImage(900, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D tmpGraphics = tmpBI.createGraphics();
int startX = 10;
int startY = 15;
int stepSize = 40;
int height = 25;
tmpGraphics.setColor(Color.BLACK);
for (int i = 0; i < 21; i++) {
tmpGraphics.drawLine(startX + i * stepSize, height+startY, startX + i * stepSize, height*2);
String str = ""+((double)(i-10))/((double)(10));
tmpGraphics.drawString(str, startX + i * stepSize, height*2+startY);
}
for (int i = 0; i < 10 * stepSize; i++) {
double ratio = ((double) i) / ((double) (10 * stepSize));
tmpGraphics.setBackground(getColor(ratio, Color.BLUE, Color.WHITE));
tmpGraphics.setColor(getColor(ratio, Color.BLUE, Color.WHITE));
tmpGraphics.drawRect(startX + i, startY , 1, height);
}
for (int i = 0; i < 10 * stepSize; i++) {
double ratio = ((double) i) / ((double) (10 * stepSize));
tmpGraphics.setBackground(getColor(ratio, Color.WHITE, Color.RED));
tmpGraphics.setColor(getColor(ratio, Color.WHITE, Color.RED));
tmpGraphics.drawRect(10 * stepSize + startX + i, startY , 1, height);
}
ImageIO.write(tmpBI, "PNG", new File("tmp.png"));
Desktop.getDesktop().open(new File("tmp.png"));
}
private Color getColor(double d, Color startColor, Color endColor) {
return new Color((int) (startColor.getRed() + d * (endColor.getRed() - startColor.getRed())), //
(int) (startColor.getGreen() + d * (endColor.getGreen() - startColor.getGreen())), //
(int) (startColor.getBlue() + d * (endColor.getBlue() - startColor.getBlue())));
}
}
.idea/workspace.xml
/dist/
/coverage/
/node_modules/
......
<component name="ProjectDictionaryState">
<dictionary name="piotr.gawron">
<words>
<w>mailto</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/frontend-js.iml" filepath="$PROJECT_DIR$/.idea/frontend-js.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -4,6 +4,7 @@ var logger = require('./logger');
var Functions = require('./Functions');
var SecurityError = require('./SecurityError');
var NetworkError = require('./NetworkError');
/**
* This static global object contains set of functions that returns/set data in
......@@ -25,11 +26,11 @@ GuiConnector.yPos = 0;
* List of GET params passed via url.
*/
GuiConnector.init = function() {
GuiConnector.init = function () {
var self = this;
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(pattern) {
String.prototype.endsWith = function (pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
};
......@@ -40,7 +41,7 @@ GuiConnector.init = function() {
alert("This webpage works well with Chrome, Firefox and Safari.");
}
// bootstrap tab initialization
$("ul.nav-tabs a").click(function(e) {
$("ul.nav-tabs a").click(function (e) {
e.preventDefault();
$(this).tab('show');
});
......@@ -48,16 +49,17 @@ GuiConnector.init = function() {
self.getParams = [];
// find GuiConnector.getParams
window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
GuiConnector.getParams[decode(arguments[1])] = decode(arguments[2]);
});
// forser browser to update mouse coordinates whenever mouse move
jQuery(document).ready(function() {
$(document).mousemove(function(e) {
jQuery(document).ready(function () {
$(document).mousemove(function (e) {
GuiConnector.updateMouseCoordinates(e.pageX, e.pageY);
});
});
......@@ -69,7 +71,7 @@ GuiConnector.init = function() {
self.addWindowResizeEvent(window.onresize);
}
window.onresize = function() {
window.onresize = function () {
for (var i = 0; i < self._windowResizeEvents.length; i++) {
self._windowResizeEvents[i]();
}
......@@ -77,18 +79,18 @@ GuiConnector.init = function() {
}
};
GuiConnector.addWindowResizeEvent = function(handler) {
GuiConnector.addWindowResizeEvent = function (handler) {
this._windowResizeEvents.push(handler);
};
/**
* Returns name of the file with LCSB logo.
*
*
* @param bigLogo
* {@link Boolean} value determining if we want to have big logo or
* small one
*/
GuiConnector.getLcsbLogoImg = function(bigLogo) {
GuiConnector.getLcsbLogoImg = function (bigLogo) {
if (bigLogo) {
return 'lcsb_logo_mid.png';
} else {
......@@ -100,26 +102,26 @@ GuiConnector.getLcsbLogoImg = function(bigLogo) {
* Returns name of the file with image that should be presented when we are
* wainting for data to be loaded.
*/
GuiConnector.getLoadingImg = function() {
GuiConnector.getLoadingImg = function () {
return "icons/ajax-loader.gif";
};
/**
* Returns home directory for images in the application.
*/
GuiConnector.getImgPrefix = function() {
GuiConnector.getImgPrefix = function () {
return "resources/images/";
};
/**
* Updates coordinates of the mouse in the browser.
*/
GuiConnector.updateMouseCoordinates = function(x, y) {
GuiConnector.updateMouseCoordinates = function (x, y) {
this.xPos = x;
this.yPos = y;
};
GuiConnector.showProcessing = function(messageText) {
GuiConnector.showProcessing = function (messageText) {
var self = GuiConnector;
if (self._processingDialog === undefined) {
self._processingDialog = document.createElement("div");
......@@ -127,11 +129,11 @@ GuiConnector.showProcessing = function(messageText) {
self._processingDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._processingDialog);
$(self._processingDialog).dialog({
modal : true,
title : "PROCESSING",
width : "150px",
closeOnEscape : false,
open : function(event, ui) {
modal: true,
title: "PROCESSING",
width: "150px",
closeOnEscape: false,
open: function (event, ui) {
$(".ui-dialog-titlebar-close", ui).hide();
},
});
......@@ -140,8 +142,8 @@ GuiConnector.showProcessing = function(messageText) {
messageText = "PROCESSING";
}
var messageImg = Functions.createElement({
type : "img",
src : 'resources/images/icons/ajax-loader.gif',
type: "img",
src: 'resources/images/icons/ajax-loader.gif',
});
self._errorDialogContent.innerHTML = "";
self._errorDialogContent.style.textAlign = "center";
......@@ -152,12 +154,12 @@ GuiConnector.showProcessing = function(messageText) {
$(self._processingDialog).dialog("open");
};
GuiConnector.hideProcessing = function() {
GuiConnector.hideProcessing = function () {
var self = GuiConnector;
$(self._processingDialog).dialog("close");
};
GuiConnector.alert = function(error) {
GuiConnector.alert = function (error) {
var self = GuiConnector;
logger.error(error);
if (self._errorDialog === undefined) {
......@@ -166,18 +168,20 @@ GuiConnector.alert = function(error) {
self._errorDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._errorDialog);
$(self._errorDialog).dialog({
classes : {
"ui-dialog" : "ui-state-error"
classes: {
"ui-dialog": "ui-state-error"
},
modal : true,
title : "ERROR"
modal: true,
title: "ERROR"
}).siblings('.ui-dialog-titlebar').css("background", "red");
}
var message = error;
if (message instanceof SecurityError) {
message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resuorce</p>";
message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resource</p>";
} else if (message instanceof NetworkError && (error.message === "XHR error" || error.message === "Failed to fetch")) {
message = "File to big.<br>Please reduce file size or contact administrators.";
} else if (message instanceof Error) {
message = "Unexpected error occured:<p>" + error.message + "</p>";
message = "Unexpected error occurred:<p>" + error.message + "</p>";
}
self._errorDialogContent.innerHTML = message;
$(self._errorDialog).dialog("open");
......
......@@ -155,7 +155,7 @@ ServerConnector.sendPostRequest = function (url, params) {
form: params
}, function (error, response, body) {
if (error) {
reject(new NetworkError(error, {
reject(new NetworkError(error.message, {
content: body,
url: url
}));
......
......@@ -11,22 +11,25 @@ var PanelControlElementType = require('../PanelControlElementType');
function ChemicalPanel(params) {
params.panelName = "chemical";
params.helpTip = '<p>source: Comparative Toxicogenomics Database <a target="_ctd" href="http://ctdbase.org/">ctdbase.org</a></p>'
+ '<p>use only the full name of chemicals according to <a target="_ctd_chemicals" href="http://ctdbase.org/voc.go?type=chem"> ctdbase/chem</a> for search</p>'
+ '<p>only curated associations between genes and chemicals with direct evidence to '
+ 'Parkinson Disease (<a href="http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300" target="_blank">D010300</a>) are displayed</p>'
+ '<p>separate multiple search by semicolon';
+ '<p>only associations between genes and chemicals with direct evidence to '
+ 'Parkinson Disease (<a href="http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300" target="_blank">D010300</a>) are displayed</p>'
+ '<p>use only the full name of chemicals according to <a target="_ctd_chemicals" href="http://ctdbase.org/voc.go?type=chem"> ctdbase/chem</a> for search</p>'
+ 'if the chemical name includes comma(s), place a semicolon behind the name to avoid a segmentation of the name</p>'
+ '<p>separate multiple search by semicolon';
params.placeholder = "full chemical name (CTD)";
AbstractDbPanel.call(this, params);
if (this.getMap().getProject().getDisease() === undefined) {
this.disablePanel("DISEASE NOT DEFINED FOR PROJECT. PLEASE, DEFINE IT IN THE ADMIN SECTION.");
}
}
ChemicalPanel.prototype = Object.create(AbstractDbPanel.prototype);
ChemicalPanel.prototype.constructor = ChemicalPanel;
ChemicalPanel.prototype.createPreamble = function(chemical) {
ChemicalPanel.prototype.createPreamble = function (chemical) {
var self = this;
var guiUtils = self.getGuiUtils();
var result = document.createElement("div");
......@@ -37,8 +40,7 @@ ChemicalPanel.prototype.createPreamble = function(chemical) {
result.appendChild(guiUtils.createParamLine("Description: ", chemical.getDescription()));
result.appendChild(guiUtils.createArrayParamLine("Synonyms: ", chemical.getSynonyms()));
result.appendChild(guiUtils.createParamLine("Direct Evidence: ", chemical.getDirectEvidence()));
result.appendChild(guiUtils
.createAnnotations("Directe Evidence Publications: ", chemical.getDirectEvidenceReferences()));
result.appendChild(guiUtils.createAnnotations("Direct Evidence Publications: ", chemical.getDirectEvidenceReferences()));
result.appendChild(guiUtils.createAnnotations("Sources: ", chemical.getReferences()));
result.appendChild(guiUtils.createNewLine());
}
......@@ -46,18 +48,18 @@ ChemicalPanel.prototype.createPreamble = function(chemical) {
return result;
};
ChemicalPanel.prototype.createTableElement = function(target, icon) {
ChemicalPanel.prototype.createTableElement = function (target, icon) {
return this.createTargetRow(target, icon);
};
ChemicalPanel.prototype.searchByQuery = function() {
ChemicalPanel.prototype.searchByQuery = function () {
var self = this;
var query = self.getControlElement(PanelControlElementType.SEARCH_INPUT).value;
return self.getOverlayDb().searchByQuery(query);
};
ChemicalPanel.prototype.init = function() {
ChemicalPanel.prototype.init = function () {
var query = ServerConnector.getSessionData().getChemicalQuery();
if (query !== undefined) {
return this.getOverlayDb().searchByEncodedQuery(query);
......
......@@ -449,7 +449,9 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
}
}
if (fileContent === null) {
GuiConnector.alert("Neither file was selected nor data was enterd");
GuiConnector.alert("Neither file was selected nor data was entered");
} else if (fileContent.length > 1024 * 256) {
GuiConnector.alert("File to big.<br>Please reduce file size or contact administrators.");
} else {
var data = {
name: nameInput.value,
......@@ -466,15 +468,11 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
$(dialog).dialog("close");
}, function (error) {
GuiConnector.hideProcessing();
if (error instanceof NetworkError) {
if (error.statusCode === HttpStatus.BAD_REQUEST) {
var errorMessage = JSON.parse(error.content);
GuiConnector.alert("Problematic input: <br/>" + errorMessage.reason);
} else {
throw error;
}
if (error instanceof NetworkError && error.statusCode === HttpStatus.BAD_REQUEST) {
var errorMessage = JSON.parse(error.content);
GuiConnector.alert("Problematic input: <br/>" + errorMessage.reason);
} else {
throw error;
GuiConnector.alert(error);
}
});
}
......
......@@ -21,8 +21,8 @@ function ProjectInfoPanel(params) {
self._createUserDataTab();
var logoutButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON);
logoutButton.onclick = function() {
return ServerConnector.logout().then(function() {
logoutButton.onclick = function () {
return ServerConnector.logout().then(function () {
window.location.reload(false);
}).then(null, GuiConnector.alert);
};
......@@ -32,191 +32,191 @@ function ProjectInfoPanel(params) {
ProjectInfoPanel.prototype = Object.create(Panel.prototype);
ProjectInfoPanel.prototype.constructor = ProjectInfoPanel;
ProjectInfoPanel.prototype._createInfoPanelGui = function() {
ProjectInfoPanel.prototype._createInfoPanelGui = function () {
var self = this;
var guiUtils = self.getGuiUtils();
var projectId = self.getMap().getProject().getProjectId();
var infoDiv = Functions.createElement({
type : "div",
name : "infoDiv",
className : "searchPanel"
type: "div",
name: "infoDiv",
className: "searchPanel"
});
this.getElement().appendChild(infoDiv);
this.setControlElement(PanelControlElementType.INFO_DIV, infoDiv);
var infoTitle = Functions.createElement({
type : "h4",
content : "PROJECT INFO:"
type: "h4",
content: "PROJECT INFO:"
});
infoDiv.appendChild(infoTitle);
var dataTab = Functions.createElement({
type : "div",
style : "width:100%;display: table;border-spacing: 10px;"
type: "div",
style: "width:100%;display: table;border-spacing: 10px;"
});
infoDiv.appendChild(dataTab);
var projectNameLabel = Functions.createElement({
type : "div",
content : "Name:"
type: "div",
content: "Name:"
});
var projectNameText = Functions.createElement({
type : "div",
style : "width:100%",
name : "projectNameText"
type: "div",
style: "width:100%",
name: "projectNameText"
});
this.setControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT, projectNameText);
dataTab.appendChild(guiUtils.createTableRow([ projectNameLabel, projectNameText ]));
dataTab.appendChild(guiUtils.createTableRow([projectNameLabel, projectNameText]));
var projectVersionLabel = Functions.createElement({
type : "div",
content : "Version:"
type: "div",
content: "Version:"
});
var projectVersionText = Functions.createElement({
type : "div",
style : "width:100%",
name : "projectVersionText"
type: "div",
style: "width:100%",
name: "projectVersionText"
});
this.setControlElement(PanelControlElementType.INFO_PROJECT_VERSION_TEXT, projectVersionText);
dataTab.appendChild(guiUtils.createTableRow([ projectVersionLabel, projectVersionText ]));
dataTab.appendChild(guiUtils.createTableRow([projectVersionLabel, projectVersionText]));
var projectDescriptionLabel = Functions.createElement({
type : "div",
content : "Description:"
type: "div",
content: "Description:"
});
var projectDescriptionText = Functions.createElement({
type : "div",
style : "width:100%",
name : "projectDescriptionText"
type: "div",
style: "width:100%",
name: "projectDescriptionText"
});
this.setControlElement(PanelControlElementType.INFO_PROJECT_DESCRIOPTION_TEXT, projectDescriptionText);
dataTab.appendChild(guiUtils.createTableRow([ projectDescriptionLabel, projectDescriptionText ]));
dataTab.appendChild(guiUtils.createTableRow([projectDescriptionLabel, projectDescriptionText]));
infoTitle = Functions.createElement({
type : "h4",
content : "Data:"
type: "h4",
content: "Data:"
});
infoDiv.appendChild(infoTitle);
var dialogDiv = Functions.createElement({
type : "div",
type: "div",
});
this.publicationListDialog = new PublicationListDialog({
customMap : self.getMap(),
element : dialogDiv,
customMap: self.getMap(),
element: dialogDiv,
});
dataTab = Functions.createElement({
type : "ul",
type: "ul",
});
infoDiv.appendChild(dataTab);
var projectPublicationsText = Functions.createElement({
type : "span",
name : "projectPublicationsText",
style : "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer",
type: "span",
name: "projectPublicationsText",
style: "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer",
});
this.setControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT, projectPublicationsText);
var projectPublicationsButton = Functions.createElement({
type : "a",
name : "projectPublicationsButton",
type: "a",
name: "projectPublicationsButton",
});
projectPublicationsButton.appendChild(Functions.createElement({
type : "span",
content : "<i class='fa fa-list'>&nbsp;",
type: "span",
content: "<i class='fa fa-list'>&nbsp;",
}));
projectPublicationsButton.appendChild(projectPublicationsText);
projectPublicationsButton.appendChild(Functions.createElement({
type : "span",
style : "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer",
content : "&nbsp;publication(s)",
type: "span",
style: "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer",
content: "&nbsp;publication(s)",
}));
this.setControlElement(PanelControlElementType.INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON, projectPublicationsButton);
var liElement = Functions.createElement({
type : "li",
style : "line-height: 30px;",
type: "li",
style: "line-height: 30px;",
});
liElement.appendChild(projectPublicationsButton);
dataTab.appendChild(liElement);
var projectOriginalFileButton = Functions.createElement({
type : "a",
name : "projectOriginalFileButton",
href : "#",
content : "<i class='fa fa-files-o'>&nbsp;source file",
type: "a",
name: "projectOriginalFileButton",
href: "#",
content: "<i class='fa fa-files-o'>&nbsp;source file",
});
this.setControlElement(PanelControlElementType.INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON, projectOriginalFileButton);
liElement = Functions.createElement({
type : "li",
style : "line-height: 30px",
type: "li",
style: "line-height: 30px",
});
liElement.appendChild(projectOriginalFileButton);
dataTab.appendChild(liElement);
var exportButton = Functions.createElement({
type : "a",