-
Notifications
You must be signed in to change notification settings - Fork 131
marianneardin-githubtracker #98
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
MarianneArdin
wants to merge
5
commits into
Technigo:main
Choose a base branch
from
MarianneArdin: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
1e7cd77
new project
MarianneArdin 6ec4907
Update README.md
MarianneArdin 5b81367
clean up code
MarianneArdin 5d9f2a0
Merge branch 'main' of https://github.com/MarianneArdin/project-githu…
MarianneArdin 5aa29f4
fixes after code review
MarianneArdin 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,20 @@ | ||
| # GitHub Tracker | ||
| Requirements: | ||
|
|
||
| Replace this readme with your own information about your project. | ||
| - A list of all repos that are forked from Technigo | ||
| - Your username and profile picture | ||
| - Most recent update (push) for each repo | ||
| - Name of your default branch for each repo | ||
| - URL to the actual GitHub repo | ||
| - Number of commits for each repo | ||
| - It should be responsive (mobile first) | ||
| - A visualisation, for example through a pie chart, of how many projects you've done so far, compared to how many you will do (in total it will be 19 weekly projects 🥳) using [Chart.js](https://www.chartjs.org/). | ||
|
|
||
| Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
|
|
||
| ## The problem | ||
|
|
||
| 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? | ||
| This project wasn't easy to get my head around. It took me a while to get all fetches to show. I also struggled a bit with the chart. | ||
|
|
||
| ## 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://marianneardin-githubtracker.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| token.js |
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,4 +1,23 @@ | ||
| //DOM-selector for the canvas 👇 | ||
| const ctx = document.getElementById('chart').getContext('2d') | ||
| //DOM-selector for the canvas | ||
|
|
||
| //"Draw" the chart here 👇 | ||
| //Chart showing completed and remaining projects | ||
|
|
||
| const drawChart = (numberOfProjects) => { | ||
| const ctx = document.getElementById('chart').getContext('2d'); | ||
| const config = { | ||
| type: 'pie', | ||
| data: { | ||
| labels: ['Projects completed', 'Projects remaining'], | ||
| datasets: [ | ||
| { | ||
| label: 'Technigo Projects', | ||
| data: [numberOfProjects, 19 - numberOfProjects], | ||
| backgroundColor: ['rgb(255,255,255)', 'rgb(102,153,153)'], | ||
| hoverOffset: 4, | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| const chart = new Chart(document.getElementById('chart'), config); | ||
| }; |
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,46 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <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" /> | ||
| </head> | ||
| <body> | ||
| <h1>GitHub Tracker</h1> | ||
| <h2>Projects:</h2> | ||
| <main id="projects"></main> | ||
| <head> | ||
| <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" /> | ||
| <!--Link to font--> | ||
| <link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
| <link | ||
| href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" | ||
| rel="stylesheet" | ||
| /> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>GitHub Tracker</h1> | ||
| <h3 id="username"></h3> | ||
| </header> | ||
| <section class="profile" id="profile"></section> | ||
|
|
||
| <!-- This will be used to draw the chart 👇 --> | ||
| <canvas id="chart"></canvas> | ||
| <section id="userContainer"></section> | ||
| <section id="projectContainer"></section> | ||
|
|
||
| <script src="./script.js"></script> | ||
| <script src="./chart.js"></script> | ||
| </body> | ||
| </html> | ||
| <!-- This will be used to draw the chart 👇 --> | ||
| <section class="chart-container"> | ||
| <canvas id="chart" class="chart"></canvas> | ||
| </section> | ||
|
|
||
| <!-- This is a little footer --> | ||
| <footer> | ||
| Page by Marianne Ardin week 7 Technigo bootcamp 2022 marianne@ardin.se | ||
| <a href="https://www.linkedin.com/in/marianneardin/" | ||
| >Marianne Ardin on linkedin</a | ||
| > | ||
| </footer> | ||
|
|
||
| <!-- link to chart.js --> | ||
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
| <script src="./token.js"></script> | ||
| <script src="./script.js"></script> | ||
| <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,92 @@ | ||
| //DOM selectors// | ||
| const userContainer = document.getElementById('userContainer') | ||
|
|
||
| //APIs to fetch from | ||
| const username = 'MarianneArdin' | ||
| const API_URL = `https://api.github.com/users/${username}` | ||
| const REPOS_URL = `https://api.github.com/users/${username}/repos` | ||
| //const API_TOKEN = TOKEN || process.env.API_TOKEN | ||
| //const API_MY_PROFILE = 'https://api.github.com/users/MarianneArdin' | ||
|
|
||
|
|
||
| //option for authorization | ||
| const options = { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: `token ${API_TOKEN}` | ||
| } | ||
| } | ||
| //FETCHES PROFILE FROM GITHUB// | ||
| const fetchProfile = () => { | ||
| fetch(API_URL, options) | ||
| .then((response) => response.json()) | ||
| .then((data) => { | ||
| console.log(data) | ||
| userContainer.innerHTML += ` | ||
| <div id="profile" class="profile"> | ||
| <div class="profile-image"> | ||
| <a href="${API_URL}"> | ||
| <img src="${data.avatar_url}" alt="Avatar of ${data.login}"> | ||
| </a> | ||
| </div> | ||
| <a href="https://github.com/MarianneArdin"><h1 class="username">${data.login}<h1></a> | ||
| <h2>My projects</h2> | ||
| </div> | ||
| <div> | ||
| <p>Public repositories: ${data.public_repos}</p> | ||
| </div> | ||
| ` | ||
| }) | ||
| } | ||
| fetchProfile() | ||
|
|
||
| //GET REPOS FROM GITHUB// | ||
| const getRepos = () => { | ||
| fetch(REPOS_URL, options) | ||
| .then((res) => res.json()) | ||
| .then((reposData) => { | ||
| console.log(reposData) | ||
| const forkedRepos = reposData.filter((repo) => repo.fork && repo.name.startsWith("project-")) | ||
| forkedRepos.forEach(repo => { | ||
| projectContainer.innerHTML += | ||
| ` | ||
| <a class="project-link" href="${repo.html_url}" target="_blank"> | ||
| <div class="forkedrepo-div"> | ||
| <h2 class="project-name"> ${repo.name}</h2> | ||
| <p class="project-info"> Default branch: ${repo.default_branch}</p> | ||
| <p class="project-info"> Recent push: ${new Date(repo.pushed_at).toDateString()}</p> | ||
| <p class="project-info" id="commits-${repo.name}"> Amount of commits: </p> | ||
| </div> ` | ||
| }) | ||
| getPullRequests(forkedRepos) | ||
|
|
||
| drawChart(forkedRepos.length) | ||
| }) | ||
| } | ||
| getRepos() | ||
|
|
||
| //GETS REPOS FROM GITHUB// | ||
| const getPullRequests = (repos) => { | ||
| repos.forEach(repo => { | ||
| fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`, options) | ||
| .then(res => res.json()) | ||
| .then((pullData) => { | ||
| let myPullRequest = pullData.find((pull) => pull.user.login === repo.owner.login) | ||
| if (myPullRequest) { | ||
| getCommits(myPullRequest.commits_url, repo.name) | ||
| } else { | ||
| document.getElementById(`commits-${repo.name}`).innerHTML += `No pulls yet.` | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| //GET NUMBER OF COMMITS | ||
| const getCommits = (commitsUrl, repo) => { | ||
| fetch(commitsUrl, options) | ||
| .then(res => res.json()) | ||
| .then((data) => { | ||
| document.getElementById(`commits-${repo}`).innerHTML += `${data.length}` | ||
| console.log(data.length) | ||
| }) | ||
| } | ||
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,69 @@ | ||
| body { | ||
| background: #FFECE9; | ||
| } | ||
| background: grey; | ||
| font-family: 'Bebas Neue', cursive; | ||
| margin: 1rem; | ||
| } | ||
|
|
||
| header { | ||
| background-color: lightgrey; | ||
| border-radius: 180%; | ||
| color: black; | ||
| text-align: center; | ||
| } | ||
|
|
||
| h1 { | ||
| font-size: 40px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| h2 { | ||
| font-size: 40px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| h3 { | ||
| font-size: 20px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| /*Image*/ | ||
| img { | ||
| width: 200px; | ||
| border-radius: 50%; | ||
| padding: 2rem; | ||
| } | ||
|
|
||
| a { | ||
| color: black; | ||
| } | ||
|
|
||
| .profile { | ||
| display: flex; | ||
| justify-content: center; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| width: 50%; | ||
| } | ||
| .forkedrepo-div { | ||
| border: black solid; | ||
| padding: 1rem; | ||
| margin: 2rem; | ||
| } | ||
| /* THE CHART SECTION */ | ||
|
|
||
| #chart-wrapper { | ||
| width: 90%; | ||
| margin: 20px auto 40px; | ||
| } | ||
|
|
||
| #chart { | ||
|
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 also would be better to use the class name instead of the id for the chart? |
||
| padding: 20%; | ||
| } | ||
|
|
||
| /* This is styling for the footer*/ | ||
| footer { | ||
| background-color: darkgrey; | ||
| text-align: center; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Here I noticed that the last div containing the p tag public repositories is outside of the main div (starting from row 26). That means that the styling done with the class name profile isn't included into that div. Perhaps that was meant to be, just wanted to brought this up just in case :)