diff --git a/src/api/status/public/js/build-log/check-for-build.js b/src/api/status/public/js/build-log/check-for-build.js index 9cd9310fb0..244064342f 100644 --- a/src/api/status/public/js/build-log/check-for-build.js +++ b/src/api/status/public/js/build-log/check-for-build.js @@ -2,6 +2,7 @@ import { checkBuildStatus, getBuildLog } from './api.js'; import terminal from './terminal.js'; import buildHeader from './build-header.js'; +import calculatorBuildInfo from './datetime-calculator.js'; let build; let reader; @@ -30,6 +31,7 @@ function processLog({ done, value }) { export default async function checkForBuild() { const status = await checkBuildStatus(); buildHeader(status); + calculatorBuildInfo(status); // If we're already building, skip this check if (build) { diff --git a/src/api/status/public/js/build-log/datetime-calculator.js b/src/api/status/public/js/build-log/datetime-calculator.js index 4e1a4fd260..f21948c9b0 100644 --- a/src/api/status/public/js/build-log/datetime-calculator.js +++ b/src/api/status/public/js/build-log/datetime-calculator.js @@ -1,14 +1,28 @@ -function calculator(startedAt = '2021-12-07') { - const dateValue = startedAt; - const date = Math.abs((new Date(dateValue).getTime() / 1000).toFixed(0)); - const currentDate = Math.abs((new Date().getTime() / 1000).toFixed(0)); +const buildDateCaltulator = document.getElementById('calculatorData'); +const buildLoading = document.getElementById('build-loading'); +const buildSuccess = document.getElementById('build-success'); +const buildFail = document.getElementById('build-fail'); + +export default function calculatorBuildInfo(data) { + const startedAt = data.startedAt; + const stoppedAt = data.stoppedAt; + const result = data.result; + + if (result == 0 && stoppedAt != 'null') { + buildSuccess.removeAttribute('hidden'); + } else if (result != 0 && stoppedAt != 'null') { + buildFail.removeAttribute('hidden'); + } else { + buildLoading.removeAttribute('hidden'); + } + + const date = Math.abs((new Date(startedAt).getTime() / 1000).toFixed(0)); + const currentDate = Math.abs((new Date(stoppedAt).getTime() / 1000).toFixed(0)); const diff = currentDate - date; const hours = Math.floor(diff / 3600) % 24; const minutes = Math.floor(diff / 60) % 60; const seconds = diff % 60; - document.getElementById('calculatorData').innerHTML = `${hours} h ${minutes} m ${seconds} s`; + buildDateCaltulator.innerText = `${hours} h ${minutes} m ${seconds} s`; } - -setInterval(calculator, 1000); diff --git a/src/api/status/public/js/pages/build.js b/src/api/status/public/js/pages/build.js index 44ce3efb15..d395ac6e21 100644 --- a/src/api/status/public/js/pages/build.js +++ b/src/api/status/public/js/pages/build.js @@ -1,6 +1,9 @@ import checkForBuild from '../build-log/check-for-build.js'; +import calculatorBuildInfo from '../build-log/datetime-calculator.js'; window.addEventListener('load', () => { checkForBuild(); + calculatorBuildInfo(); + setInterval(calculatorBuildInfo, 1000); setInterval(checkForBuild, 5000); }); diff --git a/src/api/status/src/views/builds.hbs b/src/api/status/src/views/builds.hbs index 05ba6669bb..d6a6034eec 100644 --- a/src/api/status/src/views/builds.hbs +++ b/src/api/status/src/views/builds.hbs @@ -31,6 +31,24 @@ +