diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java index 13aac7e4274322704c0f9a06b4f4c245a59a844d..af923b647b8791a013b4a3e7c532d40c9e38c870 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java @@ -1,9 +1,17 @@ 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()))); + } + } diff --git a/frontend-js/.gitignore b/frontend-js/.gitignore index 23ccee19c2ced758953730bdbcbebf2b33922f62..6e21c03544a53f12f08700ccbb114dfbebe1e590 100644 --- a/frontend-js/.gitignore +++ b/frontend-js/.gitignore @@ -1,3 +1,4 @@ +.idea/workspace.xml /dist/ /coverage/ /node_modules/ diff --git a/frontend-js/.idea/dictionaries/piotr_gawron.xml b/frontend-js/.idea/dictionaries/piotr_gawron.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a8c909a47f60a556bc261805af778533e72b7eb --- /dev/null +++ b/frontend-js/.idea/dictionaries/piotr_gawron.xml @@ -0,0 +1,7 @@ +<component name="ProjectDictionaryState"> + <dictionary name="piotr.gawron"> + <words> + <w>mailto</w> + </words> + </dictionary> +</component> \ No newline at end of file diff --git a/frontend-js/.idea/frontend-js.iml b/frontend-js/.idea/frontend-js.iml new file mode 100644 index 0000000000000000000000000000000000000000..24643cc37449b4bde54411a80b8ed61258225e34 --- /dev/null +++ b/frontend-js/.idea/frontend-js.iml @@ -0,0 +1,12 @@ +<?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 diff --git a/frontend-js/.idea/modules.xml b/frontend-js/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..45e3bd378c0fc59f695ea33bf88ea0ebcc9a62e4 --- /dev/null +++ b/frontend-js/.idea/modules.xml @@ -0,0 +1,8 @@ +<?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 diff --git a/frontend-js/.idea/vcs.xml b/frontend-js/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/frontend-js/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?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 diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index e51c5b6b697fda9026ec54db304a36b194e7ae37..f89dd7c10d0586264413dd6af7eb1b8bb62be362 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -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"); diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 1d695eb8d60441c00c48f96b1984d63e8f32443a..8e87692ac119f866cd3cd88cbddd4783c1dfafba 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -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 })); diff --git a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js index cf773acd3bffa346f359b3b7b75b89102a20e36d..b927d2f85c6f1c5f9d805c9c5a3be02ef977161e 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js @@ -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); diff --git a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js index 855cfaf57098be11362c6b25bdce273ca7284d77..429bdcefdce76ad0001a49971eeffe5da7a15c4a 100644 --- a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js @@ -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); } }); } diff --git a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js index 391ba195a7ff15e8676951f8a6988cb737df3f14..5ff245cadc646b741cccc4ef4f5858702a6c7457 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js @@ -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'> ", + type: "span", + content: "<i class='fa fa-list'> ", })); projectPublicationsButton.appendChild(projectPublicationsText); projectPublicationsButton.appendChild(Functions.createElement({ - type : "span", - style : "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", - content : " publication(s)", + type: "span", + style: "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", + content: " 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'> source file", + type: "a", + name: "projectOriginalFileButton", + href: "#", + content: "<i class='fa fa-files-o'> 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", - href : ServerConnector.getServerBaseUrl() + "/export.xhtml?id=" + projectId, - content : '<i class="fa fa-mail-forward"> EXPORT', + type: "a", + href: ServerConnector.getServerBaseUrl() + "/export.xhtml?id=" + projectId, + content: '<i class="fa fa-mail-forward"> EXPORT', }); liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px", + type: "li", + style: "line-height: 30px", }); liElement.appendChild(exportButton); dataTab.appendChild(liElement); var manualButton = Functions.createElement({ - type : "a", - name : "manualLink", - content : '<i class="fa fa-file"> MANUAL', + type: "a", + name: "manualLink", + content: '<i class="fa fa-file"> MANUAL', }); manualButton.href = "#"; - manualButton.onclick = function() { - return ServerConnector.getConfigurationParam(ConfigurationType.USER_MANUAL_FILE).then(function(manualFileUrl) { + manualButton.onclick = function () { + return ServerConnector.getConfigurationParam(ConfigurationType.USER_MANUAL_FILE).then(function (manualFileUrl) { var win = window.open(manualFileUrl, '_user_manual_'); win.focus(); }); }; liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px", + type: "li", + style: "line-height: 30px", }); liElement.appendChild(manualButton); dataTab.appendChild(liElement); }; -ProjectInfoPanel.prototype._createInfoPanelLogic = function() { +ProjectInfoPanel.prototype._createInfoPanelLogic = function () { var self = this; var downloadSourceButton = self.getControlElement(PanelControlElementType.INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON); var showPublicationsButton = self.getControlElement(PanelControlElementType.INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON); - downloadSourceButton.onclick = function() { + downloadSourceButton.onclick = function () { return self.downloadSourceFile(); }; - showPublicationsButton.onclick = function() { + showPublicationsButton.onclick = function () { return self.showPublicationListDialog(); }; }; -ProjectInfoPanel.prototype.downloadSourceFile = function() { +ProjectInfoPanel.prototype.downloadSourceFile = function () { var self = this; - return ServerConnector.getProjectSourceDownloadUrl().then(function(url) { + return ServerConnector.getProjectSourceDownloadUrl().then(function (url) { return self.downloadFile(url); }).then(null, GuiConnector.alert); }; -ProjectInfoPanel.prototype.showPublicationListDialog = function() { +ProjectInfoPanel.prototype.showPublicationListDialog = function () { return this.publicationListDialog.show(); }; -ProjectInfoPanel.prototype.refresh = function() { +ProjectInfoPanel.prototype.refresh = function () { var self = this; var projectNameText = self.getControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT); @@ -224,123 +224,124 @@ ProjectInfoPanel.prototype.refresh = function() { var projectDescriptionText = self.getControlElement(PanelControlElementType.INFO_PROJECT_DESCRIOPTION_TEXT); var projectPublicationsText = self.getControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT); - return ServerConnector.getProject().then(function(project) { + return ServerConnector.getProject().then(function (project) { projectNameText.innerHTML = project.getName(); projectVersionText.innerHTML = project.getVersion(); projectDescriptionText.innerHTML = project.getDescription(); return ServerConnector.getProjectStatistics(); - }).then(function(statistics) { + }).then(function (statistics) { projectPublicationsText.innerHTML = statistics.getPublicationCount(); return ServerConnector.getLoggedUser(); - }).then(function(user) { + }).then(function (user) { self.showUserProfilePage(user); }); }; -ProjectInfoPanel.prototype._createUserDataTab = function() { +ProjectInfoPanel.prototype._createUserDataTab = function () { var self = this; var guiUtils = self.getGuiUtils(); var userDataDiv = Functions.createElement({ - type : "div", - name : "userDataTab", - className : "searchPanel", - style : "display:none" + type: "div", + name: "userDataTab", + className: "searchPanel", + style: "display:none" }); this.getElement().appendChild(userDataDiv); this.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); var userDataTitle = Functions.createElement({ - type : "h3", - content : '<img src="./resources/images/profile.png" border="0" align="left"/><br/>User data<br/>' + type: "h3", + content: '<img src="./resources/images/profile.png" border="0" align="left"/><br/>User data<br/>' }); userDataDiv.appendChild(userDataTitle); var userDataFormTab = Functions.createElement({ - type : "div", - style : "width:100%;display: table;border-spacing: 10px;" + type: "div", + style: "width:100%;display: table;border-spacing: 10px;" }); userDataDiv.appendChild(userDataFormTab); var loginLabel = Functions.createElement({ - type : "span", - content : "LOGIN:", - style : "color:#999999" + type: "span", + content: "LOGIN:", + style: "color:#999999" }); var loginText = Functions.createElement({ - type : "span", - name : "loginValue" + type: "span", + name: "loginValue" }); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_TEXT, loginText); - userDataDiv.appendChild(guiUtils.createTableRow([ loginLabel, loginText ])); + userDataDiv.appendChild(guiUtils.createTableRow([loginLabel, loginText])); var nameLabel = Functions.createElement({ - type : "span", - content : "NAME:", - style : "color:#999999" + type: "span", + content: "NAME:", + style: "color:#999999" }); var nameText = Functions.createElement({ - type : "span", - name : "nameValue" + type: "span", + name: "nameValue" }); this.setControlElement(PanelControlElementType.USER_TAB_NAME_TEXT, nameText); - userDataDiv.appendChild(guiUtils.createTableRow([ nameLabel, nameText ])); + userDataDiv.appendChild(guiUtils.createTableRow([nameLabel, nameText])); var surnameLabel = Functions.createElement({ - type : "span", - content : "SURNAME:", - style : "color:#999999" + type: "span", + content: "SURNAME:", + style: "color:#999999" }); var surnameText = Functions.createElement({ - type : "span", - name : "surnameValue" + type: "span", + name: "surnameValue" }); this.setControlElement(PanelControlElementType.USER_TAB_SURNAME_TEXT, surnameText); - userDataDiv.appendChild(guiUtils.createTableRow([ surnameLabel, surnameText ])); + userDataDiv.appendChild(guiUtils.createTableRow([surnameLabel, surnameText])); var emailLabel = Functions.createElement({ - type : "span", - content : "EMAIL:", - style : "color:#999999" + type: "span", + content: "EMAIL:", + style: "color:#999999" }); var emailText = Functions.createElement({ - type : "span", - name : "emailValue" + type: "span", + name: "emailValue" }); self.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText); - userDataDiv.appendChild(guiUtils.createTableRow([ emailLabel, emailText ])); + userDataDiv.appendChild(guiUtils.createTableRow([emailLabel, emailText])); var centerTag = Functions.createElement({ - type : "center" + type: "center" }); userDataDiv.appendChild(centerTag); var logoutButton = Functions.createElement({ - type : "button", - name : "logoutButton", - content : "LOGOUT" + type: "button", + name: "logoutButton", + content: "LOGOUT" }); centerTag.appendChild(logoutButton); self.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton); self.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); var loginTabDiv = Functions.createElement({ - type : "div", - name : "userLoginTab", - className : "searchPanel", - style : "display:none", - content : '<h3><img src="./resources/images/profile.png" border="0" align="left"/>' - + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.<br/>' + '<center><button>LOGIN</button></center>', - }); - $(loginTabDiv).find("button")[0].onclick = function() { + type: "div", + name: "userLoginTab", + className: "searchPanel", + style: "display:none", + content: '<h3><img src="./resources/images/profile.png" border="0" align="left"/>' + + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.<br/>' + '<center><button>LOGIN</button></center>' + + '<br/><a hreg="#" name="requestAccount">Request an account</a>', + }); + $(loginTabDiv).find("button")[0].onclick = function () { return self.getParent().getLoginDialog().open(); }; - + self.getElement().appendChild(loginTabDiv); self.setControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV, loginTabDiv); }; -ProjectInfoPanel.prototype.showUserProfilePage = function(user) { +ProjectInfoPanel.prototype.showUserProfilePage = function (user) { var self = this; var userDataTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_USER_DIV); @@ -365,8 +366,13 @@ ProjectInfoPanel.prototype.showUserProfilePage = function(user) { } }; -ProjectInfoPanel.prototype.init = function() { - return this.refresh(); +ProjectInfoPanel.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"); + return self.refresh(); + }); }; module.exports = ProjectInfoPanel;