From 9235584289aed87a463e9d94fd5ce3845d81c70a Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 3 Jul 2018 11:41:59 +0200 Subject: [PATCH] download status extractet to a method --- .../src/main/js/gui/admin/EditGenomeDialog.js | 12 +---------- .../src/main/js/gui/admin/GenomeAdminPanel.js | 10 +-------- .../src/main/js/map/data/ReferenceGenome.js | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js b/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js index ea3450fc00..0eecb1c31e 100644 --- a/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js +++ b/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js @@ -363,18 +363,8 @@ EditGenomeDialog.prototype.init = function () { genomeLocalUrlInput.val(genome.getLocalUrl()); genomeLocalUrlInput.prop("disabled", true); - var progress; - if (genome.getDownloadProgress() === 100) { - if (genome.getLocalUrl() !== undefined) { - progress = "READY"; - } else { - progress = "ERROR"; - } - } else { - progress = genome.getDownloadProgress(); - } var genomeProgressInput = $("[name=genomeProgress]", self.getElement()); - genomeProgressInput.val(progress); + genomeProgressInput.val(genome.getDownloadProgressStatus()); genomeProgressInput.prop("disabled", true); }); diff --git a/frontend-js/src/main/js/gui/admin/GenomeAdminPanel.js b/frontend-js/src/main/js/gui/admin/GenomeAdminPanel.js index d3b754b0d6..fc79970c50 100644 --- a/frontend-js/src/main/js/gui/admin/GenomeAdminPanel.js +++ b/frontend-js/src/main/js/gui/admin/GenomeAdminPanel.js @@ -164,15 +164,7 @@ GenomeAdminPanel.prototype.genomeToTableRow = function (genome, user) { row[0] = genome.getType(); row[1] = self.getGuiUtils().createAnnotationLink(genome.getOrganism()).outerHTML; row[2] = genome.getVersion(); - if (genome.getDownloadProgress() === 100) { - if (genome.getLocalUrl() !== undefined) { - row[3] = "READY"; - } else { - row[3] = "ERROR"; - } - } else { - row[3] = genome.getDownloadProgress(); - } + row[3] = genome.getDownloadProgressStatus(); row[4] = genome.getSourceUrl(); var disabled = " disabled "; diff --git a/frontend-js/src/main/js/map/data/ReferenceGenome.js b/frontend-js/src/main/js/map/data/ReferenceGenome.js index f484559a1b..032563ceb1 100644 --- a/frontend-js/src/main/js/map/data/ReferenceGenome.js +++ b/frontend-js/src/main/js/map/data/ReferenceGenome.js @@ -75,6 +75,27 @@ ReferenceGenome.prototype.setDownloadProgress = function (downloadProgress) { }; +/** + * + * @returns {string} + */ +ReferenceGenome.prototype.getDownloadProgressStatus = function () { + if (this.getDownloadProgress() === 100) { + if (this.getLocalUrl() !== undefined) { + return "READY"; + } else { + return "ERROR"; + } + } else { + if (this.getDownloadProgress() === undefined) { + return "N/A"; + } else { + return this.getDownloadProgress().toString(); + } + } +}; + + /** * * @param {Annotation} organism -- GitLab