diff --git a/services/static-webserver/client/source/class/osparc/data/model/Node.js b/services/static-webserver/client/source/class/osparc/data/model/Node.js index 6585289b45a..8dfa47bc437 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Node.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Node.js @@ -1330,10 +1330,10 @@ qx.Class.define("osparc.data.model.Node", { }); }, - setNodeProgressSequence: function(progressType, progress) { + setNodeProgressSequence: function(progressType, progressReport) { const nodeStatus = this.getStatus(); if (nodeStatus.getProgressSequence()) { - nodeStatus.getProgressSequence().addProgressMessage(progressType, progress); + nodeStatus.getProgressSequence().addProgressMessage(progressType, progressReport); } }, diff --git a/services/static-webserver/client/source/class/osparc/data/model/NodeProgressSequence.js b/services/static-webserver/client/source/class/osparc/data/model/NodeProgressSequence.js index 6a57afe7dad..3d92e2aae50 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/NodeProgressSequence.js +++ b/services/static-webserver/client/source/class/osparc/data/model/NodeProgressSequence.js @@ -47,43 +47,61 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, clusterUpScaling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applyClusterUpScaling" }, sidecarPulling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applySidecarPulling" }, outputsPulling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applyOutputsPulling" }, statePulling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applyStatePulling" }, imagesPulling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applyImagesPulling" }, inputsPulling: { - check: "Number", - init: 0, + check: "Object", + init: { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + }, nullable: false, apply: "__applyInputsPulling" } @@ -92,7 +110,8 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { statics: { NODE_INDEX: { LABEL: 0, - HALO: 1, + CALC: 1, + HALO: 2, }, createTaskLayout: function(label) { @@ -130,6 +149,15 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { osparc.service.StatusUI.getStatusHalo(iconContainer, progressColor, 0); layout.addAt(iconContainer, this.NODE_INDEX.HALO); + const progressState = new qx.ui.basic.Label(); + progressState.set({ + value: qx.locale.Manager.tr("Waiting..."), + textColor: "text", + allowGrowX: true, + allowShrinkX: true + }); + layout.addAt(progressState, this.NODE_INDEX.CALC); + return layout; }, @@ -144,7 +172,7 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { return progressBar; }, - updateProgressLabel: function(atom, value) { + updateProgressLabel: function(atom, {value, progressLabel}) { if ([null, undefined].includes(value)) { return; } @@ -155,6 +183,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { icon.setVisibility(value === 1 ? "visible" : "excluded"); const progressColor = qx.theme.manager.Color.getInstance().resolve("progressbar") osparc.service.StatusUI.getStatusHalo(halo, progressColor, value * 100); + + const label = atom.getChildren()[this.NODE_INDEX.CALC]; + label.setValue(progressLabel); } }, @@ -183,21 +214,51 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { __pullingInputsLayout: null, __disclaimerText: null, + getDefaultStartValues: function() { + return { + progressLabel: qx.locale.Manager.tr("Waiting..."), + value: 0 + } + }, + + getDefaultEndValues: function() { + return { + progressLabel: "100%", + value: 1 + } + }, + getWidgetForLoadingPage: function() { return this.__mainLoadingPage; }, resetSequence: function() { + const defaultVals = this.getDefaultStartValues(); this.setOverallProgress(0); - this.setClusterUpScaling(0); - this.setSidecarPulling(0); - this.setOutputsPulling(0); - this.setStatePulling(0); - this.setImagesPulling(0); - this.setInputsPulling(0); + this.setClusterUpScaling(defaultVals); + this.setSidecarPulling(defaultVals); + this.setOutputsPulling(defaultVals); + this.setStatePulling(defaultVals); + this.setImagesPulling(defaultVals); + this.setInputsPulling(defaultVals); + }, + + getProgress: function(report) { + if (report.unit) { + return { + progressLabel: `${osparc.utils.Utils.bytesToSize(report["actual_value"], 1, false)} / ${osparc.utils.Utils.bytesToSize(report["total"], 1)}`, + value: report["actual_value"] / report["total"] + } + } + const percentage = parseFloat((report["actual_value"] / report["total"] * 100).toFixed(2)) + return { + progressLabel: `${percentage}%`, + value: report["actual_value"] / report["total"] + } }, - addProgressMessage: function(progressType, progress) { + addProgressMessage: function(progressType, progressReport) { + const progress = this.getProgress(progressReport); switch (progressType) { case "CLUSTER_UP_SCALING": this.setClusterUpScaling(progress); @@ -283,12 +344,12 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __computeOverallProgress: function() { - const overallProgress = this.getClusterUpScaling() + - this.getSidecarPulling() + - this.getOutputsPulling() + - this.getStatePulling() + - this.getImagesPulling() + - this.getInputsPulling(); + const overallProgress = this.getClusterUpScaling().value + + this.getSidecarPulling().value + + this.getOutputsPulling().value + + this.getStatePulling().value + + this.getImagesPulling().value + + this.getInputsPulling().value; this.setOverallProgress(overallProgress) }, @@ -311,8 +372,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __applySidecarPulling: function(value) { - if (value > 0) { - this.setClusterUpScaling(1); + if (value.value > 0) { + const defaultEndVals = this.getDefaultEndValues(); + this.setClusterUpScaling(defaultEndVals); } this.self().updateProgressLabel(this.__pullingSidecarLayout, value); @@ -320,8 +382,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __applyOutputsPulling: function(value) { - if (value > 0) { - this.setSidecarPulling(1); + if (value.value > 0) { + const defaultEndVals = this.getDefaultEndValues(); + this.setSidecarPulling(defaultEndVals); } this.self().updateProgressLabel(this.__pullingOutputsLayout, value); @@ -329,8 +392,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __applyStatePulling: function(value) { - if (value > 0) { - this.setSidecarPulling(1); + if (value.value > 0) { + const defaultEndVals = this.getDefaultEndValues(); + this.setSidecarPulling(defaultEndVals); } this.self().updateProgressLabel(this.__pullingStateLayout, value); @@ -338,8 +402,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __applyImagesPulling: function(value) { - if (value > 0) { - this.setSidecarPulling(1); + if (value.value > 0) { + const defaultEndVals = this.getDefaultEndValues(); + this.setSidecarPulling(defaultEndVals); } this.self().updateProgressLabel(this.__pullingImagesLayout, value); @@ -347,8 +412,9 @@ qx.Class.define("osparc.data.model.NodeProgressSequence", { }, __applyInputsPulling: function(value) { - if (value > 0) { - this.setSidecarPulling(1); + if (value.value > 0) { + const defaultEndVals = this.getDefaultEndValues(); + this.setSidecarPulling(defaultEndVals); } this.self().updateProgressLabel(this.__pullingInputsLayout, value); diff --git a/services/static-webserver/client/source/class/osparc/data/model/Study.js b/services/static-webserver/client/source/class/osparc/data/model/Study.js index d92fd874129..73230030165 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Study.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Study.js @@ -432,8 +432,8 @@ qx.Class.define("osparc.data.model.Study", { const node = workbench.getNode(nodeId); if (node) { const progressType = nodeProgressData["progress_type"]; - const progress = nodeProgressData["progress_report"]["actual_value"] / nodeProgressData["progress_report"]["total"]; - node.setNodeProgressSequence(progressType, progress); + const progressReport = nodeProgressData["progress_report"]; + node.setNodeProgressSequence(progressType, progressReport); } }, diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index ae87a278142..1606589110f 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -552,7 +552,7 @@ qx.Class.define("osparc.utils.Utils", { return L > 0.35 ? "#FFF" : "#000"; }, - bytesToSize: function(bytes, decimals = 2) { + bytesToSize: function(bytes, decimals = 2, isPrefixVisible = true) { if (!+bytes) { return "0 Bytes"; } @@ -561,7 +561,7 @@ qx.Class.define("osparc.utils.Utils", { const dm = decimals < 0 ? 0 : decimals; const i = Math.floor(Math.log(bytes) / Math.log(k)) - return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}` + return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${isPrefixVisible ? sizes[i] : ""}` }, bytesToGB: function(bytes) {