From 3f9d101e996826e6f3a00b9f8d1b92e782064786 Mon Sep 17 00:00:00 2001 From: Adrian Lopez Date: Wed, 20 May 2020 09:04:56 +0200 Subject: [PATCH] Move api key to env. Use current host for apollo client Store the api key in .env files outside of the git repo. Delete the old key Connect to the graphql endpoint using the current browser host Change the logo to be squared. Still not being displayed --- app/.gitignore | 1 + app/Makefile | 3 + app/frontend/.gitignore | 5 +- app/frontend/Makefile | 2 +- app/frontend/src/components/chrome/chrome.tsx | 5 +- app/frontend/src/components/chrome/client.tsx | 5 +- app/frontend/src/images/logo.svg | 243 +++++++++++++++++- app/frontend/src/settings.tsx | 9 +- 8 files changed, 249 insertions(+), 24 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index 3f72a16..1a1fea5 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -4,3 +4,4 @@ piclimbing TODO piclimbing.exe piclimbing.arm6 +piclimbing.osx diff --git a/app/Makefile b/app/Makefile index 792e20b..986387d 100644 --- a/app/Makefile +++ b/app/Makefile @@ -16,6 +16,9 @@ build_amd64: build_windows_amd64: GOOS=windows GOARCH=amd64 go build -o ${NAME}.exe +build_osx: + GOOS=darwin go build -o ${NAME}.osx + .PHONY: all build_amd64 build_rpizero build_windows_amd64 pkger diff --git a/app/frontend/.gitignore b/app/frontend/.gitignore index d8f6207..4278814 100644 --- a/app/frontend/.gitignore +++ b/app/frontend/.gitignore @@ -69,4 +69,7 @@ yarn-error.log .yarn-integrity # Build files -lib/ \ No newline at end of file +lib/ + +.env.development +.env.production diff --git a/app/frontend/Makefile b/app/frontend/Makefile index 0f5167b..1fa31e2 100644 --- a/app/frontend/Makefile +++ b/app/frontend/Makefile @@ -1,7 +1,7 @@ all: clean build clean: - gatsby build + gatsby clean build: gatsby build diff --git a/app/frontend/src/components/chrome/chrome.tsx b/app/frontend/src/components/chrome/chrome.tsx index 124046e..5033404 100644 --- a/app/frontend/src/components/chrome/chrome.tsx +++ b/app/frontend/src/components/chrome/chrome.tsx @@ -27,7 +27,6 @@ import { import { Link } from '@reach/router'; import { GoogleApi } from '@lourd/react-google-api'; -import { GoogleClientId, GoogleApiKey, } from '../../settings'; import 'regenerator-runtime/runtime'; import { loadState, saveState } from '../../state/localStorage'; import { client } from './client' @@ -84,8 +83,8 @@ export default class Chrome extends React.Component { 'https://sheets.googleapis.com/$discovery/rest?version=v4', 'https://www.googleapis.com/discovery/v1/apis/drive/v3/rest', ]} - clientId={GoogleClientId} - apiKey={GoogleApiKey}> + clientId={process.env.GOOGLE_CLIENT_ID} + apiKey={process.env.GOOGLE_API_KEY}> {({ authorize, loading: apiLoading, signout, signedIn, error }) => (
diff --git a/app/frontend/src/components/chrome/client.tsx b/app/frontend/src/components/chrome/client.tsx index 591f233..72b28c8 100644 --- a/app/frontend/src/components/chrome/client.tsx +++ b/app/frontend/src/components/chrome/client.tsx @@ -3,14 +3,13 @@ import { HttpLink } from 'apollo-link-http'; import { WebSocketLink } from 'apollo-link-ws'; import { getMainDefinition } from 'apollo-utilities'; import { InMemoryCache } from 'apollo-cache-inmemory'; -import { HTTPServer, WSServer } from '../../settings'; import { ApolloClient } from 'apollo-client'; import fetch from 'isomorphic-fetch'; const wsLink = process.browser ? new WebSocketLink({ // if you instantiate in the server, the error will be thrown - uri: WSServer, + uri: `ws://${window.location.host}/query`, options: { reconnect: true, }, @@ -18,7 +17,7 @@ const wsLink = process.browser : null; const httplink = new HttpLink({ - uri: HTTPServer, + uri: '/query', fetch, credentials: 'same-origin', }); diff --git a/app/frontend/src/images/logo.svg b/app/frontend/src/images/logo.svg index fa880b2..2d47f3e 100644 --- a/app/frontend/src/images/logo.svg +++ b/app/frontend/src/images/logo.svg @@ -1,15 +1,242 @@ - + + + + + + image/svg+xml + + + + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/frontend/src/settings.tsx b/app/frontend/src/settings.tsx index b0a45d3..f93cc9b 100644 --- a/app/frontend/src/settings.tsx +++ b/app/frontend/src/settings.tsx @@ -1,10 +1,3 @@ const AppName = 'piclimbing'; -const Server = '127.0.0.1:8080'; -const HTTPServer = `http://${Server}/query`; -const WSServer = `ws://${Server}/query`; -const GoogleClientId = - '275924066084-dgk36mi6e5t4c8oilvt2nmjmq0tquaq8.apps.googleusercontent.com'; -const GoogleApiKey = 'AIzaSyCl0nG267IOgnfT-sWUj0cDb4FEj8Kt9Ss'; - -export { AppName, HTTPServer, WSServer, GoogleClientId, GoogleApiKey }; +export { AppName };