From 76ab73419df7a6407fab7e4a9ed58e5a06aea015 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 10 Apr 2017 14:42:52 +0200 Subject: [PATCH] data is filled in on refresh method --- .../src/main/js/gui/ProjectInfoPanel.js | 19 ++++++++++++++++++- frontend-js/src/main/js/map/data/Project.js | 10 ++++++++++ .../src/test/js/gui/ProjectInfoPanel-test.js | 13 ++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/frontend-js/src/main/js/gui/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/ProjectInfoPanel.js index 6e921247a6..5d1b88e048 100644 --- a/frontend-js/src/main/js/gui/ProjectInfoPanel.js +++ b/frontend-js/src/main/js/gui/ProjectInfoPanel.js @@ -38,7 +38,7 @@ ProjectInfoPanel.prototype._createSubmapGui = function() { type : "div", style : "width:100%;display: table;border-spacing: 10px;" }); - infoDiv.appendChild(infoTitle); + infoDiv.appendChild(dataTab); var projectNameLabel = Functions.createElement({ type : "div", @@ -114,4 +114,21 @@ ProjectInfoPanel.prototype._createSubmapGui = function() { dataTab.appendChild(self.createTableRow([ projectOriginalFileLabel, projectOriginalFileButton ])); }; +ProjectInfoPanel.prototype.refresh = function() { + var self = this; + + var projectNameText = this.getControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT); + var projectVersionText = this.getControlElement(PanelControlElementType.INFO_PROJECT_VERSION_TEXT); + var projectDescriptionText = this.getControlElement(PanelControlElementType.INFO_PROJECT_DESCRIOPTION_TEXT); + var projectPublicationsText = this.getControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT); + + return ServerConnector.getProject().then(function(project) { + projectNameText.innerHTML = project.getName(); + projectVersionText.innerHTML = project.getVersion(); + projectDescriptionText.innerHTML = project.getDescription(); + projectPublicationsText.innerHTML = project.getPublicationCount(); + return null; + }); +}; + module.exports = ProjectInfoPanel; diff --git a/frontend-js/src/main/js/map/data/Project.js b/frontend-js/src/main/js/map/data/Project.js index 22492dc096..f806324626 100644 --- a/frontend-js/src/main/js/map/data/Project.js +++ b/frontend-js/src/main/js/map/data/Project.js @@ -33,6 +33,7 @@ Project.prototype.loadFromData = function(data) { this.setTopOverviewImage(data.topOverviewImage); this.setDisease(data.disease); this.setOrganism(data.organism); + this.setPublicationCount(data.publicationCount); this.setModel(new Model(data.map)); @@ -46,6 +47,7 @@ Project.prototype.getId = function() { Project.prototype.setId = function(id) { this._id = parseInt(id); }; + Project.prototype.getProjectId = function() { return this._projectId; }; @@ -110,4 +112,12 @@ Project.prototype.setOrganism = function(organism) { this._organism = organism; }; +Project.prototype.getPublicationCount = function() { + return this._publicationCount; +}; + +Project.prototype.setPublicationCount = function(publicationCount) { + this._publicationCount = parseInt(publicationCount); +}; + module.exports = Project; diff --git a/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js b/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js index dab817fce6..59586b970d 100644 --- a/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js +++ b/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js @@ -28,5 +28,16 @@ describe('ProjectInfoPanel', function() { }); assert.equal(logger.getWarnings().length, 0); }); - + + it('refresh', function() { + var div = document.createElement("div"); + var panel = new ProjectInfoPanel({ + element : div, + customMap : helper.createCustomMap(), + }); + return panel.refresh().then(function(result) { + assert.ok(div.innerHTML.indexOf("UNKNOWN DISEASE MAP") >= 0); + }); + }); + }); -- GitLab