diff --git a/web/src/App.js b/web/src/App.js index 2d405e2..571797a 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -18,7 +18,7 @@ class App extends Component { constructor(props){ super(props); - this.state={_id:'5a5016e775becaef2015da10', + this.state={_id:'5a232fb86ce046c749739455', skillID:'', skillName:'', invocationName:'Saburly', @@ -30,8 +30,8 @@ class App extends Component { waiting: false }; - getSkill(this.state._id).then(l=> l.text()).then(result=>{ - let jResult = JSON.parse(result)[0]; + getSkill(this.state._id).then(l=>l.json()).then(result=>{ + let jResult = result[0]; if (jResult===undefined) return; this.setState({ skillID:jResult.skillID,skillName:jResult.skillName, invocationName: jResult.invocationName, invocationAnswer: jResult.invocationAnswer, @@ -51,6 +51,26 @@ class App extends Component { } render() { + let rightPanel; + switch (this.state.selectedIndex) { + case LAUNCH_REQUEST_SELECTED_INDEX: + rightPanel = ; + break; + case CONTACT_SELECTED_INDEX: + rightPanel = ; + break; + default: + rightPanel = ; + } + return(
@@ -63,37 +83,9 @@ class App extends Component { onIntentClick={this.handleIntentClick} onAddIntentClick={this.handleAddIntentClick} selectedIndex={this.state.selectedIndex} - waiting={this.state.waiting}> - - {( - ()=>{ - if (this.state.selectedIndex===LAUNCH_REQUEST_SELECTED_INDEX){ - return ( - - - ); - }else if (this.state.selectedIndex===CONTACT_SELECTED_INDEX){ - return ( - - - ); - }else{ - return( - - - ); - } - } - )()} + waiting={this.state.waiting}/> + + {rightPanel}
); } @@ -179,10 +171,9 @@ class App extends Component { sendSkill(newAllIntents, showPopUp, resolveState, rejectState, newName, newAnswer, email, updateOnAmazon){ return new Promise((resolve,reject)=>{ - updateSkill(this.createSkill(newAllIntents,newName,newAnswer,email,updateOnAmazon)).then(l=>l.text()).then(result=>{ - let jResult = JSON.parse(result); - if (jResult.result !== RESULT_CODES.OK){ - console.log(jResult.result); + updateSkill(this.createSkill(newAllIntents,newName,newAnswer,email,updateOnAmazon)).then(l=>l.json()).then(result=>{ + if (result.result !== RESULT_CODES.OK){ + console.log(result.result); if (showPopUp) Popup.alert('Model was not saved. Please try again'); this.setState(rejectState); //reject('Error code : ' + jResult.result); diff --git a/web/src/components/Contact.js b/web/src/components/Contact.js index 8a0efa8..669945b 100644 --- a/web/src/components/Contact.js +++ b/web/src/components/Contact.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import {Button, TextField} from 'react-md'; -import '../css/Intent.css' +import '../css/Common.css'; +import '../css/components/Contact.css'; import {EMAIL_MAX_LENGTH} from '../config/constants'; class Contact extends Component { @@ -18,21 +19,20 @@ class Contact extends Component { render() { return ( -
-
Contact address will be used for direct messaging through Alexa
+
+
Contact address will be used for direct messaging through Alexa






-
diff --git a/web/src/components/IntentDetails.js b/web/src/components/IntentDetails.js index de1c4a0..5af5471 100644 --- a/web/src/components/IntentDetails.js +++ b/web/src/components/IntentDetails.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import {Button, SVGIcon, TextField} from 'react-md'; -import '../css/Intent.css' +import '../css/components/IntentDetails.css'; import {QUESTION_MAX_LENGTH, ANSWER_MAX_LENGTH, INTENT_NAME_MAX_LENGTH} from '../config/constants'; class IntentDetails extends Component { @@ -22,20 +22,19 @@ class IntentDetails extends Component { render() { return ( -
+
-
Questions
+
Questions
{ this.state.intent.questions.map((question, index)=>{ return ( @@ -44,8 +43,7 @@ class IntentDetails extends Component { id="intent question" lineDirection="center" placeholder="Question" - className="md-cell md-cell--bottom" - style={{width:'60%'}} + className="md-cell md-cell--bottom IntentDetailsInputBoxes" maxLength={QUESTION_MAX_LENGTH} rightIcon={{this.deleteQuestion(question)}}> } onChange={(e)=>{this.handleQuestionEdit(e,index)}} @@ -62,18 +60,17 @@ class IntentDetails extends Component { lineDirection="center" label="Answer" placeholder="Answer" - style={{width:'60%'}} maxLength={ANSWER_MAX_LENGTH} - className="md-cell md-cell--bottom" + className="md-cell md-cell--bottom IntentDetailsInputBoxes" onChange={this.handleAnswerEdit} value={this.state.intent.answer}/>
}



- - - + + +
); @@ -110,7 +107,6 @@ class IntentDetails extends Component { handleIntentNameEdit(e){ if (e.length === INTENT_NAME_MAX_LENGTH) return; - //e.replace(/\s/g,''); let newIntent = this.state.intent; newIntent.intentName = e; this.setState({intent: newIntent}); diff --git a/web/src/components/IntentItem.js b/web/src/components/IntentItem.js index 124d7fd..ede0eca 100644 --- a/web/src/components/IntentItem.js +++ b/web/src/components/IntentItem.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import {Button} from 'react-md'; -import '../css/Intent.css' +import '../css/components/IntentItem.css' import {INTENT_TITLE_MAX_LENGTH, INTENT_TITLE_TOOLTIP_DELAY} from '../config/constants' class IntentItem extends Component { diff --git a/web/src/components/IntentList.js b/web/src/components/IntentList.js index 6722fc0..96a86d1 100644 --- a/web/src/components/IntentList.js +++ b/web/src/components/IntentList.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import {Button} from 'react-md'; import IntentItem from './IntentItem'; -import '../css/Intent.css' +import '../css/components/IntentList.css'; import { LAUNCH_REQUEST_SELECTED_INDEX, CONTACT_SELECTED_INDEX} from '../config/constants' @@ -20,11 +20,11 @@ class IntentList extends Component { render() { return (
- - @@ -43,7 +43,7 @@ class IntentList extends Component { }) }

-
diff --git a/web/src/components/LaunchRequest.js b/web/src/components/LaunchRequest.js index c6c1b33..a6ef19a 100644 --- a/web/src/components/LaunchRequest.js +++ b/web/src/components/LaunchRequest.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import {Button, TextField} from 'react-md'; -import '../css/Intent.css' +import '../css/Common.css'; +import '../css/components/LaunchRequest.css'; import { INVOCATION_NAME_MAX_LENGTH, INVOCATION_ANSWER_MAX_LENGTH } from '../config/constants'; class LaunchRequest extends Component { @@ -19,33 +20,31 @@ class LaunchRequest extends Component { render() { return ( -
-
Invocation name customers use to activate the skill. For example "Open Saburly" or "Talk to Saburly"
+
+
Invocation name customers use to activate the skill. For example "Open Saburly" or "Talk to Saburly"


-
Answer customers get from Alexa when they activate the skill.
+
Answer customers get from Alexa when they activate the skill.




-
diff --git a/web/src/config/config.js b/web/src/config/config.js index ab2244e..4a3731b 100644 --- a/web/src/config/config.js +++ b/web/src/config/config.js @@ -1,3 +1,4 @@ -export const BASE_URL = 'tellall.saburly.com'; +//export const BASE_URL = 'tellall.saburly.com'; //for server +export const BASE_URL = 'localhost:5000'; //for local diff --git a/web/src/config/constants.js b/web/src/config/constants.js index 88e45c5..f4add8f 100644 --- a/web/src/config/constants.js +++ b/web/src/config/constants.js @@ -15,6 +15,6 @@ export const LAUNCH_REQUEST_SELECTED_INDEX = -2; export const CONTACT_SELECTED_INDEX = -3; export const RESULT_CODES = { - OK:0, - ERROR:-1 -} + OK: 0, + ERROR: -1, +}; diff --git a/web/src/css/Common.scss b/web/src/css/Common.scss new file mode 100644 index 0000000..80a7476 --- /dev/null +++ b/web/src/css/Common.scss @@ -0,0 +1,21 @@ +$minHeight : calc(100vh - 80px); //80px is height of the title div container + +/* Common for right panel components */ + +.RightPanelBox{ + float: left; + width: 70%; + min-height:$minHeight; + background-color: #f5f5f5; +} + +.PanelSubTitle{ + text-align: left; + margin-top: 30px; + margin-left: 20px; +} + +.SaveButton{ + float: right; + margin-right: 20px; +} \ No newline at end of file diff --git a/web/src/css/Intent.css b/web/src/css/Intent.css deleted file mode 100644 index bd94c64..0000000 --- a/web/src/css/Intent.css +++ /dev/null @@ -1,82 +0,0 @@ -/*IntentList and IntentItem CSS*/ -.IntentList { - width: 30%; - min-height: calc(100vh - 80px); - float: left; - background-color: #eff0f0; } - -.IntentList-title { - font-size: 1.5em; - height: 70px; - padding: 20px; - text-align: left; - background-color: #eff0f0; } - -.LaunchRequest { - text-align: left; - width: 100%; - height: 50px; - background-color: #d8d8d8; } - -.LaunchRequest-selected { - text-align: left; - width: 100%; - height: 50px; - background-color: #f5f5f5; } - -.Contact { - text-align: left; - color: #009b8a; - width: 100%; - height: 50px; - background-color: #d8d8d8; } - -.Contact-selected { - text-align: left; - color: #009b8a; - width: 100%; - height: 50px; - background-color: #f5f5f5; } - -.AddIntent { - float: right; - margin: 12px; } - -.IntentItem { - margin-top: 2px; - margin-bottom: 2px; - height: 50px; - width: 100%; - text-align: left; - background-color: #d8d8d8; } - -.IntentItem-selected { - margin-top: 2px; - margin-bottom: 2px; - height: 50px; - width: 100%; - text-align: left; - background-color: #f5f5f5; } - -/*IntentDetails CSS*/ -.IntentDetails { - float: left; - width: 70%; - min-height: calc(100vh - 80px); - background-color: #f5f5f5; } - -.QuestionBox { - margin: 25px; } - -/*LaunchRequest CSS*/ -.LaunchRequestBox { - float: left; - width: 70%; - min-height: calc(100vh - 80px); - background-color: #f5f5f5; } - -.ExplanationText { - float: left; - margin-top: 30px; - margin-left: 20px; - text-align: left; } diff --git a/web/src/css/Intent.scss b/web/src/css/Intent.scss deleted file mode 100644 index 3b35a99..0000000 --- a/web/src/css/Intent.scss +++ /dev/null @@ -1,101 +0,0 @@ -$minHeight : calc(100vh - 80px); - -/*IntentList and IntentItem CSS*/ - -.IntentList{ - width: 30%; - min-height:$minHeight; - float:left; - background-color: #eff0f0; -} - -.IntentList-title{ - font-size: 1.5em; - height: 70px; - padding: 20px; - text-align:left; - background-color: #eff0f0; -} - -.LaunchRequest{ - text-align: left; - width: 100%; - height: 50px; - background-color: #d8d8d8 -} - -.LaunchRequest-selected{ - text-align: left; - width: 100%; - height: 50px; - background-color: #f5f5f5; -} - -.Contact{ - text-align: left; - color: #009b8a; - width: 100%; - height: 50px; - background-color: #d8d8d8 -} - -.Contact-selected{ - text-align: left; - color: #009b8a; - width: 100%; - height: 50px; - background-color: #f5f5f5; -} - -.AddIntent{ - float: right; - margin: 12px; -} - -.IntentItem{ - margin-top: 2px; - margin-bottom: 2px; - height: 50px; - width:100%; - text-align:left; - background-color: #d8d8d8; -} - -.IntentItem-selected{ - margin-top: 2px; - margin-bottom: 2px; - height: 50px; - width:100%; - text-align:left; - background-color: #f5f5f5; - -} - -/*IntentDetails CSS*/ - -.IntentDetails{ - float: left; - width: 70%; - min-height:$minHeight; - background-color: #f5f5f5; -} - -.QuestionBox{ - margin:25px; -} - -/*LaunchRequest CSS*/ - -.LaunchRequestBox{ - float: left; - width:70%; - min-height:$minHeight; - background-color: #f5f5f5; -} - -.ExplanationText{ - float: left; - margin-top: 30px; - margin-left: 20px; - text-align: left; -} \ No newline at end of file diff --git a/web/src/css/components/Contact.scss b/web/src/css/components/Contact.scss new file mode 100644 index 0000000..10ce88b --- /dev/null +++ b/web/src/css/components/Contact.scss @@ -0,0 +1,4 @@ +.ContactEmailInput{ + width: 60%; + margin-left: 20px; +} diff --git a/web/src/css/components/IntentDetails.scss b/web/src/css/components/IntentDetails.scss new file mode 100644 index 0000000..8c65d70 --- /dev/null +++ b/web/src/css/components/IntentDetails.scss @@ -0,0 +1,18 @@ +.QuestionBox{ + margin:25px; +} + +.QuestionTitle{ + margin-top:20px; + margin-left: 30px; + float: left; +} + +.IntentDetailsInputBoxes{ + width: 60%; +} + +.IntentDetailsButton{ + float: left; + margin-left: 25px; +} \ No newline at end of file diff --git a/web/src/css/components/IntentItem.scss b/web/src/css/components/IntentItem.scss new file mode 100644 index 0000000..c729317 --- /dev/null +++ b/web/src/css/components/IntentItem.scss @@ -0,0 +1,18 @@ +.IntentItem{ + margin-top: 2px; + margin-bottom: 2px; + height: 50px; + width:100%; + text-align:left; + background-color: #d8d8d8; +} + +.IntentItem-selected{ + margin-top: 2px; + margin-bottom: 2px; + height: 50px; + width:100%; + text-align:left; + background-color: #f5f5f5; + +} diff --git a/web/src/css/components/IntentList.scss b/web/src/css/components/IntentList.scss new file mode 100644 index 0000000..fd5f29c --- /dev/null +++ b/web/src/css/components/IntentList.scss @@ -0,0 +1,52 @@ +$minHeight : calc(100vh - 80px); //80px is height of the title div container + + +.IntentList{ + width: 30%; + min-height:$minHeight; + float:left; + background-color: #eff0f0; +} + +.IntentList-title{ + font-size: 1.5em; + height: 70px; + padding: 20px; + text-align:left; + background-color: #eff0f0; +} + +.AddIntent{ + float: right; + margin: 12px; +} + +.LaunchRequestButton{ + text-align: left; + width: 100%; + height: 50px; + background-color: #d8d8d8 +} + +.LaunchRequestButton-selected{ + text-align: left; + width: 100%; + height: 50px; + background-color: #f5f5f5; +} + +.ContactButton{ + text-align: left; + color: #009b8a; + width: 100%; + height: 50px; + background-color: #d8d8d8 +} + +.ContactButton-selected{ + text-align: left; + color: #009b8a; + width: 100%; + height: 50px; + background-color: #f5f5f5; +} \ No newline at end of file diff --git a/web/src/css/components/LaunchRequest.scss b/web/src/css/components/LaunchRequest.scss new file mode 100644 index 0000000..35fc714 --- /dev/null +++ b/web/src/css/components/LaunchRequest.scss @@ -0,0 +1,11 @@ +.ExplanationText{ + float: left; + margin-top: 30px; + margin-left: 20px; + text-align: left; +} + +.InvocationInputBoxes{ + width: 60%; + margin-left: 20px; +} \ No newline at end of file