Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret.js
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# 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.
Assignment to fetch Technigo Projects with name and URL + number of commits via pull requests.
Also calculate projects made comparing to projects remaining.

## 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 with the Js file - trying one API fetch at a time - console logging and then positioning the data in InnerHTML before declaring and invoking next function. After all information i needed was fetched I did the styling. Last I made the chart and the token.
I googled, used SO for checking other people questions regarding this project.
If I had more time I would have added more information like commit comments.

## 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://ecstatic-wing-3740de.netlify.app/
29 changes: 27 additions & 2 deletions code/chart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
//DOM-selector for the canvas 👇
//DOM-selector for the canvas
const ctx = document.getElementById('chart').getContext('2d')

//"Draw" the chart here 👇
const activateChart = (projects) => {

const labels = [
'Projects completed',
'Projects in pipeline',
];

const data = {
labels: labels,
datasets: [{
data: [projects, 19-projects],
backgroundColor: ['rgb(255, 99, 132)','rgb(255, 69, 0)'],
borderColor: ['rgb(255, 99, 132)','rgb(255, 69, 0)'],
Comment on lines +15 to +16

Choose a reason for hiding this comment

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

Ah smart solution for "removing" the border on the chart!

}]
};

const config = {
type: 'doughnut',
data: data,
};

new Chart(document.getElementById('chart'),config);

}


Binary file added code/hero-grafitti2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 20 additions & 6 deletions code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@
<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="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&family=Roboto:wght@100;300;400;500;700;900&family=Tangerine:wght@400;700&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<link rel="stylesheet" href="./style.css" />
</head>
<body>
<h1>GitHub Tracker</h1>
<h2>Projects:</h2>
<main id="projects"></main>

<!-- This will be used to draw the chart 👇 -->
<canvas id="chart"></canvas>
<header class="hero-image">
</header>
<main id="projects">
<section class="user-container" id="userContainer"></section>
<section class="project-container" id="projectContainer"></section>
</main>

<section class="chart-section">
<div class="chart-container">
<canvas class= "chart" id="chart" >
</canvas>
</div>
</section>

<!-- secret TOKEN file also deducted with .gitignore file-->
<script src="./secret.js"></script>
<script src="./script.js"></script>
<script src="./chart.js"></script>
</body>
Expand Down
102 changes: 102 additions & 0 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//DOM selectors
const userContainer = document.getElementById ('userContainer')
const projectContainer = document.getElementById ('projectContainer')

//Global selectors
const user = 'josse79'
const API_USER = `https://api.github.com/users/${user}`
const API_REPOS_LIST = `https://api.github.com/users/${user}/repos`

//The TOKEN function
const options = {
method: 'GET',
headers: {
Authorization: 'API_KEY'
}
}

//1st function and fetch to get the user details
const getUser = () => {
fetch(API_USER, options)
.then(res => res.json())
.then(data => {
userContainer.innerHTML = `
<img class='user-image' src='${data.avatar_url}'/>
<h2 class='user-name'> ${data.login}</h2>`
})
getRepos ()
}
//2nd function and fetch to get the repo list
const getRepos = () => {
fetch(API_REPOS_LIST, options)
.then(res => res.json())
.then(data => {
//Filtering out the forked repos & repos starting with project
const forkedRepos = data.filter((repo) => repo.fork && repo.name.startsWith('project'))
forkedRepos.forEach((repo) => {
//Positioning the information in HTML also with dynamic ID repo.name
projectContainer.innerHTML += `
<div class='repos' id=${repo.name}>
<h1>${repo.name}</h1>
<a href='${repo.html_url}' target='_blank'>${repo.html_url}</a>
<p>Default branch ${repo.default_branch}</p>
<p>Recent push: ${new Date(repo.pushed_at).toDateString()}</p>
</div>`
})
//Passing the filtered repos to next function
getPullRequests(forkedRepos)
//Passing the filtered repos length to chartfunction in chart.js
activateChart(forkedRepos.length)
})

//3rd function and fetch to get all the pulls with help of repo.name
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(data => {
//Filter my own pulls by comparing user login and repo owner
const filteredPulls = data.find((pull) => pull.user.login === repo.owner.login)
//Passing the filtered pulls to next functions
if (filteredPulls) {
//Passing the commits_url and review_comments_url as arguments to next functions
//Also passing along the dynamic ID repo.name to be able to positioning in HTML
getCommits(filteredPulls.commits_url, repo.name)
getReview(filteredPulls.review_comments_url, repo.name)
} else {
document.getElementById(`${repo.name}`).innerHTML += `
<p>No pull request made</p>`
}
})
})
}

//4th function and fetch. Fetch (commits_url declared in getPullRequests function
//therefore activated by argument URL and repoName
const getCommits = (URL, repoName) => {
fetch(URL, options)
.then(res => res.json())
.then(data => {
//Positioning by dynamic ID repoName
document.getElementById(repoName).innerHTML += `
<p>Number of commits: ${data.length}</p>`
})
}

//5th function and fetch. Fetch (commits_url declared in getPullRequests function
//therefore activated by argument URL and repoName
const getReview = (URL, repoName) => {
fetch(URL, options)
.then(res => res.json())
.then(data => {
//If any review made - positioning data by dynamic ID repoName
if (`${data[0].user.login} == ''`) {
document.getElementById(repoName).innerHTML += `
<p>Review made by: ${data[0].user.login}</p>`
Comment on lines +92 to +95

Choose a reason for hiding this comment

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

Impressive to add the username of the code reviewer

} else {
}
})
}
}
//Invoking first function
getUser ()
115 changes: 113 additions & 2 deletions code/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,114 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: "Roboto", sans-serif
}

h1 {
max-height: 5vh;
min-height: 2vh;
font-weight: 500;
padding-bottom: 1vh;
margin-bottom: 1vh
}

p {
padding: 0.5vh
}

a {
color: rgb(255, 69, 0)
}

.hero-image {
background-image: url("hero-grafitti2.jpg");
width: 100vw;
height: 30vh;
background-position: center;
background-size: cover;
background-repeat: no-repeat
}

body {
background: #FFECE9;
}
color: black;
}

.user-container {
position: relative;
text-align: center;
bottom: 12vh
}

.user-image {
border-radius: 50%;
width: 25vh;
filter: grayscale(100%)
}

.project-container {
display: grid;
margin-top: -5vh;
justify-content: center;
text-align: center;
}
.repos {
padding-bottom: 5vh;
font-weight: 300;
margin-bottom: 5vh;
padding: 1vh;
cursor: pointer;
}

.project-container :hover {
background: linear-gradient(90deg, #D1D1D1, #e6e6e6 50%, #e6e6e6 50%, #e6e6e6 50%, #D1D1D1);

Choose a reason for hiding this comment

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

Didn't notice the hover gradient at first but so nice with a subtle and minimal gradient. Have to try this out on a future project!

}

.chart-section {
display: flex;
justify-content: center;
margin: 7vh 0 15vh;
}
.chart-container {
max-width: 50vw;
min-width: 50vw
}

/*media queries*/
@media screen and (min-width: 668px) {
.hero-image {
height: 35vh
}
.user-container {
bottom: 15vh
}
.user-image {
width: 30vh
}
.project-container {
grid-template-columns: 1fr 1fr
}
h1 {
margin-bottom: 2vh
}
}

@media screen and (min-width: 1025px) and (orientation: landscape) {
.hero-image {
height: 55vh
}
.user-container {
bottom: 18vh
}
.user-image {
width: 35vh
}
.project-container {
margin-left: 12vw;
margin-right: 12vw
}
}