Skip to content

Commit

Permalink
Format of average Layer time #310
Browse files Browse the repository at this point in the history
  • Loading branch information
j7126 committed Jan 27, 2022
1 parent 5220652 commit 3f1bf8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions octoprint_dashboard/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ $(function () {
self.lastLayerDuration = ko.observable("-");
self.lastLayerDurationInSeconds = ko.observable("-");
self.averageLayerDuration = ko.observable("-");
self.averageLayerDurationInSeconds = ko.observable("-");
self.changeFilamentCount = ko.observable("-");

self.feedrate = ko.observable(0);
Expand Down Expand Up @@ -317,7 +316,6 @@ $(function () {
if (data.lastLayerDuration) { self.lastLayerDuration(data.lastLayerDuration); }
if (data.lastLayerDurationInSeconds) { self.lastLayerDurationInSeconds(data.lastLayerDurationInSeconds); }
if (data.averageLayerDuration) { self.averageLayerDuration(data.averageLayerDuration); }
if (data.averageLayerDurationInSeconds) { self.averageLayerDurationInSeconds(data.averageLayerDurationInSeconds); }

// System Stats handling
if (data.cpuPercent) { self.cpuPercent(data.cpuPercent); }
Expand Down Expand Up @@ -757,6 +755,18 @@ $(function () {

// --- Time Display Code ---

self.formatSeconds = function (seconds) {
var minutes = Math.floor(seconds / 60);
seconds %= 60;
seconds = String(seconds).padStart(2, '0');
var hours = Math.floor(minutes / 60);
minutes %= 60;
minutes = String(minutes).padStart(2, '0');
if (hours != 0)
return `${hours}:${minutes}:${seconds}`;
return `${minutes}:${seconds}`;
}

var formatTime = (date) => {
var str = "";
var ampm = "";
Expand Down
2 changes: 1 addition & 1 deletion octoprint_dashboard/templates/dashboard_tab.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
<div class="dashboardGridItem layerProgress" data-bind="visible: printerStateModel.isPrinting()">
<img class="dashboardIcon" title="{{ _('Layer Time') }}" src="plugin/dashboard/static/img/layer-time-average-icon.png">
<span id="averageLayerDuration"
title="{{ _('Average Layer Time') }}" data-bind="html: averageLayerDuration()"></span>
title="{{ _('Average Layer Time') }}" data-bind="html: formatSeconds(averageLayerDuration())"></span>
</div>

</div>
Expand Down

0 comments on commit 3f1bf8e

Please sign in to comment.