From 24da914a252c2b827e126c1fc00a86b38e9efdcb Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 10 Apr 2017 13:57:43 +0200 Subject: [PATCH] project info panel created --- frontend-js/src/main/js/gui/Panel.js | 22 +++- .../main/js/gui/PanelControlElementType.js | 8 ++ .../src/main/js/gui/ProjectInfoPanel.js | 117 ++++++++++++++++++ .../src/main/js/gui/PublicationListDialog.js | 28 +++++ frontend-js/src/main/js/gui/UserPanel.js | 25 ++-- .../src/test/js/gui/ProjectInfoPanel-test.js | 32 +++++ 6 files changed, 213 insertions(+), 19 deletions(-) create mode 100644 frontend-js/src/main/js/gui/ProjectInfoPanel.js create mode 100644 frontend-js/src/main/js/gui/PublicationListDialog.js create mode 100644 frontend-js/src/test/js/gui/ProjectInfoPanel-test.js diff --git a/frontend-js/src/main/js/gui/Panel.js b/frontend-js/src/main/js/gui/Panel.js index 7d02ff730e..d9aec0adc4 100644 --- a/frontend-js/src/main/js/gui/Panel.js +++ b/frontend-js/src/main/js/gui/Panel.js @@ -5,6 +5,7 @@ var GuiConnector = require('../GuiConnector'); var AbstractGuiElement = require('./AbstractGuiElement'); var PanelControlElementType = require('./PanelControlElementType'); +var Functions = require('../Functions'); var logger = require('../logger'); @@ -25,10 +26,10 @@ Panel.prototype.constructor = Panel; Panel.prototype.disablePanel = function(message) { var self = this; - + var searchQueryElement = self.getControlElement(PanelControlElementType.SEARCH_DIV); var searchResultsElement = self.getControlElement(PanelControlElementType.SEARCH_RESULTS_DIV); - + searchQueryElement.style.visibility = "hidden"; searchResultsElement.style.visibility = "hidden"; var hideReasonDiv = document.createElement("div"); @@ -404,4 +405,21 @@ Panel.prototype.getControlElement = function(type) { return this._controlElements[type]; }; +Panel.prototype.createTableRow = function(elements) { + var row = Functions.createElement({ + type : "div", + style : "display: table-row;" + }); + + for (var i = 0; i < elements.length; i++) { + var cell = Functions.createElement({ + type : "div", + style : "display: table-cell;" + }); + cell.appendChild(elements[i]); + row.appendChild(cell); + } + return row; +} + module.exports = Panel; diff --git a/frontend-js/src/main/js/gui/PanelControlElementType.js b/frontend-js/src/main/js/gui/PanelControlElementType.js index dc2638d5d0..5306661659 100644 --- a/frontend-js/src/main/js/gui/PanelControlElementType.js +++ b/frontend-js/src/main/js/gui/PanelControlElementType.js @@ -33,6 +33,14 @@ var PanelControlElementType = { SUBMAP_TABLE : "SUBMAP_TABLE", SUBMAP_DIV : "SUBMAP_DIV", + INFO_DIV : "INFO_DIV", + INFO_PROJECT_NAME_TEXT : "INFO_PROJECT_NAME_TEXT", + INFO_PROJECT_VERSION_TEXT : "INFO_PROJECT_VERSION_TEXT", + INFO_PROJECT_DESCRIOPTION_TEXT : "INFO_PROJECT_DESCRIOPTION_TEXT", + INFO_PROJECT_PUBLICATIONS_TEXT : "INFO_PROJECT_PUBLICATIONS_TEXT", + INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON : "INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON", + INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON : "INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON", + }; module.exports = PanelControlElementType; diff --git a/frontend-js/src/main/js/gui/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/ProjectInfoPanel.js new file mode 100644 index 0000000000..6e921247a6 --- /dev/null +++ b/frontend-js/src/main/js/gui/ProjectInfoPanel.js @@ -0,0 +1,117 @@ +"use strict"; + +/* exported logger */ + +var Panel = require('./Panel'); +var PanelControlElementType = require('./PanelControlElementType'); + +var logger = require('../logger'); +var Functions = require('../Functions'); + +function ProjectInfoPanel(params) { + params.panelName = "user"; + Panel.call(this, params); + var self = this; + self._createSubmapGui(); +} + +ProjectInfoPanel.prototype = Object.create(Panel.prototype); +ProjectInfoPanel.prototype.constructor = ProjectInfoPanel; + +ProjectInfoPanel.prototype._createSubmapGui = function() { + var self = this; + var infoDiv = Functions.createElement({ + type : "div", + name : "infoDiv", + className : "searchPanel" + }); + this.getElement().appendChild(infoDiv); + this.setControlElement(PanelControlElementType.INFO_DIV, infoDiv); + + var infoTitle = Functions.createElement({ + type : "h5", + content : "PROJECT INFO:" + }); + infoDiv.appendChild(infoTitle); + + var dataTab = Functions.createElement({ + type : "div", + style : "width:100%;display: table;border-spacing: 10px;" + }); + infoDiv.appendChild(infoTitle); + + var projectNameLabel = Functions.createElement({ + type : "div", + content : "Name:" + }); + var projectNameText = Functions.createElement({ + type : "div", + style : "width:100%", + name : "projectNameText" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT, projectNameText); + dataTab.appendChild(self.createTableRow([ projectNameLabel, projectNameText ])); + + var projectVersionLabel = Functions.createElement({ + type : "div", + content : "Version:" + }); + var projectVersionText = Functions.createElement({ + type : "div", + style : "width:100%", + name : "projectVersionText" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_VERSION_TEXT, projectVersionText); + dataTab.appendChild(self.createTableRow([ projectVersionLabel, projectVersionText ])); + + var projectDescriptionLabel = Functions.createElement({ + type : "div", + content : "Description:" + }); + var projectDescriptionText = Functions.createElement({ + type : "div", + style : "width:100%", + name : "projectDescriptionText" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_DESCRIOPTION_TEXT, projectDescriptionText); + dataTab.appendChild(self.createTableRow([ projectDescriptionLabel, projectDescriptionText ])); + + var projectPublicationsLabel = Functions.createElement({ + type : "div", + content : "Publications:" + }); + + var projectPublicationsDiv = Functions.createElement({ + type : "div" + }); + var projectPublicationsText = Functions.createElement({ + type : "div", + style : "width:100%", + name : "projectPublicationsText" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT, projectPublicationsText); + + var projectPublicationsButton = Functions.createElement({ + type : "button", + name : "projectPublicationsButton", + content : "SHOW" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON, projectPublicationsButton); + projectPublicationsDiv.appendChild(projectPublicationsText); + projectPublicationsDiv.appendChild(projectPublicationsButton); + + dataTab.appendChild(self.createTableRow([ projectPublicationsLabel, projectPublicationsDiv ])); + + var projectOriginalFileLabel = Functions.createElement({ + type : "div", + content : "Original file:" + }); + var projectOriginalFileButton = Functions.createElement({ + type : "button", + name : "projectOriginalFileButton" + }); + this.setControlElement(PanelControlElementType.INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON, projectOriginalFileButton); + dataTab.appendChild(self.createTableRow([ projectOriginalFileLabel, projectOriginalFileButton ])); +}; + +module.exports = ProjectInfoPanel; diff --git a/frontend-js/src/main/js/gui/PublicationListDialog.js b/frontend-js/src/main/js/gui/PublicationListDialog.js new file mode 100644 index 0000000000..3e135a0220 --- /dev/null +++ b/frontend-js/src/main/js/gui/PublicationListDialog.js @@ -0,0 +1,28 @@ +"use strict"; + +/* exported logger */ + +var AbstractGuiElement = require('./AbstractGuiElement'); +var GuiConnector = require('../GuiConnector'); + +var functions = require('../functions'); +var logger = require('../logger'); + +function PublicationListDialog(params) { + AbstractGuiElement.call(this, params); + var self = this; + $(self.getElement()).dialog({ + autoOpen : false, + resizable : false, + }); +} + +PublicationListDialog.prototype = Object.create(AbstractGuiElement.prototype); +PublicationListDialog.prototype.constructor = PublicationListDialog; + + +PublicationListDialog.prototype.destroy = function() { + $(this.getElement()).dialog("destroy"); +}; + +module.exports = PublicationListDialog; diff --git a/frontend-js/src/main/js/gui/UserPanel.js b/frontend-js/src/main/js/gui/UserPanel.js index f1c7980831..10012af75e 100644 --- a/frontend-js/src/main/js/gui/UserPanel.js +++ b/frontend-js/src/main/js/gui/UserPanel.js @@ -50,18 +50,8 @@ function UserPanel(params) { UserPanel.prototype = Object.create(Panel.prototype); UserPanel.prototype.constructor = UserPanel; -function createTableRow(elements) { - var row = Functions.createElement({type:"div", style:"display: table-row;"} ); - - for (var i=0;i<elements.length;i++) { - var cell =Functions.createElement({type:"div", style:"display: table-cell;"} ); - cell.appendChild(elements[i]); - row.appendChild(cell); - } - return row; -} - UserPanel.prototype._createLoginTab = function() { + var self = this; var loginTabDiv = Functions.createElement({type:"div", name:"userLoginTab", className:"searchPanel" }); this.getElement().appendChild(loginTabDiv); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV, loginTabDiv); @@ -76,13 +66,13 @@ UserPanel.prototype._createLoginTab = function() { var loginInput = Functions.createElement({type:"input", inputType:"text", style:"width:100%", name:"loginText"} ); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT, loginInput); - authorizationFormTab.appendChild(createTableRow([loginLabel, loginInput])); + authorizationFormTab.appendChild(self.createTableRow([loginLabel, loginInput])); var passwordLabel = Functions.createElement({type:"div", content:"LOGIN:"} ); var passwordInput = Functions.createElement({type:"input", inputType:"password", style:"width:100%", name:"passwordText"} ); this.setControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT, passwordInput); - authorizationFormTab.appendChild(createTableRow([passwordLabel, passwordInput])); + authorizationFormTab.appendChild(self.createTableRow([passwordLabel, passwordInput])); var centerTag = Functions.createElement({type:"center"} ); loginTabDiv.appendChild(centerTag); @@ -94,6 +84,7 @@ UserPanel.prototype._createLoginTab = function() { }; UserPanel.prototype._createUserDataTab = function() { + var self = this; var userDataDiv = Functions.createElement({type:"div", name:"userDataTab", className:"searchPanel", style:"display:none"}); this.getElement().appendChild(userDataDiv); this.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); @@ -107,22 +98,22 @@ UserPanel.prototype._createUserDataTab = function() { var loginLabel = Functions.createElement({type:"span", content:"LOGIN:", style:"color:#999999"} ); var loginText = Functions.createElement({type:"span", name:"loginValue"} ); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_TEXT, loginText); - userDataDiv.appendChild(createTableRow([loginLabel, loginText])); + userDataDiv.appendChild(self.createTableRow([loginLabel, loginText])); var nameLabel = Functions.createElement({type:"span", content:"NAME:", style:"color:#999999"} ); var nameText = Functions.createElement({type:"span", name:"nameValue"} ); this.setControlElement(PanelControlElementType.USER_TAB_NAME_TEXT, nameText); - userDataDiv.appendChild(createTableRow([nameLabel, nameText])); + userDataDiv.appendChild(self.createTableRow([nameLabel, nameText])); var surnameLabel = Functions.createElement({type:"span", content:"SURNAME:", style:"color:#999999"} ); var surnameText = Functions.createElement({type:"span", name:"surnameValue"} ); this.setControlElement(PanelControlElementType.USER_TAB_SURNAME_TEXT, surnameText); - userDataDiv.appendChild(createTableRow([surnameLabel, surnameText])); + userDataDiv.appendChild(self.createTableRow([surnameLabel, surnameText])); var emailLabel = Functions.createElement({type:"span", content:"EMAIL:", style:"color:#999999"} ); var emailText = Functions.createElement({type:"span", name:"emailValue"} ); this.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText); - userDataDiv.appendChild(createTableRow([emailLabel, emailText])); + userDataDiv.appendChild(self.createTableRow([emailLabel, emailText])); var centerTag = Functions.createElement({type:"center"} ); userDataDiv.appendChild(centerTag); diff --git a/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js b/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js new file mode 100644 index 0000000000..dab817fce6 --- /dev/null +++ b/frontend-js/src/test/js/gui/ProjectInfoPanel-test.js @@ -0,0 +1,32 @@ +"use strict"; + +var Helper = require('../helper'); + +require("../mocha-config.js"); + +var ProjectInfoPanel = require('../../../main/js/gui/ProjectInfoPanel'); + +var chai = require('chai'); +var assert = chai.assert; +var logger = require('../logger'); + +describe('ProjectInfoPanel', function() { + + var helper; + before(function() { + helper = new Helper(); + }); + + it('contructor', function() { + var div = document.createElement("div"); + + var map = helper.createCustomMap(); + + new ProjectInfoPanel({ + element : div, + customMap : map + }); + assert.equal(logger.getWarnings().length, 0); + }); + +}); -- GitLab