From ce9e0f8adfce019da9a4c162489cd70c8aeebc9d Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Tue, 11 Jun 2019 14:55:35 -0400 Subject: [PATCH 01/16] testing auth --- src/main/components/RequestBar.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index 55d406e..f6e2321 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -17,6 +17,13 @@ const RequestBar = (props) => { function sendFetch(e) { e.preventDefault(); const sendingObj = { method: selected, mode: 'cors' }; + sendingObj.headers = { + 'Content-Type': 'application/json', + token_type: 'Bearer', + Authorization: 'Bearer RCHzqJmqDK-BgGQYiNjqjV5f0GuhOybwvvkSJGkWDKTdX03BXU3aT83MMKNmdoKvs3_sy4vWgj-60sDtbYb_WkLs0jvYoyzWyPZXiqNAs4JoN7J2vQ626rcQI4DkXHYx', + }; + console.log(sendingObj); + if (SourceOrDest === 'dest') sendingObj.body = JSON.stringify(requestBody); fetch(uri, sendingObj) From 8c263f25b56f5622ea37fa796e16faf5079ac8ef Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Tue, 11 Jun 2019 15:31:57 -0400 Subject: [PATCH 02/16] turned off cors protection for the app --- public/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/main.js b/public/main.js index dff3ce8..722794e 100644 --- a/public/main.js +++ b/public/main.js @@ -15,6 +15,7 @@ function createWindow() { height: 600, webPreferences: { nodeIntegration: true, + webSecurity: false, }, }); From c0e2796b5b0c747102eafd2015031d0dc0c6bcee Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Tue, 11 Jun 2019 16:16:49 -0400 Subject: [PATCH 03/16] auth will return later --- src/main/components/RequestBar.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index f6e2321..0d652b6 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -19,9 +19,12 @@ const RequestBar = (props) => { const sendingObj = { method: selected, mode: 'cors' }; sendingObj.headers = { 'Content-Type': 'application/json', - token_type: 'Bearer', Authorization: 'Bearer RCHzqJmqDK-BgGQYiNjqjV5f0GuhOybwvvkSJGkWDKTdX03BXU3aT83MMKNmdoKvs3_sy4vWgj-60sDtbYb_WkLs0jvYoyzWyPZXiqNAs4JoN7J2vQ626rcQI4DkXHYx', }; + // sendingObj.params = { + // term: 'tacos', + // location: 'main 123st', + // }; console.log(sendingObj); if (SourceOrDest === 'dest') sendingObj.body = JSON.stringify(requestBody); From 3749059dd7672371b2b2eb7b7549aedbe19088a1 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Tue, 11 Jun 2019 20:42:46 -0400 Subject: [PATCH 04/16] cleaning up object --- src/main/components/RequestBar.jsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index 0d652b6..5d825cb 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -17,15 +17,7 @@ const RequestBar = (props) => { function sendFetch(e) { e.preventDefault(); const sendingObj = { method: selected, mode: 'cors' }; - sendingObj.headers = { - 'Content-Type': 'application/json', - Authorization: 'Bearer RCHzqJmqDK-BgGQYiNjqjV5f0GuhOybwvvkSJGkWDKTdX03BXU3aT83MMKNmdoKvs3_sy4vWgj-60sDtbYb_WkLs0jvYoyzWyPZXiqNAs4JoN7J2vQ626rcQI4DkXHYx', - }; - // sendingObj.params = { - // term: 'tacos', - // location: 'main 123st', - // }; - console.log(sendingObj); + if (SourceOrDest === 'dest') sendingObj.body = JSON.stringify(requestBody); From da49c82f376e4dd2ea8e16dc1a48a44d39551ca2 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 11:23:53 -0400 Subject: [PATCH 05/16] enabling chrome dev tools --- public/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/main.js b/public/main.js index 722794e..256921c 100644 --- a/public/main.js +++ b/public/main.js @@ -21,6 +21,13 @@ function createWindow() { mainWindow.loadURL(isDev ? 'http://localhost:8080' : `file://${__dirname}/../dist/index.html`); + const path = require('path') + const os = require('os') + + BrowserWindow.addDevToolsExtension( + path.join(os.homedir(), './Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/3.6.0'), + ); + mainWindow.on('closed', () => { mainWindow = null; }); From a9be1e8e1dcfa75646ababd17ff4e0285e0627a5 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 11:26:07 -0400 Subject: [PATCH 06/16] refactored the send fetch function for space complexity, each itteration was creating a new fucntion definition with the same functionality --- src/main/components/RequestBar.jsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index d6f77fe..c63814c 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -16,6 +16,16 @@ const RequestBar = (props) => { else if (name === 'uri') setUri(value); }; + const runTest = (link, sendingObj, testsClone, i) => { + const test = testsClone; + fetch(link, sendingObj) + .then((response) => { + test[i].status = response.status; + if (i === test.length - 1) setTests(test); + }) + .catch(error => console.log(error)); + }; + function sendFetch(e) { e.preventDefault(); @@ -28,17 +38,10 @@ const RequestBar = (props) => { } else if (SourceOrDest === 'dest') { const testsClone = [...tests]; const sendingObj = { method: selected, mode: 'cors' }; - let counter = 0; + for (let i = 0; i < testsClone.length; i += 1) { sendingObj.body = JSON.stringify(testsClone[i].payload); - - fetch(uri, sendingObj) - .then((response) => { - counter += 1; - testsClone[i].status = response.status; - if (counter === testsClone.length) setTests(testsClone); - }) - .catch(error => console.log(error)); + runTest(uri, sendingObj, testsClone, i); } } } From eae03c6c0351622478fdd128f6e071fef803f693 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 11:27:30 -0400 Subject: [PATCH 07/16] removed quotes from the dash for display --- src/main/components/ResponseComponent.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/components/ResponseComponent.jsx b/src/main/components/ResponseComponent.jsx index 2942e61..f3ef263 100644 --- a/src/main/components/ResponseComponent.jsx +++ b/src/main/components/ResponseComponent.jsx @@ -10,7 +10,7 @@ const ResponseComponent = (props) => { return (
-

{`${checkmark} ' - ' ${status}`}

+

{`${checkmark} - ${status}`}

From 08c810de6a25e936a7a8690a20a17d65e1802009 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 13:42:29 -0400 Subject: [PATCH 08/16] added react dev tools --- public/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/public/main.js b/public/main.js index 256921c..358fad6 100644 --- a/public/main.js +++ b/public/main.js @@ -1,5 +1,7 @@ const { app, BrowserWindow } = require('electron'); const isDev = require('electron-is-dev'); +const path = require('path'); +const os = require('os'); if (isDev) { console.log('Running in development'); @@ -21,13 +23,12 @@ function createWindow() { mainWindow.loadURL(isDev ? 'http://localhost:8080' : `file://${__dirname}/../dist/index.html`); - const path = require('path') - const os = require('os') - - BrowserWindow.addDevToolsExtension( - path.join(os.homedir(), './Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/3.6.0'), - ); + if (isDev) { + BrowserWindow.addDevToolsExtension( + path.join(os.homedir(), './Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/3.6.0_0'), + ); + } mainWindow.on('closed', () => { mainWindow = null; }); From 172ea2992b7d8a47c2ea900a89a50a29ec514519 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 18:23:26 -0400 Subject: [PATCH 09/16] added header to the request bar --- src/main/components/HeaderBar.jsx | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/components/HeaderBar.jsx diff --git a/src/main/components/HeaderBar.jsx b/src/main/components/HeaderBar.jsx new file mode 100644 index 0000000..e3bf97b --- /dev/null +++ b/src/main/components/HeaderBar.jsx @@ -0,0 +1,39 @@ +import React, { useState, useEffect } from 'react'; + +const HeaderBar = (props) => { + console.log(props); + const headKey = 'Authorization'; + const AuthType = 'Bearer Token'; + const [selected, setSelected] = useState(headKey); + const [type, setType] = useState(AuthType); + const [headerKey, setHeaderKey] = useState(''); + console.log(selected); + + const handleChange = (e) => { + const { name, value } = e.target; + console.log(name); + if (name === 'header') setSelected(value); + + }; + + return ( +
+

Header Bar

+
+ + + +
+
+ ); + +}; + +export default HeaderBar; From 78d4c34a4a066c518757878be204946018b71397 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 18:27:00 -0400 Subject: [PATCH 10/16] added header to the request bar --- src/main/components/RequestBar.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index c63814c..ca1683b 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -1,4 +1,6 @@ import React, { useState } from 'react'; +import HeaderBar from './HeaderBar.jsx'; + const RequestBar = (props) => { const { @@ -68,6 +70,7 @@ const RequestBar = (props) => { +
); }; From e8a7bf8b415ffd9e73a1caac258c99af2d7ad219 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 20:01:32 -0400 Subject: [PATCH 11/16] change the state of the header and moved it up to the request bar --- src/main/components/HeaderBar.jsx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/components/HeaderBar.jsx b/src/main/components/HeaderBar.jsx index e3bf97b..48a9f31 100644 --- a/src/main/components/HeaderBar.jsx +++ b/src/main/components/HeaderBar.jsx @@ -1,33 +1,23 @@ import React, { useState, useEffect } from 'react'; const HeaderBar = (props) => { - console.log(props); - const headKey = 'Authorization'; - const AuthType = 'Bearer Token'; - const [selected, setSelected] = useState(headKey); - const [type, setType] = useState(AuthType); - const [headerKey, setHeaderKey] = useState(''); - console.log(selected); + const { + header, authType, handleChange, + } = props; - const handleChange = (e) => { - const { name, value } = e.target; - console.log(name); - if (name === 'header') setSelected(value); - - }; return (

Header Bar

- -
From e34b003fb71ece4f6f4d975a46aa06dcde947a7a Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 20:27:44 -0400 Subject: [PATCH 12/16] changed name to say header --- src/main/components/HeaderBar.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/components/HeaderBar.jsx b/src/main/components/HeaderBar.jsx index 48a9f31..8bfdd7e 100644 --- a/src/main/components/HeaderBar.jsx +++ b/src/main/components/HeaderBar.jsx @@ -1,14 +1,13 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; const HeaderBar = (props) => { const { header, authType, handleChange, } = props; - return (
-

Header Bar

+

Headers

- +
); }; From babbe058e6aa9bc722a4fc4eb6edc2902158d2d1 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 20:33:06 -0400 Subject: [PATCH 14/16] final commit before pulling from dev --- src/main/components/RequestBar.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/components/RequestBar.jsx b/src/main/components/RequestBar.jsx index 0f81044..697da49 100644 --- a/src/main/components/RequestBar.jsx +++ b/src/main/components/RequestBar.jsx @@ -43,8 +43,6 @@ const RequestBar = (props) => { const sendingObj = { method: selected, mode: 'cors' }; if (headerType !== 'NONE') sendingObj.headers = { [headerType]: headerKey }; - console.log('val of obj', sendingObj); - fetch(uri, sendingObj) .then(res => res.json()) .then(res => setData(res)); From ffa855fb44a20a10579e3ef0de47a490fbbd29f9 Mon Sep 17 00:00:00 2001 From: Donald Blanc Date: Wed, 12 Jun 2019 21:56:00 -0400 Subject: [PATCH 15/16] changed line 13 to reflect Authentication per conor's suggestions --- src/main/components/HeaderBar.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/components/HeaderBar.jsx b/src/main/components/HeaderBar.jsx index 8bfdd7e..48889ee 100644 --- a/src/main/components/HeaderBar.jsx +++ b/src/main/components/HeaderBar.jsx @@ -5,11 +5,12 @@ const HeaderBar = (props) => { header, authType, handleChange, } = props; + console.log(authType); return (

Headers

-