Commit 5cb80905 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

adding gene variant data overlay is possible

parent 3161ebba
Pipeline #5688 passed with stage
in 1 minute and 54 seconds
......@@ -120,9 +120,18 @@ Configuration.prototype.getOptions = function () {
return result;
};
/**
*
* @param {string[]} overlayTypes
*/
Configuration.prototype.setOverlayTypes = function (overlayTypes) {
this._overlayTypes = overlayTypes;
};
/**
*
* @returns {string[]}
*/
Configuration.prototype.getOverlayTypes = function () {
return this._overlayTypes;
};
......
......@@ -1910,6 +1910,7 @@ ServerConnector.addOverlay = function (params) {
content: overlay.getContent(),
filename: overlay.getFilename(),
googleLicenseConsent: overlay.isGoogleLicenseConsent(),
type: overlay.getType(),
fileId: params.fileId
};
return self.getProjectId(params.projectId).then(function (result) {
......@@ -1920,6 +1921,12 @@ ServerConnector.addOverlay = function (params) {
});
};
/**
*
* @param {string} name
* @param {string} content
* @returns {Promise}
*/
ServerConnector.addOverlayFromString = function (name, content) {
var fileName = name + ".txt";
var overlay = new DataOverlay({
......
......@@ -27,9 +27,9 @@ function AbstractGuiElement(params) {
var self = this;
self.setElement(params.element);
self.setConfiguration(params.configuration);
self.setProject(params.project);
self.setMap(params.customMap);
self.setConfiguration(params.configuration);
self.setServerConnector(params.serverConnector);
self._controlElements = [];
......
......@@ -18,6 +18,19 @@ var HttpStatus = require('http-status-codes');
var Promise = require("bluebird");
var TextEncoder = require('text-encoding').TextEncoder;
/**
*
* @param {Object} params
* @param {HTMLElement} params.element
* @param {CustomMap} params.customMap
* @param {Configuration} params.configuration
* @param {Project} params.project
* @param {ServerConnector} [params.serverConnector]
*
* @constructor
*
* @extends AbstractGuiElement
*/
function AddOverlayDialog(params) {
AbstractGuiElement.call(this, params);
var self = this;
......@@ -28,9 +41,12 @@ function AddOverlayDialog(params) {
AddOverlayDialog.prototype = Object.create(AbstractGuiElement.prototype);
AddOverlayDialog.prototype.constructor = AddOverlayDialog;
/**
*
*/
AddOverlayDialog.prototype.createGui = function () {
var self = this;
var guiUtils = new GuiUtils();
var guiUtils = new GuiUtils(self.getConfiguration());
var content = document.createElement("div");
content.style.width = "100%";
content.style.height = "100%";
......@@ -52,6 +68,24 @@ AddOverlayDialog.prototype.createGui = function () {
content.appendChild(descriptionInput);
content.appendChild(guiUtils.createNewLine());
content.appendChild(guiUtils.createLabel("Type: "));
content.appendChild(guiUtils.createNewLine());
var types = self.getConfiguration().getOverlayTypes();
var typeSelect = Functions.createElement({
type: "select",
name: "overlay-type",
value: types[0]
});
for (var i = 0; i < types.length; i++) {
$(typeSelect).append($('<option>', {
value: types[i],
text: types[i]
}));
}
content.appendChild(typeSelect);
content.appendChild(guiUtils.createNewLine());
content.appendChild(guiUtils.createLabel("Upload file: "));
var fileInput = Functions.createElement({
type: "input",
......@@ -100,6 +134,7 @@ AddOverlayDialog.prototype.processFile = function (file) {
var overlay = overlayParser.parse(evt.target.result);
var nameInput = $("[name='overlay-name']", self.getElement())[0];
var descriptionInput = $("[name='overlay-description']", self.getElement())[0];
var typeSelect = $("[name='overlay-type']", self.getElement());
if (overlay.getName() !== undefined) {
nameInput.value = overlay.getName();
} else {
......@@ -116,6 +151,9 @@ AddOverlayDialog.prototype.processFile = function (file) {
if (overlay.getDescription() !== undefined) {
descriptionInput.value = overlay.getDescription();
}
if (overlay.getType() !== undefined) {
typeSelect.val(overlay.getType());
}
resolve(self.getFileContent());
} catch (error) {
reject(error);
......@@ -155,32 +193,39 @@ AddOverlayDialog.prototype.getFileContent = function () {
}
};
/**
*
* @returns {Promise}
*/
AddOverlayDialog.prototype.init = function () {
return Promise.resolve();
};
AddOverlayDialog.prototype.addOverlay = function () {
var self = this;
var nameInput = $("[name='overlay-name']", self.getElement())[0];
var descriptionInput = $("[name='overlay-description']", self.getElement())[0];
var filename = $("[name='overlay-file']", self.getElement())[0].value;
var type = $("[name='overlay-type']", self.getElement()).val();
var consent = $("[name='overlay-google-consent']", self.getElement()).is(":checked");
var overlay = new DataOverlay({
name: nameInput.value,
description: descriptionInput.value,
filename: filename,
googleLicenseConsent: consent
googleLicenseConsent: consent,
type: type
});
if (filename === undefined || filename === "") {
filename = "unknown.txt";
}
GuiConnector.showProcessing();
return ServerConnector.uploadFile({
return self.getServerConnector().uploadFile({
filename: filename,
content: self.getFileContent()
}).then(function (file) {
return ServerConnector.addOverlay({
return self.getServerConnector().addOverlay({
fileId: file.id,
overlay: overlay,
projectId: self.getProject().getProjectId()
......
......@@ -962,7 +962,8 @@ EditProjectDialog.prototype.openAddOverlayDialog = function () {
self._addOverlayDialog = new AddOverlayDialog({
project: self.getProject(),
customMap: null,
element: document.createElement("div")
element: document.createElement("div"),
configuration: self.getConfiguration()
});
self._addOverlayDialog.addListener("onAddOverlay", function () {
return self.refreshOverlays();
......
......@@ -20,6 +20,19 @@ var SubmapPanel = require('./SubmapPanel');
var Functions = require('../../Functions');
var logger = require('../../logger');
/**
*
* @param {Object} params
* @param {HTMLElement} params.element
* @param {CustomMap} params.customMap
* @param {Configuration} params.configuration
* @param {Project} [params.project]
* @param {ServerConnector} [params.serverConnector]
*
* @constructor
*
* @extends AbstractGuiElement
*/
function LeftPanel(params) {
AbstractGuiElement.call(this, params);
var self = this;
......@@ -274,6 +287,7 @@ LeftPanel.prototype.addTab = function (params, tabData) {
this._panels.push(new params.panelClass({
element: data.content,
customMap: self.getMap(),
configuration: self.getConfiguration(),
parent: self
}));
......
......@@ -16,11 +16,12 @@ var Promise = require('bluebird');
/**
*
* @param {Object} params
* @param {Configuration} [params.configuration]
* @param {HTMLElement} params.element
* @param {Project} params.project
* @param {CustomMap} params.customMap
* @param {Configuration} [params.configuration]
* @param {Project} [params.project]
* @param params.parent
*
* @constructor
* @extends Panel
*/
......@@ -30,6 +31,9 @@ function OverlayPanel(params) {
params["helpTip"] = "<p>Overlays tab allows to display or generate custom coloring of elements and interactions in the map.</p>"
+ "<p>General overlays are overlays accessible for every user viewing the content.</p>"
+ "<p>Custom overlays are user-provided overlays, this menu becomes available upon login (see below).</p>";
if (params.project === undefined) {
params.project = params.customMap.getProject();
}
Panel.call(this, params);
//overflow is defined in minerva-overlay-panel, so remove the one that is already there
......@@ -211,8 +215,8 @@ OverlayPanel.prototype.createTableHeader = function (edit) {
/**
*
* @param {DataOverlay} overlay
* @param {boolean} checked
* @param {boolean} disabled
* @param {boolean} [checked=false]
* @param {boolean} [disabled=false]
* @returns {HTMLElement}
*/
OverlayPanel.prototype.createOverlayRow = function (overlay, checked, disabled) {
......@@ -536,7 +540,8 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
self._addOverlayDialog = new AddOverlayDialog({
project: self.getProject(),
customMap: self.getMap(),
element: document.createElement("div")
element: document.createElement("div"),
configuration: self.getConfiguration()
});
self._addOverlayDialog.addListener("onAddOverlay", function (e) {
self.getProject().addDataOverlay(e.arg);
......
......@@ -7,6 +7,11 @@ var TextDecoder = require('text-encoding').TextDecoder;
function OverlayParser() {
}
/**
*
* @param {string| Uint8Array|ArrayBuffer} content
* @returns {DataOverlay}
*/
OverlayParser.prototype.parse = function (content) {
if (content instanceof Uint8Array || content instanceof ArrayBuffer) {
content = new TextDecoder("UTF8").decode(content);
......
......@@ -331,7 +331,8 @@ function create(params) {
leftPanel = new LeftPanel({
element: functions.getElementByClassName(element, "minerva-left-panel"),
customMap: customMap
customMap: customMap,
configuration: params.getConfiguration()
});
var pluginManager = new PluginManager({
......
......@@ -17,7 +17,9 @@ describe('AddOverlayDialog', function () {
dialog = new AddOverlayDialog({
element: testDiv,
project: project,
customMap: null
customMap: null,
configuration: helper.getConfiguration(),
serverConnector: ServerConnector
});
dialog.setFileContent("s1\n");
......
......@@ -9,6 +9,19 @@ var chai = require('chai');
var assert = chai.assert;
var logger = require('../../logger');
/**
*
* @param {CustomMap} map
* @returns {OverlayPanel}
*/
function createOverlayPanel(map) {
return new OverlayPanel({
element: testDiv,
customMap: map,
configuration: helper.getConfiguration()
});
}
describe('OverlayPanel', function () {
it('constructor', function () {
......@@ -138,10 +151,7 @@ describe('OverlayPanel', function () {
it('open', function () {
var map = helper.createCustomMap();
var panel = new OverlayPanel({
element: testDiv,
customMap: map
});
var panel = createOverlayPanel(map);
return panel.openAddOverlayDialog().then(function () {
return panel.destroy();
......@@ -150,11 +160,7 @@ describe('OverlayPanel', function () {
it('trigger onAddOverlay event handler', function () {
var map = helper.createCustomMap();
var panel = new OverlayPanel({
element: testDiv,
customMap: map
});
var panel = createOverlayPanel(map);
return panel.init().then(function () {
return panel.openAddOverlayDialog();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment