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

download button for project logs

parent 9d3bed38
Pipeline #4250 passed with stage
in 1 minute and 5 seconds
......@@ -7,6 +7,8 @@ var Promise = require("bluebird");
var AbstractGuiElement = require('../AbstractGuiElement');
var Functions = require('../../Functions');
var GuiConnector = require('../../GuiConnector');
function LogListDialog(params) {
AbstractGuiElement.call(this, params);
......@@ -41,6 +43,37 @@ LogListDialog.prototype.createLogListDialogGui = function () {
self.tableElement = tableElement;
self.getElement().appendChild(tableElement);
var menuRow = Functions.createElement({
type: "div",
className: "minerva-menu-row",
style: "display:table-row; margin:10px"
});
self.getElement().appendChild(menuRow);
var downloadButton = Functions.createElement({
type: "button",
name: "saveUser",
content: '<span class="ui-icon ui-icon-disk"></span>&nbsp;DOWNLOAD',
onclick: function () {
GuiConnector.showProcessing();
return self.downloadAll().then(function (result) {
var blob = new Blob([result], {
type: "text/plain;charset=utf-8"
});
var FileSaver = require("file-saver");
return FileSaver.saveAs(blob, self._projectId + "-logs.txt");
}).then(function () {
GuiConnector.hideProcessing();
}, function (error) {
GuiConnector.hideProcessing();
GuiConnector.alert(error);
});
},
xss: false
});
menuRow.appendChild(downloadButton);
};
LogListDialog.prototype._dataTableAjaxCall = function (data, callback) {
......@@ -59,7 +92,7 @@ LogListDialog.prototype._dataTableAjaxCall = function (data, callback) {
var entry = logEntries.data[i];
var row = [];
row[0] = entry.id ;
row[0] = entry.id;
row[1] = entry.content;
out.push(row);
}
......@@ -72,6 +105,23 @@ LogListDialog.prototype._dataTableAjaxCall = function (data, callback) {
});
};
LogListDialog.prototype.downloadAll = function (data, callback) {
var self = this;
return ServerConnector.getProjectLogs({
length: 2147483646,
projectId: self._projectId,
level: self._level
}).then(function (logEntries) {
var response = "";
var tmp = [];
for (var i = 0; i < logEntries.data.length; i++) {
tmp.push(logEntries.data[i].content);
}
response = tmp.join("\n");
return response;
});
};
LogListDialog.prototype.open = function () {
var self = this;
if (!$(self.getElement()).hasClass("ui-dialog-content")) {
......
......@@ -45,8 +45,25 @@ describe('LogListDialog', function () {
}).then(function () {
assert.ok(callbackCalled);
}).finally(function () {
dialog.destroy();
return dialog.destroy();
});
});
it('downloadAll', function () {
var div = testDiv;
var map = helper.createCustomMap();
var dialog = new LogListDialog({
element: div,
customMap: map
});
return dialog.downloadAll().then(function (content) {
assert.ok(content);
return dialog.destroy();
});
});
});
{"data":[{"id":0,"content":"Miriam data (REACTOME: REACT_20130) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":1,"content":"Miriam data (HGNC: 2141) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":2,"content":"Miriam data (KEGG_GENES: 6546) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":3,"content":"Miriam data (REFSEQ: NP_001106272.1) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":4,"content":"Miriam data (REFSEQ: NP_001106271.1) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":5,"content":"Miriam data (REFSEQ: NP_001106273.1) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":6,"content":"Miriam data (REFSEQ: NP_001239553.1) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":7,"content":"Miriam data (PHARM: PA314) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":8,"content":"Miriam data (REFSEQ: NP_066920.1) for sa14 already exists. Ignoring...","level":"WARNING"},{"id":9,"content":"No valid disease is provided for project:UNKNOWN DISEASE MAP","level":"WARNING"},{"id":10,"content":"No valid organism is provided for project:UNKNOWN DISEASE MAP","level":"WARNING"}],"filteredSize":11,"length":11,"start":0,"totalSize":11}
\ No newline at end of file
......@@ -870,15 +870,17 @@ public class ProjectService implements IProjectService {
modelDao.update(originalModel);
if (params.isCacheModel()) {
cacheData(originalModel, params);
}
if (params.isAnalyzeAnnotations()) {
analyzeAnnotations(originalModel, params);
}
Logger.getRootLogger().removeAppender(appender);
project.addLoggingInfo(appender);
if (params.isCacheModel()) {
cacheData(originalModel, params);
}
updateProjectStatus(project, ProjectStatus.DONE, IProgressUpdater.MAX_PROGRESS, params);
if (project.getNotifyEmail() != null && !project.getNotifyEmail().equals("")) {
try {
......
Supports Markdown
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