Commit b6acc1ac authored by Piotr Gawron's avatar Piotr Gawron
Browse files

plugins in admin panel can be revalidated

parent e785b1fb
......@@ -11,6 +11,8 @@ minerva (15.0.0~alpha.1) stable; urgency=medium
upload (#820)
* Small improvement: items in context menu are reorganized (#787)
* Small improvement: CellDesigner files from version 2.5 should be parseable
* Small improvement: plugins in admin panel can be revalidated to update info
about the plugins (name, version)
* Bug fix: compartments limited by corner (left-top corner compartment, etc)
are parsed properly from CellDesigner files
* Bug fix: structural states of proteins are imported properly from SBGNML PD
......
......@@ -1399,6 +1399,8 @@ ServerConnector.removePlugin = function (params) {
* @param {Object} params
* @param {string} params.hash
* @param {boolean} [params.isDefault]
* @param {boolean} [params.version]
* @param {boolean} [params.name]
*
* @returns {Promise<PluginData[]>}
*/
......@@ -1407,7 +1409,9 @@ ServerConnector.updatePlugin = function (params) {
var content = {
plugin: {
hash: params.hash,
isDefault: params.isDefault
isDefault: params.isDefault,
version: params.version,
name: params.name
}
};
return self.sendPatchRequest(self.getPluginUrl(params), content);
......
......@@ -65,6 +65,8 @@ PluginAdminPanel.prototype._createGui = function () {
title: 'Url'
}, {
title: 'Default'
}, {
title: 'Re-Validate'
}, {
title: 'Remove',
orderable: false
......@@ -91,10 +93,67 @@ PluginAdminPanel.prototype._createGui = function () {
}).catch(GuiConnector.alert);
});
$(pluginsTable).on("click", "[name='re-validate-plugin']", function () {
var button = this;
var hash = $(button).attr("data");
var error = false;
var plugin;
return self.getServerConnector().getPluginData(hash).then(function (response) {
plugin = response;
return self.getServerConnector().sendRequest({
url: plugin.getUrls()[0],
description: "Loading plugin: " + plugin.getUrls()[0],
method: "GET"
});
}).then(function (content) {
var pluginRawData = undefined;
// noinspection JSUnusedLocalSymbols
var minervaDefine = function (pluginFunction) {
try {
if (typeof pluginFunction === "function") {
pluginRawData = pluginFunction();
} else {
pluginRawData = pluginFunction;
}
} catch (e) {
error = e;
}
};
content += "//# sourceURL=" + plugin.getUrls()[0];
eval(content);
if (error) {
return self.askConfirmRemoval({
title: "INFO",
content: "Plugin source file does not exist. Do you want to remove this plugin?",
input: false
}).then(function (param) {
if (param.status) {
return self.getServerConnector().removePlugin({hash: hash}).then(function () {
return self.onRefreshClicked();
});
}
});
} else {
return self.getServerConnector().updatePlugin({
hash: hash,
version: pluginRawData.getVersion(),
name: pluginRawData.getName()
}).then(function () {
return self.onRefreshClicked();
});
}
}).catch(GuiConnector.alert);
});
$(pluginsTable).on("click", "[name='edit-default-plugin']", function () {
var checkbox = this;
var hash = $(this).attr("data");
return self.getServerConnector().updatePlugin({hash: hash, isDefault: $(checkbox).is(':checked')}).then(function () {
return self.getServerConnector().updatePlugin({
hash: hash,
isDefault: $(checkbox).is(':checked')
}).then(function () {
return self.onRefreshClicked();
}).catch(GuiConnector.alert);
});
......@@ -212,8 +271,9 @@ PluginAdminPanel.prototype.pluginToTableRow = function (plugin) {
checked = " checked ";
}
row[3] = "<input type='checkbox' name='edit-default-plugin' " + checked + " data='" + plugin.getHash() + "' />";
row[4] = "<button name='re-validate-plugin' data='" + plugin.getHash() + "' ><i class='fa fa-check-circle'></button>";
row[4] = "<button name='removePlugin' data='" + plugin.getHash() + "' ><i class='fa fa-trash-alt'></button>";
row[5] = "<button name='removePlugin' data='" + plugin.getHash() + "' ><i class='fa fa-trash-alt'></button>";
return row;
};
......
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