Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added live build status to Telescope dashboard: #2582

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

mqnguyen5
Copy link
Contributor

@mqnguyen5 mqnguyen5 commented Dec 8, 2021

Issue This PR Addresses

Fixes #2416

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

  • Added scripts for fetching and rendering build-header
  • Added html template for build-header
  • Imported build-header to run on load

Screen Shot 2021-12-08 at 1 01 37 PM

Screen Shot 2021-12-08 at 1 22 59 PM

Screen Shot 2021-12-08 at 1 29 28 PM

To test the feature locally, do the following:

  • Change autodeploymentUrl in public/js/buildl-log/api.js
const autodeploymentUrl = (path) => `//dev.api.telescope.cdot.systems:4000/${path}`;  
  • Allow all connectSrc in src/server.js
connectSrc: ["'self'", "*"]
  • Change current to previous inside src/api/status/public/js/build-log/api.js
export const checkBuildStatus = async () => {
  try {
    const res = await fetch(autodeploymentUrl('status'));
    if (!res.ok) {
      throw new Error('unable to get build info');
    }
    const data = await res.json();
    if (!data.current) {
      return { building: false };
    }
    return {
      building: true,
      title: data.type,
      githubData: data.current.githubData,
      startedAt: new Date(data.current.startedDate),
      stoppedAt: new Date(data.current.stopDate),
      result: data.code,
    };
  } catch (err) {
    console.error(err);
    return { building: false };
  }
};

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@gitpod-io
Copy link

gitpod-io bot commented Dec 8, 2021

@Andrewnt219
Copy link
Contributor

Can you update the branch and add an instruction for testing this feature?

@Andrewnt219
Copy link
Contributor

@humphd Since there's no way to run the autodeployment locally, maybe it's easier to point this to the stagging or prod autodployment?

const autodeploymentUrl = (path) => `//${window.location.hostname}:4000/${path}`;

@humphd
Copy link
Contributor

humphd commented Dec 8, 2021

@Andrewnt219 great suggestion. For reviewing this, that works, and we can change it back before we merge. @mqnguyen5 can you point it at https://dev.telescope.cdot.systems for now?

@mqnguyen5
Copy link
Contributor Author

Will do

src/api/status/public/js/build-log/build-header.js Outdated Show resolved Hide resolved
Comment on lines 12 to 13
resMsg.toggleAttribute('hidden');
buildHeaderInfo.toggleAttribute('hidden');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the build header switch between loading state and info state every 5s. Like, 5s of info and 5s of loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have any suggestions on how to fix it? I've tried using setAttribute and removeAttribute here but it doesn't seems to do the trick

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the function should only render the build info, not toggling between two states (i.e. only render info state)? I don't think there's a case where toggling between those two is necessary.

@Yoda-Canada
Copy link
Contributor

Yoda-Canada commented Dec 8, 2021

I have changed current to previous inside src/api/status/public/js/build-log/api.js, but can't get the result which have the data. It only display loading status. How to get the previous information?
image

@mqnguyen5
Copy link
Contributor Author

change inside the if statement as well

@manekenpix
Copy link
Member

We really need to get better at rebasing instead of merging master into our branches

image

@Yoda-Canada
Copy link
Contributor

Yoda-Canada commented Dec 8, 2021

@mqnguyen5 I changed, but the result is still display loading status. Do I need to add a specific address?

@mqnguyen5
Copy link
Contributor Author

@Yoda-Canada sorry, I just updated the instruction to test this feature. You mind trying it again?

@mqnguyen5
Copy link
Contributor Author

mqnguyen5 commented Dec 9, 2021

We really need to get better at rebasing instead of merging master into our branches

image

@manekenpix Sorry about that, you mind showing me a better way to do it instead of git pull upstream master?

@Andrewnt219
Copy link
Contributor

you mind showing me a better way to do it instead of git pull upstream master?

Use git pull --rebase upstream master

@Yoda-Canada
Copy link
Contributor

Yoda-Canada commented Dec 9, 2021

@mqnguyen5 I followed your new steps, and it only displayed the loading page. Do you use a specific address to get the following data?
image

@Andrewnt219
Copy link
Contributor

@mqnguyen5 Handlebars PR is merged, can you rebase this? The changes in build.html go into builds.hbs

@mqnguyen5
Copy link
Contributor Author

Will do, I'll try to get it done soon.

@humphd
Copy link
Contributor

humphd commented Dec 12, 2021

https://en.wikipedia.org/wiki/Exit_status

In Unix, a zero exit code means it worked, anything else is an error.

@Yoda-Canada
Copy link
Contributor

@mqnguyen5 your code buildResult.innerText = result != 0 ? 'Good' : 'Error'; is correct. My point of view is wrong, sorry for that.

@humphd
Copy link
Contributor

humphd commented Dec 12, 2021

Good to clarify, there are lots of moving pieces here.

Copy link
Contributor

@Andrewnt219 Andrewnt219 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you rebase and revert the change to autodeploymentUrl?

Andrewnt219
Andrewnt219 previously approved these changes Dec 13, 2021
@Andrewnt219 Andrewnt219 dismissed their stale review December 13, 2021 04:10

Still need to rebase

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things, looks good otherwise.

Fix and rebase please.

src/api/status/public/js/build-log/build-header.js Outdated Show resolved Hide resolved
src/api/status/public/js/build-log/build-header.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Kevan-Y Kevan-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it looks good this way
image
Maybe you can hide the part below on loading

You can add hidden in element of id="build-header-info"
and have a quick check if elem build-header-info is hidden or not after line 12 in src/api/status/public/js/build-log/build-header.js

if (buildHeaderInfo.hidden) {
    buildHeaderInfo.removeAttribute('hidden');
}

@mqnguyen5
Copy link
Contributor Author

Changes have been made in response to @humphd and @Kevan-Y reviews. Sorry for not able to complete this PR sooner, I should've schedule my time better.

	* 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
Copy link
Contributor

@Andrewnt219 Andrewnt219 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Well done 👍.

Copy link
Contributor

@Yoda-Canada Yoda-Canada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!You've really done hard work.

Copy link
Contributor

@Kevan-Y Kevan-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@humphd humphd merged commit 2f2f88b into Seneca-CDOT:master Dec 14, 2021
@Andrewnt219 Andrewnt219 mentioned this pull request Jan 23, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add live build status details in status dashboard
6 participants