diff --git a/public/components/authenticate.js b/public/components/authenticate.js new file mode 100644 index 0000000..623e494 --- /dev/null +++ b/public/components/authenticate.js @@ -0,0 +1,68 @@ +'use strict'; +var React = require('react'); +var ReactBootstrap = require('react-bootstrap'); +var $ = require('jquery'); + +var Authenticate = React.createClass({ + logout: function () { + this.props.refreshAuth(null, null); + window.location.href = "/"; + }, + refreshToken: function (event) { + event.preventDefault(); + var self = this; + $.ajax({ + url: '/refresh_token', + data: { + 'refresh_token': self.props.auth.refresh_token + }, + success: function (data) { + self.props.refreshAuth(data.access_token, self.props.auth.refresh_token); + }, + error: function (xhr, status, err) { + console.error(status, err); + } + }); + }, + render: function () { + var auth; + var Nav = ReactBootstrap.Nav, + NavItem = ReactBootstrap.NavItem, + Navbar = ReactBootstrap.Navbar; + + if (this.props.auth.access_token == null) { + auth = ( + + ); + } + else { + auth = ( + + ); + } + + return ( + + + + Duplicate Finder + + + + + + {auth} + + + ); + } +}); + +module.exports = Authenticate; diff --git a/public/components/duplicate-finder-box.js b/public/components/duplicate-finder-box.js index c7d8677..7daa80d 100644 --- a/public/components/duplicate-finder-box.js +++ b/public/components/duplicate-finder-box.js @@ -1,6 +1,7 @@ 'use strict'; var React = require('react'); var ReactBootstrap = require('react-bootstrap'); +var $ = require('jquery'); var DuplicatesBox = require('./duplicates-box'); var PlaylistBox = require('./playlist-box'); diff --git a/public/script.jsx b/public/script.jsx index 2ca4c32..e8282c4 100644 --- a/public/script.jsx +++ b/public/script.jsx @@ -22,67 +22,7 @@ function getHashParams() { var DuplicateFinderBox = require('./components/duplicate-finder-box'); -var Authenticate = React.createClass({ - logout: function () { - this.props.refreshAuth(null, null); - window.location.href = "/"; - }, - refreshToken: function (event) { - event.preventDefault(); - var self = this; - $.ajax({ - url: '/refresh_token', - data: { - 'refresh_token': self.props.auth.refresh_token - }, - success: function (data) { - self.props.refreshAuth(data.access_token, self.props.auth.refresh_token); - }, - error: function (xhr, status, err) { - console.error(status, err); - } - }); - }, - render: function () { - var auth; - var Nav = ReactBootstrap.Nav, - NavItem = ReactBootstrap.NavItem, - Navbar = ReactBootstrap.Navbar; - - if (this.props.auth.access_token == null) { - auth = ( - - ); - } - else { - auth = ( - - ); - } - - return ( - - - - Duplicate Finder - - - - - - {auth} - - - ); - } -}); +var Authenticate = require('./components/authenticate'); var App = React.createClass({ getInitialState: function () {