Commit 8c4a3096b2db2d98a5b1bf612fe644ca432e0c33

Authored by Deepak
1 parent 217abcceeb
Exists in master

added settings and run file

imports/client/app/routes.js
1 /* eslint-disable max-len */ 1 /* eslint-disable max-len */
2 2
3 import React from 'react'; 3 import React from 'react';
4 import { render } from 'react-dom'; 4 import { render } from 'react-dom';
5 import { Router, Route, 5 import { Router, Route,
6 IndexRoute, browserHistory } from 'react-router'; 6 IndexRoute, browserHistory } from 'react-router';
7 import { Meteor } from 'meteor/meteor'; 7 import { Meteor } from 'meteor/meteor';
8 8
9 /** 9 /**
10 * General Components 10 * General Components
11 */ 11 */
12 import Index from '/imports/client/views/app/module/Index'; 12 import Index from '/imports/client/views/app/module/Index';
13 import NotFound from '/imports/client/views/org/NotFound';
13 14
14 /** 15 /**
15 * Org Components 16 * Org Components
16 */ 17 */
17 18
18 import { App } from '/imports/client/layouts/OrgApp'; 19 import { App } from '/imports/client/layouts/OrgApp';
19 import { AppModule } from '/imports/client/views/org/app/module/Index'; 20 import { AppModule } from '/imports/client/views/org/app/module/Index';
20 import { Orgs } from '/imports/collections/orgs/index'; 21 import { Orgs } from '/imports/collections/orgs/index';
21 import { importCsvController } from '/imports/client/views/org/importCsv/index' 22 import { importCsvController } from '/imports/client/views/org/importCsv/index'
22 23
23 //admin 24 //admin
24 import { StudentDataController } from '/imports/client/views/org/admin/students/index' 25 import { StudentDataController } from '/imports/client/views/org/admin/students/index'
26 //students
27
28 //teachers
29
30 //parents
25 31
26 32
27 import NotFound from '/imports/client/views/org/NotFound';
28 33
29 /** 34 /**
30 * NonOrg Components 35 * NonOrg Components
31 */ 36 */
32 import Signup from '/imports/client/views/nonOrg/enter/SignupView'; 37 import Signup from '/imports/client/views/nonOrg/enter/SignupView';
38 import { NonOrgApp } from '/imports/client/layouts/NonOrgApp';
33 39
34 /** 40 /**
35 * Invalid Org Components 41 * Invalid Org Components
36 */ 42 */
37 43
38 const authenticate = (nextState, replace) => {
39 if (!Meteor.loggingIn() && !Meteor.userId()) {
40 replace({
41 pathname: '/login',
42 state: { nextPathname: nextState.location.pathname },
43 });
44 }
45 };
46
47
48 const detectOrg = () => {
49 orgSlug = "";
50 var hostnameArray = document.location.hostname.split( "." );
51 if(hostnameArray[1]=='localhost'){
52 orgSlug = hostnameArray[0];
53 }
54 if(orgSlug!=""){
55 Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) {
56 if(res){
57 Session.set('orgId', res._id);
58 Session.set('orgSlug', orgSlug);
59 render(getOrgRoutes(),document.getElementById('app'));
60 }else{
61 render(getInvalidOrgRoute(),document.getElementById('app'));
62 }
63 });
64 }else{
65 render(getNonOrgRoutes(),document.getElementById('app'));
66 }
67 }
68 const checkSlug = (nextState, replace) => {
69 orgId = Session.get('orgId');
70 }
71
72 /** 44 /**
73 There are three types of routes 45 There are three types of routes
74 1)getOrgRoutes: all the routes that should be present for a registered org 46 1)getOrgRoutes: all the routes that should be present for a registered org
75 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) 47 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D)
76 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal 48 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal
77 **/ 49 **/
78 const getOrgRoutes = () => ( 50 const getOrgRoutes = () => (
79 <Router history={ browserHistory }> 51 <Router history={ browserHistory }>
80 <Route path="/" component={ App }> 52 <Route path="/" component={ App }>
81 <IndexRoute name="index" component={ AppModule } /> 53 <IndexRoute name="index" component={ AppModule } />
82 <Route name="import" path="/import" component={ importCsvController } /> 54 <Route name="import" path="/import" component={ importCsvController } />
83 <Route name="student" path="/students" component={ StudentDataController } /> 55 <Route name="student" path="/students" component={ StudentDataController } />
84 <Route path="*" component={ NotFound } /> 56 <Route path="*" component={ NotFound } />
85 </Route> 57 </Route>
86 </Router> 58 </Router>
87 ) 59 )
88 60
89 61
90 const getInvalidOrgRoute = () => ( 62 const getInvalidOrgRoute = () => (
91 <Router history={ browserHistory }> 63 <Router history={ browserHistory }>
92 <Route path="/" component={ App }> 64 <Route path="/" component={ App }>
93 <IndexRoute name="index" component={ NotFound } /> 65 <IndexRoute name="index" component={ NotFound } />
94 <Route path="*" component={ NotFound } /> 66 <Route path="*" component={ NotFound } />
95 </Route> 67 </Route>
96 </Router> 68 </Router>
97 ) 69 )
98 70
99 const getNonOrgRoutes = () => ( 71 const getNonOrgRoutes = () => (
100 <Router history={ browserHistory }> 72 <Router history={ browserHistory }>
101 <Route path="/" component={ App }> 73 <Route path="/" component={ NonOrgApp }>
102 <IndexRoute name="index" component={ Index } /> 74 <IndexRoute name="index" component={ Index } />
103 <Route name="signup" path="/signup" component={ Signup } /> 75 <Route name="signup" path="/signup" component={ Signup } />
104 <Route path="*" component={ NotFound } /> 76 <Route path="*" component={ NotFound } />
105 </Route> 77 </Route>
106 </Router> 78 </Router>
107 ) 79 )
108 80
81 //Authenticate function to give access to users only
82 const authenticate = (nextState, replace) => {
83 if (!Meteor.loggingIn() && !Meteor.userId()) {
84 replace({
85 pathname: '/login',
86 state: { nextPathname: nextState.location.pathname },
87 });
88 }
imports/client/layouts/NonOrgApp.js
1 import React from 'react'; 1 import React, { Component } from 'react';
2 import { Grid } from 'react-bootstrap'; 2 import { Grid } from 'react-bootstrap';
3 import AppNavigation from '../containers/AppNavigation.js'; 3 import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index';
4 /**
5 * user based redirection will take place here
6 */
7 export class App extends Component {
8 constructor(props) {
9 super(props);
10 this.state = {
4 11
5 const App = ({ children }) => ( 12 };
6 <div> 13 };
7 <AppNavigation /> 14 render(){
8 <Grid> 15 return (
9 { children } 16 <div>
10 </Grid> 17 <AppNavigationController />
11 </div> 18 <Grid>
12 ); 19 { this.props.children }
13 20 </Grid>
14 App.propTypes = { 21 </div>
15 children: React.PropTypes.node, 22 )
16 }; 23 }
17 24 }
18 export default App;
imports/client/views/nonOrg/app/module/Index.js
File was created 1 import React from 'react';
2 import { Jumbotron } from 'react-bootstrap';
3
4 const Index = () => (
5 <div className="Index">
6 <Jumbotron className="text-center">
7 <h2>Base</h2>
8 <p>A starting point for Meteor applications.</p>
9 <p><a className="btn btn-success" href="https://themeteorchef.com/base" role="button">Read the Documentation</a></p>
10 <p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.11.1</p>
11 </Jumbotron>
12 </div>
13 );
14
15 export default Index;
16
imports/client/views/nonOrg/app/module/navigation/AppNavigation.js
File was created 1 import React from 'react';
2 import { Navbar } from 'react-bootstrap';
3 import { Link } from 'react-router';
4 import PublicNavigation from './PublicNavigation.js';
5 import AuthenticatedNavigation from './AuthenticatedNavigation.js';
6
7 const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />);
8
9 const AppNavigation = ({ hasUser }) => (
10 <Navbar>
11 <Navbar.Header>
12 <Navbar.Brand>
13 <Link to="/">Application Name</Link>
14 </Navbar.Brand>
15 <Navbar.Toggle />
16 </Navbar.Header>
17 <Navbar.Collapse>
18 { renderNavigation(hasUser) }
19 </Navbar.Collapse>
20 </Navbar>
21 );
22
23 AppNavigation.propTypes = {
24 hasUser: React.PropTypes.object,
25 };
26
27 export default AppNavigation;
28
imports/client/views/nonOrg/app/module/navigation/AuthenticatedNavigation.js
File was created 1 import React from 'react';
2 import { browserHistory } from 'react-router';
3 import { LinkContainer } from 'react-router-bootstrap';
4 import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
5 import { Meteor } from 'meteor/meteor';
6
7 const handleLogout = () => Meteor.logout(() => browserHistory.push('/login'));
8
9 const userName = () => {
10 const user = Meteor.user();
11 const name = user && user.profile ? user.profile.name : '';
12 return user ? `${name.first} ${name.last}` : '';
13 };
14
15 const AuthenticatedNavigation = () => (
16 <div>
17 <Nav>
18 <LinkContainer to="/documents">
19 <NavItem eventKey={ 2 } href="/documents">Documents</NavItem>
20 </LinkContainer>
21 </Nav>
22 <Nav pullRight>
23 <NavDropdown eventKey={ 3 } title={ userName() } id="basic-nav-dropdown">
24 <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem>
25 </NavDropdown>
26 </Nav>
27 </div>
28 );
29
30 export default AuthenticatedNavigation;
31
imports/client/views/nonOrg/app/module/navigation/Loading.js
File was created 1 import React from 'react';
2
3 const Loading = () => (
4 <svg
5 version="1.1"
6 className="Loading"
7 xmlns="http://www.w3.org/2000/svg"
8 x="0px"
9 y="0px"
10 width="40px"
11 height="40px"
12 viewBox="0 0 40 40"
13 enableBackground="new 0 0 40 40">
14 <path
15 opacity="1.0"
16 fill="#eee"
17 d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,
18 14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,
19 5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,
20 5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,
21 26.541,26.626,31.749,20.201,31.749z"/>
22 <path
23 fill="#da5347"
24 d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
25 C22.32,8.481,24.301,9.057,26.013,10.047z">
26 </path>
27 </svg>
28 );
29
30 export default Loading;
31
imports/client/views/nonOrg/app/module/navigation/PublicNavigation.js
File was created 1 import React from 'react';
2 import { LinkContainer } from 'react-router-bootstrap';
3 import { Nav, NavItem } from 'react-bootstrap';
4
5 const PublicNavigation = () => (
6 <Nav pullRight>
7 <LinkContainer to="signup">
8 <NavItem eventKey={ 1 } href="/signup">Sign Up</NavItem>
9 </LinkContainer>
10 <LinkContainer to="login">
11 <NavItem eventKey={ 2 } href="/login">Log In</NavItem>
12 </LinkContainer>
13 </Nav>
14 );
15
16 export default PublicNavigation;
17
imports/client/views/nonOrg/app/module/navigation/index.js
File was created 1 import { composeWithTracker } from 'react-komposer';
2 import { Meteor } from 'meteor/meteor';
3 import AppNavigation from '../components/AppNavigation.js';
4
5 const composer = (props, onData) => onData(null, { hasUser: Meteor.user() });
6
7 export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation);
8
imports/server/emails/verifyEmail.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Accounts } from 'meteor/accounts-base'; 2 import { Accounts } from 'meteor/accounts-base';
3 3
4 Accounts.config({ 4 Accounts.config({
5 sendVerificationEmail: true 5 sendVerificationEmail: true
6 }); 6 });
7 7
8 Accounts.emailTemplates.verifyEmail = { 8 Accounts.emailTemplates.verifyEmail = {
9 subject() { 9 subject() {
10 return '[YoungDesk] Verify Your Email Address'; 10 return '[YoungDesk] Verify Your Email Address';
11 }, 11 },
12 text(user, url) { 12 text(user, url) {
13 console.log(user); 13 console.log(user);
14 if(user.firstName){ 14 if(user.firstName){
15 const name = user.firstName; 15 const name = user.firstName;
16 }else{ 16 }else{
17 const name = user.profile.firstName; 17 const name = user.profile.firstName;
18 } 18 }
19 const name = user.firstName;
20 const theUrl = Meteor.absoluteUrl(`back/verifyEmail/${_.last(url.split('/'))}`); 19 const theUrl = Meteor.absoluteUrl(`back/verifyEmail/${_.last(url.split('/'))}`);
21 20
22 return ( 21 return (
23 ` 22 `
24 Hello, ${name}! 23 Hello, ${name}!
25 24
26 25
27 To verify your email address, visit the following link: 26 To verify your email address, visit the following link:
28 27
29 ${theUrl} 28 ${theUrl}
30 29
31 If you did not request this verification, please ignore this email. 30 If you did not request this verification, please ignore this email.
32 31
33 ` 32 `
34 ); 33 );
35 }, 34 },
36 }; 35 };
37 36