From 70f8b53abbd1e2aeb7a44d056e2e8e3f51fe784c Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Mon, 21 Feb 2022 14:23:33 +0200 Subject: [PATCH 1/8] start project --- code/script.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/code/script.js b/code/script.js index e69de29b..169cc784 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,39 @@ +const API_URL = +let reponame + + +fetch(API_URL) +.then((response) => { + return response.json() +}) +.then((data) => { + console.log(data) + const technigoRepos = data.filter((repo) => repo.name.includes('project-')) + + console.log(technigoRepos) + + + reponame = data[3].name + console.log(reponame) + + + const API_URL_PR = `https://api.github.com/repos/Technigo/${reponame}/pulls` + + fetch(API_URL_PR) +.then((response) => { + return response.json() +}) +.then((data) => { + console.log(data) +}) + + + + + + + + +}) + + From e206646408ac0ebde57c42007da1a06548d487ff Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Wed, 23 Feb 2022 14:08:45 +0200 Subject: [PATCH 2/8] try to code --- code/chart.js | 30 +++++++++++++ code/index.html | 29 +++++++++--- code/script.js | 114 +++++++++++++++++++++++++++++++----------------- code/style.css | 41 ++++++++++++++++- 4 files changed, 168 insertions(+), 46 deletions(-) diff --git a/code/chart.js b/code/chart.js index 92e85a30..70279ea8 100644 --- a/code/chart.js +++ b/code/chart.js @@ -2,3 +2,33 @@ const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 + const labels = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + ]; + + const data = { + labels: labels, + datasets: [{ + label: 'My First dataset', + backgroundColor: 'black', + borderColor: 'grey', + data: [0, 10, 5, 2, 20, 30, 45], + }] + }; + + const config = { + type: 'line', + data: data, + options: {} + }; + + const myChart = new Chart( + document.getElementById('chart'), + config + ); + diff --git a/code/index.html b/code/index.html index 2fb5e0ae..9fe28bd1 100644 --- a/code/index.html +++ b/code/index.html @@ -1,21 +1,38 @@ + - Project GitHub Tracker + + + Project GitHub Tracker + + -

GitHub Tracker

-

Projects:

-
- - +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/code/script.js b/code/script.js index 169cc784..1884705e 100644 --- a/code/script.js +++ b/code/script.js @@ -1,39 +1,75 @@ -const API_URL = -let reponame - - -fetch(API_URL) -.then((response) => { - return response.json() -}) -.then((data) => { - console.log(data) - const technigoRepos = data.filter((repo) => repo.name.includes('project-')) - - console.log(technigoRepos) - - - reponame = data[3].name - console.log(reponame) - - - const API_URL_PR = `https://api.github.com/repos/Technigo/${reponame}/pulls` - - fetch(API_URL_PR) -.then((response) => { - return response.json() -}) -.then((data) => { - console.log(data) -}) - - - - - - - - -}) - - +let USER = 'qwer-ctrl' + + + +const profile = document.getElementById('profile-container') +const projects = document.getElementById('projects') + +const fetchProfile = () => { +fetch(USER_URL) + .then((response) => response.json()) + .then((data) => { + profile.innerHTML += ` +
+
+ + Avatar of ${data.login} + +
+

${data.login}

+

+
+

Public repositories: ${data.public_repos}

+
+ ` + }) +} +fetchProfile() + +const fetchRepos = () => { +fetch(REPOS_URL) + .then((response) => response.json()) + .then((data) => { + const technigoRepos = data.filter( + (repo) => repo.name.includes('project-') && repo.fork) + technigoRepos.forEach((repo) => { + projects.innerHTML += ` +
+

${repo.name}

+

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

+

Branch: ${repo.default_branch}

+

Commits:

+

${repo.language}

+
+ ` + }) + fetchPullRequests(technigoRepos) + }) +} + +fetchRepos() + /*const fetchPullRequests = (repositories) => { + repositories.forEach((repo) => { + fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`) + .then((response) => response.json()) + .then((data) => { + const pullRequest = data.find((pull) => pull.user.login === repo.owner.login) + if (pullRequest) { + fetchCommits(pullRequest.commits_url, repo.name) + } else { + document.getElementById(`commit_${repo.name}`) + .innerHTML = 'No pull reguest'; + } + }) + }) + } + + const fetchCommits = (commitsUrl, repoName) => { + fetch(commitsUrl) + .then((response) => response.json()) + .then((data) => { + document.getElementById(`commit_${repoName}`).innerHTML += data.length + }) + } + +fetchRepos()*/ \ No newline at end of file diff --git a/code/style.css b/code/style.css index 7c8ad447..12b99bc5 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,42 @@ body { - background: #FFECE9; + background: white; +} + +header { + text-align: center; + background-color: rgb(34, 33, 33); + margin-bottom: 20px; +} + +.profile-image > a > img { + border: 2px solid black; + border-radius: 50%; + width: 160px; + height: 160px; +} + +.username { + margin-left: 30px; + margin-top: 50px; +} + +.profile { + display:flex; + justify-content: flex-start; + flex-direction: row; +} + +.projects { + display: flex; + flex-flow: row wrap; + +} + +.projects-card { + width: 100%; + background-color: white; + border: 1px solid grey; + border-radius: 0.4rem; + padding: 1rem; + margin-bottom: 15px; } \ No newline at end of file From 3df9251815c454cfe3e429fef37a89153a693f62 Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Fri, 25 Feb 2022 13:23:18 +0200 Subject: [PATCH 3/8] token --- code/.gitignore | 1 + code/chart.js | 55 ++++++++++++------------- code/index.html | 13 +++--- code/script.js | 36 ++++++++++++----- code/style.css | 105 +++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 155 insertions(+), 55 deletions(-) create mode 100644 code/.gitignore diff --git a/code/.gitignore b/code/.gitignore new file mode 100644 index 00000000..1c453411 --- /dev/null +++ b/code/.gitignore @@ -0,0 +1 @@ +token.js \ No newline at end of file diff --git a/code/chart.js b/code/chart.js index 70279ea8..259e973e 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,34 +1,29 @@ //DOM-selector for the canvas 👇 const ctx = document.getElementById('chart').getContext('2d') +const technigoProjects = 19 -//"Draw" the chart here 👇 - const labels = [ - 'January', - 'February', - 'March', - 'April', - 'May', - 'June', - ]; - - const data = { - labels: labels, - datasets: [{ - label: 'My First dataset', - backgroundColor: 'black', - borderColor: 'grey', - data: [0, 10, 5, 2, 20, 30, 45], - }] - }; - - const config = { - type: 'line', - data: data, - options: {} - }; - - const myChart = new Chart( - document.getElementById('chart'), - config - ); +//"Draw" the chart here 👇 +const myChart = (repos) => { +new Chart(ctx, { + type: 'doughnut', + data: { + labels: ['Projects I will do during bootcamp', 'Projects I have done during this bootcamp'], + datasets: [{ + label: '# of Votes', + data: [technigoProjects - repos.length, + repos.length,], + backgroundColor: [ + 'rgba(46, 204, 113, 0.2)', + 'rgba(34,139,34, 0.5)' + ], + borderColor: [ + 'rgba(38, 166, 91, 1)', + 'rgba(0,100,0, 1)' + ], + borderWidth: 1 + }] + }, + +}) +}; \ No newline at end of file diff --git a/code/index.html b/code/index.html index 9fe28bd1..4db2367f 100644 --- a/code/index.html +++ b/code/index.html @@ -15,22 +15,25 @@
- + + +
-
+
-
+
+

My technigo projects in statistics

-
+
- + diff --git a/code/script.js b/code/script.js index 1884705e..4a23e1de 100644 --- a/code/script.js +++ b/code/script.js @@ -1,12 +1,22 @@ let USER = 'qwer-ctrl' +const USER_URL = `https://api.github.com/users/${USER}` +const REPOS_URL = `https://api.github.com/users/${USER}/repos` +const TOKEN = API_TOKEN + +const options = { + method: "GET", + headers: { + Authorization: `token ${TOKEN}` + } +} const profile = document.getElementById('profile-container') const projects = document.getElementById('projects') const fetchProfile = () => { -fetch(USER_URL) +fetch(USER_URL, options) .then((response) => response.json()) .then((data) => { profile.innerHTML += ` @@ -16,10 +26,10 @@ fetch(USER_URL) Avatar of ${data.login} -

${data.login}

+

${data.login}

-

Public repositories: ${data.public_repos}

+

Public repositories: ${data.public_repos}

` }) @@ -27,7 +37,7 @@ fetch(USER_URL) fetchProfile() const fetchRepos = () => { -fetch(REPOS_URL) +fetch(REPOS_URL, options) .then((response) => response.json()) .then((data) => { const technigoRepos = data.filter( @@ -35,7 +45,7 @@ fetch(REPOS_URL) technigoRepos.forEach((repo) => { projects.innerHTML += `
-

${repo.name}

+

${repo.name}

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

Branch: ${repo.default_branch}

Commits:

@@ -43,14 +53,15 @@ fetch(REPOS_URL)
` }) + myChart(technigoRepos) fetchPullRequests(technigoRepos) + }) } -fetchRepos() - /*const fetchPullRequests = (repositories) => { + const fetchPullRequests = (repositories) => { repositories.forEach((repo) => { - fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`) + fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`, options) .then((response) => response.json()) .then((data) => { const pullRequest = data.find((pull) => pull.user.login === repo.owner.login) @@ -58,18 +69,21 @@ fetchRepos() fetchCommits(pullRequest.commits_url, repo.name) } else { document.getElementById(`commit_${repo.name}`) - .innerHTML = 'No pull reguest'; + .innerHTML = 'No pullrequest available'; } }) }) } const fetchCommits = (commitsUrl, repoName) => { - fetch(commitsUrl) + fetch(commitsUrl, options) .then((response) => response.json()) .then((data) => { document.getElementById(`commit_${repoName}`).innerHTML += data.length }) } -fetchRepos()*/ \ No newline at end of file + //I used this API for my project: `https://api.github.com/repos/${username}/${repo.name}/commits` + + +fetchRepos() \ No newline at end of file diff --git a/code/style.css b/code/style.css index 12b99bc5..8ea4863f 100644 --- a/code/style.css +++ b/code/style.css @@ -1,15 +1,43 @@ body { background: white; + margin: 0; + font-family: Helvetica, sans-serif; + color: #6a727b; + font-weight: 100; } header { - text-align: center; - background-color: rgb(34, 33, 33); + background-color: #24292f; margin-bottom: 20px; + text-align: center; +} + +#hamburger-icon { + font-size: 30px; + color: white; + padding: 20px +} + +#github-icon { + font-size: 50px; + color: white; + padding: 20px; + margin-left: 120px; + margin-right: 120px; +} + +#bell-icon { + font-size: 30px; + color: white; + padding: 20px +} + +.input { + display:none; } .profile-image > a > img { - border: 2px solid black; + border: 2px solid rgb(212, 210, 210); border-radius: 50%; width: 160px; height: 160px; @@ -18,25 +46,84 @@ header { .username { margin-left: 30px; margin-top: 50px; + font-size: 25px; } .profile { display:flex; justify-content: flex-start; flex-direction: row; + margin: 10px; +} + +.public-repositories { + margin-left: 10px; } .projects { display: flex; flex-flow: row wrap; - } .projects-card { width: 100%; background-color: white; - border: 1px solid grey; - border-radius: 0.4rem; - padding: 1rem; - margin-bottom: 15px; -} \ No newline at end of file + border: 1px solid #d3d7da; + border-radius: 6px; + padding: 16px; + margin: 0 10px 15px 10px; +} + +h2 { + text-align: center; + padding-bottom: 20px; + color: #4a4d52; +} + +#chart-container { + margin: 40px auto 20px auto; +} + +/*desktop*/ +@media (min-width: 1100px) and (max-width: 1280px) { + + .projects { + display: flex; + flex-wrap: wrap; + justify-content: center; + } + + .projects .projects-card { + flex-basis: 45%; + } + + .profile-image > a > img { + width: 270px; + height: 270px; + } + + .public-repositories { + margin-left: 20px; + } + + #chart-container { + width: 50%; + height: 50%; + } + + header { + text-align:start; + } + + #hamburger-icon { + display: none; + } + + #github-icon { + margin-left: 0; + } + + #bell-icon { + display: none; + } +} From f6de60a9566335360db8c0d09bccc1afaf88baa0 Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Fri, 25 Feb 2022 13:35:55 +0200 Subject: [PATCH 4/8] api --- code/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/script.js b/code/script.js index 4a23e1de..fb3a5cac 100644 --- a/code/script.js +++ b/code/script.js @@ -4,14 +4,14 @@ const USER_URL = `https://api.github.com/users/${USER}` const REPOS_URL = `https://api.github.com/users/${USER}/repos` const TOKEN = API_TOKEN - +console.log(TOKEN) const options = { method: "GET", headers: { - Authorization: `token ${TOKEN}` + Authorization: `token ${TOKEN}`, } } - +console.log(options) const profile = document.getElementById('profile-container') const projects = document.getElementById('projects') From 34225c1cf8398c46798cef325224707ca5ca7bec Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Fri, 25 Feb 2022 13:45:24 +0200 Subject: [PATCH 5/8] api2 --- code/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/script.js b/code/script.js index fb3a5cac..63e834fb 100644 --- a/code/script.js +++ b/code/script.js @@ -4,7 +4,7 @@ const USER_URL = `https://api.github.com/users/${USER}` const REPOS_URL = `https://api.github.com/users/${USER}/repos` const TOKEN = API_TOKEN -console.log(TOKEN) + const options = { method: "GET", headers: { From 6325a694598b34f962f5cd3de35fa3e82736fcc3 Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Fri, 25 Feb 2022 14:16:16 +0200 Subject: [PATCH 6/8] api3 --- code/script.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/script.js b/code/script.js index 63e834fb..9d7d39f7 100644 --- a/code/script.js +++ b/code/script.js @@ -3,15 +3,14 @@ let USER = 'qwer-ctrl' const USER_URL = `https://api.github.com/users/${USER}` const REPOS_URL = `https://api.github.com/users/${USER}/repos` -const TOKEN = API_TOKEN const options = { method: "GET", headers: { - Authorization: `token ${TOKEN}`, + Authorization: `token ${API_TOKEN}`, } } -console.log(options) +console.log(TOKEN) const profile = document.getElementById('profile-container') const projects = document.getElementById('projects') From 0144ae93f40405086f5e02139a26a3ce4cc181e4 Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Fri, 25 Feb 2022 14:34:14 +0200 Subject: [PATCH 7/8] test --- code/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/script.js b/code/script.js index 9d7d39f7..2215c0c3 100644 --- a/code/script.js +++ b/code/script.js @@ -10,7 +10,7 @@ const options = { Authorization: `token ${API_TOKEN}`, } } -console.log(TOKEN) +console.log(API_TOKEN) const profile = document.getElementById('profile-container') const projects = document.getElementById('projects') From 2d4be6a95b96c91e27ad9f179814a054a84df1b2 Mon Sep 17 00:00:00 2001 From: anki palviainen Date: Sun, 17 Apr 2022 12:34:57 +0300 Subject: [PATCH 8/8] clean --- code/script.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/script.js b/code/script.js index 2215c0c3..f2987854 100644 --- a/code/script.js +++ b/code/script.js @@ -82,7 +82,5 @@ fetch(REPOS_URL, options) }) } - //I used this API for my project: `https://api.github.com/repos/${username}/${repo.name}/commits` - fetchRepos() \ No newline at end of file