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

refresh of progress is synchronized

parent efd8fc39
......@@ -643,7 +643,8 @@ h1 {
.minerva-plugin-tab .minerva-menu-row button,
.minerva-edit-project-dialog .minerva-menu-row button,
.minerva-users-tab .minerva-menu-row button,
.minerva-genome-tab .minerva-menu-row button {
.minerva-genome-tab .minerva-menu-row button,
.minerva-edit-genome-dialog .minerva-menu-row button {
margin: 5px;
}
......@@ -1104,6 +1105,7 @@ input[type=file] {
background: #f5f5f5;
cursor: pointer;
}
#minervaAppDiv table.dataTable.hover tbody tr:hover,
#minervaAppDiv table.dataTable.display tbody tr:hover,
#minervaAppDiv table.dataTable.display tbody tr:hover > .sorting_1,
......
......@@ -32,6 +32,7 @@ function EditGenomeDialog(params) {
self.setReferenceGenome(params.referenceGenome);
$(self.getElement()).css({overflow: "hidden"});
$(self.getElement()).addClass("minerva-edit-genome-dialog");
self.createGui();
self.registerListenerType("onSave");
......@@ -240,6 +241,18 @@ EditGenomeDialog.prototype.createGeneMappingTabContent = function () {
menuRow.appendChild(addGeneMappingButton);
var refreshButton = Functions.createElement({
type: "button",
name: "saveGenome",
content: ' REFRESH',
onclick: function () {
return self.refresh();
},
xss: false
});
menuRow.appendChild(refreshButton);
return result;
};
......@@ -259,7 +272,7 @@ EditGenomeDialog.prototype.onSaveClicked = function () {
genome.setVersion(self.getSelectedVersion());
return self.getServerConnector().addReferenceGenome(genome).then(function () {
return self.callListeners("onSave");
}).catch(function(e){
}).catch(function (e) {
if (e instanceof ObjectExistsError) {
GuiConnector.alert("Reference genome already exists");
} else {
......@@ -433,7 +446,7 @@ EditGenomeDialog.prototype.geneMappingToTableRow = function (geneMapping) {
var row = [];
row[0] = geneMapping.getName();
row[1] = geneMapping.getSourceUrl();
row[2] = geneMapping.getProgress();
row[2] = geneMapping.getProgressStatus();
row[3] = "<button name='removeMapping' data='" + geneMapping.getId() + "'><i class='fa fa-trash-o' style='font-size:17px'></button>";
return row;
};
......@@ -468,34 +481,40 @@ EditGenomeDialog.prototype.init = function () {
*/
EditGenomeDialog.prototype.refresh = function () {
var self = this;
var genome = self.getReferenceGenome();
var dataTable = $("[name=detailsTable]", self.getElement()).DataTable();
var data = [];
data.push(['Organism', Functions.createElement({type: "select", name: "genomeOrganismSelect"}).outerHTML]);
data.push(['Type', Functions.createElement({type: "select", name: "genomeTypeSelect"}).outerHTML]);
data.push(['Version', Functions.createElement({type: "select", name: "genomeVersionSelect"}).outerHTML]);
data.push(['Source url', Functions.createElement({type: "input", name: "genomeSourceUrl"}).outerHTML]);
data.push(['Local url', Functions.createElement({type: "input", name: "genomeLocalUrl"}).outerHTML]);
data.push(['Progress', Functions.createElement({type: "input", name: "genomeProgress"}).outerHTML]);
dataTable.clear().rows.add(data).draw();
dataTable = $("[name=geneMappingTable]", self.getElement()).DataTable();
data = [];
var page = dataTable.page();
for (var i = 0; i < genome.getGeneMappings().length; i++) {
var geneMapping = genome.getGeneMappings()[i];
var rowData = self.geneMappingToTableRow(geneMapping);
data.push(rowData);
var refreshReferenceGenomePromise = Promise.resolve();
if (!self.isNew()) {
refreshReferenceGenomePromise = self.getServerConnector().getReferenceGenome({genomeId: self.getReferenceGenome().getId()}).then(function (genome) {
self.setReferenceGenome(genome);
});
}
//it should be simplified, but I couldn't make it work
dataTable.clear().rows.add(data).page(page).draw(false).page(page).draw(false);
return refreshReferenceGenomePromise.then(function () {
var genome = self.getReferenceGenome();
var dataTable = $("[name=detailsTable]", self.getElement()).DataTable();
var data = [];
data.push(['Organism', Functions.createElement({type: "select", name: "genomeOrganismSelect"}).outerHTML]);
data.push(['Type', Functions.createElement({type: "select", name: "genomeTypeSelect"}).outerHTML]);
data.push(['Version', Functions.createElement({type: "select", name: "genomeVersionSelect"}).outerHTML]);
data.push(['Source url', Functions.createElement({type: "input", name: "genomeSourceUrl"}).outerHTML]);
data.push(['Local url', Functions.createElement({type: "input", name: "genomeLocalUrl"}).outerHTML]);
data.push(['Progress', Functions.createElement({type: "input", name: "genomeProgress"}).outerHTML]);
dataTable.clear().rows.add(data).draw();
dataTable = $("[name=geneMappingTable]", self.getElement()).DataTable();
data = [];
var page = dataTable.page();
for (var i = 0; i < genome.getGeneMappings().length; i++) {
var geneMapping = genome.getGeneMappings()[i];
var rowData = self.geneMappingToTableRow(geneMapping);
data.push(rowData);
}
//it should be simplified, but I couldn't make it work
dataTable.clear().rows.add(data).page(page).draw(false).page(page).draw(false);
return self._fillOrganismSelect(genome);
return self._fillOrganismSelect(genome);
});
};
/**
......@@ -522,6 +541,7 @@ EditGenomeDialog.prototype.destroy = function () {
/**
*
* @return {Promise}
*/
EditGenomeDialog.prototype.open = function () {
var self = this;
......@@ -541,6 +561,8 @@ EditGenomeDialog.prototype.open = function () {
});
}
$(div).dialog("open");
return self.refresh();
};
/**
......
......@@ -297,11 +297,9 @@ GenomeAdminPanel.prototype.showEditDialog = function (id) {
}
return self.getDialog(referenceGenome);
}).then(function (dialog) {
dialog.open();
return dialog.open();
}).finally(function () {
GuiConnector.hideProcessing();
}).catch(function (error) {
GuiConnector.hideProcessing();
return Promise.reject(error);
});
};
......@@ -314,11 +312,9 @@ GenomeAdminPanel.prototype.onAddClicked = function () {
GuiConnector.showProcessing();
var referenceGenome = new ReferenceGenome();
return self.getDialog(referenceGenome).then(function (dialog) {
dialog.open();
GuiConnector.hideProcessing();
}).catch(function (error) {
return dialog.open();
}).finally(function () {
GuiConnector.hideProcessing();
return Promise.reject(error);
});
};
......
......@@ -84,6 +84,27 @@ ReferenceGenomeGeneMapping.prototype.getSourceUrl = function () {
return this._sourceUrl;
};
/**
*
* @returns {string}
*/
ReferenceGenomeGeneMapping.prototype.getProgressStatus = function () {
var progress = this.getProgress();
if (progress === 100) {
if (this.getLocalUrl() !== undefined) {
return "READY";
} else {
return "ERROR";
}
} else {
if (progress === undefined) {
return "N/A";
} else {
return progress.toFixed(2) + ' %';
}
}
};
/**
*
* @param {string} url
......
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