Skip to content

Commit 57beb46

Browse files
committed
fixed the repos info
1 parent 3599422 commit 57beb46

7 files changed

Lines changed: 199 additions & 157 deletions

File tree

code/assets/hello_hero_img.jpg

477 KB
Loading
File renamed without changes.

code/chart.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const ctx = document.getElementById('chart').getContext('2d')
1+
const ctx = document.getElementById('chart').getContext('2d');
22

33

4-
5-
6-
const drawChart = (number) => {
4+
const drawChart = (amount) => {
75
const config = {
8-
type: 'doughnut',
9-
data: {
10-
labels: ["Projects done", "Still to do"],
11-
datasets: [
12-
{
13-
label: "My first Dataset",
14-
data: [number, 20 - number], // divide donut to 2 different parts
15-
backgroundColor: [
16-
"rgb(255, 99, 132)",
17-
"rgb(54, 162, 235)",
18-
],
19-
hoverOffset:4,
20-
},
6+
type: 'doughnut',
7+
data: {
8+
labels: [
9+
'Completed projects',
10+
'Projects left to build',
2111
],
12+
datasets: [{
13+
label: 'My Technigo projects',
14+
data: [amount, 19-amount],
15+
backgroundColor: [
16+
'rgb(219,57,141)',
17+
'rgb(0,255,255)',
18+
],
19+
hoverOffset: 4
20+
}],
2221
},
23-
}
24-
const myChart = new Chart(ctx, config);
25-
};
22+
};
23+
24+
const projectsChart = new Chart(ctx, config);
25+
}

code/index.html

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,47 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<title>Mamites GitHub Tracker</title>
99
<link rel="stylesheet" href="./style.css" />
10-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
11-
12-
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300&display=swap" rel="stylesheet">
1310

11+
<link rel="preconnect" href="https://fonts.googleapis.com">
12+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13+
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100&display=swap" rel="stylesheet">
14+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
1415
</head>
1516

1617
<body>
17-
<nav class="topnav">
18-
<div class="githublogo-container">
19-
<h4>Github Tracker</h4>
20-
</div>
21-
</nav>
22-
<header class="header"></header>
23-
<section class="profile-container" id="profile-container">
24-
<img class="profile-image" src="" id="image" />
25-
<div>
26-
<h1></h1>
27-
</div>
28-
</section>
18+
<header>
19+
<h1>My GitHub Tracker</h1>
20+
</header>
21+
22+
23+
<div class="profile-container" id="profileContainer">
24+
<img id="profileImage" class="profile-image" alt="profile-image" />
25+
<p id="userName" class="user-name"></p>
26+
</div>
2927
<div class="tracker">
30-
<h1>Welcome! This is my github tracker</h1>
31-
<h2>Recent projects:</h2>
28+
<h2>GitHub Tracker</h2>
29+
<h4>Projects:
30+
</h4>
31+
</div>
32+
</div>
33+
<div class="projects-containter">
34+
<main id="projects" class="projects"></main>
3235
</div>
33-
<main id="projects" class="projects"></main>
34-
3536
<!-- This will be used to draw the chart 👇 -->
36-
<canvas id="chart" class="chart"></canvas>
37+
<div class="canvas-container">
38+
<canvas id="chart" class="chart"></canvas>
39+
</div>
3740

3841

3942
<script src="./script.js"></script>
4043
<script src="./chart.js"></script>
44+
45+
46+
47+
<footer>
48+
<p>This GitHub Tracker is Made by <a class="hover" href="https://www.linkedin.com/in/mamite-andersson/">me Mamite!
49+
<br></a> Student at <a class="hover" href="https://www.technigo.io/program">Technigo Boot Camp</a> 2021</p>
50+
</footer>
4151
</body>
4252

4353
</html>

code/script.js

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,69 @@
1-
const USER= "mamite100";
2-
const REPOS_URL= `https://api.github.com/users/${USER}/repos`;
3-
const projectsContainer = document.
4-
getElementById("projects");
1+
/* my user*/
2+
/*can't get my USER*/
3+
const USER = 'mamite100';
4+
5+
const REPOS_URL = `https://api.github.com/users/${USER}/repos`;
6+
7+
const PROFILE_URL = `https://api.github.com/users/${USER}`
8+
9+
const profileContainer = document.getElementById('profile-container')
10+
const projectsContainer = document.getElementById('projects');
11+
12+
const fetchProfile = () => {
13+
fetch(PROFILE_URL)
14+
.then(res => res.json())
15+
.then(profileData => {
16+
profileContainer.innerHTML +=`
17+
<img src=${profileData.avatar_url} class='profile-img'>
18+
<h2>${profileData.name}</h2>
19+
<p>${profileData.login}</p>`
20+
});
21+
}
522

623
const fetchRepositories = () => {
7-
fetch (REPOS_URL)
8-
.then((res) => res.json())
9-
.then((data) => {
10-
const technigoRepositories = data.filter((repo) => repo.name.includes("project-") && repo.fork
11-
);
12-
technigoRepositories.forEach(
13-
(repo) => {
14-
projectsContainer.innerHTML += `
15-
<div>
16-
<a href="${repo.html_url }" > ${repo.name} with default branch
17-
${repo.default_branch}</a>
18-
<p> Recent push: ${new Date (repo.pushed_at) .toDateString() } </p>
19-
<p id="commit-${repo.name}"> Commits: </p>
20-
</div>
24+
fetch(REPOS_URL)
25+
.then((res) => res.json())
26+
.then((data) => {
27+
const technigoRepositories = data.filter(
28+
(repo) => repo.name.includes('project-') && repo.fork
29+
);
30+
31+
technigoRepositories.forEach((repo) => {
32+
projectsContainer.innerHTML += `
33+
<div>
34+
<a href="${repo.html_url}">${repo.name} with default branch ${
35+
repo.default_branch
36+
}</a>
37+
<p>Recent push: ${new Date(repo.pushed_at).toDateString()}</p>
38+
<p id="commit-${repo.name}">Commits amount: </p>
39+
</div>
2140
`;
22-
});
23-
});
41+
42+
});
43+
44+
fetchPullRequestsArray(technigoRepositories);
45+
46+
//draw chart with technigoRepos data. I can't get the char?
47+
drawBarChart(technigoRepos.length);
48+
});
2449
};
2550

26-
const fetchPullRequestsArray = ( allRepositories) => {
27-
allRepositories.forEach((repo) => {
28-
const PULL_URL =
29-
`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`;
30-
fetch (PULL_URL)
31-
.then( (res) => res.json())
32-
.then((data) => {
33-
const myPullRequest = data.find(
34-
(pull) => pull.user.login === repo.owner.login
35-
);
36-
if (myPullRequest) {
51+
const fetchPullRequestsArray = (allRepositories) => {
52+
allRepositories.forEach((repo) => {
53+
const PULL_URL = `https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`;
54+
55+
fetch(PULL_URL)
56+
.then((res) => res.json())
57+
.then((data) => {
58+
const myPullRequest = data.find(
59+
(pull) => pull.user.login === repo.owner.login
60+
);
61+
62+
if (myPullRequest) {
3763
fetchCommits(myPullRequest.commits_url, repo.name);
3864
} else {
3965
document.getElementById(`commit-${repo.name}`).innerHTML =
40-
'No pull request yet done : ( ';
66+
'No pull request yet done :(';
4167
}
4268
});
4369
});
@@ -51,4 +77,4 @@ const fetchCommits = (myCommitsUrl, myRepoName) => {
5177
});
5278
};
5379

54-
fetchRepositories();
80+
fetchRepositories();

0 commit comments

Comments
 (0)