diff --git a/frontend-js/.idea/codeStyleSettings.xml b/frontend-js/.idea/codeStyleSettings.xml index 5555dd266682059e1b1fed89915c4ef70b2bba45..2f2668eaed631cedf3c03fdeeed7683329188219 100644 --- a/frontend-js/.idea/codeStyleSettings.xml +++ b/frontend-js/.idea/codeStyleSettings.xml @@ -4,6 +4,6 @@ <option name="PER_PROJECT_SETTINGS"> <value /> </option> - <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" /> + <option name="PREFERRED_PROJECT_CODE_STYLE" value="custom" /> </component> </project> \ No newline at end of file diff --git a/frontend-js/package.json b/frontend-js/package.json index 70fa016010a68c5ad2a044c70175dfcb778f0f43..3ef40c46bae2aa51b177d90f0a69c3c9a0cb0b95 100644 --- a/frontend-js/package.json +++ b/frontend-js/package.json @@ -22,6 +22,7 @@ "browserify": "^13.1.1", "chai": "^3.5.0", "clean-css-cli": "^4.1.10", + "del": "^3.0.0", "datatables.net": "^1.10.13", "exorcist": "^0.4.0", "file-url": "^2.0.0", @@ -32,11 +33,11 @@ "jsdom-global": "^2.1.1", "jshint": "^2.9.4", "log4js-memory-appender": "1.0.5", + "mkdirp": "^0.5.1", "mocha": "^3.5.3", "uglifyjs": "^2.4.10" }, "dependencies": { - "del": "^3.0.0", "dual-listbox": "1.0.7", "file-saver": "^1.3.3", "http-status-codes": "^1.3.0", @@ -44,7 +45,6 @@ "jstree": "^3.3.4", "jszip": "^3.1.4", "log4js": "0.6.38", - "mkdirp": "^0.5.1", "pileup": "^0.6.8", "request": "^2.82.0", "spectrum-colorpicker": "^1.8.0" diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index cc14c32533d5ba85c11ecee7461efb4634030f73..234d25051aabbc24e764d6f8387c1dc0229cbed2 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -190,6 +190,10 @@ GuiConnector.prototype.alert = function (error) { message = error.message; } 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 ValidationError) { + message = error.message; + } else if (message instanceof GuiMessageError) { + message = error.message; } else if (message instanceof Error) { message = "Unexpected error occurred:<p>" + error.message + "</p>"; } diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index dc8d708a46b5b052fd52618343773250094cfbc6..3c2213a19f51780e9ee49f1a2ec5cfe540dc3338 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -628,10 +628,7 @@ ServerConnector.getUpdateUserPreferencesUrl = function (queryParams, filterParam }); }; -ServerConnector.getConfiguration = function (params) { - if (params === undefined) { - params = {}; - } +ServerConnector.getConfiguration = function () { var self = this; if (this._configuration === undefined) { return self.sendGetRequest(self.getConfigurationUrl()).then(function (content) { diff --git a/frontend-js/src/main/js/gui/AddOverlayDialog.js b/frontend-js/src/main/js/gui/AddOverlayDialog.js index 54f3352b94e30f350929feee6b25834adf469212..4697a5357ac7d584a9a14ec46f53226c6788588c 100644 --- a/frontend-js/src/main/js/gui/AddOverlayDialog.js +++ b/frontend-js/src/main/js/gui/AddOverlayDialog.js @@ -98,8 +98,8 @@ AddOverlayDialog.prototype.processFile = function (file) { if (filename.lastIndexOf("\\") >= 0) { filename = filename.substr(filename.lastIndexOf("\\") + 1); } - nameInput.value = filename; + } if (overlay.getDescription() !== undefined) { descriptionInput.value = overlay.getDescription(); diff --git a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js index cd600c7da6e948092e17b085473e11efaaecdf0a..3df5b8900852fa9044d3cdf9ab855f822f5f085b 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js @@ -18,11 +18,12 @@ function ChemicalPanel(params) { + '<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."); - } + 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); diff --git a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js index 584d8c662607ebeabdd23546c5461cb5fabb369e..5c9e715d05d5f09287cd286394ecd292476e751d 100644 --- a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js @@ -137,22 +137,22 @@ LeftPanel.prototype.init = function () { } promises.push(self.getHeader().init()); - var initEvents = new Promise(function(resolve) { - self.getMap().addListener("onBioEntityClick", function(e) { - return self.showElementDetails(e.arg); - }); - self.getMap().getOverlayByName("search").addListener("onSearch", function(e) { - if (e.arg.type === AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES) { - return self.showElementDetails(e.arg.identifiedElements[0][0]); - } else { - return self.showElementDetails(undefined); - } + var initEvents = new Promise(function (resolve) { + self.getMap().addListener("onBioEntityClick", function (e) { + return self.showElementDetails(e.arg); + }); + self.getMap().getOverlayByName("search").addListener("onSearch", function (e) { + if (e.arg.type === AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES) { + return self.showElementDetails(e.arg.identifiedElements[0][0]); + } else { + return self.showElementDetails(undefined); + } + }); + resolve(); }); - resolve(); - }); - promises.push(initEvents); + promises.push(initEvents); promises.push(self.getLoginDialog().init()); - return Promise.all(promises); + return Promise.all(promises); }; LeftPanel.prototype.showElementDetails = function (element) { @@ -183,19 +183,19 @@ LeftPanel.prototype.showElementDetails = function (element) { openTabName = undefined; } - 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) { + 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 =""; div.appendChild(self.prepareElementDetailsContent(bioEntity)); - $(div).dialog("open"); - $(div).dialog("option", "title", self.getElementTitle(bioEntity)); - $(div).scrollTop(0); - }); - } else { - $(div).dialog("close"); - return Promise.resolve(); - } + $(div).dialog("open"); + $(div).dialog("option", "title", self.getElementTitle(bioEntity)); + $(div).scrollTop(0); + }); + } else { + $(div).dialog("close"); + return Promise.resolve(); + } }; LeftPanel.prototype.prepareElementDetailsContent = function (bioEntity) { diff --git a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js index 53de4d5b1d5ad86a1c740f1b0822eb7ebdf63fbb..59a9c11b038ce6328d372d3801fa8aaa8fd67762 100644 --- a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js @@ -9,8 +9,10 @@ var PanelControlElementType = require('../PanelControlElementType'); var GuiConnector = require('../../GuiConnector'); var logger = require('../../logger'); var Functions = require('../../Functions'); +var NetworkError = require('../../NetworkError'); var Promise = require('bluebird'); +var HttpStatus = require('http-status-codes'); function OverlayPanel(params) { params.panelName = "overlays"; diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js index 1f6f2d0e3f4b2896ae4c06187518b60434210a71..d591c7171bd048347b831ba840b76be7846a0734 100644 --- a/frontend-js/src/main/js/map/data/IdentifiedElement.js +++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js @@ -104,7 +104,7 @@ IdentifiedElement.prototype.getId = function() { return this.id; }; -IdentifiedElement.prototype.setId = function (id) { +IdentifiedElement.prototype.setId = function(id) { // some elements are identified by id that is not a number (like point on the // map) if (!isNaN(id)) { @@ -154,77 +154,77 @@ IdentifiedElement.prototype.setType = function(type) { /** * Returns icon that should be used for visualization. - * + * * @returns icon that should be used for visualization */ -IdentifiedElement.prototype.getIcon = function () { +IdentifiedElement.prototype.getIcon = function() { return this._visualizationdata._icon; }; -IdentifiedElement.prototype.setIcon = function (icon) { +IdentifiedElement.prototype.setIcon = function(icon) { this._visualizationdata._icon = icon; }; -IdentifiedElement.prototype.getColor = function () { +IdentifiedElement.prototype.getColor = function() { return this._visualizationdata._color; }; -IdentifiedElement.prototype.setColor = function (color) { +IdentifiedElement.prototype.setColor = function(color) { this._visualizationdata._color = color; }; -IdentifiedElement.prototype.getOpacity = function () { +IdentifiedElement.prototype.getOpacity = function() { return this._visualizationdata._opacity; }; -IdentifiedElement.prototype.setOpacity = function (opacity) { +IdentifiedElement.prototype.setOpacity = function(opacity) { this._visualizationdata._opacity = opacity; }; -IdentifiedElement.prototype.getLineWeight = function () { +IdentifiedElement.prototype.getLineWeight = function() { return this._visualizationdata._lineWeight; }; -IdentifiedElement.prototype.setLineWeight = function (lineWeight) { +IdentifiedElement.prototype.setLineWeight = function(lineWeight) { this._visualizationdata._lineWeight = lineWeight; }; -IdentifiedElement.prototype.getLineOpacity = function () { +IdentifiedElement.prototype.getLineOpacity = function() { return this._visualizationdata._lineOpacity; }; -IdentifiedElement.prototype.setLineOpacity = function (lineOpacity) { +IdentifiedElement.prototype.setLineOpacity = function(lineOpacity) { this._visualizationdata._lineOpacity = lineOpacity; }; -IdentifiedElement.prototype.getLineColor = function () { +IdentifiedElement.prototype.getLineColor = function() { return this._visualizationdata._lineColor; }; -IdentifiedElement.prototype.setLineColor = function (lineColor) { +IdentifiedElement.prototype.setLineColor = function(lineColor) { this._visualizationdata._lineColor = lineColor; }; -IdentifiedElement.prototype.getOnClickHandler = function () { +IdentifiedElement.prototype.getOnClickHandler = function() { return this._visualizationdata._onClickHandler; }; -IdentifiedElement.prototype.setOnClickHandler = function (onClickHandler) { +IdentifiedElement.prototype.setOnClickHandler = function(onClickHandler) { this._visualizationdata._onClickHandler = onClickHandler; }; -IdentifiedElement.prototype.equals = function (argument) { +IdentifiedElement.prototype.equals = function(argument) { if (argument instanceof IdentifiedElement) { return (this.getType() === argument.getType() && // - this.getId() === argument.getId() && // - this.getModelId() === argument.getModelId()); + this.getId() === argument.getId() && // + this.getModelId() === argument.getModelId()); } else { return false; } }; -IdentifiedElement.prototype.toString = function () { +IdentifiedElement.prototype.toString = function() { var self = this; return "[" + IdentifiedElement.prototype.constructor.name + "] " + self.getType() + " " + self.getId() + " (model: " - + self.getModelId() + ")"; + + self.getModelId() + ")"; }; module.exports = IdentifiedElement; diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index 95c127229c36242afdafef77e07853eb6ee8f16a..d1f21cb4f60e9be6561da22e8d800396e190b7f0 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -114,7 +114,7 @@ describe('CustomMap', function () { }); }); - it("simple", function() { + it("simple", function () { var map = helper.createCustomMap(); var alias = helper.createAlias(map); map.getModel().addAlias(alias); diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index b80acc556ca188d5862bb04baafab05ba8b1a196..fb1152a76f8bc55fadca05d49e3a12a0e700b2ed 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -395,26 +395,26 @@ describe('minerva global', function () { }); }); - it("setCenter", function() { + it("setCenter", function () { var options = { - projectId : "sample", - element : testDiv + projectId: "sample", + element: testDiv }; var globalResult; - return minerva.create(options).then(function(result) { + return minerva.create(options).then(function (result) { globalResult = result; return result.setCenter({ - modelId : 15781, - x : 10, - y : 20, + modelId: 15781, + x: 10, + y: 20, }); - }).then(function() { + }).then(function () { var sessionData = ServerConnectorMock.getSessionData(globalResult.getProject()); var center = sessionData.getCenter(globalResult.getProject().getModel()); assert.ok(center instanceof google.maps.Point); assert.closeTo(parseFloat(center.x), 10, helper.EPSILON); assert.closeTo(parseFloat(center.y), 20, helper.EPSILON); - }).then(function() { + }).then(function () { globalResult.destroy(); }); }); diff --git a/frontend-js/src/test/js/mocha-config.js b/frontend-js/src/test/js/mocha-config.js index 588d605604565ba1dea05ca05a9700d1d841391b..a65e6f684a8ad0322d458827db3be8eef2a1b3a5 100644 --- a/frontend-js/src/test/js/mocha-config.js +++ b/frontend-js/src/test/js/mocha-config.js @@ -40,9 +40,9 @@ before(function () { global.document.elementFromPoint = function () { }; -global.$ = require('jquery'); -global.jQuery = $; -global.window.$ = $; + global.$ = require('jquery'); + global.jQuery = $; + global.window.$ = $; // additions to jsdom implementations: global.Option = window.Option;