UNPKG

header-ui

Version:
193 lines (172 loc) 9.66 kB
import React from 'react'; import { Card, CardHeader, CardContent } from '@material-ui/core'; class CloudUser extends React.Component { constructor() { super() this.state = { } } copyToClipboard(element) { const range = document.createRange(); const selection = window.getSelection(); // Clear selection from any previous data. selection.removeAllRanges(); // Make the range select the entire content of the contentHolder paragraph. range.selectNodeContents(document.querySelector(element)); // Add that range to the selection. selection.addRange(range); // Copy the selection to clipboard. document.execCommand('copy'); // Clear selection if you want to. selection.removeAllRanges(); } handleExpandChange = (expanded) => { this.setState({ expanded: expanded }); }; handleToggle = (event, toggle) => { this.setState({ expanded: toggle }); }; handleExpand = () => { this.setState({ expanded: true }); }; handleReduce = () => { this.setState({ expanded: false }); }; render() { let TABLE = "User"; let columnsData = ["createdAt", "expires", "username"] return ( <div> <div className="method"> <a id="CloudUser-constructor" name="CloudObject-constructor" className="section-anchor" /> <Card style={{marginBottom:16}}> <CardHeader title="Instantiate a CloudUser" style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}} /> <CardContent> {/*overlay={<CardHeader title="Overlay title" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Overlay subtitle" />} >*/} <div className="method-example" id="api-summary-example"> <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_initiateUser")}> </span> <pre id="pre_initiateUser"> <span className="code-red">{`var`}</span>{` obj = `}<span className="code-red">{`new`}</span>{` CB.CloudUser();`} </pre> </div>{/* method-example */} </CardContent> <CardHeader title="Constructor : CloudUser()" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Instantiates a CloudUser object." /> <CardContent> <div className="method-description"> <div className="method-list"> <h6>Argument</h6> <p>It takes no argument.</p> <h6>Returns</h6> <p>void</p> </div> </div> </CardContent> </Card> <a id="CloudUser-signup" name="CloudObject-set" className="section-anchor" /> <Card style={{marginBottom:16}}> <CardHeader title="Sign Up a new User" style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}} /> <CardContent> {/*overlay={<CardHeader title="Overlay title" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Overlay subtitle" />} >*/} <div className="method-example" id="api-summary-example"> <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_signUp")}> </span> <pre id="pre_signUp"> { `//create a new user. `}<span className="code-red">{`var`}</span>{` user = `}<span className="code-red">{`new`}</span>{` CB.CloudUser(`}<span className="code-yellow">{`"${TABLE}"`}</span>{`); user.set(`}<span className="code-yellow">{`"${columnsData[0].name}", "${columnsData[0].value}"`}</span>{`); user.set(`}<span className="code-yellow">{`"${columnsData[1].name}", "${columnsData[1].value}"`}</span>{`); user.set(`}<span className="code-yellow">{`"${columnsData[2].name}", "${columnsData[2].value}"`}</span>{`); user.signUp({ success:`}<span className="code-red">{`function`}</span>{`(user) { //Registration successfull }, error: `}<span className="code-red">{`function`}</span>{`(err) { //Error in user registration. } });` } </pre> </div>{/* method-example */} </CardContent> <CardHeader title="CloudUser.signUp( [callback] )" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Registers new user given its username, email and password. " /> <CardContent> <div className="method-description"> <div className="method-list"> <h6>Arguments</h6> <dl className="argument-list"> <dt>callback</dt> <dd className>Object <span>[optional] if provided must have success and error functions to handle respective response.</span></dd> <div className="clearfix" /> </dl> <h6>Returns</h6> <p>It returns a CloudUser object which has the user information if registration is successful otherwise an error object along with JQuery promise (if callback is not provided).</p> </div> </div> </CardContent> </Card> <a id="CloudUser-login" name="CloudObject-get" className="section-anchor" /> <Card style={{marginBottom:16}}> <CardHeader title="Login a User" style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}} /> <CardContent> {/*overlay={<CardHeader title="Overlay title" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Overlay subtitle" />} >*/} <div className="method-example" id="api-summary-example"> <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_login")}> </span> <pre id="pre_login"> { `//login a user. `}<span className="code-red">{`var`}</span>{` user = `}<span className="code-red">{`new`}</span>{` CB.CloudUser(`}<span className="code-yellow">{`"${TABLE}"`}</span>{`); user.set(`}<span className="code-yellow">{`"${columnsData[0].name}", "${columnsData[0].value}"`}</span>{`); user.set(`}<span className="code-yellow">{`"${columnsData[1].name}", "${columnsData[1].value}"`}</span>{`); user.logIn({ success:`}<span className="code-red">{`function`}</span>{`(user) { //Registration successfull }, error: `}<span className="code-red">{`function`}</span>{`(err) { //Error in user registration. } });` } </pre> </div>{/* method-example */} </CardContent> <CardHeader title="CloudUser.logIn( [callback] )" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Logins user given its username and password." /> <CardContent> <div className="method-description"> <div className="method-list"> <h6>Argument</h6> <dl className="argument-list"> <dt>callback</dt> <dd className>Object<span>[optional] if provided must have success and error functions to handle respective response.</span></dd> <div className="clearfix" /> </dl> <h6>Returns</h6> <p>It returns a CloudUser object which has the user information if registration is successful otherwise an error object along with JQuery promise (if callback is not provided).</p> </div> </div> </CardContent> </Card> </div> </div> ); } } export default CloudUser;