Commit 3e3adf2f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

content with type of data overlay could crash upload

parent 1cedc4b2
Pipeline #17289 failed with stage
in 18 minutes and 20 seconds
minerva (14.0.5) stable; urgency=medium
* Bug fix: copy-paste of genetic-variant data overlay into Add overlay
content dialog could crash upload (#1040)
minerva (14.0.4) stable; urgency=high
* Bug fix: some SBGN files uploaded to minerva could not be exported to SBML
due to problems with identifiers used by SBGN (#1006)
......
......@@ -106,6 +106,11 @@ AddOverlayDialog.prototype.createGui = function () {
type: "textarea",
name: "overlay-content"
});
contentInput.onchange = function () {
if (contentInput.value !== undefined && contentInput.value !== null) {
self.onContentChanged(contentInput.value);
}
};
content.appendChild(contentInput);
content.appendChild(guiUtils.createNewLine());
......@@ -127,6 +132,48 @@ AddOverlayDialog.prototype.createGui = function () {
self.getElement().appendChild(content);
};
AddOverlayDialog.prototype.onContentChanged = function (content) {
var self = this;
var overlayParser = new OverlayParser();
var overlay = overlayParser.parse(content);
var nameInput = $("[name='overlay-name']", self.getElement())[0];
var descriptionInput = $("[name='overlay-description']", self.getElement())[0];
if (overlay.getName() !== undefined) {
nameInput.value = overlay.getName();
} else {
var filename = $("[name='overlay-file']", self.getElement())[0].value;
if (filename.indexOf(".") > 0) {
filename = filename.substr(0, filename.indexOf("."));
}
if (filename.lastIndexOf("\\") >= 0) {
filename = filename.substr(filename.lastIndexOf("\\") + 1);
}
if (filename !== "") {
nameInput.value = filename;
}
}
if (overlay.getDescription() !== undefined) {
descriptionInput.value = overlay.getDescription();
}
var typeSelect = $("[name='overlay-type']", self.getElement())[0];
$(typeSelect).attr("disabled", false);
if (overlay.getType() !== undefined) {
if ($("option[value='" + overlay.getType() + "']", typeSelect).length === 0) {
GuiConnector.warn("Invalid type: " + overlay.getType());
} else {
$(typeSelect).attr("disabled", true);
}
self.setType(overlay.getType());
} else {
self.setType("GENERIC");
}
if (overlayParser.containsMixedNewLineCharacters(content)) {
GuiConnector.warn("Selected file contains new line characters from different operating systems " +
"(MAC/Windows/Linux). This might cause confusion when reading the file in the editor later on.")
}
};
/**
*
* @param file
......@@ -141,45 +188,8 @@ AddOverlayDialog.prototype.processFile = function (file) {
reader.readAsArrayBuffer(file);
reader.onload = function (evt) {
try {
var overlayParser = new OverlayParser();
self.setFileContent(evt.target.result);
var overlay = overlayParser.parse(evt.target.result);
var nameInput = $("[name='overlay-name']", self.getElement())[0];
var descriptionInput = $("[name='overlay-description']", self.getElement())[0];
if (overlay.getName() !== undefined) {
nameInput.value = overlay.getName();
} else {
var filename = $("[name='overlay-file']", self.getElement())[0].value;
if (filename.indexOf(".") > 0) {
filename = filename.substr(0, filename.indexOf("."));
}
if (filename.lastIndexOf("\\") >= 0) {
filename = filename.substr(filename.lastIndexOf("\\") + 1);
}
nameInput.value = filename;
}
if (overlay.getDescription() !== undefined) {
descriptionInput.value = overlay.getDescription();
}
var typeSelect = $("[name='overlay-type']", self.getElement())[0];
$(typeSelect).attr("disabled", false);
if (overlay.getType() !== undefined) {
if ($("option[value='" + overlay.getType() + "']", typeSelect).length === 0) {
GuiConnector.warn("Invalid type: " + overlay.getType());
} else {
$(typeSelect).attr("disabled", true);
}
self.setType(overlay.getType());
} else {
self.setType("GENERIC");
}
if (overlayParser.containsMixedNewLineCharacters(evt.target.result)) {
GuiConnector.warn("Selected file contains new line characters from different operating systems " +
"(MAC/Windows/Linux). This might cause confusion when reading the file in the editor later on.")
}
self.onContentChanged(evt.target.result);
resolve(self.getFileContent());
} catch (error) {
reject(error);
......
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