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

[WIP] Add a GUI #59

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

[WIP] Add a GUI #59

wants to merge 40 commits into from

Conversation

CapriciousRebel
Copy link
Collaborator

@CapriciousRebel CapriciousRebel commented Oct 23, 2021

Currently, the GUI is a work in progress.

How to use it?

  1. run npm install.
  2. add your GH_TOKEN in the .env file.
  3. run any command and pass the --gui option
  4. open localhost:3000!
    To run a different command, go back to terminal, and run another command along with the --gui option (close the terminal that was running first with Cmd + C), then come back and refresh the browser

At this stage, I have used the following stack:
Ejs: Generating HTML using templating.
Express: Serving the generated HTML and the static files(CSS styles).
TailwindCSS: For styling the HTML.

Tasks:

  • Stage 1 + 2

  • Stage 3a: Building the API for the server

  • Stage 3b: Updating the frontend and integrating it with the server
  • Finalize the design for the frontend with @ljharb
  • Implement the designs in the frontend
  • [x ] Integrate with the backend

  • Transition Stage [3-4]: Do extensive testing of the solution and fix any issues, write tests

  • Stage 4: Host the solution?

@CapriciousRebel CapriciousRebel changed the title [WIP] Add a GUI for repo-report [WIP] Add a GUI Oct 23, 2021
@thehanimo
Copy link
Collaborator

Hey @CapriciousRebel! Nice work all around. Really excited for the GUI! Just thought I'll add a few thoughts here:

  • I don't think we're using tailwindcss the right way. Pretty sure we don't have to add that huge static/style.css in our repo. I see a lot of similar stylesheets in node_modules/tailwindcss/dist/ so double check if this is the right way.

  • Do we need a server to view the static file? Why don't we generate the html file with ejs, store it in a folder (like cache) and just open up the file on the browser? Doesn't that seem simpler?

  • We have an eslint config set up so It'd be nice if you could lint the code before each commit :)

@CapriciousRebel
Copy link
Collaborator Author

@thehanimo thanks for your comments!
I agree with each point that you have mentioned. I just wanted to create a Proof of Concept as soon as possible and so I worked on this over the weekend. I will address each point you mentioned in future commits :)

@CapriciousRebel
Copy link
Collaborator Author

@rosekamallove I have squashed all the commits into one, and fixed all eslint issues as well, now you can rebase and continue work!

Copy link
Collaborator

@thehanimo thehanimo left a comment

Choose a reason for hiding this comment

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

@CapriciousRebel I still see src/static/style.css with 188,032 lines?

@rosekamallove
Copy link
Collaborator

It is the 4th task, see the first comment

@thehanimo
Copy link
Collaborator

It is the 4th task, see the first comment

Got it! My bad.

@CapriciousRebel
Copy link
Collaborator Author

@rosekamallove added the purge command, kindly rebase once.
You can run it using npm run build:css

@CapriciousRebel
Copy link
Collaborator Author

@rosekamallove what is the update on your tasks?

@rosekamallove
Copy link
Collaborator

Will push the changes by the end of this week, Diwali

views/index.ejs Outdated Show resolved Hide resolved
const { getMetrics } = require('../metrics');

// Metric names and their extraction method to be used on the query result (Order is preserved)
const metricNames = [
Copy link
Owner

Choose a reason for hiding this comment

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

seems like this file contains a lot of copied code from elsewhere in the repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is the code from the details.js file. Kindly consider this commit as an intermediate step. I was having some trouble with the exports(for some reason importing the detail function gave errors, saying detail wasn't a function). So I just copy-pasted the code instead to make things work for the time being. I will fix this in a future commit and perhaps squash this commit.

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good :-) just calling it out so it's not forgotten.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is still a doubt for me, could you probably suggest me a fix for this? I'm not sure why importing from detail.js is not working. Perhaps there is some issue with express js? Not really sure

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure either. Can you restore the import, and i'll try it locally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's address this issue at the very end of this PR, once we have everything in working order.

@CapriciousRebel
Copy link
Collaborator Author

@ljharb a gentle reminder for a review on this PR

src/server/controllers.js Outdated Show resolved Hide resolved
src/server/controllers.js Outdated Show resolved Hide resolved
src/static/index.html Outdated Show resolved Hide resolved
src/static/index.html Outdated Show resolved Hide resolved
src/static/index.html Outdated Show resolved Hide resolved
src/static/index.html Outdated Show resolved Hide resolved
src/static/index.html Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
@CapriciousRebel
Copy link
Collaborator Author

Will update the PR before the end of the year :)

@CapriciousRebel
Copy link
Collaborator Author

@ljharb updated my PR, left replies on your comments. Could you please give a further review?

.gitignore Outdated Show resolved Hide resolved
src/commands/detail.js Outdated Show resolved Hide resolved
src/commands/detail.js Outdated Show resolved Hide resolved
src/server/app.js Outdated Show resolved Hide resolved
src/server/controllers.js Outdated Show resolved Hide resolved
src/server/controllers.js Outdated Show resolved Hide resolved
src/server/controllers.js Outdated Show resolved Hide resolved
src/static/index.html Show resolved Hide resolved
src/static/style.css Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
@CapriciousRebel
Copy link
Collaborator Author

CapriciousRebel commented Dec 29, 2021

@ljharb updated my PR, also left replies on some comments for further discussion.

@CapriciousRebel
Copy link
Collaborator Author

@ljharb I have left more replies on our conversations, I guess we are really close to finishing this PR :)
:excited:

@ljharb
Copy link
Owner

ljharb commented Dec 30, 2021

also see some of the hidden conversations (#59 (comment))

@CapriciousRebel
Copy link
Collaborator Author

@ljharb updated my PR to include the token as a flag or positional argument from the frontend itself, also added a minimal error handler as well for when the user doesn't provide the token, maybe someday we could evolve the error handling to a modal in the frontend, after having handled all errors in the backend (ex: Bad Credentials error for GitHub token is not handled yet in the backend)
Could you please give the PR another glance and leave your comments?

Also could you please address #59 (comment)

@ljharb
Copy link
Owner

ljharb commented Jan 1, 2022

I'm confused; the frontend shouldn't be supplying the token - the invocation to start the server should be.

@CapriciousRebel
Copy link
Collaborator Author

I see, so basically, a person does this:

  • opens up terminal and types repo-report --gui --token=<token>
  • browser opens up with the gui
  • now the person can type in their command without having the need to pass the token every time.

This flow makes perfect sense to me, but I am a bit confused as to where will the token be stored during this time?

  • The token cannot be stored on the server, unless we use some in-memory store or a global variable that remains persistent through the operation because the most important point to focus on is that we run yargs-parser every time a command is sent from the frontend:

Screenshot 2022-01-03 at 8 52 32 AM

  • In normal cases, the token is stored in the frontend as an HTTP-only cookie (safe from XSS attacks) or as a session variable that can be killed the moment the session ends, but we ruled out the possibility of storing the token in the frontend in our earlier discussions.

Summary: Where would the GitHub token be stored once the user provides it at the time of GUI invocation so that the user doesn't have to provide it every time from the frontend via the command?

@CapriciousRebel
Copy link
Collaborator Author

@ljharb gentle reminder to give an update on this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants