From aa77d0befd6d8476da34c2ffc2f7a536ef606d9d Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Mon, 27 Sep 2021 22:14:58 +0200 Subject: [PATCH 01/12] fetch repos --- code/chart.js | 4 +++- code/script.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/chart.js b/code/chart.js index 92e85a30..8daf14a3 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,4 +1,6 @@ //DOM-selector for the canvas 👇 -const ctx = document.getElementById('chart').getContext('2d') +const ctx = document.getElementById("chart").getContext("2d"); //"Draw" the chart here 👇 + +console.log("chart is heart"); diff --git a/code/script.js b/code/script.js index e69de29b..a7116693 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,15 @@ +const USER = "ebbadelsol"; +const REPOS_URL = `https://api.github.com/users/${USER}/repos`; +const projectsContainer = document.getElementById("projects"); + +const getRepos = () => { + fetch(REPOS_URL) + .then((response) => response.json()) + .then((data) => { + console.log("All Repos from the json:", data); + const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); + technigoProjects.forEach((repo) => (projectsContainer.innerHTML += /*html*/ `

${repo.name}

`)); + }); +}; + +getRepos(); From 0b6405606ad5d161471dfdd0bef474a6eca3864e Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Tue, 28 Sep 2021 20:28:26 +0200 Subject: [PATCH 02/12] chart --- code/chart.js | 18 ++++++++++++++++-- code/index.html | 38 +++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/code/chart.js b/code/chart.js index 8daf14a3..025c68f9 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,6 +1,20 @@ //DOM-selector for the canvas 👇 const ctx = document.getElementById("chart").getContext("2d"); -//"Draw" the chart here 👇 +// Chart +const config = { + type: "doughnut", + data: { + labels: ["Red", "Yellow"], //Change the label + datasets: [ + { + label: "My First Dataset", //Change the label + data: [5, 19 - 5], // Change the data + backgroundColor: ["rgb(255, 99, 132)", "rgb(255, 205, 86)"], + hoverOffset: 4, + }, + ], + }, +}; -console.log("chart is heart"); +const reposChart = new Chart(ctx, config); diff --git a/code/index.html b/code/index.html index 2fb5e0ae..30ba4362 100644 --- a/code/index.html +++ b/code/index.html @@ -1,21 +1,25 @@ - - - - - Project GitHub Tracker - - - -

GitHub Tracker

-

Projects:

-
+ + + + + Project GitHub Tracker + + + + + +

GitHub Tracker

+

Projects:

+
- - + +
+ +
- - - - \ No newline at end of file + + + + From e982366910fa3f8949d29dec9962e19d5962c428 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:54:11 +0200 Subject: [PATCH 03/12] fetching pullrequest, commits and review --- code/chart.js | 32 +++++++++++++++++--------------- code/script.js | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/code/chart.js b/code/chart.js index 025c68f9..7dbb4cc3 100644 --- a/code/chart.js +++ b/code/chart.js @@ -2,19 +2,21 @@ const ctx = document.getElementById("chart").getContext("2d"); // Chart -const config = { - type: "doughnut", - data: { - labels: ["Red", "Yellow"], //Change the label - datasets: [ - { - label: "My First Dataset", //Change the label - data: [5, 19 - 5], // Change the data - backgroundColor: ["rgb(255, 99, 132)", "rgb(255, 205, 86)"], - hoverOffset: 4, - }, - ], - }, -}; +const drawChart = (numberOfProjects) => { + const config = { + type: "doughnut", + data: { + labels: ["Red", "Yellow"], //Change the label + datasets: [ + { + label: "My First Dataset", //Change the label + data: [numberOfProjects, 19 - numberOfProjects], // Change the data + backgroundColor: ["rgb(255, 99, 132)", "rgb(255, 205, 86)"], + hoverOffset: 4, + }, + ], + }, + }; -const reposChart = new Chart(ctx, config); + const reposChart = new Chart(ctx, config); +}; diff --git a/code/script.js b/code/script.js index a7116693..16ca954c 100644 --- a/code/script.js +++ b/code/script.js @@ -6,10 +6,47 @@ const getRepos = () => { fetch(REPOS_URL) .then((response) => response.json()) .then((data) => { - console.log("All Repos from the json:", data); + //console.log("All Repos from the json:", data); const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); technigoProjects.forEach((repo) => (projectsContainer.innerHTML += /*html*/ `

${repo.name}

`)); + getPullRequests(technigoProjects); + drawChart(technigoProjects.length); }); }; getRepos(); + +const getPullRequests = (repos) => { + // Get all the PRs for each project. + repos.forEach((repo) => { + fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`) + .then((response) => response.json()) + .then((data) => { + //console.log("Data from pull request:", data); + + const filteredPull = data.find((pull) => pull.user.login === repo.owner.login); + + //console.log("My pull request for:", filteredPull); + + getCommits(filteredPull.commits_url); + + getReview(filteredPull.review_comments_url); + }); + }); +}; + +const getCommits = (url) => { + fetch(url) + .then((response) => response.json()) + .then((data) => { + //console.log("My commits:", data); + }); +}; + +const getReview = (url) => { + fetch(url) + .then((response) => response.json()) + .then((data) => { + //console.log("My review:", data); + }); +}; From 0528af5dc45c6feb89ca563a7b5f3c2c19495048 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Wed, 29 Sep 2021 16:56:42 +0200 Subject: [PATCH 04/12] changing innerHTML --- code/chart.js | 2 +- code/script.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/code/chart.js b/code/chart.js index 7dbb4cc3..406a84b6 100644 --- a/code/chart.js +++ b/code/chart.js @@ -6,7 +6,7 @@ const drawChart = (numberOfProjects) => { const config = { type: "doughnut", data: { - labels: ["Red", "Yellow"], //Change the label + labels: ["Finished projects", "Projects left"], //Change the label datasets: [ { label: "My First Dataset", //Change the label diff --git a/code/script.js b/code/script.js index 16ca954c..cfd30223 100644 --- a/code/script.js +++ b/code/script.js @@ -8,7 +8,17 @@ const getRepos = () => { .then((data) => { //console.log("All Repos from the json:", data); const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); - technigoProjects.forEach((repo) => (projectsContainer.innerHTML += /*html*/ `

${repo.name}

`)); + + technigoProjects.forEach((repo) => { + projectsContainer.innerHTML += /*html*/ ` +
+ ${repo.name} with default branch ${repo.default_branch} +

Recent push: ${new Date(repo.pushed_at).toDateString()}

+

Commits amount:

+
+ `; + }); + getPullRequests(technigoProjects); drawChart(technigoProjects.length); }); @@ -28,18 +38,20 @@ const getPullRequests = (repos) => { //console.log("My pull request for:", filteredPull); - getCommits(filteredPull.commits_url); + getCommits(filteredPull.commits_url, repo.name); getReview(filteredPull.review_comments_url); }); }); }; -const getCommits = (url) => { +const getCommits = (url, repoName) => { fetch(url) .then((response) => response.json()) .then((data) => { - //console.log("My commits:", data); + console.log("My commits:", data); + console.log(repoName); + document.getElementById(`commits-${repoName}`).innerHTML += data.length; }); }; From 71b12ce9509f9234dccb6ca6073e390a0e00c0cc Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Wed, 29 Sep 2021 17:43:28 +0200 Subject: [PATCH 05/12] reviewed by --- code/script.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/code/script.js b/code/script.js index cfd30223..7cb9a58a 100644 --- a/code/script.js +++ b/code/script.js @@ -11,8 +11,9 @@ const getRepos = () => { technigoProjects.forEach((repo) => { projectsContainer.innerHTML += /*html*/ ` -
- ${repo.name} with default branch ${repo.default_branch} +
+ ${repo.name} +

Default branch ${repo.default_branch}

Recent push: ${new Date(repo.pushed_at).toDateString()}

Commits amount:

@@ -40,7 +41,7 @@ const getPullRequests = (repos) => { getCommits(filteredPull.commits_url, repo.name); - getReview(filteredPull.review_comments_url); + getReview(filteredPull.review_comments_url, repo.name); }); }); }; @@ -49,16 +50,19 @@ const getCommits = (url, repoName) => { fetch(url) .then((response) => response.json()) .then((data) => { - console.log("My commits:", data); - console.log(repoName); + //console.log("My commits:", data); document.getElementById(`commits-${repoName}`).innerHTML += data.length; }); }; -const getReview = (url) => { +const getReview = (url, repoName) => { fetch(url) .then((response) => response.json()) .then((data) => { //console.log("My review:", data); + // console.log(`Reviewed by ${data[0].user.login}`); + document.getElementById(`${repoName}-container`).innerHTML += /*html*/ ` +

Reviewed by: ${data[0].user.login}

+ `; }); }; From efb115c0ce8a52af3ca517d69d7590f3df0416e6 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Wed, 29 Sep 2021 20:18:19 +0200 Subject: [PATCH 06/12] user info --- code/index.html | 6 +++++- code/script.js | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/code/index.html b/code/index.html index 30ba4362..544c5f70 100644 --- a/code/index.html +++ b/code/index.html @@ -12,7 +12,11 @@

GitHub Tracker

Projects:

-
+ +
+
+
+
diff --git a/code/script.js b/code/script.js index 7cb9a58a..a76b0411 100644 --- a/code/script.js +++ b/code/script.js @@ -1,6 +1,22 @@ const USER = "ebbadelsol"; const REPOS_URL = `https://api.github.com/users/${USER}/repos`; const projectsContainer = document.getElementById("projects"); +const userContainer = document.getElementById("user-container"); + +const getUser = () => { + fetch(`https://api.github.com/users/${USER}`) + .then((response) => response.json()) + .then((data) => { + // console.log("Image URL: ", data.avatar_url); + // console.log("User: ", data.login); + userContainer.innerHTML += /*html*/ ` + +

${data.login}

+ `; + }); +}; + +getUser(); const getRepos = () => { fetch(REPOS_URL) @@ -15,7 +31,7 @@ const getRepos = () => { ${repo.name}

Default branch ${repo.default_branch}

Recent push: ${new Date(repo.pushed_at).toDateString()}

-

Commits amount:

+

Amount of commits:

`; }); From e0600fccacfbeac887eb5064a1643dab3ad37660 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Wed, 29 Sep 2021 20:26:28 +0200 Subject: [PATCH 07/12] netlify-link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1613a3b0..c82641d6 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ Describe how you approached to problem, and what tools and techniques you used t ## 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-ebbadelsol.netlify.app/ From 83ce46d74bc5318295c62a7faad9644d25322844 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Thu, 30 Sep 2021 21:14:35 +0200 Subject: [PATCH 08/12] some CSS styling --- code/index.html | 32 +++++++++++++------- code/script.js | 17 ++++++----- code/style.css | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 108 insertions(+), 20 deletions(-) diff --git a/code/index.html b/code/index.html index 544c5f70..734b3c03 100644 --- a/code/index.html +++ b/code/index.html @@ -5,24 +5,36 @@ Project GitHub Tracker + + + + + + + + + + + + + - -

GitHub Tracker

-

Projects:

+ +
-
-
+
+
+
+
+ +
+
- -
- -
- diff --git a/code/script.js b/code/script.js index a76b0411..b7c57aab 100644 --- a/code/script.js +++ b/code/script.js @@ -1,6 +1,6 @@ const USER = "ebbadelsol"; const REPOS_URL = `https://api.github.com/users/${USER}/repos`; -const projectsContainer = document.getElementById("projects"); +const projectsContainer = document.getElementById("projects-container"); const userContainer = document.getElementById("user-container"); const getUser = () => { @@ -11,7 +11,7 @@ const getUser = () => { // console.log("User: ", data.login); userContainer.innerHTML += /*html*/ ` -

${data.login}

+

${data.login}

`; }); }; @@ -27,12 +27,13 @@ const getRepos = () => { technigoProjects.forEach((repo) => { projectsContainer.innerHTML += /*html*/ ` -
- ${repo.name} -

Default branch ${repo.default_branch}

-

Recent push: ${new Date(repo.pushed_at).toDateString()}

-

Amount of commits:

+
+ ${repo.name} +

Default branch ${repo.default_branch}

+

Recent push: ${new Date(repo.pushed_at).toDateString()}

+

Amount of commits:

+
`; }); @@ -78,7 +79,7 @@ const getReview = (url, repoName) => { //console.log("My review:", data); // console.log(`Reviewed by ${data[0].user.login}`); document.getElementById(`${repoName}-container`).innerHTML += /*html*/ ` -

Reviewed by: ${data[0].user.login}

+

Reviewed by: ${data[0].user.login}

`; }); }; diff --git a/code/style.css b/code/style.css index 7c8ad447..7acc94eb 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,78 @@ +* { + margin: 0; + padding: 0; +} + body { - background: #FFECE9; -} \ No newline at end of file + font-family: "Roboto", sans-serif; + color: #222222; +} + +.background-image { + width: 100vw; + height: 225px; + background-image: url("https://images.unsplash.com/photo-1548092372-0d1bd40894a3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80"); /* Change image */ + background-size: cover; + background-repeat: no-repeat; +} + +.user-container { + position: relative; + text-align: center; + bottom: 72px; +} + +.user-image { + border-radius: 50%; + width: 126px; + border: solid 6px #ffffff; +} + +.user-name { + font-size: 26px; + font-weight: 700; + margin-top: 3px; +} + +.project { + display: flex; + flex-direction: column; + align-items: center; + padding: 40px 0; +} + +.projects-container { + line-height: 1.8; + margin-top: -40px; +} + +.projects-container :hover { + background: linear-gradient(90deg, white, #e6e6e6 50%, #e6e6e6 50%, #e6e6e6 50%, white); +} + +.project-info { + font-family: "Open Sans", sans-serif; + font-size: 15px; + font-weight: 400; + color: #666666; +} + +.project-info :hover { + background: none; +} + +.project-name { + font-family: "Open Sans", sans-serif; + color: #222222; + text-decoration: none; + font-size: 18px; + font-weight: 700; +} + +hr { + margin: auto; + width: 75vw; + background: linear-gradient(90deg, white, #e6e6e6, #e6e6e6, #e6e6e6, white); + height: 1px; + border: none; +} From 60c094a2304728ad0abbde684a70dc9c85e8b8f5 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Fri, 1 Oct 2021 12:40:08 +0200 Subject: [PATCH 09/12] fixed console errors and hover --- code/script.js | 44 +++++++++++++++++++++----------------------- code/style.css | 21 +++++++++++++-------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/code/script.js b/code/script.js index b7c57aab..82ed3637 100644 --- a/code/script.js +++ b/code/script.js @@ -7,8 +7,6 @@ const getUser = () => { fetch(`https://api.github.com/users/${USER}`) .then((response) => response.json()) .then((data) => { - // console.log("Image URL: ", data.avatar_url); - // console.log("User: ", data.login); userContainer.innerHTML += /*html*/ `

${data.login}

@@ -22,17 +20,18 @@ const getRepos = () => { fetch(REPOS_URL) .then((response) => response.json()) .then((data) => { - //console.log("All Repos from the json:", data); const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); technigoProjects.forEach((repo) => { projectsContainer.innerHTML += /*html*/ ` -
- ${repo.name} -

Default branch ${repo.default_branch}

-

Recent push: ${new Date(repo.pushed_at).toDateString()}

-

Amount of commits:

-
+ +
+

${repo.name}

+

Default branch ${repo.default_branch}

+

Recent push: ${new Date(repo.pushed_at).toDateString()}

+

Amount of commits:

+
+

`; }); @@ -45,20 +44,18 @@ const getRepos = () => { getRepos(); const getPullRequests = (repos) => { - // Get all the PRs for each project. repos.forEach((repo) => { fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`) .then((response) => response.json()) .then((data) => { - //console.log("Data from pull request:", data); - const filteredPull = data.find((pull) => pull.user.login === repo.owner.login); - //console.log("My pull request for:", filteredPull); - - getCommits(filteredPull.commits_url, repo.name); - - getReview(filteredPull.review_comments_url, repo.name); + if (filteredPull) { + getCommits(filteredPull.commits_url, repo.name); + getReview(filteredPull.review_comments_url, repo.name); + } else { + document.getElementById(`commits-${repo.name}`).innerHTML = "No pull request made"; + } }); }); }; @@ -67,7 +64,6 @@ const getCommits = (url, repoName) => { fetch(url) .then((response) => response.json()) .then((data) => { - //console.log("My commits:", data); document.getElementById(`commits-${repoName}`).innerHTML += data.length; }); }; @@ -76,10 +72,12 @@ const getReview = (url, repoName) => { fetch(url) .then((response) => response.json()) .then((data) => { - //console.log("My review:", data); - // console.log(`Reviewed by ${data[0].user.login}`); - document.getElementById(`${repoName}-container`).innerHTML += /*html*/ ` -

Reviewed by: ${data[0].user.login}

- `; + if (data.length === 0) { + document.getElementById(`${repoName}-container`).innerHTML += ""; + } else { + document.getElementById(`${repoName}-container`).innerHTML += /*html*/ ` +

Reviewed by ${data[0].user.login}

+ `; + } }); }; diff --git a/code/style.css b/code/style.css index 7acc94eb..4fc41698 100644 --- a/code/style.css +++ b/code/style.css @@ -11,7 +11,7 @@ body { .background-image { width: 100vw; height: 225px; - background-image: url("https://images.unsplash.com/photo-1548092372-0d1bd40894a3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80"); /* Change image */ + background-image: url("https://images.unsplash.com/photo-1548092372-0d1bd40894a3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80"); background-size: cover; background-repeat: no-repeat; } @@ -46,27 +46,32 @@ body { margin-top: -40px; } -.projects-container :hover { +/* .projects-container :hover { background: linear-gradient(90deg, white, #e6e6e6 50%, #e6e6e6 50%, #e6e6e6 50%, white); -} +} */ .project-info { font-family: "Open Sans", sans-serif; font-size: 15px; font-weight: 400; color: #666666; -} - -.project-info :hover { - background: none; + pointer-events: none; } .project-name { font-family: "Open Sans", sans-serif; color: #222222; - text-decoration: none; font-size: 18px; font-weight: 700; + pointer-events: none; +} + +.project-link { + text-decoration: none; +} + +.project-link :hover { + background: linear-gradient(90deg, white, #e6e6e6 50%, #e6e6e6 50%, #e6e6e6 50%, white); } hr { From 5734abea9421d837aab228d798e6a5a82ea26688 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Fri, 1 Oct 2021 16:53:21 +0200 Subject: [PATCH 10/12] chart and media queries --- code/chart.js | 8 ++++---- code/index.html | 9 +++++---- code/script.js | 2 +- code/style.css | 46 ++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/code/chart.js b/code/chart.js index 406a84b6..540bdd1c 100644 --- a/code/chart.js +++ b/code/chart.js @@ -6,13 +6,13 @@ const drawChart = (numberOfProjects) => { const config = { type: "doughnut", data: { - labels: ["Finished projects", "Projects left"], //Change the label + labels: ["Finished projects", "Projects left"], datasets: [ { - label: "My First Dataset", //Change the label - data: [numberOfProjects, 19 - numberOfProjects], // Change the data + label: "Technigo Projects", + data: [numberOfProjects, 19 - numberOfProjects], backgroundColor: ["rgb(255, 99, 132)", "rgb(255, 205, 86)"], - hoverOffset: 4, + hoverOffset: 5, }, ], }, diff --git a/code/index.html b/code/index.html index 734b3c03..171f7b53 100644 --- a/code/index.html +++ b/code/index.html @@ -24,13 +24,14 @@ -
+
-
-
- +
+

Overview of Projects

+
+
diff --git a/code/script.js b/code/script.js index 82ed3637..56600464 100644 --- a/code/script.js +++ b/code/script.js @@ -54,7 +54,7 @@ const getPullRequests = (repos) => { getCommits(filteredPull.commits_url, repo.name); getReview(filteredPull.review_comments_url, repo.name); } else { - document.getElementById(`commits-${repo.name}`).innerHTML = "No pull request made"; + document.getElementById(`commits-${repo.name}`).innerHTML = "No pull request"; } }); }); diff --git a/code/style.css b/code/style.css index 4fc41698..6b8c858f 100644 --- a/code/style.css +++ b/code/style.css @@ -8,12 +8,15 @@ body { color: #222222; } -.background-image { +.hero-image { width: 100vw; - height: 225px; - background-image: url("https://images.unsplash.com/photo-1548092372-0d1bd40894a3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80"); + /* height: 280px; */ + height: 40vh; + background-image: url("https://images.unsplash.com/photo-1618401471353-b98afee0b2eb?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2376&q=80"); + background-position: center; background-size: cover; background-repeat: no-repeat; + filter: grayscale(100%); } .user-container { @@ -46,10 +49,6 @@ body { margin-top: -40px; } -/* .projects-container :hover { - background: linear-gradient(90deg, white, #e6e6e6 50%, #e6e6e6 50%, #e6e6e6 50%, white); -} */ - .project-info { font-family: "Open Sans", sans-serif; font-size: 15px; @@ -58,7 +57,8 @@ body { pointer-events: none; } -.project-name { +.project-name, +.chart-heading { font-family: "Open Sans", sans-serif; color: #222222; font-size: 18px; @@ -81,3 +81,33 @@ hr { height: 1px; border: none; } + +.chart-section { + display: flex; + flex-direction: column; + align-items: center; + margin: 40px 0 80px; +} + +.chart-container { + width: 70vw; +} + +.chart { + margin-top: 20px; +} + +@media (min-width: 768px) { + .chart-container { + width: 40vw; + } +} + +@media (min-width: 1025px) { + .hero-image { + height: 70vh; + } + .chart-container { + width: 30vw; + } +} From b28c7a83014c8addf15a054ae04277a8e04a9040 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:38:35 +0200 Subject: [PATCH 11/12] read-me --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c82641d6..83142ea1 100644 --- a/README.md +++ b/README.md @@ -1,12 +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. +The assignment was to create a GitHub tracker with all my Technigo-repos. ## 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 by fetching all the data that I wanted from the GitHub API. I began with fetching all the repos and filtering out only the forked ones from Technigo and continued with fetching the pull requests, commits and reviews. In order to inject data from one function to another I used dynamic IDs and DOM-selector. + +If I had more time I would have wanted to sort the data by latest repo. I would also have wanted to add a dropdown meny were the user can choose to sort the repos after language. I would also like to style the GitHub tracker a bit more. ## View it live From 9d3db1ac69a880f4a805f96e174f432ee28b72d7 Mon Sep 17 00:00:00 2001 From: e-delsol <80672920+e-delsol@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:56:17 +0200 Subject: [PATCH 12/12] sorting the repos --- README.md | 2 +- code/script.js | 86 ++++++++++++++++++++++++++------------------------ 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 83142ea1..7bc7b8ff 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The assignment was to create a GitHub tracker with all my Technigo-repos. I started by fetching all the data that I wanted from the GitHub API. I began with fetching all the repos and filtering out only the forked ones from Technigo and continued with fetching the pull requests, commits and reviews. In order to inject data from one function to another I used dynamic IDs and DOM-selector. -If I had more time I would have wanted to sort the data by latest repo. I would also have wanted to add a dropdown meny were the user can choose to sort the repos after language. I would also like to style the GitHub tracker a bit more. +If I had more time I would like to add a dropdown menu were the user can choose to sort or display the repos after language. I would also like to style the GitHub tracker a bit more. ## View it live diff --git a/code/script.js b/code/script.js index 56600464..8c8cbc47 100644 --- a/code/script.js +++ b/code/script.js @@ -4,26 +4,28 @@ const projectsContainer = document.getElementById("projects-container"); const userContainer = document.getElementById("user-container"); const getUser = () => { - fetch(`https://api.github.com/users/${USER}`) - .then((response) => response.json()) - .then((data) => { - userContainer.innerHTML += /*html*/ ` + fetch(`https://api.github.com/users/${USER}`) + .then((response) => response.json()) + .then((data) => { + userContainer.innerHTML += /*html*/ `

${data.login}

`; - }); + }); }; getUser(); const getRepos = () => { - fetch(REPOS_URL) - .then((response) => response.json()) - .then((data) => { - const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); + fetch(REPOS_URL) + .then((response) => response.json()) + .then((data) => { + const technigoProjects = data.filter((repo) => repo.fork && repo.name.startsWith("project-")); - technigoProjects.forEach((repo) => { - projectsContainer.innerHTML += /*html*/ ` + technigoProjects.sort((oldestRepo, newestRepo) => new Date(newestRepo.pushed_at) - new Date(oldestRepo.pushed_at)); + + technigoProjects.forEach((repo) => { + projectsContainer.innerHTML += /*html*/ `

${repo.name}

@@ -34,50 +36,50 @@ const getRepos = () => {

`; - }); + }); - getPullRequests(technigoProjects); - drawChart(technigoProjects.length); - }); + getPullRequests(technigoProjects); + drawChart(technigoProjects.length); + }); }; getRepos(); const getPullRequests = (repos) => { - repos.forEach((repo) => { - fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`) - .then((response) => response.json()) - .then((data) => { - const filteredPull = data.find((pull) => pull.user.login === repo.owner.login); + repos.forEach((repo) => { + fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`) + .then((response) => response.json()) + .then((data) => { + const filteredPull = data.find((pull) => pull.user.login === repo.owner.login); - if (filteredPull) { - getCommits(filteredPull.commits_url, repo.name); - getReview(filteredPull.review_comments_url, repo.name); - } else { - document.getElementById(`commits-${repo.name}`).innerHTML = "No pull request"; - } - }); - }); + if (filteredPull) { + getCommits(filteredPull.commits_url, repo.name); + getReview(filteredPull.review_comments_url, repo.name); + } else { + document.getElementById(`commits-${repo.name}`).innerHTML = "No pull request"; + } + }); + }); }; const getCommits = (url, repoName) => { - fetch(url) - .then((response) => response.json()) - .then((data) => { - document.getElementById(`commits-${repoName}`).innerHTML += data.length; - }); + fetch(url) + .then((response) => response.json()) + .then((data) => { + document.getElementById(`commits-${repoName}`).innerHTML += data.length; + }); }; const getReview = (url, repoName) => { - fetch(url) - .then((response) => response.json()) - .then((data) => { - if (data.length === 0) { - document.getElementById(`${repoName}-container`).innerHTML += ""; - } else { - document.getElementById(`${repoName}-container`).innerHTML += /*html*/ ` + fetch(url) + .then((response) => response.json()) + .then((data) => { + if (data.length === 0) { + document.getElementById(`${repoName}-container`).innerHTML += ""; + } else { + document.getElementById(`${repoName}-container`).innerHTML += /*html*/ `

Reviewed by ${data[0].user.login}

`; - } - }); + } + }); };