Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d87b9b9
Added some layout and javascript
emmajosefina Feb 21, 2022
ecb1080
Some layout changes
emmajosefina Feb 21, 2022
fbf01ff
Added more layout for mobile
emmajosefina Feb 21, 2022
d9126a1
Added more colors
emmajosefina Feb 21, 2022
59608b5
Added more design
emmajosefina Feb 21, 2022
8146151
API IS WORKIN
emmajosefina Feb 22, 2022
6873762
Added some comments in js
emmajosefina Feb 22, 2022
532ae31
Fetched data worked
emmajosefina Feb 23, 2022
48f8690
Added new token
emmajosefina Feb 23, 2022
307c1a4
Changed to new token
emmajosefina Feb 23, 2022
b4409c8
Fetched data and started styling
emmajosefina Feb 23, 2022
f245d41
added more data and styled it
emmajosefina Feb 23, 2022
d27f80a
Fixed fetch and JavaScript styling
emmajosefina Feb 23, 2022
7ea017e
Added more styling and tablet design
emmajosefina Feb 23, 2022
9016a76
Added more responsive design
emmajosefina Feb 23, 2022
4ae0893
Added more responsive design
emmajosefina Feb 23, 2022
9d7671d
Added more responsive design
emmajosefina Feb 23, 2022
36cafff
Latest update with styling
emmajosefina Feb 25, 2022
8270b85
Removed secret file
emmajosefina Feb 25, 2022
f5c8b94
New secret file
emmajosefina Feb 25, 2022
4f427bd
Remove secret file part 2
emmajosefina Feb 25, 2022
2d8553f
Added secret file now
emmajosefina Feb 25, 2022
9a01bf4
Added everything and changed index
emmajosefina Feb 25, 2022
4ae2bc2
Added gitignore moved file
emmajosefina Feb 25, 2022
ffec937
Added comments and som structure
emmajosefina Feb 25, 2022
d89d237
Added a few things
emmajosefina Feb 25, 2022
676f599
Removed unnessecary pictures and added favicon
emmajosefina Feb 26, 2022
69dd254
Filtered only project from Technigo
emmajosefina Feb 26, 2022
d905eee
Added javascript to fix header
emmajosefina Feb 26, 2022
98d2086
Added more javascript in design
emmajosefina Feb 26, 2022
5a1ad61
Added more javascript to add url in right format
emmajosefina Feb 26, 2022
71fd5d4
Added user API
emmajosefina Feb 26, 2022
fff1bbb
Started fetching more data for pull request
emmajosefina Feb 26, 2022
ed0087d
More styling
emmajosefina Feb 26, 2022
19405d7
Added more responsive styling
emmajosefina Feb 26, 2022
ef1bfb3
Added more responsiveness
emmajosefina Feb 26, 2022
b941b58
Added javascript for boxes
emmajosefina Feb 26, 2022
805339b
Added API
emmajosefina Feb 26, 2022
4f1b211
Trying to fix pull request
emmajosefina Feb 26, 2022
6bc8f1e
Latest push with functions
emmajosefina Feb 26, 2022
8d56681
Pull request function works
emmajosefina Feb 26, 2022
113d0bc
Added commits
emmajosefina Feb 26, 2022
beb718c
trying to fix fetch
emmajosefina Feb 26, 2022
fb6a761
Changed position of getCommits function
emmajosefina Feb 27, 2022
4056a22
Fixed javascript
emmajosefina Feb 27, 2022
e262ddd
Added chart.js
emmajosefina Feb 27, 2022
5226d08
Added chart but not showing right things
emmajosefina Feb 27, 2022
fe25f8f
Fixing chart
emmajosefina Feb 27, 2022
a6ed3b0
git commits working again
emmajosefina Feb 27, 2022
b34fd5b
Numbers are being shown
emmajosefina Feb 27, 2022
2e44c8f
Fixed pull
emmajosefina Feb 27, 2022
253ae16
Declared funcion findingPulls
emmajosefina Feb 27, 2022
441059d
Fixed chart
emmajosefina Feb 27, 2022
263a519
styling for charts
emmajosefina Feb 27, 2022
6596035
more for chart
emmajosefina Feb 27, 2022
fe2006f
Changed pull request
emmajosefina Feb 27, 2022
a857c7b
Latest code, commit working
emmajosefina Feb 27, 2022
f732b69
Responsive
emmajosefina Feb 27, 2022
c8c6fef
Everything done
emmajosefina Feb 27, 2022
4359191
Last version
emmajosefina Feb 27, 2022
6c4ef5b
Added reaadme file
emmajosefina Feb 27, 2022
4fec26a
Update README.md
emmajosefina Feb 27, 2022
2aedf0a
Update README.md
emmajosefina Feb 27, 2022
7d010ae
Update README.md
emmajosefina Feb 27, 2022
d0fed93
Last few fixes
emmajosefina Feb 27, 2022
26fa291
Update README.md
emmajosefina Feb 27, 2022
5a36db5
Made it responsive
emmajosefina Mar 20, 2022
212fa1d
Merge branch 'main' of https://github.com/emmajosefina/project-github…
emmajosefina Mar 20, 2022
f0318aa
Updated token and added some code in index.html
emmajosefina Mar 27, 2022
a679bc4
Updated
emmajosefina Mar 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
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/
2 changes: 2 additions & 0 deletions code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// .gitignore file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job with gitignore!

secret.js
36 changes: 33 additions & 3 deletions code/chart.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,

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The 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 👇
Binary file added code/images/github-logo-extra-big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/images/github-logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 47 additions & 6 deletions code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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-->

Choose a reason for hiding this comment

The 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">

Choose a reason for hiding this comment

The 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>

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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>
134 changes: 134 additions & 0 deletions code/script.js
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('-', ' ')}
Copy link

@idanaslund idanaslund Feb 28, 2022

Choose a reason for hiding this comment

The 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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good with the month as short

</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.`;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done with displaying the pull requests!

});

});
};
Loading