From 54c248844069a186b690a73de5f581628cfb02ed Mon Sep 17 00:00:00 2001 From: talksik Date: Mon, 19 Aug 2019 21:00:42 -0700 Subject: [PATCH] attempting utube and gsearch with bugs --- config.dev.json | 2 +- src/components/MainCommand.js | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/config.dev.json b/config.dev.json index 96e1dbd..fc3b4e1 100644 --- a/config.dev.json +++ b/config.dev.json @@ -1,7 +1,7 @@ { "server_url": "http://localhost:5000", - "DEFAULT_LOGO": "https://s3-us-west-1.amazonaws.com/charify-assets/defaultLogo.png", + "DEFAULT_LOGO": "https://icon-library.net/images/free-google-icon/free-google-icon-17.jpg", "GOOGLE_API_KEY": "AIzaSyCZCgZY7ZlSMk1DW0NEEoHZ9qwdSL4AR1k", "OAUTH2_CLIENT_ID": "951578952608-6v55t0skirb80r8rtcvelhj4lfnpp2iq.apps.googleusercontent.com", diff --git a/src/components/MainCommand.js b/src/components/MainCommand.js index 32676c3..3050862 100644 --- a/src/components/MainCommand.js +++ b/src/components/MainCommand.js @@ -9,9 +9,12 @@ import { Button } from '@material-ui/core'; import { Send } from '@material-ui/icons'; const INITIAL_COMMAND_STATE = { - command: 'default', + command: 'google', commandInput: '', - commandIcon: envVars.DEFAULT_LOGO, + commandIcon: + envVars.DEFAULT_LOGO != null + ? envVars.DEFAULT_LOGO + : 'https://s3-us-west-1.amazonaws.com/charify-assets/defaultLogo.png', commandInputPlaceholder: 'Do Everything You Want', commandComplete: false, commandProcessedData: null @@ -68,7 +71,8 @@ class MainCommand extends Component { this.setState({ googleAccessToken: signInResponse.Zi.access_token, - googleAuthUser: signInResponse.w3 + googleAuthUser: signInResponse.w3, + commandComplete: true }); }; @@ -109,6 +113,19 @@ class MainCommand extends Component { } } + if (newInput.includes('google') || this.state.command == 'google') { + newCommand = 'google'; + newCommandComplete = true; + newCommandInputPlaceholder = 'search for anything'; + } else if (newInput.includes('utube')) { + newCommand = 'utube'; + newCommandIcon = + 'https://cdn2.iconfinder.com/data/icons/micon-social-pack/512/youtube-512.png'; + newInput = newInput.replace('utube', ''); + newCommandComplete = true; + newCommandInputPlaceholder = 'search for any video'; + } + this.setState({ command: newCommand, commandInput: newInput, @@ -123,6 +140,7 @@ class MainCommand extends Component { // TODO: make executing api calls modular with helpers/services const processedData = this.state.commandProcessedData; + console.log(this.state.command); if (this.state.command == 'gmail') { const message = `From: ${this.state.googleAuthUser.U3}\r\n` + @@ -148,6 +166,17 @@ class MainCommand extends Component { sendEmail.execute(function(response) { console.log('Sent the Email!', response); }); + } else if (this.state.command == 'google') { + window.open( + 'https://www.google.com/search?q=' + this.state.commandInput, + '_blank' + ); + } else if (this.state.command == 'utube') { + window.open( + 'https://www.youtube.com/results?search_query=' + + this.state.commandInput, + '_blank' + ); } this.setState(INITIAL_COMMAND_STATE, () => console.log(this.state));