-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added live build status to Telescope dashboard:
* added scripts for fetching and rendering build-header * added html template for build-header * imported build-header to run on load made adjustments based on feedbacks: * removed fetch from build-header * moved build-header call to check-for-build so they are in sync * added extra return data (githubData, stop date, result code) from API * changed auto-deployment url to https://dev.telescope.cdot.systems * moved the build-header function call to before the if statement * removed the state toggling code * moved build-headers into .hbs file * changed returning stoppedAt value to use current date * removed the line setting innerText for build-header title * modified build-header to use card component from material dashboard * centered build-header title * reverted autodeployment url * hid build-header info when in loading state and show when data is fetched * removed the use of setAttribute and replaced them with setter on the DOM element API
- Loading branch information
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const buildHeaderTitle = document.getElementById('build-header-title'); | ||
const buildHeaderInfo = document.getElementById('build-header-info'); | ||
const buildSender = document.getElementById('build-sender'); | ||
const buildSenderName = document.getElementById('build-sender-name'); | ||
const buildSenderImg = document.getElementById('build-sender-img'); | ||
const buildGitSHA = document.getElementById('build-git-sha'); | ||
const buildResult = document.getElementById('build-result'); | ||
const buildStarted = document.getElementById('build-started'); | ||
const buildDuration = document.getElementById('build-duration'); | ||
|
||
function renderBuildInfo({ githubData, startedAt, stoppedAt, result }) { | ||
if (buildHeaderInfo.hidden) { | ||
buildHeaderInfo.removeAttribute('hidden'); | ||
} | ||
buildHeaderTitle.innerHTML = ''; | ||
buildSender.href = githubData.sender.html_url; | ||
buildSenderName.innerText = githubData.sender.login; | ||
buildSenderImg.src = githubData.sender.avatar_url; | ||
buildGitSHA.href = githubData.compare; | ||
buildGitSHA.innerText = githubData.after.substring(0, 7); | ||
buildResult.innerText = result === 0 ? 'Good' : 'Error'; | ||
buildStarted.innerText = new Date(startedAt).toUTCString(); | ||
|
||
const duration = new Date(stoppedAt).getTime() - new Date(startedAt).getTime(); | ||
const minutes = Math.floor(duration / 60000); | ||
const seconds = ((duration % 60000) / 1000).toFixed(0); | ||
buildDuration.innerText = `${minutes}m ${seconds}s`; | ||
} | ||
|
||
export default function buildHeader(data) { | ||
if (!data.building) { | ||
const icon = document.createElement('i'); | ||
icon.className = 'fas fa-server px-2'; | ||
buildHeaderTitle.innerHTML = ''; | ||
buildHeaderTitle.append(icon); | ||
buildHeaderTitle.innerHTML += 'Unable to get build info.'; | ||
buildHeaderInfo.innerHTML = ''; | ||
return; | ||
} | ||
renderBuildInfo(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters