From dd0429dc96c734ffe2ef408f9c077855782bfe46 Mon Sep 17 00:00:00 2001 From: Karin Nordkvist Date: Thu, 24 Feb 2022 13:54:20 +0100 Subject: [PATCH 1/2] Test --- code/chart.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/code/chart.js b/code/chart.js index 92e85a30..25785589 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,4 +1,31 @@ -//DOM-selector for the canvas 👇 -const ctx = document.getElementById('chart').getContext('2d') - //"Draw" the chart here 👇 +const labels = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'Another month', + ]; + + const data = { + labels: labels, + datasets: [{ + label: 'My First dataset', + backgroundColor: ['rgb(255, 99, 132)', 'rgb(100, 5, 100)'], + borderColor: 'rgb(255, 99, 132)', + data: [0, 10, 5, 2, 20, 30, 45], + }] + }; + + const config = { + type: 'doughnut', + data: data, + options: {} + }; + + const myChart = new Chart( + document.getElementById('chart'), + config + ); \ No newline at end of file From 7c37188524d460267e729bcee61b4bfe2c7a09fc Mon Sep 17 00:00:00 2001 From: Karin Nordkvist Date: Thu, 24 Feb 2022 13:55:44 +0100 Subject: [PATCH 2/2] Did add . --- code/.gitignore | 27 +++++++++++++++++++++++++++ code/index.html | 4 +++- code/package-lock.json | 21 +++++++++++++++++++++ code/script.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 code/.gitignore create mode 100644 code/package-lock.json diff --git a/code/.gitignore b/code/.gitignore new file mode 100644 index 00000000..6b858da6 --- /dev/null +++ b/code/.gitignore @@ -0,0 +1,27 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + + +# Ignore Mac system files +.DS_store + +# Ignore node_modules folder +node_modules + +# Ignore all text files +*.txt + +# Ignore files related to API keys +.env + +# misc +/.pnp +.pnp.js +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# other +token.js + + + diff --git a/code/index.html b/code/index.html index 2fb5e0ae..3fccc4d3 100644 --- a/code/index.html +++ b/code/index.html @@ -6,6 +6,7 @@ Project GitHub Tracker +

GitHub Tracker

@@ -15,7 +16,8 @@

Projects:

- + + \ No newline at end of file diff --git a/code/package-lock.json b/code/package-lock.json new file mode 100644 index 00000000..29ceaa3f --- /dev/null +++ b/code/package-lock.json @@ -0,0 +1,21 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "chart.js": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.1.tgz", + "integrity": "sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==" + }, + "dotenv": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==" + }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==" + } + } +} diff --git a/code/script.js b/code/script.js index e69de29b..8f6c076a 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,38 @@ +const username = 'karinnordkvist' +const testUser = 'molbimien' +let reponame = '' +const API_URL = `https://api.github.com/users/${username}/repos` + + +const API_TOKEN = TOKEN || process.env.API_KEY; + +const options = { + method: 'GET', // POST, PATCH, DELETE + headers: { + Authorization: `token ${API_TOKEN}` + } + } + +fetch(API_URL, options) +.then(res => res.json()) +.then(data => { + console.log(data) + reponame = data[8].name + + const API_URL_PR = `https://api.github.com/repos/Technigo/${data[8].name}/pulls` + + fetch(API_URL_PR, options) + .then(res => res.json()) + .then(data2 => { + console.log(data2) + + const allPRs = data2.filter(item => item.head.user.login === testUser) + console.log() + + const COMMENTS_URL = allPRs[0].commits_url + fetch(COMMENTS_URL) + .then(res => res.json()) + .then(data3 => console.log(data3)) + + }) + }) \ No newline at end of file