-
Notifications
You must be signed in to change notification settings - Fork 131
Week 7 – Github Tracker – Emma Lindell #111
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
base: main
Are you sure you want to change the base?
Changes from all commits
d87b9b9
ecb1080
fbf01ff
d9126a1
59608b5
8146151
6873762
532ae31
48f8690
307c1a4
b4409c8
f245d41
d27f80a
7ea017e
9016a76
4ae0893
9d7671d
36cafff
8270b85
f5c8b94
4f427bd
2d8553f
9a01bf4
4ae2bc2
ffec937
d89d237
676f599
69dd254
d905eee
98d2086
5a1ad61
71fd5d4
fff1bbb
ed0087d
19405d7
ef1bfb3
b941b58
805339b
4f1b211
6bc8f1e
8d56681
113d0bc
beb718c
fb6a761
4056a22
e262ddd
5226d08
fe25f8f
a6ed3b0
b34fd5b
2e44c8f
253ae16
441059d
263a519
6596035
fe2006f
a857c7b
f732b69
c8c6fef
4359191
6c4ef5b
4fec26a
2aedf0a
7d010ae
d0fed93
26fa291
5a36db5
212fa1d
f0318aa
a679bc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| # GitHub Tracker | ||
| # GitHub Tracker 📊 | ||
|
|
||
| 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. | ||
| This weeks project was to create a GitHub tracker using JavaScript and GitHub API. | ||
|
|
||
| ## 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? | ||
| I started the project by fetching the data and filtered the repositories I wanted to show on my site. My main struggle this week was JavaScript, I found it hard to create more structure of it. To solve my problem I discussed a lot with my team and asked questions in StackOverflow. If I had more time I would like to fetch more data to display on my page, and also make it even more responsive. | ||
|
|
||
| ## 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://github-tracker-emmajosefina.netlify.app/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // .gitignore file | ||
| secret.js | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,34 @@ | ||
| //DOM-selector for the canvas 👇 | ||
| const ctx = document.getElementById('chart').getContext('2d') | ||
| const ctx = document.getElementById('chart').getContext('2d') | ||
|
|
||
| const renderChart = (completedProjects) => { | ||
|
|
||
|
|
||
| const labels = [ | ||
| 'Projects done', | ||
| 'Projects left to do' | ||
| ]; | ||
|
|
||
| const data = { | ||
| labels: labels, | ||
| datasets: [{ | ||
| backgroundColor: 'rgb(217, 169, 165)', | ||
| label: 'Technigo Projects', | ||
| borderColor: 'rgb(192, 113, 106)', | ||
| data: [completedProjects, 19-completedProjects], | ||
| }] | ||
| }; | ||
|
|
||
| const config = { | ||
| type: 'bar', | ||
| data: data, | ||
| options: { | ||
| responsive: true, | ||
|
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. Did you want the chart to cover the page from side to side? Because the size of the chart is good for mobile size but displays quite big in desktop size.
Author
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. Thanks for noticing Ida! I thought about that too and want to change it for desktop. Do you know which element to add in that case? 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. I found the instructions here: https://www.chartjs.org/docs/latest/configuration/responsive.html
Author
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. Oh, thanks! I got a 404 though :( |
||
| } | ||
| }; | ||
|
|
||
|
|
||
| new Chart( | ||
| document.getElementById('chart'), | ||
| config | ||
| )} | ||
|
|
||
| //"Draw" the chart here 👇 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,18 +4,59 @@ | |
| <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> | ||
| <title>Project GitHub Tracker – emmajosefina</title> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
|
|
||
| <!-- GOOGLE FONT--> | ||
|
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. I like that you explain what these do! |
||
| <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=Heebo:wght@100;200;300;400&display=swap" rel="stylesheet"> | ||
|
|
||
| <!-- FONT AWESOME--> | ||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | ||
|
|
||
| <!-- FAVICON --> | ||
| <link rel="icon" href="images/github-logo-small.png" type="image/gif" sizes="16x16"> | ||
|
|
||
| <!-- CHART SCRIPT--> | ||
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h1>GitHub Tracker</h1> | ||
| <h2>Projects:</h2> | ||
| <main id="projects"></main> | ||
| <header class="navbar"> | ||
| <a href="https://github.com/emmajosefina"> | ||
|
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. Smart and simple to put the profile name in html |
||
| <img src="images/github-logo-extra-big.png" class="github-logo" alt="github-logo"> | ||
| </a> | ||
| </header> | ||
|
|
||
|
|
||
|
|
||
| <!-- This will be used to draw the chart 👇 --> | ||
| <canvas id="chart"></canvas> | ||
| <div class="chart-parent"> | ||
|
|
||
| <div class="chart-container"> | ||
| <div id="mainContent" class="main-content"></div> | ||
| <canvas class="chart" id="chart"></canvas> | ||
| </div> | ||
| </div> | ||
|
|
||
| <section id="projectInfo" class="user-info"></section> | ||
|
|
||
| <footer> | ||
| <p> | ||
| <a href="https://www.linkedin.com/in/emmalindell4/" class="fa fa-linkedin fa-2x"></a> | ||
|
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. Looks good! Maybe for accessibility make them easier for a screenreader to explain?
Author
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. Great thanks, will think about it for this week's project |
||
| <a href="https://github.com/emmajosefina" class="fa fa-github fa-2x"></a> | ||
| </p> | ||
|
|
||
| <footer class="footer-text"> | ||
| <p>Project 7 – Github Tracker</p> | ||
| <p>By Emma Lindell @ Technigo Bootcamp 2022</p> | ||
| </footer> | ||
|
|
||
| </footer> | ||
|
|
||
| <script src="./secret.js"></script> | ||
| <script src="./script.js"></script> | ||
| <script src="./chart.js"></script> | ||
|
|
||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| // Token | ||
| const options = { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: `TOKEN ${API_TOKEN}` | ||
| } | ||
| } | ||
|
|
||
| // DOM selectors | ||
| const projectInfo = document.getElementById('projectInfo') | ||
| const userInfo = document.getElementById('userInfo') | ||
| const aboutUser = document.getElementById('aboutUser') | ||
| const profilePicture = document.getElementById('profilePicture') | ||
| const mainContent = document.getElementById('mainContent') | ||
|
|
||
|
|
||
| // Github API | ||
| const username = 'emmajosefina' | ||
| const API_URL = `https://api.github.com/users/${username}/repos` | ||
| const API_USER = `https://api.github.com/users/${username}` | ||
|
|
||
|
|
||
|
|
||
| //------------------ FIRST FETCH - USER PROFILE -----------------------// | ||
| const getProfile = () => { | ||
| fetch(API_USER, options) | ||
| .then((res) => res.json()) | ||
| .then((data) => { | ||
| mainContent.innerHTML += | ||
| ` | ||
| <section class="profile-box"> | ||
| <img src="${data.avatar_url}" id="profilePicture" class="profile-picture" /> | ||
| <p class="full-name">${data.name}</p> | ||
| <p class="username">${data.login}</p> | ||
| </section> | ||
| <div class="status-box"> | ||
| <p class="status-text">${data.bio} 👩💻</p> | ||
| </div> | ||
| `; | ||
| }); | ||
| }; | ||
| getProfile(); | ||
|
|
||
|
|
||
| //------------------ SECOND FETCH - ALL REPOS -----------------------// | ||
| const findingAllRepos = (repos) => { | ||
| fetch(API_URL, options) | ||
| .then((res) => res.json()) | ||
| .then((data) => { | ||
|
|
||
|
|
||
|
|
||
| // Fetches only repositories from Technigo // | ||
| const forkedRepos = data.filter((repo) => repo.fork && repo.name.startsWith('project-')) | ||
|
|
||
|
|
||
| forkedRepos.forEach((repo) => | ||
| projectInfo.innerHTML += | ||
|
|
||
| ` | ||
| <div class="projectContainer"> | ||
| <p class="smallerContainer"> | ||
| <span class="header-project"> | ||
| ${repo.name.replace('project-', '').replace('-', ' ')} | ||
|
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. Really nice removing "project" and the hyphens, I never got around to that myself. It also makes it more visible that the repos ar displayed alphabetically. |
||
| </span> | ||
| </p> | ||
| <p class="smallerContainer"> | ||
| <span> Updated:</span> | ||
| <span> ${new Date(repo.pushed_at).toLocaleDateString('en-SE', {year: 'numeric', month: 'short', day: 'numeric'})}</span> | ||
|
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. Looks really good with the month as |
||
| </p> | ||
| <p class="smallerContainer"> | ||
| <span> | ||
| Default branch: </span> | ||
| <span>${repo.default_branch}</span> | ||
| </p> | ||
| <p class="smallerContainer" id="commit-${repo.name}"> | ||
| <span> | ||
| Number of commits: | ||
| </span> | ||
| </p> | ||
| <p class="smallerContainer" id="pull-request-${repo.name}"> | ||
| <span>Pull requests: </span> | ||
| </p> | ||
| <p class="smallerContainer"> | ||
| <img src="images/github-logo-extra-big.png" alt="github-logo" width="15px" /> | ||
| <span><a class="project-url" href="${repo.svn_url}"> | ||
| ${repo.name}</span> | ||
| </a> | ||
| </p> | ||
| </div> | ||
| ` | ||
| ) | ||
| getPullRequest(forkedRepos) | ||
| renderChart(forkedRepos.length) | ||
| }) | ||
| } | ||
| findingAllRepos() | ||
|
|
||
|
|
||
|
|
||
| const getCommits = (myCommitsUrl, myRepoName) => { | ||
| fetch(myCommitsUrl, options) | ||
| .then((res) => { | ||
| return res.json() | ||
| }) | ||
| .then((data) => { | ||
|
|
||
| document.getElementById(`commit-${myRepoName}`).innerHTML += data.length | ||
| }) | ||
| } | ||
|
|
||
| //------------------ THIRD FETCH - PULL REQUESTS -----------------------// | ||
| const getPullRequest = (repos) => { | ||
| repos.forEach((repo) => { | ||
| fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`, options) | ||
| .then((res) => res.json()) | ||
| .then((data) => { | ||
|
|
||
| //Filter out pullrequests | ||
| const pulls = data.find((pull) => pull.user.login === repo.owner.login) | ||
| const myPullRequests = data.filter((pullRequest) => { | ||
| return pullRequest.user.login === username | ||
| }) | ||
| document.getElementById(`pull-request-${repo.name}`).innerHTML = `Pull Request: ${myPullRequests.length}` | ||
| if (pulls) { | ||
| getCommits(pulls.commits_url, repo.name) | ||
| } else { | ||
| document.getElementById( | ||
| `commit-${repo.name}`).innerHTML += `no commits visible, pull request unavailable.`; | ||
| } | ||
|
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. Nicely done with displaying the pull requests! |
||
| }); | ||
|
|
||
| }); | ||
| }; | ||
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.
Good job with gitignore!