-
Notifications
You must be signed in to change notification settings - Fork 131
Project-github-tracker #118
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
Open
JensBergqvist
wants to merge
5
commits into
Technigo:main
Choose a base branch
from
JensBergqvist:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,10 @@ | ||
| # GitHub Tracker | ||
| This week we were asked to build a github tracker for our Technigo projects. | ||
|
|
||
| Replace this readme with your own information about your project. | ||
|
|
||
| Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
|
|
||
| ## The problem | ||
| I had massive problems with showing my commits. Whenever I invoked the code to display it, several of my projects disappeared. I needed to make an if else statement to be able to display all the projects. | ||
|
|
||
| Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
|
|
||
| ## View it live | ||
|
|
||
| Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
| https://brave-hopper-89f38f.netlify.app |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,21 +1,25 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1-0"/> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Project GitHub Tracker</title> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
| </head> | ||
| <body> | ||
| <h1>GitHub Tracker</h1> | ||
| <h2>Projects:</h2> | ||
|
|
||
| <main id="projects"></main> | ||
|
|
||
| <!-- This will be used to draw the chart 👇 --> | ||
| <canvas id="chart"></canvas> | ||
| <div class = "chart"> | ||
| <canvas id="chart"></canvas> | ||
| </div> | ||
|
|
||
| <script src="./script.js"></script> | ||
| <script src="./chart.js"></script> | ||
| <div class = chart> <script src="./chart.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,72 @@ | ||
| //DOM selectors | ||
| const username = 'JensBergqvist' | ||
| const projects = document.getElementById("projects") | ||
|
|
||
|
|
||
| const API_REPOS = `https://api.github.com/users/${username}/repos`; | ||
| const API_PROFIL = `https://api.github.com/users/${username}` | ||
| //Picture and name | ||
|
|
||
| const profilePic = () => { | ||
| fetch(API_PROFIL) | ||
| .then(res => res.json()) | ||
| .then(data => { | ||
| // console.log(data) | ||
| picture = data.avatar_url | ||
| let profilePicture = `<div class = "profile"><h1>${username}</h1> <img class = "photo" src="${picture}" /> | ||
| </div>`; | ||
| return (projects.innerHTML = profilePicture) | ||
| }) | ||
| } | ||
|
|
||
| profilePic() | ||
|
|
||
| const getRepos = () => { | ||
| fetch(API_REPOS) | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project')) | ||
|
|
||
|
|
||
| forkedRepos.forEach(repo => { | ||
| projects.innerHTML += `<div class='repo-card'> | ||
| <a href='${repo.html_url}'><p>Repo name: ${repo.name}</p></a> | ||
| <p>Default branch: ${repo.default_branch}</p> | ||
| <p>Last push: ${new Date(repo.pushed_at).toDateString()} | ||
| <p id =${repo.name}>Number of commits: </p> | ||
|
|
||
| </div> | ||
| ` | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe here you could look over your structure a bit and remove blanks space so that it follows codeguidlines |
||
|
|
||
| }) | ||
|
|
||
| getPullRequest(forkedRepos) | ||
| drawChart(forkedRepos.length) | ||
| }) | ||
| } | ||
|
|
||
| const getPullRequest= (repos) => { | ||
| repos.forEach((repo)=> { | ||
| fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`) | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| const myPullRequest = data.find((pull)=> pull.user.login === repo.owner.login) | ||
| if (myPullRequest) { | ||
| getCommits(myPullRequest.commits_url, repo.name) | ||
| } else { | ||
| document.getElementById(`${repo.name}`).innerHTML=`No pullrequest ` | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| const getCommits=(commits, myRepoName) => { | ||
| fetch(commits) | ||
| .then(response => response.json()) | ||
| .then(data =>{ | ||
| document.getElementById(`${myRepoName}`).innerHTML += data.length | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You solved it, good job:)!! |
||
| }) | ||
| } | ||
|
|
||
| getRepos() | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,45 @@ | ||
| * { | ||
| box-sizing: border-box; | ||
| -webkit-box-sizing: border-box; | ||
| -moz-box-sizing: border-box; | ||
| -webkit-font-smoothing: antialiased; | ||
| text-rendering: optimizeLegibility; | ||
| } | ||
|
|
||
| body { | ||
| background: #FFECE9; | ||
| background: #39c440; | ||
| font-family:Verdana, Geneva, Tahoma, sans-serif; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| max-height: 100vh | ||
|
|
||
| } | ||
| .repo-card { | ||
| padding-left: 10px; | ||
| border-style: dashed; | ||
|
|
||
| } | ||
|
|
||
| h1 { | ||
| display: flex; | ||
| width: 100%; | ||
| margin: auto; | ||
| margin-top: 10%; | ||
| justify-content: center; | ||
| font-family:Verdana, Geneva, Tahoma, sans-serif | ||
| } | ||
|
|
||
| .chart { | ||
| width: 50%; | ||
| height:50%; | ||
| } | ||
|
|
||
| .profile { | ||
| justify-content: center; | ||
|
|
||
| } | ||
|
|
||
| .photo { | ||
| width: 100% | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting solution with the variable and the the returnstatment, tought me something new!