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 @@
code/secret.js
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did you know you could add the .DS_Store file into your gitignore file as well so it doesn't get committed?

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
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.
-track nr of forked technigo projects and link to the repository
-display user img
-display user name
-display default branch
-display last push
-display number och commits

## 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?
My biggest issue was with getting the fetch for number of commits but solved the problem in the end with help from student collegue.
I had passed on the wrong parameters and was actually looking for the commits in the wrong place.

## 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://tender-minsky-8b6ded.netlify.app/
Binary file added code/.DS_Store
Binary file not shown.
39 changes: 36 additions & 3 deletions code/chart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
//DOM-selector for the canvas 👇
const ctx = document.getElementById('chart').getContext('2d')

//"Draw" the chart here 👇
// //DOM-selector for the canvas 👇
const ctx = document.getElementById("chart").getContext("2d");


const drawChart = (amount) => {
const labels = [
'Projects done',
'Technigo projects',
];

const data = {
labels: labels,
datasets: [{
label: 'My First dataset',
data: [amount, 19-amount],
Comment on lines +6 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job passing in the amount of projected you have completed in your drawChart function. Nicely done!

backgroundColor: ['rgba(203,108,127,255)', 'rgba(245,243,240)' ],
borderColor: 'none',
}]
};

const config = {
type: 'doughnut',
data: data,
options: {
responsive: true,
maintainAspectRatio: true,
}
};

const myChart = new Chart(
document.getElementById('chart'),
config
);
}

console.log('test')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think you forgot to remove a console log here on line 37 :)

Binary file added code/img/.DS_Store
Binary file not shown.
Binary file added code/img/susan-wilkinson-SjhL-Zrol6A-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 21 additions & 6 deletions code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project GitHub Tracker</title>
<link rel="stylesheet" href="./style.css" />
<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="hero">
<div id="userDataWrapper" class="user-data-wrapper"></div>
<section class="img-wrapper" id="imgWrapper"> </section>
</header>

<main class="project-wrapper" id="projects"></main>

<!-- This will be used to draw the chart 👇 -->
<canvas id="chart"></canvas>
<section class="chart-box">
<divc class="chart-wrapper" style="position: relative;">
<canvas id="chart"></canvas>
</div>
</section>

<footer>
<p> images from unsplash.com</p>
</footer>
Comment on lines +13 to +29
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

NIce job keeping your html file minimal and great job using semantic html.


<script src="./script.js"></script>
<script src="./chart.js"></script>
<script src="./secret.js"></script>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would suggest removing this script tag for the secret js file. I don't believe you have a secret js file?

<script src="./script.js"></script>
</body>
</html>
</html>

107 changes: 107 additions & 0 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//DOM-selectors

const imgWrapper = document.getElementById('imgWrapper')
const userDataWrapper = document.getElementById('userDataWrapper')
const projects = document.getElementById('projects')

//Github API
const username = 'Nosslexa'
const API_URL = `https://api.github.com/users/${username}/repos`

const options = {
method: 'GET',
headers: {
Authorization: 'API_TOKEN'
}
}
Comment on lines +11 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would suggest removing this as well since, I mentioned earlier that you don't seem to have a secret file and I think you can remove this code from line 11-16, since you don't seem to be using it in your script file.



// This function fetch all my repos and then filters() out the ones forked = true and starts with "project-"
const getRepos = () => {
fetch(API_URL, options)
.then(res => res.json())
.then(data => {
console.log(data)
console.log(data[0].owner)
Comment on lines +24 to +25
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think you forgot to remove some console logs here in this file as well :)


const forkedRepos = data.filter((repo) => repo.fork && repo.name.startsWith("project-"))
console.log(forkedRepos)

getPullRequests(forkedRepos)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job passing on your forked projects into your getPullRequests function.



// injects profile img and user data to the HTML.
imgWrapper.innerHTML = `
<div>
<img class="img" src="${data[0].owner.avatar_url}" alt="userimage">
</div>
`

userDataWrapper.innerHTML += `
<h1>Github tracker</h1>
<p>${data[0].owner.login} : Frida Axelsson</p>
`

//display repo info
forkedRepos.forEach((data) => {
let projectID = data.id

projects.innerHTML +=`
<div class="repo-card" id="${projectID}">
<a href="${data.html_url}">
<h3>${data.name}</h3></a>
<p>Branch: ${data.default_branch}</p>
<p>Last push: ${new Date(data.pushed_at).toDateString()}</p>
<p id="repoName" > </p>
</div>`

getCommits(data, projectID);
})
getPullRequests(forkedRepos)
drawChart(forkedRepos.length)
})
}

//funktion to get commits
const getCommits = (projects, projectID) => {
const GIT_COMMIT_API = projects.commits_url.replace("{/sha}", "")
fetch (GIT_COMMIT_API)
.then((res) => res.json())
.then(data => {
let numberOfCommits = data.length
document.getElementById(projectID).innerHTML +=`
<p> Number of commits: ${numberOfCommits}</p>`
})
}

//function to find() my pullrequests and comments
const getPullRequests = (forkedRepos) => {
forkedRepos.forEach(repo => {
fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`,)
.then(res => res.json())
.then(data => {
console.log(data)

const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login)
console.log(myPullRequests)
})
})
}


getRepos()















Comment on lines +93 to +107
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would suggest removing the empty lines you have here and the ones in your css file to keep your file clean.

168 changes: 166 additions & 2 deletions code/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,167 @@
body {
background: #FFECE9;
}
background: white;
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}

header{
background: pink;
}

.hero{
background-image: url(./img/susan-wilkinson-SjhL-Zrol6A-unsplash.jpg) ;
background-position: left bottom;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
position: relative;
height: 300px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
Comment on lines +13 to +24
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job utilizing flex box in your project!

.user-data-wrapper{
height: 200px;
text-align: center;
color: #f5f3f0;
display: flex;
flex-direction: column;
justify-content: center;
}

.user-data-wrapper p{
font-size: smaller;
margin: 0;
padding: 0;
}

.user-data-wrapper h1{
margin-bottom: 0;
}

.img-wrapper{
display: flex;
justify-content: center;
align-self: flex-end;
position: absolute;
top: 200px;
}

img{
border-radius: 50%;
height: 150px;
filter: saturate(70%);
filter: grayscale(50%);
align-self: flex-end;
}

.project-wrapper{
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
margin-top: 25%;
margin-bottom: 25%;
}

.repo-card{
height: 40vh;
width: 80vw;
background-color: #f5f3f0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.repo-card a {
text-decoration: none;
color: black;

}

.chart-box{
display: flex;
justify-content: center;
}



footer{
font-size: small;
background-color: #f5f3f0;
color: gray;
width: 100%;
height: 10vh;
margin: 0%;
display: flex;
justify-content: center;
align-items: flex-end;
margin-top: 25%;
}

@media (min-width: 768px) and (orientaion: landscape) {
.hero{
height: 400px;
}

.img-wrapper{
top: 300px;
}

img{
height: 200px;
}
.project-wrapper{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-bottom: 25%;
}

.repo-card{
height: 20vh;
width: 40vw;
display: flex;
flex-direction: column;
justify-content: center;
border: solid;
}
}

.repo-card h3{
margin-bottom: 10px;
}
.repo-card p{
margin: 2px;
}

@media (min-width: 992px){
.project-wrapper{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-bottom: 25%;
}

.repo-card{
height: 45vh;
width: 30vw;
display: flex;
flex-direction: column;
justify-content: center;

}

img{
height: 300px;
}

}