-
Notifications
You must be signed in to change notification settings - Fork 131
GitHub Tracker by Birgit Nehrwein #23
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
nehrwein
wants to merge
19
commits into
Technigo:main
Choose a base branch
from
nehrwein: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
19 commits
Select commit
Hold shift + click to select a range
e7e5069
Getting started with the first functions getRepos(), getPushBranchURL…
nehrwein f4c5e0a
fetched commits and drew the chart for 'done projects'
nehrwein 123aec7
started styling the header and user-section
nehrwein 3214658
worked on no. of commits
nehrwein f7ef0f5
fixed problems with getting no of commits
nehrwein d630a84
more attempts to get the toggle work (no succeed)
nehrwein 07ca34d
fixed commits accordion, added media queries & styling
nehrwein 831bf7d
some styling
nehrwein a017a81
styled header and chart legend
nehrwein c88e402
fixed sort
nehrwein 3a5bfd7
commented out token section
nehrwein deecb87
updated Read.me
nehrwein d234e05
adjusting font-size
nehrwein e4b8403
test pushing without prettier extension
nehrwein 70a84d4
changed tab size to 4
nehrwein 264b648
fixed intendation
nehrwein 427e208
fixed indentation
nehrwein dbeaf80
commented out authorization
nehrwein 5abde44
fixed sorting bug
nehrwein 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,25 @@ | ||
| # GitHub Tracker | ||
|
|
||
| Replace this readme with your own information about your project. | ||
| This project is all about working with the Github-API. | ||
|
|
||
| The tracker shows | ||
| - username/pic | ||
| - all the repos that are done by me during the Technigo bootcamp | ||
| - no. of commits and commit messages for each repository | ||
| - a doughnut pie from chart.js | ||
|
|
||
|
|
||
|
|
||
| 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? | ||
| I focussed in this project on gaining data from the API and filter/sort it in a way that I get all the entries I want to show in my tracker. | ||
|
|
||
| I kept the design simple and made it look close to the original GitHub-website. | ||
|
|
||
| If I would have more time, I would like to add "no. of commits" to the sort field and maybe add a search field also. | ||
|
|
||
|
|
||
| ## 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. | ||
| Take a look at the project here: https://github-tracker-nehrwein.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 |
|---|---|---|
| @@ -1,4 +1,34 @@ | ||
| //DOM-selector for the canvas 👇 | ||
| const ctx = document.getElementById('chart').getContext('2d') | ||
|
|
||
| const drawChart = (doneProjects) => { | ||
| //config for the the doughnut-chart: | ||
| const config = { | ||
| type: 'doughnut', | ||
| data: { | ||
| labels: [ | ||
| 'Finished Projects', | ||
| 'Projects left' | ||
| ], | ||
| datasets: [{ | ||
| label: 'My First Dataset', | ||
| data: [doneProjects, totalProjects - doneProjects], | ||
| backgroundColor: [ | ||
| 'rgb(120, 129, 131)', | ||
| 'rgb(198, 207, 215)', | ||
| ], | ||
| hoverOffset: 5 | ||
| }], | ||
| }, | ||
| options: { | ||
| plugins: { | ||
| legend: { | ||
| position: 'right', | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| //"Draw" the chart here 👇 | ||
| //rendering the chart in the browser/ newChart(where to put it, what to put) | ||
| const chart = new Chart(ctx, 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
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,135 @@ | ||
| //DOM SELECTORS | ||
| const userSection = document.getElementById("user-section") | ||
|
|
||
| //GLOBAL VARIABLES | ||
| /* const options = { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: `token xxx` | ||
| }, | ||
| }; */ | ||
|
|
||
| const REPO_API = "https://api.github.com/users/nehrwein/repos"; | ||
| const totalProjects = 19; | ||
|
|
||
| //FUNCTIONS | ||
|
|
||
|
|
||
| const getRepos = () => { | ||
| fetch(REPO_API, /* options */) | ||
| .then((res) => res.json()) | ||
| .then((data) => { | ||
|
|
||
| //forkedRepos shows a list of all repos that are forked ones from Technigo | ||
| const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-')) | ||
|
|
||
| //show the newest repos first (default) | ||
| forkedRepos.sort((a, b) => { | ||
| return new Date(b.pushed_at) - new Date(a.pushed_at); | ||
| }); | ||
|
|
||
| //My name, username and profile picture | ||
| const userName = data[0].owner.login | ||
| const profilePic = data[0].owner.avatar_url | ||
|
|
||
| userSection.innerHTML += /* html */` | ||
| <div class="userImage_Text"> | ||
| <div class="userImageDiv"> | ||
| <img class="userImage" id="userImage" src="${profilePic}" alt="Github Avatar"> | ||
| </div> | ||
| <div class="userTextDiv"> | ||
| <p class="myName">Birgit</p> | ||
| <p class="userName">${userName}</p> | ||
| </div> | ||
| </div> | ||
|
|
||
| <label for="sort"></label> | ||
| <select class="sort" name="sort" id="sort"> | ||
| <option disabled="" value="">Sorted by: </option> | ||
| <option value="updated">Last updated</option> | ||
| <option value="name">Name</option> | ||
| </select> | ||
| ` | ||
|
|
||
| const sortBtn = document.getElementById('sort') | ||
| sortBtn.addEventListener('change', () => sort(sortBtn.value, forkedRepos)) | ||
|
|
||
| drawProjects(forkedRepos); | ||
| drawChart(forkedRepos.length) | ||
| }) | ||
| } | ||
|
|
||
| //sorting the projects by name, last updated | ||
| const sort = (value, repos) => { | ||
| if (value === "name") { | ||
| repos.sort((a, b) => { | ||
| return (a.name) > (b.name) ? 1 : -1; | ||
| }); | ||
| drawProjects(repos) | ||
| } else if (value === "updated") { | ||
| repos.sort((a, b) => { | ||
| return new Date(b.pushed_at) - new Date(a.pushed_at); | ||
| }); | ||
| drawProjects(repos) | ||
| } | ||
| } | ||
|
|
||
| const drawProjects = (forkedRepositories) => { | ||
| document.getElementById('projects-section').innerHTML = ` ` | ||
| forkedRepositories.forEach((repo) => { | ||
| document.getElementById('projects-section').innerHTML += ` | ||
| <div class="projects-div" id="projects"> | ||
| <a href="${repo.html_url}">${repo.name}</a> | ||
| <p>default branch: ${repo.default_branch}</p> | ||
| <p>Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB')}</p> | ||
| <p class="noOfCommits" id="commit-${repo.name}">Commits: 0</p> | ||
| <ul id="commitMessages-${repo.name}"></ul> | ||
| </div> | ||
| `; | ||
|
|
||
| getCommits(forkedRepositories, repo.name); | ||
| }); | ||
|
|
||
| forkedRepositories.forEach((repo) => { | ||
| document | ||
| .getElementById(`commit-${repo.name}`) | ||
| .addEventListener('click', () => { | ||
| document | ||
| .getElementById(`commitMessages-${repo.name}`) | ||
| .classList.toggle('active'); | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| const getCommits = (filteredArray, myRepoName) => { | ||
|
|
||
| //First make a new array with all the needed APIs (found under commit_urls in forkedRepos) | ||
| const allCommitUrls = filteredArray.map(repo => repo.commits_url) | ||
|
|
||
| allCommitUrls.forEach(commitAPI => { | ||
| //the URLs end with {/sha}, therefore the last 6 chars need to be sliced | ||
| commitAPI = commitAPI.slice(0, -6) | ||
|
|
||
| //now the URLs can be passed on to get data about number and content of commits | ||
| fetch(commitAPI, /* options */) | ||
| .then((res) => res.json()) | ||
| .then((data) => { | ||
| const authorCommits = data.filter(commits => commits.author.login === 'nehrwein' && commits.url.includes(myRepoName)) | ||
| if (authorCommits.length > 0) { | ||
| document.getElementById(`commit-${myRepoName}`).innerHTML = ` | ||
| Commits: ${authorCommits.length}<i class="fas fa-bars"></i> | ||
| ` | ||
| authorCommits.forEach(element => { | ||
| document.getElementById(`commitMessages-${myRepoName}`).innerHTML += ` | ||
| <li>${element.commit.message}</li> | ||
| ` | ||
| }) | ||
| } | ||
| }) | ||
| }); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| getRepos(); | ||
|
|
||
Oops, something went wrong.
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.
I really love our code Birgit and it was so interesting on Friday when you showed it to the group. I think you made an awesome site!!! The implementation of an accordion is just the next level of the project! everything seems to work fine the only trouble I have is whit the sorting function (the name sorting is not working for me). That's not a mandatory feature so if you don't have the time not bother to fix it! You and I did solve some functions in different ways and it is really fun to see our solutions, the code is easy to read and understand!
[YES ] Am I able to understand the code easily?
[NO ] Does the code have lots of duplicates? Could it be tidied up?
[ works ] Does it work or does anything look broken?
[Yes and above! ] Does it follow the general and blue requirements?
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.
Hej Jessica,
thank you so much for your kind review! 👍
And thanks for pointing out, that the sorting isn't working. I will have a look at it again. 🙂