From: Minji Park Date: Mon, 17 Apr 2017 11:16:36 +0000 (+0900) Subject: Modify cloud dashboard for sign-up X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de0208f8b65281318d5382e1c50b1021b589c3a5;p=contrib%2Fiotivity.git Modify cloud dashboard for sign-up - change sign-up page to insert oauth provider manually - sign-out bug fixed Change-Id: Ie9bd0bae006a1cdc7bfabd5686e51da15c9d22d5 Signed-off-by: Minji Park Reviewed-on: https://gerrit.iotivity.org/gerrit/19025 Tested-by: jenkins-iotivity Reviewed-by: Jee Hyeok Kim --- diff --git a/cloud/dashboard/src/Client.js b/cloud/dashboard/src/Client.js index 2dc8b4e..8ae5a8d 100644 --- a/cloud/dashboard/src/Client.js +++ b/cloud/dashboard/src/Client.js @@ -117,8 +117,7 @@ var Client = new function() { // send sign-in request. this.onSignIn = function(packet) { if(packet.getCode === 68) { - Client.event.emit(SIGNIN, packet.getPayloadObject.uid, - packet.getPayloadObject.accesstoken); + Client.event.emit(SIGNIN); } else { Client.event.emit(ERROR, "SignIn Failed" + packet.getCode); } diff --git a/cloud/dashboard/src/components/MainAppBar.js b/cloud/dashboard/src/components/MainAppBar.js index ede3c3e..07a7925 100644 --- a/cloud/dashboard/src/components/MainAppBar.js +++ b/cloud/dashboard/src/components/MainAppBar.js @@ -40,9 +40,9 @@ const style = { } } -const handleSignout = () => { +const handleSignout = (di, accesstoken) => { console.debug("sign out clicked"); - Client.signOut(); + Client.signOut(di, accesstoken); }; const handleDisconnect = () => { @@ -59,7 +59,7 @@ const Menu = (props) => ( anchorOrigin={{horizontal: 'right', vertical: 'bottom'}} > - {props.signin ? : null} + {props.signin ? : null} ); @@ -71,7 +71,9 @@ class MainAppBar extends React.Component { super(props, context); this.state = { - signin: props.signin + signin: props.signin, + di: props.di, + accesstoken: props.accesstoken } }; @@ -85,7 +87,7 @@ class MainAppBar extends React.Component { titleStyle={style.font} /* TODO add icon */ //iconElementLeft={ } - iconElementRight={ } + iconElementRight={ } showMenuIconButton={false} style={style.basic} /> diff --git a/cloud/dashboard/src/components/SignupButton.js b/cloud/dashboard/src/components/SignupButton.js index 7b1b497..644aa64 100644 --- a/cloud/dashboard/src/components/SignupButton.js +++ b/cloud/dashboard/src/components/SignupButton.js @@ -22,8 +22,6 @@ import React from 'react'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import RaisedButton from 'material-ui/RaisedButton'; -import SelectField from 'material-ui/SelectField'; -import MenuItem from 'material-ui/MenuItem'; import TextField from 'material-ui/TextField'; import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; @@ -80,28 +78,38 @@ class SignupButton extends React.Component { }; handleAuthcodeButtonClicked = (value) => { - this.setState({ provider : value }); - }; - - handleSelectfieldChange = (event, index, value) => { - this.setState({ provider : value }); + this.setState({ provider : value, providerError : '' }); }; handleTextChange = (event) => { + var currentProviderErr = this.state.providerError; var currentCodeErr = this.state.codeError; - this.setState({ code : event.target.value }); - if (event.target.value.length !== 0) { - currentCodeErr = ''; - } else { - currentCodeErr = errorText; + switch(event.target.id) { + case "provider": + this.setState({ provider : event.target.value }); + if (event.target.value.length !== 0) { + currentProviderErr = ''; + } else { + currentProviderErr = errorText; + } + break; + case "code": + this.setState({ code : event.target.value }); + if (event.target.value.length !== 0) { + currentCodeErr = ''; + } else { + currentCodeErr = errorText; + } + break; + default: + return; } - - this.setState({ codeError : currentCodeErr }); + this.setState({ providerError : currentProviderErr, codeError : currentCodeErr }) }; handleSubmit = () => { - if (this.state.code.length === 0) { + if (this.state.provider.length === 0 || this.state.code.length === 0) { return; } @@ -123,6 +131,7 @@ class SignupButton extends React.Component { open: false, provider: 'github', code: '', + providerError: '', codeError: errorText, dialogMessage: '', signup: false @@ -134,15 +143,14 @@ class SignupButton extends React.Component { ,
, - - - - ,
, + errorText={this.state.providerError} + errorStyle={style.error} + onChange={this.handleTextChange} + />,
, ,
, , @@ -76,7 +76,7 @@ Client.event.on(DISCONNECTED, function() { Client.event.on(SIGNIN, function() { unmountDefaultPage(); - renderDefaultPage(true); + renderDefaultPage(true, getDeviceId(), getAccesstoken()); ReactDOM.unmountComponentAtNode(document.getElementById('body')); }); @@ -86,7 +86,7 @@ Client.event.on(SIGNOUT, function() { Client.removeClientData(['accesstoken']); unmountDefaultPage(); - renderDefaultPage(false); + renderDefaultPage(false, '', ''); ReactDOM.render( , @@ -99,9 +99,9 @@ ReactDOM.render( document.getElementById('body') ); -function renderDefaultPage(signinStatue) { +function renderDefaultPage(signinStatue, di, accesstoken) { ReactDOM.render( - , + , document.getElementById('appbar') ); ReactDOM.render(