From cc8fd8a946eb91032517986ddad90f0fe1bfd521 Mon Sep 17 00:00:00 2001 From: Deepak Date: Sat, 11 Mar 2017 10:38:20 +0530 Subject: [PATCH] Moved all files to respective folder and app is working without any errors --- imports/client/components/validation.js | 4 + imports/client/layouts/InvalidOrgApp.js | 18 ++++ imports/client/layouts/NonOrgApp.js | 18 ++++ imports/client/layouts/OrgApp.js | 18 ++++ imports/client/views/app/module/Index.js | 15 +++ .../views/app/module/navigation/AppNavigation.js | 27 +++++ .../module/navigation/AuthenticatedNavigation.js | 30 ++++++ .../client/views/app/module/navigation/Loading.js | 30 ++++++ .../app/module/navigation/PublicNavigation.js | 16 +++ .../client/views/app/module/navigation/index.js | 7 ++ imports/client/views/invalidOrg/NotFound.js | 12 +++ imports/client/views/nonOrg/NotFound.js | 12 +++ imports/client/views/nonOrg/enter/SignupView.js | 116 +++++++++++++++++++++ imports/client/views/nonOrg/enter/signup.js | 97 +++++++++++++++++ imports/client/views/org/NotFound.js | 12 +++ imports/client/views/org/enter/Login.js | 54 ++++++++++ imports/client/views/org/enter/RecoverPassword.js | 43 ++++++++ imports/client/views/org/enter/ResetPassword.js | 58 +++++++++++ imports/client/views/org/enter/module/login.js | 57 ++++++++++ .../views/org/enter/module/recover-password.js | 42 ++++++++ .../views/org/enter/module/reset-password.js | 54 ++++++++++ imports/collections/orgs/methods.js | 3 +- imports/modules/login.js | 57 ---------- imports/modules/recover-password.js | 42 -------- imports/modules/reset-password.js | 54 ---------- imports/modules/signup.js | 97 ----------------- imports/modules/validation.js | 4 - imports/startup/client/routes.js | 47 +++++---- imports/ui/components/AppNavigation.js | 27 ----- imports/ui/components/AuthenticatedNavigation.js | 30 ------ imports/ui/components/DocumentEditor.js | 46 -------- imports/ui/components/DocumentsList.js | 24 ----- imports/ui/components/Loading.js | 30 ------ imports/ui/components/PublicNavigation.js | 16 --- imports/ui/containers/AppNavigation.js | 7 -- imports/ui/containers/DocumentsList.js | 15 --- imports/ui/containers/EditDocument.js | 16 --- imports/ui/containers/ViewDocument.js | 16 --- imports/ui/layouts/App.js | 18 ---- imports/ui/pages/Index.js | 15 --- imports/ui/pages/NotFound.js | 12 --- imports/ui/pages/Signup.js | 116 --------------------- 42 files changed, 766 insertions(+), 666 deletions(-) create mode 100644 imports/client/components/validation.js create mode 100644 imports/client/layouts/InvalidOrgApp.js create mode 100644 imports/client/layouts/NonOrgApp.js create mode 100644 imports/client/layouts/OrgApp.js create mode 100644 imports/client/views/app/module/Index.js create mode 100644 imports/client/views/app/module/navigation/AppNavigation.js create mode 100644 imports/client/views/app/module/navigation/AuthenticatedNavigation.js create mode 100644 imports/client/views/app/module/navigation/Loading.js create mode 100644 imports/client/views/app/module/navigation/PublicNavigation.js create mode 100644 imports/client/views/app/module/navigation/index.js create mode 100644 imports/client/views/invalidOrg/NotFound.js create mode 100644 imports/client/views/nonOrg/NotFound.js create mode 100644 imports/client/views/nonOrg/enter/SignupView.js create mode 100644 imports/client/views/nonOrg/enter/signup.js create mode 100644 imports/client/views/org/NotFound.js create mode 100644 imports/client/views/org/enter/Login.js create mode 100644 imports/client/views/org/enter/RecoverPassword.js create mode 100644 imports/client/views/org/enter/ResetPassword.js create mode 100644 imports/client/views/org/enter/module/login.js create mode 100644 imports/client/views/org/enter/module/recover-password.js create mode 100644 imports/client/views/org/enter/module/reset-password.js delete mode 100644 imports/modules/login.js delete mode 100644 imports/modules/recover-password.js delete mode 100644 imports/modules/reset-password.js delete mode 100644 imports/modules/signup.js delete mode 100644 imports/modules/validation.js delete mode 100644 imports/ui/components/AppNavigation.js delete mode 100644 imports/ui/components/AuthenticatedNavigation.js delete mode 100644 imports/ui/components/DocumentEditor.js delete mode 100644 imports/ui/components/DocumentsList.js delete mode 100644 imports/ui/components/Loading.js delete mode 100644 imports/ui/components/PublicNavigation.js delete mode 100644 imports/ui/containers/AppNavigation.js delete mode 100644 imports/ui/containers/DocumentsList.js delete mode 100644 imports/ui/containers/EditDocument.js delete mode 100644 imports/ui/containers/ViewDocument.js delete mode 100644 imports/ui/layouts/App.js delete mode 100644 imports/ui/pages/Index.js delete mode 100644 imports/ui/pages/NotFound.js delete mode 100644 imports/ui/pages/Signup.js diff --git a/imports/client/components/validation.js b/imports/client/components/validation.js new file mode 100644 index 0000000..4902821 --- /dev/null +++ b/imports/client/components/validation.js @@ -0,0 +1,4 @@ +/* eslint-disable no-unused-vars */ + +import $ from 'jquery'; +import 'jquery-validation'; diff --git a/imports/client/layouts/InvalidOrgApp.js b/imports/client/layouts/InvalidOrgApp.js new file mode 100644 index 0000000..1a8c89c --- /dev/null +++ b/imports/client/layouts/InvalidOrgApp.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { Grid } from 'react-bootstrap'; +import AppNavigation from '../containers/AppNavigation.js'; + +const App = ({ children }) => ( +
+ + + { children } + +
+); + +App.propTypes = { + children: React.PropTypes.node, +}; + +export default App; diff --git a/imports/client/layouts/NonOrgApp.js b/imports/client/layouts/NonOrgApp.js new file mode 100644 index 0000000..1a8c89c --- /dev/null +++ b/imports/client/layouts/NonOrgApp.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { Grid } from 'react-bootstrap'; +import AppNavigation from '../containers/AppNavigation.js'; + +const App = ({ children }) => ( +
+ + + { children } + +
+); + +App.propTypes = { + children: React.PropTypes.node, +}; + +export default App; diff --git a/imports/client/layouts/OrgApp.js b/imports/client/layouts/OrgApp.js new file mode 100644 index 0000000..bdbff38 --- /dev/null +++ b/imports/client/layouts/OrgApp.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { Grid } from 'react-bootstrap'; +import AppNavigation from '/imports/client/views/app/module/navigation/AppNavigation'; + +const App = ({ children }) => ( +
+ + + { children } + +
+); + +App.propTypes = { + children: React.PropTypes.node, +}; + +export default App; diff --git a/imports/client/views/app/module/Index.js b/imports/client/views/app/module/Index.js new file mode 100644 index 0000000..5da010c --- /dev/null +++ b/imports/client/views/app/module/Index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { Jumbotron } from 'react-bootstrap'; + +const Index = () => ( +
+ +

Base

+

A starting point for Meteor applications.

+

Read the Documentation

+

Currently at v4.11.1

+
+
+); + +export default Index; diff --git a/imports/client/views/app/module/navigation/AppNavigation.js b/imports/client/views/app/module/navigation/AppNavigation.js new file mode 100644 index 0000000..319c936 --- /dev/null +++ b/imports/client/views/app/module/navigation/AppNavigation.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Navbar } from 'react-bootstrap'; +import { Link } from 'react-router'; +import PublicNavigation from './PublicNavigation.js'; +import AuthenticatedNavigation from './AuthenticatedNavigation.js'; + +const renderNavigation = hasUser => (hasUser ? : ); + +const AppNavigation = ({ hasUser }) => ( + + + + Application Name + + + + + { renderNavigation(hasUser) } + + +); + +AppNavigation.propTypes = { + hasUser: React.PropTypes.object, +}; + +export default AppNavigation; diff --git a/imports/client/views/app/module/navigation/AuthenticatedNavigation.js b/imports/client/views/app/module/navigation/AuthenticatedNavigation.js new file mode 100644 index 0000000..87a0c38 --- /dev/null +++ b/imports/client/views/app/module/navigation/AuthenticatedNavigation.js @@ -0,0 +1,30 @@ +import React from 'react'; +import { browserHistory } from 'react-router'; +import { LinkContainer } from 'react-router-bootstrap'; +import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; +import { Meteor } from 'meteor/meteor'; + +const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); + +const userName = () => { + const user = Meteor.user(); + const name = user && user.profile ? user.profile.name : ''; + return user ? `${name.first} ${name.last}` : ''; +}; + +const AuthenticatedNavigation = () => ( +
+ + +
+); + +export default AuthenticatedNavigation; diff --git a/imports/client/views/app/module/navigation/Loading.js b/imports/client/views/app/module/navigation/Loading.js new file mode 100644 index 0000000..c97a7eb --- /dev/null +++ b/imports/client/views/app/module/navigation/Loading.js @@ -0,0 +1,30 @@ +import React from 'react'; + +const Loading = () => ( + + + + + +); + +export default Loading; diff --git a/imports/client/views/app/module/navigation/PublicNavigation.js b/imports/client/views/app/module/navigation/PublicNavigation.js new file mode 100644 index 0000000..d04fc80 --- /dev/null +++ b/imports/client/views/app/module/navigation/PublicNavigation.js @@ -0,0 +1,16 @@ +import React from 'react'; +import { LinkContainer } from 'react-router-bootstrap'; +import { Nav, NavItem } from 'react-bootstrap'; + +const PublicNavigation = () => ( + +); + +export default PublicNavigation; diff --git a/imports/client/views/app/module/navigation/index.js b/imports/client/views/app/module/navigation/index.js new file mode 100644 index 0000000..65f743d --- /dev/null +++ b/imports/client/views/app/module/navigation/index.js @@ -0,0 +1,7 @@ +import { composeWithTracker } from 'react-komposer'; +import { Meteor } from 'meteor/meteor'; +import AppNavigation from '../components/AppNavigation.js'; + +const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); + +export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); diff --git a/imports/client/views/invalidOrg/NotFound.js b/imports/client/views/invalidOrg/NotFound.js new file mode 100644 index 0000000..260a2fb --- /dev/null +++ b/imports/client/views/invalidOrg/NotFound.js @@ -0,0 +1,12 @@ +import React from 'react'; +import { Alert } from 'react-bootstrap'; + +const NotFound = () => ( +
+ +

Error [404]: { window.location.pathname } does not exist.

+
+
+); + +export default NotFound; diff --git a/imports/client/views/nonOrg/NotFound.js b/imports/client/views/nonOrg/NotFound.js new file mode 100644 index 0000000..260a2fb --- /dev/null +++ b/imports/client/views/nonOrg/NotFound.js @@ -0,0 +1,12 @@ +import React from 'react'; +import { Alert } from 'react-bootstrap'; + +const NotFound = () => ( +
+ +

Error [404]: { window.location.pathname } does not exist.

+
+
+); + +export default NotFound; diff --git a/imports/client/views/nonOrg/enter/SignupView.js b/imports/client/views/nonOrg/enter/SignupView.js new file mode 100644 index 0000000..bec41b1 --- /dev/null +++ b/imports/client/views/nonOrg/enter/SignupView.js @@ -0,0 +1,116 @@ +import React from 'react'; +import { Link } from 'react-router'; +import { Row, Col, FormGroup, + ControlLabel, FormControl, + InputGroup, Button } from 'react-bootstrap'; +import handleSignup from './signup'; +import { Orgs } from '/imports/collections/orgs/index'; + +export default class Signup extends React.Component { + constructor(props) { + super(props); + this.state = { + orgSlug: "" + }; + } + componentWillMount(){ + Meteor.subscribe('allOrgsSlug'); + } + + componentDidMount() { + handleSignup({ component: this }); + } + handleChange(e) { + this.setState({ orgSlug: e.target.value }); + } + handleSubmit(event) { + event.preventDefault(); + } + checkExistingOrgSlug() { + console.log(this.state.orgSlug); + if(this.state.orgSlug==""){return null} + searchOrg = Orgs.find({slug:this.state.orgSlug}).fetch(); + if(searchOrg.length>0){ + return "error" + }else{ + return "success" + } + } + render() { + return ( +
+ + +

Sign Up

+
(this.signupForm = form) } + onSubmit={ this.handleSubmit } + > + + + + Organisation name + + this.handleChange(e)} + /> + @yd.com + + + + + + + + First Name + + + + + + Last Name + + + + + + Email Address + + + + Password + + + +
+

Already have an account? Log In.

+ +
+
+ ); + } +} diff --git a/imports/client/views/nonOrg/enter/signup.js b/imports/client/views/nonOrg/enter/signup.js new file mode 100644 index 0000000..de9c35c --- /dev/null +++ b/imports/client/views/nonOrg/enter/signup.js @@ -0,0 +1,97 @@ +/* eslint-disable no-undef */ + +import { browserHistory } from 'react-router'; +import { Accounts } from 'meteor/accounts-base'; +import { Bert } from 'meteor/themeteorchef:bert'; +import { Loading } from '/imports/client/components/Loading'; +import '/imports/client/components/validation'; +import { Orgs } from '/imports/collections/orgs/index'; + +let component; + +const getUserData = () => ({ + email: document.querySelector('[name="emailAddress"]').value, + password: document.querySelector('[name="password"]').value, + profile: { + name: { + first: document.querySelector('[name="firstName"]').value, + last: document.querySelector('[name="lastName"]').value, + }, + }, +}); + +const signup = () => { + const user = getUserData(); + + Accounts.createUser(user, (error) => { + if (error) { + Bert.alert(error.reason, 'danger'); + } else { + browserHistory.push('/'); + Bert.alert('Welcome!', 'success'); + } + }); +}; +$.validator.addMethod( + "uniqueSlug", + function(value, element) { + slug = Orgs.find({slug:value}).fetch(); + console.log(slug); + if(slug.length>0){ + return false; + }else{ + return true + } + }, + "Name is Already Taken" +); +const validate = () => { + $(component.signupForm).validate({ + rules: { + orgSlug: { + required: true, + uniqueSlug: true + }, + firstName: { + required: true, + }, + lastName: { + required: true, + }, + emailAddress: { + required: true, + email: true, + }, + password: { + required: true, + minlength: 6, + }, + }, + messages: { + orgSlug: { + required: 'Choose your school url', + uniqueSlug: 'This has already been taken!' + }, + firstName: { + required: 'First name?', + }, + lastName: { + required: 'Last name?', + }, + emailAddress: { + required: 'Need an email address here.', + email: 'Is this email address legit?', + }, + password: { + required: 'Need a password here.', + minlength: 'Use at least six characters, please.', + }, + }, + submitHandler() { signup(); }, + }); +}; + +export default function handleSignup(options) { + component = options.component; + validate(); +} diff --git a/imports/client/views/org/NotFound.js b/imports/client/views/org/NotFound.js new file mode 100644 index 0000000..260a2fb --- /dev/null +++ b/imports/client/views/org/NotFound.js @@ -0,0 +1,12 @@ +import React from 'react'; +import { Alert } from 'react-bootstrap'; + +const NotFound = () => ( +
+ +

Error [404]: { window.location.pathname } does not exist.

+
+
+); + +export default NotFound; diff --git a/imports/client/views/org/enter/Login.js b/imports/client/views/org/enter/Login.js new file mode 100644 index 0000000..c6e5cb7 --- /dev/null +++ b/imports/client/views/org/enter/Login.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { Link } from 'react-router'; +import { Row, Col, FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; +import handleLogin from './module/login'; + +export default class Login extends React.Component { + componentDidMount() { + handleLogin({ component: this }); + } + + handleSubmit(event) { + event.preventDefault(); + } + + render() { + return ( +
+ + +

Login

+
(this.loginForm = form) } + className="login" + onSubmit={ this.handleSubmit } + > + + Email Address + + + + + Password + Forgot Password? + + + + +
+ +
+
+ ); + } +} diff --git a/imports/client/views/org/enter/RecoverPassword.js b/imports/client/views/org/enter/RecoverPassword.js new file mode 100644 index 0000000..ba4adc5 --- /dev/null +++ b/imports/client/views/org/enter/RecoverPassword.js @@ -0,0 +1,43 @@ +import React from 'react'; +import { Row, Col, Alert, FormGroup, FormControl, Button } from 'react-bootstrap'; +import handleRecoverPassword from './module/recover-password'; + +export default class RecoverPassword extends React.Component { + componentDidMount() { + handleRecoverPassword({ component: this }); + } + + handleSubmit(event) { + event.preventDefault(); + } + + render() { + return ( +
+ + +

Recover Password

+ + Enter your email address below to receive a link to reset your password. + +
(this.recoverPasswordForm = form) } + className="recover-password" + onSubmit={ this.handleSubmit } + > + + + + +
+ +
+
+ ); + } +} diff --git a/imports/client/views/org/enter/ResetPassword.js b/imports/client/views/org/enter/ResetPassword.js new file mode 100644 index 0000000..c4893aa --- /dev/null +++ b/imports/client/views/org/enter/ResetPassword.js @@ -0,0 +1,58 @@ +import React from 'react'; +import { Row, Col, Alert, FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; +import handleResetPassword from './module/reset-password'; + +export default class ResetPassword extends React.Component { + componentDidMount() { + handleResetPassword({ component: this, token: this.props.params.token }); + } + + handleSubmit(event) { + event.preventDefault(); + } + + render() { + return ( +
+ + +

Reset Password

+ + To reset your password, enter a new one below. You will be logged in + with your new password. + +
(this.resetPasswordForm = form) } + className="reset-password" + onSubmit={ this.handleSubmit } + > + + New Password + + + + Repeat New Password + + + +
+ +
+
+ ); + } +} + +ResetPassword.propTypes = { + params: React.PropTypes.object, +}; diff --git a/imports/client/views/org/enter/module/login.js b/imports/client/views/org/enter/module/login.js new file mode 100644 index 0000000..a83a0d3 --- /dev/null +++ b/imports/client/views/org/enter/module/login.js @@ -0,0 +1,57 @@ +/* eslint-disable no-undef */ + +import { browserHistory } from 'react-router'; +import { Meteor } from 'meteor/meteor'; +import { Bert } from 'meteor/themeteorchef:bert'; +import '/imports/client/components/validation'; + +let component; + +const login = () => { + const email = document.querySelector('[name="emailAddress"]').value; + const password = document.querySelector('[name="password"]').value; + + Meteor.loginWithPassword(email, password, (error) => { + if (error) { + Bert.alert(error.reason, 'warning'); + } else { + Bert.alert('Logged in!', 'success'); + + const { location } = component.props; + if (location.state && location.state.nextPathname) { + browserHistory.push(location.state.nextPathname); + } else { + browserHistory.push('/'); + } + } + }); +}; + +const validate = () => { + $(component.loginForm).validate({ + rules: { + emailAddress: { + required: true, + email: true, + }, + password: { + required: true, + }, + }, + messages: { + emailAddress: { + required: 'Need an email address here.', + email: 'Is this email address legit?', + }, + password: { + required: 'Need a password here.', + }, + }, + submitHandler() { login(); }, + }); +}; + +export default function handleLogin(options) { + component = options.component; + validate(); +} diff --git a/imports/client/views/org/enter/module/recover-password.js b/imports/client/views/org/enter/module/recover-password.js new file mode 100644 index 0000000..60aa93a --- /dev/null +++ b/imports/client/views/org/enter/module/recover-password.js @@ -0,0 +1,42 @@ +/* eslint-disable no-undef */ + +import { Accounts } from 'meteor/accounts-base'; +import { Bert } from 'meteor/themeteorchef:bert'; +import '/imports/client/components/validation'; + +let component; + +const handleRecovery = () => { + Accounts.forgotPassword({ + email: document.querySelector('[name="emailAddress"]').value, + }, (error) => { + if (error) { + Bert.alert(error.reason, 'warning'); + } else { + Bert.alert('Check your inbox for a reset link!', 'success'); + } + }); +}; + +const validate = () => { + $(component.recoverPasswordForm).validate({ + rules: { + emailAddress: { + required: true, + email: true, + }, + }, + messages: { + emailAddress: { + required: 'Need an email address here.', + email: 'Is this email address legit?', + }, + }, + submitHandler() { handleRecovery(); }, + }); +}; + +export default function handleRecoverPassword(options) { + component = options.component; + validate(); +} diff --git a/imports/client/views/org/enter/module/reset-password.js b/imports/client/views/org/enter/module/reset-password.js new file mode 100644 index 0000000..614a18e --- /dev/null +++ b/imports/client/views/org/enter/module/reset-password.js @@ -0,0 +1,54 @@ +/* eslint-disable no-undef */ + +import { browserHistory } from 'react-router'; +import { Accounts } from 'meteor/accounts-base'; +import { Bert } from 'meteor/themeteorchef:bert'; +import '/imports/client/components/validation'; + +let component; +let token; + +const handleReset = () => { + const password = document.querySelector('[name="newPassword"]').value; + Accounts.resetPassword(token, password, (error) => { + if (error) { + Bert.alert(error.reason, 'danger'); + } else { + browserHistory.push('/'); + Bert.alert('Password reset!', 'success'); + } + }); +}; + +const validate = () => { + $(component.resetPasswordForm).validate({ + rules: { + newPassword: { + required: true, + minlength: 6, + }, + repeatNewPassword: { + required: true, + minlength: 6, + equalTo: '[name="newPassword"]', + }, + }, + messages: { + newPassword: { + required: 'Enter a new password, please.', + minlength: 'Use at least six characters, please.', + }, + repeatNewPassword: { + required: 'Repeat your new password, please.', + equalTo: 'Hmm, your passwords don\'t match. Try again?', + }, + }, + submitHandler() { handleReset(); }, + }); +}; + +export default function handleResetPassword(options) { + component = options.component; + token = options.token; + validate(); +} diff --git a/imports/collections/orgs/methods.js b/imports/collections/orgs/methods.js index ce69eb5..7238325 100644 --- a/imports/collections/orgs/methods.js +++ b/imports/collections/orgs/methods.js @@ -28,8 +28,7 @@ export const checkExistingOrg = new ValidatedMethod({ }).validator(), run({slug}) { - org = Orgs.find({slug:slug}).fetch(); - console.log(org); + org = Orgs.findOne({slug:slug}); return org; }, diff --git a/imports/modules/login.js b/imports/modules/login.js deleted file mode 100644 index 6447a77..0000000 --- a/imports/modules/login.js +++ /dev/null @@ -1,57 +0,0 @@ -/* eslint-disable no-undef */ - -import { browserHistory } from 'react-router'; -import { Meteor } from 'meteor/meteor'; -import { Bert } from 'meteor/themeteorchef:bert'; -import './validation.js'; - -let component; - -const login = () => { - const email = document.querySelector('[name="emailAddress"]').value; - const password = document.querySelector('[name="password"]').value; - - Meteor.loginWithPassword(email, password, (error) => { - if (error) { - Bert.alert(error.reason, 'warning'); - } else { - Bert.alert('Logged in!', 'success'); - - const { location } = component.props; - if (location.state && location.state.nextPathname) { - browserHistory.push(location.state.nextPathname); - } else { - browserHistory.push('/'); - } - } - }); -}; - -const validate = () => { - $(component.loginForm).validate({ - rules: { - emailAddress: { - required: true, - email: true, - }, - password: { - required: true, - }, - }, - messages: { - emailAddress: { - required: 'Need an email address here.', - email: 'Is this email address legit?', - }, - password: { - required: 'Need a password here.', - }, - }, - submitHandler() { login(); }, - }); -}; - -export default function handleLogin(options) { - component = options.component; - validate(); -} diff --git a/imports/modules/recover-password.js b/imports/modules/recover-password.js deleted file mode 100644 index 24c0e04..0000000 --- a/imports/modules/recover-password.js +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-disable no-undef */ - -import { Accounts } from 'meteor/accounts-base'; -import { Bert } from 'meteor/themeteorchef:bert'; -import './validation.js'; - -let component; - -const handleRecovery = () => { - Accounts.forgotPassword({ - email: document.querySelector('[name="emailAddress"]').value, - }, (error) => { - if (error) { - Bert.alert(error.reason, 'warning'); - } else { - Bert.alert('Check your inbox for a reset link!', 'success'); - } - }); -}; - -const validate = () => { - $(component.recoverPasswordForm).validate({ - rules: { - emailAddress: { - required: true, - email: true, - }, - }, - messages: { - emailAddress: { - required: 'Need an email address here.', - email: 'Is this email address legit?', - }, - }, - submitHandler() { handleRecovery(); }, - }); -}; - -export default function handleRecoverPassword(options) { - component = options.component; - validate(); -} diff --git a/imports/modules/reset-password.js b/imports/modules/reset-password.js deleted file mode 100644 index 11b1aaa..0000000 --- a/imports/modules/reset-password.js +++ /dev/null @@ -1,54 +0,0 @@ -/* eslint-disable no-undef */ - -import { browserHistory } from 'react-router'; -import { Accounts } from 'meteor/accounts-base'; -import { Bert } from 'meteor/themeteorchef:bert'; -import './validation.js'; - -let component; -let token; - -const handleReset = () => { - const password = document.querySelector('[name="newPassword"]').value; - Accounts.resetPassword(token, password, (error) => { - if (error) { - Bert.alert(error.reason, 'danger'); - } else { - browserHistory.push('/'); - Bert.alert('Password reset!', 'success'); - } - }); -}; - -const validate = () => { - $(component.resetPasswordForm).validate({ - rules: { - newPassword: { - required: true, - minlength: 6, - }, - repeatNewPassword: { - required: true, - minlength: 6, - equalTo: '[name="newPassword"]', - }, - }, - messages: { - newPassword: { - required: 'Enter a new password, please.', - minlength: 'Use at least six characters, please.', - }, - repeatNewPassword: { - required: 'Repeat your new password, please.', - equalTo: 'Hmm, your passwords don\'t match. Try again?', - }, - }, - submitHandler() { handleReset(); }, - }); -}; - -export default function handleResetPassword(options) { - component = options.component; - token = options.token; - validate(); -} diff --git a/imports/modules/signup.js b/imports/modules/signup.js deleted file mode 100644 index 4376a4e..0000000 --- a/imports/modules/signup.js +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable no-undef */ - -import { browserHistory } from 'react-router'; -import { Accounts } from 'meteor/accounts-base'; -import { Bert } from 'meteor/themeteorchef:bert'; -import { Loading } from '/imports/client/components/Loading'; -import './validation.js'; -import { Orgs } from '/imports/collections/orgs/index'; - -let component; - -const getUserData = () => ({ - email: document.querySelector('[name="emailAddress"]').value, - password: document.querySelector('[name="password"]').value, - profile: { - name: { - first: document.querySelector('[name="firstName"]').value, - last: document.querySelector('[name="lastName"]').value, - }, - }, -}); - -const signup = () => { - const user = getUserData(); - - Accounts.createUser(user, (error) => { - if (error) { - Bert.alert(error.reason, 'danger'); - } else { - browserHistory.push('/'); - Bert.alert('Welcome!', 'success'); - } - }); -}; -$.validator.addMethod( - "uniqueSlug", - function(value, element) { - slug = Orgs.find({slug:value}).fetch(); - console.log(slug); - if(slug.length>0){ - return false; - }else{ - return true - } - }, - "Name is Already Taken" -); -const validate = () => { - $(component.signupForm).validate({ - rules: { - orgSlug: { - required: true, - uniqueSlug: true - }, - firstName: { - required: true, - }, - lastName: { - required: true, - }, - emailAddress: { - required: true, - email: true, - }, - password: { - required: true, - minlength: 6, - }, - }, - messages: { - orgSlug: { - required: 'Choose your school url', - uniqueSlug: 'This has already been taken!' - }, - firstName: { - required: 'First name?', - }, - lastName: { - required: 'Last name?', - }, - emailAddress: { - required: 'Need an email address here.', - email: 'Is this email address legit?', - }, - password: { - required: 'Need a password here.', - minlength: 'Use at least six characters, please.', - }, - }, - submitHandler() { signup(); }, - }); -}; - -export default function handleSignup(options) { - component = options.component; - validate(); -} diff --git a/imports/modules/validation.js b/imports/modules/validation.js deleted file mode 100644 index 4902821..0000000 --- a/imports/modules/validation.js +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-unused-vars */ - -import $ from 'jquery'; -import 'jquery-validation'; diff --git a/imports/startup/client/routes.js b/imports/startup/client/routes.js index 7b1042e..36d266e 100644 --- a/imports/startup/client/routes.js +++ b/imports/startup/client/routes.js @@ -4,17 +4,13 @@ import React from 'react'; import { render } from 'react-dom'; import { Router, Route, IndexRoute, browserHistory } from 'react-router'; import { Meteor } from 'meteor/meteor'; -import App from '../../ui/layouts/App.js'; -import Documents from '../../ui/pages/Documents.js'; -import NewDocument from '../../ui/pages/NewDocument.js'; -import EditDocument from '../../ui/containers/EditDocument.js'; -import ViewDocument from '../../ui/containers/ViewDocument.js'; -import Index from '../../ui/pages/Index.js'; -import Login from '../../ui/pages/Login.js'; -import NotFound from '../../ui/pages/NotFound.js'; -import RecoverPassword from '../../ui/pages/RecoverPassword.js'; -import ResetPassword from '../../ui/pages/ResetPassword.js'; -import Signup from '../../ui/pages/Signup.js'; +import App from '/imports/client/layouts/OrgApp'; +import Index from '/imports/client/views/app/module/Index'; +import Login from '/imports/client/views/org/enter/Login'; +import NotFound from '/imports/client/views/org/NotFound'; +import RecoverPassword from '/imports/client/views/org/enter/RecoverPassword'; +import ResetPassword from '/imports/client/views/org/enter/ResetPassword'; +import Signup from '/imports/client/views/nonOrg/enter/SignupView'; import { Orgs } from '/imports/collections/orgs/index'; @@ -26,6 +22,8 @@ const authenticate = (nextState, replace) => { }); } }; + + const detectOrg = (nextState, replace) => { orgSlug = ""; var hostnameArray = document.location.hostname.split( "." ); @@ -34,10 +32,9 @@ const detectOrg = (nextState, replace) => { } if(orgSlug!=""){ Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { - if(res.length>0){ - console.log(res); - console.log(res[0]._id._str); - Session.set('orgId', res[0]._id._str); + console.log(res); + if(res){ + Session.set('orgId', res._id._str); render(getOrgRoutes(),document.getElementById('react-root')); }else{ render(getInvalidOrgRoute(),document.getElementById('react-root')); @@ -49,9 +46,14 @@ const detectOrg = (nextState, replace) => { } const checkSlug = (nextState, replace) => { orgId = Session.get('orgId'); - console.log("orgId"); - console.log(orgId); } + +/** +There are three types of routes +1)getOrgRoutes: all the routes that should be present for a registered org +2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) +3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal +**/ const getOrgRoutes = () => ( @@ -63,20 +65,21 @@ const getOrgRoutes = () => ( ) -const getNonOrgRoutes = () => ( + +const getInvalidOrgRoute = () => ( - - + ) -const getInvalidOrgRoute = () => ( +const getNonOrgRoutes = () => ( - + + diff --git a/imports/ui/components/AppNavigation.js b/imports/ui/components/AppNavigation.js deleted file mode 100644 index 319c936..0000000 --- a/imports/ui/components/AppNavigation.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { Navbar } from 'react-bootstrap'; -import { Link } from 'react-router'; -import PublicNavigation from './PublicNavigation.js'; -import AuthenticatedNavigation from './AuthenticatedNavigation.js'; - -const renderNavigation = hasUser => (hasUser ? : ); - -const AppNavigation = ({ hasUser }) => ( - - - - Application Name - - - - - { renderNavigation(hasUser) } - - -); - -AppNavigation.propTypes = { - hasUser: React.PropTypes.object, -}; - -export default AppNavigation; diff --git a/imports/ui/components/AuthenticatedNavigation.js b/imports/ui/components/AuthenticatedNavigation.js deleted file mode 100644 index 87a0c38..0000000 --- a/imports/ui/components/AuthenticatedNavigation.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { browserHistory } from 'react-router'; -import { LinkContainer } from 'react-router-bootstrap'; -import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; -import { Meteor } from 'meteor/meteor'; - -const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); - -const userName = () => { - const user = Meteor.user(); - const name = user && user.profile ? user.profile.name : ''; - return user ? `${name.first} ${name.last}` : ''; -}; - -const AuthenticatedNavigation = () => ( -
- - -
-); - -export default AuthenticatedNavigation; diff --git a/imports/ui/components/DocumentEditor.js b/imports/ui/components/DocumentEditor.js deleted file mode 100644 index 94f0ac6..0000000 --- a/imports/ui/components/DocumentEditor.js +++ /dev/null @@ -1,46 +0,0 @@ -/* eslint-disable max-len, no-return-assign */ - -import React from 'react'; -import { FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; -import documentEditor from '../../modules/document-editor.js'; - -export default class DocumentEditor extends React.Component { - componentDidMount() { - documentEditor({ component: this }); - setTimeout(() => { document.querySelector('[name="title"]').focus(); }, 0); - } - - render() { - const { doc } = this.props; - return (
(this.documentEditorForm = form) } - onSubmit={ event => event.preventDefault() } - > - - Title - - - - Body - - - -
); - } -} - -DocumentEditor.propTypes = { - doc: React.PropTypes.object, -}; diff --git a/imports/ui/components/DocumentsList.js b/imports/ui/components/DocumentsList.js deleted file mode 100644 index 2c36e26..0000000 --- a/imports/ui/components/DocumentsList.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import { browserHistory } from 'react-router'; -import { ListGroup, ListGroupItem, Alert } from 'react-bootstrap'; - -const handleNav = (_id) => { - browserHistory.push(`/documents/${_id}`); -} - -const DocumentsList = ({ documents }) => ( - documents.length > 0 ? - {documents.map(({ _id, title }) => ( - handleNav(_id) }> - { title } - - ))} - : - No documents yet. -); - -DocumentsList.propTypes = { - documents: React.PropTypes.array, -}; - -export default DocumentsList; diff --git a/imports/ui/components/Loading.js b/imports/ui/components/Loading.js deleted file mode 100644 index c97a7eb..0000000 --- a/imports/ui/components/Loading.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; - -const Loading = () => ( - - - - - -); - -export default Loading; diff --git a/imports/ui/components/PublicNavigation.js b/imports/ui/components/PublicNavigation.js deleted file mode 100644 index d04fc80..0000000 --- a/imports/ui/components/PublicNavigation.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { LinkContainer } from 'react-router-bootstrap'; -import { Nav, NavItem } from 'react-bootstrap'; - -const PublicNavigation = () => ( - -); - -export default PublicNavigation; diff --git a/imports/ui/containers/AppNavigation.js b/imports/ui/containers/AppNavigation.js deleted file mode 100644 index 65f743d..0000000 --- a/imports/ui/containers/AppNavigation.js +++ /dev/null @@ -1,7 +0,0 @@ -import { composeWithTracker } from 'react-komposer'; -import { Meteor } from 'meteor/meteor'; -import AppNavigation from '../components/AppNavigation.js'; - -const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); - -export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); diff --git a/imports/ui/containers/DocumentsList.js b/imports/ui/containers/DocumentsList.js deleted file mode 100644 index 248d63e..0000000 --- a/imports/ui/containers/DocumentsList.js +++ /dev/null @@ -1,15 +0,0 @@ -import { composeWithTracker } from 'react-komposer'; -import { Meteor } from 'meteor/meteor'; -import Documents from '../../api/documents/documents.js'; -import DocumentsList from '../components/DocumentsList.js'; -import Loading from '../components/Loading.js'; - -const composer = (params, onData) => { - const subscription = Meteor.subscribe('documents.list'); - if (subscription.ready()) { - const documents = Documents.find().fetch(); - onData(null, { documents }); - } -}; - -export default composeWithTracker(composer, Loading)(DocumentsList); diff --git a/imports/ui/containers/EditDocument.js b/imports/ui/containers/EditDocument.js deleted file mode 100644 index 2174053..0000000 --- a/imports/ui/containers/EditDocument.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import { composeWithTracker } from 'react-komposer'; -import Documents from '../../api/documents/documents.js'; -import EditDocument from '../pages/EditDocument.js'; -import Loading from '../components/Loading.js'; - -const composer = ({ params }, onData) => { - const subscription = Meteor.subscribe('documents.view', params._id); - - if (subscription.ready()) { - const doc = Documents.findOne(); - onData(null, { doc }); - } -}; - -export default composeWithTracker(composer, Loading)(EditDocument); diff --git a/imports/ui/containers/ViewDocument.js b/imports/ui/containers/ViewDocument.js deleted file mode 100644 index 28626d8..0000000 --- a/imports/ui/containers/ViewDocument.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import { composeWithTracker } from 'react-komposer'; -import Documents from '../../api/documents/documents.js'; -import ViewDocument from '../pages/ViewDocument.js'; -import Loading from '../components/Loading.js'; - -const composer = ({ params }, onData) => { - const subscription = Meteor.subscribe('documents.view', params._id); - - if (subscription.ready()) { - const doc = Documents.findOne(); - onData(null, { doc }); - } -}; - -export default composeWithTracker(composer, Loading)(ViewDocument); diff --git a/imports/ui/layouts/App.js b/imports/ui/layouts/App.js deleted file mode 100644 index 1a8c89c..0000000 --- a/imports/ui/layouts/App.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Grid } from 'react-bootstrap'; -import AppNavigation from '../containers/AppNavigation.js'; - -const App = ({ children }) => ( -
- - - { children } - -
-); - -App.propTypes = { - children: React.PropTypes.node, -}; - -export default App; diff --git a/imports/ui/pages/Index.js b/imports/ui/pages/Index.js deleted file mode 100644 index 5da010c..0000000 --- a/imports/ui/pages/Index.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { Jumbotron } from 'react-bootstrap'; - -const Index = () => ( -
- -

Base

-

A starting point for Meteor applications.

-

Read the Documentation

-

Currently at v4.11.1

-
-
-); - -export default Index; diff --git a/imports/ui/pages/NotFound.js b/imports/ui/pages/NotFound.js deleted file mode 100644 index 260a2fb..0000000 --- a/imports/ui/pages/NotFound.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { Alert } from 'react-bootstrap'; - -const NotFound = () => ( -
- -

Error [404]: { window.location.pathname } does not exist.

-
-
-); - -export default NotFound; diff --git a/imports/ui/pages/Signup.js b/imports/ui/pages/Signup.js deleted file mode 100644 index bf67559..0000000 --- a/imports/ui/pages/Signup.js +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react'; -import { Link } from 'react-router'; -import { Row, Col, FormGroup, - ControlLabel, FormControl, - InputGroup, Button } from 'react-bootstrap'; -import handleSignup from '../../modules/signup'; -import { Orgs } from '/imports/collections/orgs/index'; - -export default class Signup extends React.Component { - constructor(props) { - super(props); - this.state = { - orgSlug: "" - }; - } - componentWillMount(){ - Meteor.subscribe('allOrgsSlug'); - } - - componentDidMount() { - handleSignup({ component: this }); - } - handleChange(e) { - this.setState({ orgSlug: e.target.value }); - } - handleSubmit(event) { - event.preventDefault(); - } - checkExistingOrgSlug() { - console.log(this.state.orgSlug); - if(this.state.orgSlug==""){return null} - searchOrg = Orgs.find({slug:this.state.orgSlug}).fetch(); - if(searchOrg.length>0){ - return "error" - }else{ - return "success" - } - } - render() { - return ( -
- - -

Sign Up

-
(this.signupForm = form) } - onSubmit={ this.handleSubmit } - > - - - - Organisation name - - this.handleChange(e)} - /> - @yd.com - - - - - - - - First Name - - - - - - Last Name - - - - - - Email Address - - - - Password - - - -
-

Already have an account? Log In.

- -
-
- ); - } -} -- 2.0.0