From 9d78f74d39841bded142b212991471563658564c Mon Sep 17 00:00:00 2001 From: dandeloid <82587220+dandeloid@users.noreply.github.com> Date: Mon, 27 Sep 2021 22:27:23 +0200 Subject: [PATCH 01/10] First --- code/ToDO | 7 +++++ code/chart.js | 29 +++++++++++++++++++ code/index.html | 12 ++++++++ code/script.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 code/ToDO diff --git a/code/ToDO b/code/ToDO new file mode 100644 index 00000000..686fc245 --- /dev/null +++ b/code/ToDO @@ -0,0 +1,7 @@ +todo: + +1. fetch the repos and console log them +2. get them in the browser +3. filter out the technigo repos +4. test chart library + diff --git a/code/chart.js b/code/chart.js index 92e85a30..ceaabfb8 100644 --- a/code/chart.js +++ b/code/chart.js @@ -2,3 +2,32 @@ const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 + +// console.log('Chart is here') //just checks if Chart.js is on + + +// needs fixing... went to fast + +const drawChart = (amount) => { + const config = { + type: 'doughnut', + data: { + labels: [ + 'Finished', + 'Not Finished', + ], + datasets: [{ + label: 'My First Dataset', + data: [amount, 20-amount], + backgroundColor: [ + 'rgb(255, 99, 132)', + 'rgb(54, 162, 235)', + ], + hoverOffset: 4 + }] + }, + }; + + const myChart = new Chart (ctx, config) +} + diff --git a/code/index.html b/code/index.html index 2fb5e0ae..890a0b8a 100644 --- a/code/index.html +++ b/code/index.html @@ -6,15 +6,27 @@ Project GitHub Tracker + + +

GitHub Tracker

+

Profile:

+
+

Projects:

+ + + + + diff --git a/code/script.js b/code/script.js index e69de29b..635a0759 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,76 @@ +//console.log('JS is here') // just test if JS is here + +const USER = 'dandeloid' +const REPOS_URL = `https://api.github.com/users/${USER}/repos` +const profileContainer = document.getElementById('profile') +const projectsContainer = document.getElementById('projects') +const pullContainer = document.getElementById('pullRequests') + +//fetch for profile name and profile picture +const getProfile = () => { +fetch (`https://api.github.com/users/${USER}`) + .then(response => response.json()) + .then(data => { + profileContainer.innerHTML = ` +

${data.login}

+ + ` + }) +} +getProfile() + + +//fetch for Technigo forked repos +const getRepos = () => { + fetch (REPOS_URL) + .then(response => response.json()) + .then(data => { + console.log(data) + // data.forEach(repo => console.log(repo.name)) // logs all repos + const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-')) + //forkedRepos.forEach(repo => console.log(repo.name)) //logs all filtered repo + + forkedRepos.forEach(repo => projectsContainer.innerHTML += ` +

${repo.name}

+

${repo.pushed_at.slice(0, 10)} - ${repo.pushed_at.slice(11, 16)}

+

${repo.default_branch}

+ GitHub address + `) + + + + + drawChart(forkedRepos.length) + + + }) + +} +getRepos() + + + + + + + + + +//fetch for Technigo pull requests +/* const getPullRequests = (repos) => { + repos.forEach(repo => { + fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls`) + .then(response => response.json()) + .then(data => { + console.log(data) + + + const pullReq = data.map(pull => pull.user.login.includes(repo.owner.login)) + pullReq.forEach(repo => pullContainer.innerHTML += `

${repo.name}

`) + + + }) + }) +} */ +// getPullRequests(forkedRepos) <<< neeed to be in getRepos to invoke from there + From 670ebeb9a69c8cd7f9dcb21bfd8556a51faaa2c0 Mon Sep 17 00:00:00 2001 From: dandeloid <82587220+dandeloid@users.noreply.github.com> Date: Wed, 29 Sep 2021 20:40:38 +0200 Subject: [PATCH 02/10] commit undefined no longer undefined --- code/index.html | 2 ++ code/script.js | 80 +++++++++++++++++++++++++++---------------------- code/style.css | 11 +++++-- 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/code/index.html b/code/index.html index 890a0b8a..abcb71cd 100644 --- a/code/index.html +++ b/code/index.html @@ -24,7 +24,9 @@

Projects:

+
+
diff --git a/code/script.js b/code/script.js index 635a0759..06dd3eda 100644 --- a/code/script.js +++ b/code/script.js @@ -1,5 +1,3 @@ -//console.log('JS is here') // just test if JS is here - const USER = 'dandeloid' const REPOS_URL = `https://api.github.com/users/${USER}/repos` const profileContainer = document.getElementById('profile') @@ -13,64 +11,74 @@ fetch (`https://api.github.com/users/${USER}`) .then(data => { profileContainer.innerHTML = `

${data.login}

- + ` }) } getProfile() - //fetch for Technigo forked repos const getRepos = () => { fetch (REPOS_URL) .then(response => response.json()) .then(data => { console.log(data) - // data.forEach(repo => console.log(repo.name)) // logs all repos const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-')) //forkedRepos.forEach(repo => console.log(repo.name)) //logs all filtered repo - forkedRepos.forEach(repo => projectsContainer.innerHTML += ` -

${repo.name}

-

${repo.pushed_at.slice(0, 10)} - ${repo.pushed_at.slice(11, 16)}

-

${repo.default_branch}

- GitHub address - `) - - - - - drawChart(forkedRepos.length) - - + forkedRepos.forEach((repo) => { + projectsContainer.innerHTML += ` +

${repo.name}

+

${repo.pushed_at.slice(0, 10)} - ${repo.pushed_at.slice(11, 16)}

+

${repo.default_branch}

+ GitHub address +

Commits amount:

+ ` + }) + drawChart(forkedRepos.length) + fetchPullRequestsArray(forkedRepos) }) - } -getRepos() - - +//fetch pull request +const fetchPullRequestsArray = (allRepositories) => { + allRepositories.forEach((repo) => { + const PULL_URL = `https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100` + fetch(PULL_URL) + .then((response) => response.json()) + .then((data) => { + //console.log(`Mother repo for project ${repo.name}`, data) + const myPullRequest = data.find(pull => pull.user.login === repo.owner.login) + //console.log(myPullRequest) + if (myPullRequest){ + fetchCommits(myPullRequest.commits_url, repo.name) + } else { + document.getElementById(`commit-${repo.name}`).innerHTML = 'Commits amount: No pull' + } + }) + }) +} +//fetch nr of commits +const fetchCommits = (myCommitsUrl, myRepoName) => { + fetch(myCommitsUrl) + .then ((response) => response.json()) + .then((data) => { + document.getElementById(`commit-${myRepoName}`).innerHTML += data.length + }) + } +getRepos() -//fetch for Technigo pull requests -/* const getPullRequests = (repos) => { - repos.forEach(repo => { - fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls`) +// commit count test +/* fetch ('https://api.github.com/repos/dandeloid/project-guess-who/commits') .then(response => response.json()) .then(data => { - console.log(data) - - - const pullReq = data.map(pull => pull.user.login.includes(repo.owner.login)) - pullReq.forEach(repo => pullContainer.innerHTML += `

${repo.name}

`) + const count = data.filter(nr => nr.commit.committer.name === 'dandeloid') + console.log(count.length) + }) */ - - }) - }) -} */ -// getPullRequests(forkedRepos) <<< neeed to be in getRepos to invoke from there diff --git a/code/style.css b/code/style.css index 7c8ad447..a1733ab7 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,10 @@ body { - background: #FFECE9; -} \ No newline at end of file + background: #9ae393; +} +.profile-picture { + width: 300px; + border-radius: 100%; +} +.chart { + width: 300px; +} From c885526945a449f1be9dc744f335521e52c55b7f Mon Sep 17 00:00:00 2001 From: dandeloid <82587220+dandeloid@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:42:46 +0200 Subject: [PATCH 03/10] some crappy styling --- code/ToDO | 7 ------- code/chart.js | 2 +- code/index.html | 17 ++++++++--------- code/script.js | 15 ++++++++------- code/style.css | 40 ++++++++++++++++++++++++++++++++++++++-- 5 files changed, 55 insertions(+), 26 deletions(-) delete mode 100644 code/ToDO diff --git a/code/ToDO b/code/ToDO deleted file mode 100644 index 686fc245..00000000 --- a/code/ToDO +++ /dev/null @@ -1,7 +0,0 @@ -todo: - -1. fetch the repos and console log them -2. get them in the browser -3. filter out the technigo repos -4. test chart library - diff --git a/code/chart.js b/code/chart.js index ceaabfb8..a46e216d 100644 --- a/code/chart.js +++ b/code/chart.js @@ -23,7 +23,7 @@ const drawChart = (amount) => { 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', ], - hoverOffset: 4 + hoverOffset: 1 }] }, }; diff --git a/code/index.html b/code/index.html index abcb71cd..edc64029 100644 --- a/code/index.html +++ b/code/index.html @@ -11,23 +11,22 @@ -

GitHub Tracker

-

Profile:

-
-

Projects:

-
+

GitHub Tracker

+
- +

Projects:

+
-
- +
+ diff --git a/code/script.js b/code/script.js index 06dd3eda..7e73df61 100644 --- a/code/script.js +++ b/code/script.js @@ -10,8 +10,8 @@ fetch (`https://api.github.com/users/${USER}`) .then(response => response.json()) .then(data => { profileContainer.innerHTML = ` -

${data.login}

+

Profile: ${data.login}

` }) } @@ -28,11 +28,13 @@ const getRepos = () => { forkedRepos.forEach((repo) => { projectsContainer.innerHTML += ` -

${repo.name}

-

${repo.pushed_at.slice(0, 10)} - ${repo.pushed_at.slice(11, 16)}

-

${repo.default_branch}

- GitHub address -

Commits amount:

+
+

${repo.name}

+

${repo.pushed_at.slice(0, 10)} - ${repo.pushed_at.slice(11, 16)}

+

Branch name: ${repo.default_branch}

+ GitHub address +

Commits amount:

+
` }) drawChart(forkedRepos.length) @@ -68,7 +70,6 @@ const fetchCommits = (myCommitsUrl, myRepoName) => { }) } - getRepos() diff --git a/code/style.css b/code/style.css index a1733ab7..de4405df 100644 --- a/code/style.css +++ b/code/style.css @@ -1,10 +1,46 @@ body { - background: #9ae393; + background: black; + color: white; + max-width: 300px; + margin: auto; +} +.title { + text-align: center; +} +.profile { + border: 1px solid white; + padding: 10px; } .profile-picture { - width: 300px; + width: 100%; border-radius: 100%; } +.profile-title { + text-align: center; +} +.projects-title { + border: 1px solid white; + padding: 10px; + text-align: center; +} +.projects { + border: 1px solid white; + padding: 10px; +} +.single-project { + border: 1px solid white; + padding: 10px; + margin: 10px 0; +} + .chart { width: 300px; + margin: 20px 0; +} + +footer { + border: 1px solid white; + padding: 10px; + margin-top: 10px; + text-align: center; } From d0c2c762ed5f1b51e59b08b1b77032d30d0f459e Mon Sep 17 00:00:00 2001 From: dandeloid <82587220+dandeloid@users.noreply.github.com> Date: Fri, 1 Oct 2021 13:23:11 +0200 Subject: [PATCH 04/10] some more styling --- .DS_Store | Bin 0 -> 6148 bytes code/.DS_Store | Bin 0 -> 6148 bytes code/chart.js | 3 +- code/github-icon-black.svg | 26 ++++++++++++++++ code/index.html | 18 ++++++----- code/script.js | 35 +++++++++------------ code/style.css | 62 ++++++++++++++++++++++++++++++------- 7 files changed, 104 insertions(+), 40 deletions(-) create mode 100644 .DS_Store create mode 100644 code/.DS_Store create mode 100644 code/github-icon-black.svg diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9d9e578f836a8e9846e0685949969611774982a6 GIT binary patch literal 6148 zcmeHK!A{#i5Sq+ZVd~C*Xl~ki)HyP}6?_E+Ir`~>VOfj>Q^h4esAG8#$$HoK6G%?0IKn z`|#w;*U7i(`GwmHg%8!rQ;$F4JB--^&*DK@nDR4x93RjwZP6z6Xa~4LCzRcx>Ib5J zr3zgUVL%uV2IiLme-!G+^ZSbOX2O6l@Q)ba^C5&XMjmU2_UJ%kO8_AMMp}VwfBk_W zJAjeL+95m;(BN7?Ih_51H!<6#eiz|;$9a^@^|aK#qnJmLJy%V99KJ>rNFRPF=F{D cUV>VIKV$MiSqo_(UY7;B7hht*Y4X06%Q@gEh? zcNZZ;j$1sT_WshMOgW|ptivv1Bbp!8jT2c@9>1##~Rr zcO>~B`>Yn}fZQdfnBj$toG~9zG&y)Dr@s1tku&affyeIs%1H-fjaTk%##J)%-3hJj z>+J`FO*2!#6fgyLSOMm2wdl~Jm8O6xU { 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', ], - hoverOffset: 1 + hoverOffset: 2, + borderWidth: 0, }] }, }; diff --git a/code/github-icon-black.svg b/code/github-icon-black.svg new file mode 100644 index 00000000..bdf7b7a0 --- /dev/null +++ b/code/github-icon-black.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/index.html b/code/index.html index edc64029..a4c1f940 100644 --- a/code/index.html +++ b/code/index.html @@ -12,17 +12,21 @@ -

GitHub Tracker

-
+
+

GitHub Tracker

+
-

Projects:

-
+

Projects

+
-
- -
+ +
+ +
+ +