mirror of
https://github.com/bastienwirtz/homer.git
synced 2024-11-07 08:44:00 +01:00
Fix octoprint timestamp (#693)
update octoprint service with timestamp changes
This commit is contained in:
parent
11cdb50ea5
commit
ea12ee520b
@ -12,9 +12,9 @@
|
||||
<i class="fa-solid fa-gear mr-1"></i>
|
||||
<b v-if="completion">{{ completion.toFixed() }}%</b>
|
||||
<span class="separator mx-1"> | </span>
|
||||
<span v-if="printTime" :title="`${toTime(printTimeLeft)} left`">
|
||||
<span v-if="printTime" :title="`${formatTime(printTimeLeft)} left`">
|
||||
<i class="fa-solid fa-stopwatch mr-1"></i>
|
||||
{{ toTime(printTime) }}
|
||||
{{ formatTime(printTime) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="!error && display == 'text' && statusClass == 'ready'">
|
||||
@ -33,8 +33,8 @@
|
||||
class="progress is-primary"
|
||||
:value="completion"
|
||||
max="100"
|
||||
:title="`${state} - ${completion.toFixed()}%, ${toTime(
|
||||
printTimeLeft,
|
||||
:title="`${state} - ${completion.toFixed()}%, ${formatTime(
|
||||
printTimeLeft
|
||||
)} left`"
|
||||
>
|
||||
{{ completion }}%
|
||||
@ -115,9 +115,28 @@ export default {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
toTime: function (timastamp) {
|
||||
return new Date(timastamp * 1000).toTimeString().substring(0, 5);
|
||||
},
|
||||
formatTime: function (seconds) {
|
||||
const days = Math.floor(seconds / 86400);
|
||||
let remainingSeconds = seconds % 86400;
|
||||
const hours = Math.floor(remainingSeconds / 3600);
|
||||
remainingSeconds %= 3600;
|
||||
const minutes = Math.floor(remainingSeconds / 60);
|
||||
const secs = remainingSeconds % 60;
|
||||
|
||||
const formattedHrs = hours.toString().padStart(2, '0')
|
||||
const formattedMins = minutes.toString().padStart(2, '0')
|
||||
const formattedSecs = secs.toString().padStart(2, '0')
|
||||
|
||||
if (days > 0) {
|
||||
return `${days}d ${formattedHrs}h ${formattedMins}m`;
|
||||
} else if (hours > 0) {
|
||||
return `${formattedHrs}h ${formattedMins}m ${formattedSecs}s`;
|
||||
} else if (minutes > 0) {
|
||||
return `${formattedMins}m ${formattedSecs}s`;
|
||||
} else {
|
||||
return `${secs} seconds`;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user