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

Merge tag 'v13.1.2' into merge-13.1.2

parents 8d8768e6 fe66c92c
Pipeline #11968 passed with stage
in 7 minutes and 40 seconds
......@@ -27,6 +27,13 @@ minerva (14.0.0~alpha.0) unstable; urgency=low
-- Sascha Herzinger <sascha.herzinger@uni.lu> Wed, 22 May 2019 10:30:00 +0200
minerva (13.1.2) stable; urgency=medium
* Bug fix: Information about problematic zip file is more specific (#865)
* Bug fix: Url didn't contain list of opened plugins and they weren't reload
automatically on refresh (#866)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 22 Jul 2019 17:00:00 +0200
minerva (13.1.1) stable; urgency=medium
* Bug fix: adding gene mapping before the genome caused an error (#835)
* Bug fix: "Terms of Use" change to "Terms of Service" in all places (#843)
......
......@@ -1320,6 +1320,19 @@ ServerConnector.getPluginsData = function () {
});
};
/**
*
* @param {string} hash
* @returns {Promise<PluginData>}
*/
ServerConnector.getPluginData = function (hash) {
var self = this;
return self.sendGetRequest(self.getPluginUrl({hash: hash})).then(function (content) {
var data = JSON.parse(content);
return new PluginData(data);
}).catch(self.processNetworkError);
};
/**
*
* @param {Object} params
......
......@@ -157,7 +157,7 @@ AddProjectDialog.prototype.createGeneralTabContent = function () {
name: "project-file"
});
fileInput.addEventListener("change", function () {
return self.callListeners("onFileUpload", fileInput.files[0]).then(null, GuiConnector.alert);
return self.callListeners("onFileUpload", fileInput.files[0]).catch(GuiConnector.alert);
}, false);
self.addListener("onFileUpload", function (e) {
var file = e.arg;
......@@ -1449,7 +1449,12 @@ AddProjectDialog.prototype.createZipEntry = function (jsZipEntry, zipObject) {
type = "MAP";
data.root = true;
} else {
throw new ValidationError("Unrecognized file: " + filename);
var version = self.getConfiguration().getVersion();
var minorVersion = version.split(".")[0] + "." + version.split(".")[1];
var url = 'https://minerva.pages.uni.lu/doc/admin_manual/v' + minorVersion + '/advanced_upload/';
throw new ValidationError("Unrecognized file: " + filename + ". Please refer to <a target='#' href='" + url +
"'>manual</a> for information about allowed zip file content");
}
if (type === "MAP") {
var name = jsZipEntry.name.toLowerCase();
......
......@@ -278,13 +278,13 @@ function initGlobals(params) {
if (global.ServerConnector === undefined) {
global.ServerConnector = ServerConnector;
if (params.isDebug()) {
logger.level="debug";
logger.level = "debug";
} else {
logger.level="info";
logger.level = "info";
}
GuiConnector.init();
if (GuiConnector.getParams['debug'] !== undefined) {
logger.level="debug";
logger.level = "debug";
}
} else {
logger.warn("global ServerConnector found");
......@@ -584,6 +584,18 @@ function create(params) {
for (var i = 0; i < params.getPlugins().length; i++) {
promises.push(leftPanel.getPluginManager().addPlugin(params.getPlugins()[i]))
}
if (GuiConnector.getParams['plugins'] !== undefined) {
var hashes = GuiConnector.getParams['plugins'].split(",");
for (i = 0; i < hashes.length; i++) {
promises.push(ServerConnector.getPluginData(hashes[i]).then(function (plugin) {
if (plugin !== null) {
return leftPanel.getPluginManager().addPlugin({url: plugin.getUrls()[0]});
} else {
GuiConnector.warn("Plugin list contains invalid object.");
}
}))
}
}
return Promise.all(promises);
}).then(function () {
return ServerConnector.getLoggedUser();
......@@ -674,7 +686,7 @@ function createLoginDiv(configuration) {
className: "minerva-login-caps-lock-warning",
content: "Warning: Caps lock is on"
}));
GuiConnector.addListener("onCapsLockChange",function(e){
GuiConnector.addListener("onCapsLockChange", function (e) {
if (e.arg) {
$(".minerva-login-caps-lock-warning").css("display", "block");
} else {
......
......@@ -39,6 +39,12 @@ var pluginId = 0;
function Plugin(options) {
ObjectWithListeners.call(this);
var self = this;
/**
*
* @type {string}
* @private
*/
self._hash = '';
self.setOptions(options);
self.registerListenerType("onUnload");
self.registerListenerType("onResize");
......@@ -162,6 +168,7 @@ Plugin.prototype.load = function () {
version: self.getVersion()
}));
}).then(function () {
self._hash = hash;
if (error) {
return Promise.reject(error);
}
......@@ -243,6 +250,14 @@ Plugin.prototype.getName = function () {
return this.getLoadedPluginData().getName();
};
/**
*
* @returns {string}
*/
Plugin.prototype.getHash = function () {
return this._hash;
};
/**
*
* @returns {string}
......
......@@ -27,6 +27,10 @@ var Functions = require('../Functions');
function PluginManager(options) {
AbstractGuiElement.call(this, options);
var self = this;
/**
* @type Plugin[]
*/
self._plugins = [];
self._pluginOnResizeHandlers = {};
......@@ -132,6 +136,7 @@ PluginManager.prototype.addPlugin = function (options) {
}
}
}).then(function () {
GuiConnector.setUrlParam("plugins", self._getLoadedPluginsAsHashList());
return plugin;
}).catch(function (e) {
return plugin.unload().then(function () {
......@@ -149,6 +154,26 @@ PluginManager.prototype.isValidUrl = function (url) {
return isUrl(url);
};
/**
*
* @return {string}
* @private
*/
PluginManager.prototype._getLoadedPluginsAsHashList = function () {
var self = this;
var hashes = '';
for (var i = 0; i < self._plugins.length; i++) {
if (hashes !== '') {
hashes += ",";
}
hashes += self._plugins[i].getHash();
}
if (hashes === '') {
hashes = undefined;
}
return hashes;
};
/**
*
* @returns {Promise|PromiseLike}
......@@ -193,6 +218,7 @@ PluginManager.prototype.removePlugin = function (plugin) {
}
GuiConnector.removeWindowResizeEvent(self._pluginOnResizeHandlers[plugin.getPluginId()]);
return plugin.unload().then(function () {
GuiConnector.setUrlParam("plugins", self._getLoadedPluginsAsHashList());
if (self._plugins.length === 0) {
$(self.getElement()).hide();
return self.getMap().getMapCanvas().triggerListeners("resize");
......
......@@ -97,6 +97,20 @@ describe('AddProjectDialog', function () {
return dialog.destroy();
});
});
it('invalid zip', function () {
var dialog = createDialog();
var file;
var buf = fs.readFileSync("testFiles/map/invalid-project.zip");
buf.name = "invalid-project.zip";
return dialog.init().then(function () {
return dialog.setZipFileContent(buf);
}).catch(function (e) {
assert.ok(e instanceof ValidationError);
}).finally(function () {
return dialog.destroy();
});
});
it('CellDesigner file', function () {
var dialog = createDialog();
var file;
......
......@@ -6,6 +6,8 @@ var Plugin = require('../../../main/js/plugin/Plugin');
var PluginManager = require('../../../main/js/plugin/PluginManager');
var ProxyAccessPlugin = require('./ProxyAccessPlugin');
var GuiConnector = require('../../../main/js/GuiConnector');
var logger = require('../logger');
var chai = require('chai');
var assert = chai.assert;
......@@ -45,6 +47,12 @@ describe('PluginManager', function () {
assert.equal(1, manager.getPlugins().length);
});
});
it('check url', function () {
var manager = createPluginManager();
return manager.addPlugin({url: "./testFiles/plugin/empty.js"}).then(function () {
assert.ok(GuiConnector.getParams['plugins']);
});
});
it('with min width', function () {
var manager = createPluginManager();
return manager.addPlugin({url: "./testFiles/plugin/min-width.js"}).then(function () {
......@@ -125,6 +133,16 @@ describe('PluginManager', function () {
assert.equal(-1, testDiv.innerHTML.indexOf("tab-pane"));
});
});
it('check url', function () {
var manager = createPluginManager();
return manager.addPlugin({url: "./testFiles/plugin/empty.js"}).then(function (plugin) {
return manager.removePlugin(plugin);
}).then(function () {
assert.notOk(GuiConnector.getParams['plugins']);
});
});
it('removing non existing plugin', function () {
var manager = createPluginManager();
var plugin = new Plugin({url: "testFiles/plugin/empty.js"});
......
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