-
Notifications
You must be signed in to change notification settings - Fork 130
GitHub Tracker - Jessica Sandler #105
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
jessand77
wants to merge
22
commits into
Technigo:main
Choose a base branch
from
jessand77: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 17 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
400819c
First commit
7b4b25a
Second commit
2b9c753
Added getCommits function etc
jessand77 3199be4
Added pull request commits etc
jessand77 32a3a0c
Added some styling and comment/commit message lists
jessand77 7db2bec
Added gitignore
jessand77 65bf852
Added some more styling
jessand77 31a4dd8
Tried to fix token
jessand77 39db693
Update index.html
jessand77 46d7642
Update index.html
jessand77 be9ad4b
Update index.html
jessand77 51da6ef
Added chart trial
jessand77 291cfda
Chart trial
jessand77 cf1d134
Added buttons
jessand77 d43b3e6
Updated getCommits function and changed colors
jessand77 878caa9
Added pull requests for pair and group projects
jessand77 b242b32
Updated README.md etc
jessand77 06c9b6c
updated getPullRequests function
jessand77 75248f4
Removed options
jessand77 b25f1b1
Added pull request info
jessand77 eb8bd28
Add PR title for project-auth
jessand77 d5acff0
Uncomment options in script.js
jessand77 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
Binary file not shown.
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,23 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files | ||
|
|
||
| # Ignore Mac system files | ||
| .DS_store | ||
|
|
||
| # Ignore node_modules folder | ||
| node_modules | ||
|
|
||
| # Ignore all text files | ||
| *.txt | ||
|
|
||
| # Ignore files related to API keys | ||
| .env | ||
|
|
||
| # misc | ||
| /.pnp | ||
| .pnp.js | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # other | ||
| code/secret.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,13 +1,7 @@ | ||
| # 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. | ||
|
|
||
| ## 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? | ||
| The GitHub Tracker displays my repos that are forked from Technigo with info about them fetched using the GitHub API. It also includes a chart that was created using chart.js. | ||
|
|
||
| ## 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://jessicas-github-tracker-project.netlify.app |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,162 @@ | ||
| const userSection = document.getElementById("user"); | ||
| const projectSection = document.getElementById("projects"); | ||
|
|
||
| const username = 'jessand77'; | ||
| const API_USER_INFO = `https://api.github.com/users/${username}`; | ||
| const API_REPOS = `${API_USER_INFO}/repos`; | ||
|
|
||
| const options = { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: 'token ' + API_TOKEN | ||
| } | ||
| }; | ||
|
|
||
| const fetchUserInfo = () => { | ||
| fetch(API_USER_INFO, options) | ||
| .then(res => res.json()) | ||
| .then(user => { | ||
| userSection.innerHTML = ` | ||
| <h3>${user.name}</h3> | ||
| <p>Username: ${user.login}</p> | ||
| <a href="${user.html_url}" target="_blank"><img class="avatar" src="${user.avatar_url}" alt="profile picture" /></a> | ||
| `; | ||
| }); | ||
| }; | ||
|
|
||
| const getCommits = (pullRequestCommitsUrl, reponame) => { | ||
| fetch(pullRequestCommitsUrl, options) | ||
| .then(res => res.json()) | ||
| .then(commits => { | ||
|
|
||
| let repoDiv = document.getElementById(`${reponame}-div`); | ||
| let repoDivContent = document.getElementById(`${reponame}-div-content`); | ||
|
|
||
| let commitParagraph = document.createElement('p'); | ||
| commitParagraph.innerHTML = `Number of commits: <span>${commits.length}</span>`; | ||
| repoDivContent.appendChild(commitParagraph); | ||
|
|
||
| // Create a new div to put the commit messages and the hide commits button in | ||
| let commitDiv = document.createElement('div'); | ||
| commitDiv.className = 'commit-div'; | ||
| commitDiv.style.display = 'none'; | ||
| repoDiv.appendChild(commitDiv); | ||
|
|
||
| let commitMessageList = document.createElement('ol'); | ||
| commitMessageList.className = 'message-list'; | ||
| commitDiv.appendChild(commitMessageList); | ||
|
|
||
| commits.forEach(commit => { | ||
| let commitMessage = document.createElement('li'); | ||
| commitMessage.innerHTML = commit.commit.message; | ||
| commitMessageList.appendChild(commitMessage); | ||
| }); | ||
|
|
||
| // Buttons to show or hide commit comments | ||
| let showCommitsButton = document.createElement('button'); | ||
| showCommitsButton.className = 'commits-button'; | ||
| showCommitsButton.innerHTML = 'Show commits'; | ||
| repoDivContent.appendChild(showCommitsButton); | ||
|
|
||
| let hideCommitsButton = document.createElement('button'); | ||
| hideCommitsButton.className = 'commits-button'; | ||
| hideCommitsButton.innerHTML = 'Hide commits'; | ||
| commitDiv.appendChild(hideCommitsButton); | ||
|
|
||
| const showCommitMessageList = () => { | ||
| repoDivContent.style.display = 'none'; | ||
| commitDiv.style.display = 'block'; | ||
| } | ||
|
|
||
| const hideCommitMessageList = () => { | ||
| commitDiv.style.display = 'none'; | ||
| repoDivContent.style.display = 'flex'; | ||
| } | ||
|
|
||
| showCommitsButton.addEventListener('click', showCommitMessageList); | ||
| hideCommitsButton.addEventListener('click', hideCommitMessageList); | ||
| }) | ||
| } | ||
|
|
||
| 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(pullRequests => { | ||
|
|
||
| // How can I get the pull requests for the repos that I am not the owner of without hardcoding like this? | ||
| const firstTitleToSearchFor = 'Week 4 project - Sofie Pellegrini & Jessica Sandler'; | ||
| const secondTitleToSearchFor = 'Week 6 project : Jessica - Maurii - Nadia - Rijad - Terese'; | ||
|
|
||
| const myPullRequests = pullRequests | ||
| .filter(pullRequest => pullRequest.user.login === username || pullRequest.title === firstTitleToSearchFor || pullRequest.title === secondTitleToSearchFor) | ||
|
|
||
| //If the length is 0 no pull request has been made | ||
| if (myPullRequests.length === 0) { | ||
|
|
||
| let repoDivContent = document.getElementById(`${repo.name}-div-content`); | ||
| let commitParagraph = document.createElement('p'); | ||
|
|
||
| commitParagraph.innerHTML = `<span>No pull request found</span>`; | ||
| commitParagraph.className = "no-pullrequest"; | ||
|
|
||
| repoDivContent.appendChild(commitParagraph); | ||
| } | ||
|
|
||
| //Fetches the commits for all the projects where a pull request has been made | ||
| myPullRequests.forEach(myPullRequest => { | ||
| getCommits(myPullRequest.commits_url, repo.name); | ||
| }); | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| // This function filters out repos that are forked and start with "project" | ||
| const getTechnigoRepos = (repos) => { | ||
| return repos | ||
| .filter(repo => repo.fork === true && repo.name.startsWith("project")) | ||
| }; | ||
|
|
||
|
Comment on lines
+115
to
+135
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. Good use of comments |
||
| const fetchRepos = () => { | ||
| fetch(API_REPOS, options) | ||
| .then(res => res.json()) | ||
| .then(repos => { | ||
|
|
||
| const technigoRepos = getTechnigoRepos(repos); | ||
|
|
||
| getPullRequests(technigoRepos); | ||
|
|
||
| projectSection.innerHTML = ` | ||
| <h2>My Technigo projects:</h2> | ||
| <div class="repo-container" id="repoContainer"></div> | ||
| `; | ||
|
|
||
| // Get the number of forked Technigo projects and draw the chart | ||
| const numberOfTechnigoRepos = technigoRepos.length; | ||
| drawChart(numberOfTechnigoRepos); | ||
|
|
||
| technigoRepos.forEach((repo) => { | ||
|
|
||
| const mostRecentPush = new Date(repo.pushed_at).toLocaleDateString('en-GB'); | ||
|
|
||
| repoContainer.innerHTML += ` | ||
| <div id=${repo.name}-div class="repo-div"> | ||
| <div id=${repo.name}-div-content class="repo-div-content"> | ||
| <h4><a href="${repo.html_url}" target="_blank">${repo.name}</a></h4> | ||
| <p>Most recent push: <span>${mostRecentPush}</span></p> | ||
| <p>Default branch: <span>${repo.default_branch}</span></p> | ||
| </div> | ||
| </div> | ||
| `; | ||
|
|
||
| }); | ||
| }); | ||
| }; | ||
|
|
||
|
|
||
| fetchUserInfo(); | ||
| fetchRepos(); | ||
|
|
||
|
|
||
|
|
||
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.
Really cool feature