Commit 316564385fd4f2c5c8a600b1919fac18233ca197

Authored by Deepak
1 parent ce82de088e
Exists in master

Added logout button to non org and fixed some css

client/stylesheets/custom.css
1 body 1 body
2 { 2 {
3 background: -webkit-linear-gradient(#00b395, #00b395); 3 background: -webkit-linear-gradient(#00b395, #00b395);
4 background: -o-linear-gradient(#00b395, #00b395); 4 background: -o-linear-gradient(#00b395, #00b395);
5 background: linear-gradient(#00b395, #00b395); 5 background: linear-gradient(#00b395, #00b395);
6 } 6 }
7 7
8 table .dropdown span{ 8 table .dropdown span{
9 color: #000000; 9 color: #000000;
10 } 10 }
11 table .dropdown-toggle{ 11 table .dropdown-toggle{
12 cursor: pointer; 12 cursor: pointer;
13 } 13 }
14 table .dropdown .fa{ 14 table .dropdown .fa{
15 display: inline; 15 display: inline;
16 margin: 6px 6px; 16 margin: 6px 6px;
17 } 17 }
18 table .dropdown-menu { 18 table .dropdown-menu {
19 min-width: 134px; 19 min-width: 134px;
20 } 20 }
21 table .dropdown-menu > li { 21 table .dropdown-menu > li {
22 cursor: pointer; 22 cursor: pointer;
23 } 23 }
24 table .dropdown-menu > li:hover{ 24 table .dropdown-menu > li:hover{
25 text-decoration: none; 25 text-decoration: none;
26 color: #333333; 26 color: #333333;
27 background-color: #f5f5f5; 27 background-color: #f5f5f5;
28 } 28 }
29 table .dropdown-menu > li > span{ 29 table .dropdown-menu > li > span{
30 padding: 6px 16px; 30 padding: 6px 16px;
31 display: block; 31 display: block;
32 } 32 }
33 span.logout { 33 span.logout {
34 background-color: #1a222f; 34 background-color: #1a222f;
35 border-color: #ffffff; 35 border-color: #ffffff;
36 color: #fff; 36 color: #fff;
37 cursor: pointer; 37 cursor: pointer;
38 } 38 }
39 button.close span{ 39 button.close span{
40 font-size: 24px; 40 font-size: 24px;
41 color: black; 41 color: black;
42 } 42 }
43 .panel-body{ 43 .panel-body{
44 max-height: 550px; 44 max-height: 550px;
45 overflow-y: scroll; 45 overflow-y: scroll;
46 } 46 }
47 .verifyEmailBox .wizardPane-title h3, .wizardPane-title span{
48 color: #000000;
49 }
50
51 .verifyEmailBox .wizardPane-section1{
52 background-color: #ffffff;
53 }
47 54
imports/client/layouts/NonOrgApp.js
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 import { Grid } from 'react-bootstrap'; 2 import { Grid } from 'react-bootstrap';
3 import { Link } from 'react-router'; 3 import { Link } from 'react-router';
4 import { Row, Col, FormGroup, 4 import { Row, Col, FormGroup,
5 ControlLabel, FormControl, 5 ControlLabel, FormControl,
6 InputGroup, Button, 6 InputGroup, Button,
7 Navbar,Modal, Nav, NavItem, 7 Navbar,Modal, Nav, NavItem,
8 Glyphicon, Collapse, 8 Glyphicon, Collapse,
9 NavbarToggler, NavbarBrand, 9 NavbarToggler, NavbarBrand,
10 NavLink, DropdownItem, DropdownToggle, DropdownMenu, 10 NavLink, DropdownItem, DropdownToggle, DropdownMenu,
11 NavDropdown, MenuItem } from 'react-bootstrap'; 11 NavDropdown, MenuItem } from 'react-bootstrap';
12 import { LinkContainer } from 'react-router-bootstrap'; 12 import { LinkContainer } from 'react-router-bootstrap';
13 import {AppNavigation} from '/imports/client/views/nonOrg/app/module/navigation/AppNavigation.js';
13 import './NonOrgApp.css'; 14 import './NonOrgApp.css';
14 /** 15 /**
15 * user based redirection will take place here 16 * user based redirection will take place here
16 */ 17 */
17 export class NonOrgApp extends Component { 18 export class NonOrgApp extends Component {
18 constructor(props) { 19 constructor(props) {
19 super(props); 20 super(props);
20 this.state = { 21 this.state = {
21 22
22 }; 23 };
23 }; 24 };
24 render(){ 25 render(){
25 return ( 26 return (
26 <div> 27 <div>
27 <Navbar> 28 <AppNavigation/>
28 <Navbar.Header>
29 <Navbar.Brand className='brand-style'>
30 <Link to="/">YOUNGDESK</Link>
31 </Navbar.Brand>
32 <Navbar.Toggle />
33 </Navbar.Header>
34 <Navbar.Collapse>
35 <Nav pullRight>
36 <LinkContainer to="login" >
37 <NavItem className='nav-item' eventKey={ 2 } href="/login">Log in</NavItem>
38 </LinkContainer>
39 </Nav>
40 </Navbar.Collapse>
41 </Navbar>
42 <Grid> 29 <Grid>
43 { this.props.children } 30 { this.props.children }
44 </Grid> 31 </Grid>
45 </div> 32 </div>
46 ) 33 )
47 } 34 }
48 } 35 }
imports/client/views/nonOrg/app/module/navigation/AppNavigation.js
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 import { Navbar } from 'react-bootstrap'; 2 import { Navbar } from 'react-bootstrap';
3 import { Link } from 'react-router'; 3 import { Link } from 'react-router';
4 import {PublicNavigation} from './PublicNavigation.js'; 4 import AuthenticatedNavigation from './AuthenticatedNavigation.js';
5 import {AuthenticatedNavigation} from './AuthenticatedNavigation.js';
6 // import '/imports/client/assets/css/icons/icomoon/styles.css'; 5 // import '/imports/client/assets/css/icons/icomoon/styles.css';
7 // import '/imports/client/assets/css/bootstrap.css'; 6 // import '/imports/client/assets/css/bootstrap.css';
8 // import '/imports/client/assets/css/core.css'; 7 // import '/imports/client/assets/css/core.css';
9 // import '/imports/client/assets/css/components.css'; 8 // import '/imports/client/assets/css/components.css';
10 // import '/imports/client/assets/css/colors.css'; 9 // import '/imports/client/assets/css/colors.css';
11 // import '/imports/client/assets/css/colors.css'; 10 // import '/imports/client/assets/css/colors.css';
12 export class AppNavigation extends Component { 11 export class AppNavigation extends Component {
13 12
14 constructor(props) { 13 constructor(props) {
15 super(props); 14 super(props);
16 this.state = { 15 this.state = {
17 16
18 }; 17 };
19 }; 18 };
20 19
21 onUpdate(key, value) { 20 onUpdate(key, value) {
22 this.setState({[key]: value}); 21 this.setState({[key]: value});
23 }; 22 };
24 render() { 23 render() {
25 const {user} = this.props.data;
26 console.log(user);
27 if(user){
28 return(
29 <AuthenticatedNavigation
30 data = {this.props.data}
31 />
32 )
33 }else{
34 return( 24 return(
35 <Navbar> 25 <Navbar>
36 <Navbar.Header> 26 <Navbar.Header>
37 <Navbar.Brand> 27 <Navbar.Brand>
38 <Link to="/">Application Name</Link> 28 <Link to="/">YoungDesk</Link>
39 </Navbar.Brand> 29 </Navbar.Brand>
40 <Navbar.Toggle /> 30 <Navbar.Toggle />
41 </Navbar.Header> 31 </Navbar.Header>
42 <Navbar.Collapse> 32 <Navbar.Collapse>
43 <PublicNavigation /> 33 <AuthenticatedNavigation
34 />
44 </Navbar.Collapse> 35 </Navbar.Collapse>
45 </Navbar> 36 </Navbar>
46
47 ) 37 )
48 }
49
50 return (
51 <div></div>
52 );
53 }; 38 };
54 39
55 }; 40 };
imports/client/views/nonOrg/app/module/navigation/AuthenticatedNavigation.js
1 import React from 'react'; 1 import React from 'react';
2 import { browserHistory } from 'react-router'; 2 import { browserHistory } from 'react-router';
3 import { LinkContainer } from 'react-router-bootstrap'; 3 import { LinkContainer } from 'react-router-bootstrap';
4 import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; 4 import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
5 import { Meteor } from 'meteor/meteor'; 5 import { Meteor } from 'meteor/meteor';
6 6
7 const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); 7 const handleLogout = () => Meteor.logout();
8 8
9 const userName = () => { 9 const userName = () => {
10 const user = Meteor.user(); 10 const user = Meteor.user();
11 const name = user && user.profile ? user.profile.name : ''; 11 console.log("user------");
12 return user ? `${name.first} ${name.last}` : ''; 12 console.log(user);
13 return user ? `${user.firstName} ${user.lastName}` : '';
13 }; 14 };
14 15
15 const AuthenticatedNavigation = () => ( 16 const AuthenticatedNavigation = () => (
16 <div> 17 <div>
17 <Nav> 18 <Nav pullRight>
18 <LinkContainer to="/documents"> 19 <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem>
19 <NavItem eventKey={ 2 } href="/documents">Documents</NavItem>
20 </LinkContainer>
21 </Nav> 20 </Nav>
22 </div> 21 </div>
23 ); 22 );
24 23
25 export default AuthenticatedNavigation; 24 export default AuthenticatedNavigation;
imports/client/views/verify/EmailPane.js
1 import React from 'react'; 1 import React from 'react';
2 import { Link } from 'react-router'; 2 import { Link } from 'react-router';
3 import { If, Case } from '/imports/client/components/Logic'; 3 import { If, Case } from '/imports/client/components/Logic';
4 import { Bert } from 'meteor/themeteorchef:bert'; 4 import { Bert } from 'meteor/themeteorchef:bert';
5 import './emailpane.css'; 5 import './emailpane.css';
6 6
7 import { Row, Col, Alert,ControlLabel, 7 import { Row, Col, Alert,ControlLabel,
8 FormGroup, FormControl, Button } from 'react-bootstrap'; 8 FormGroup, FormControl, Button } from 'react-bootstrap';
9 9
10 10
11 export class EmailPane extends React.Component { 11 export class EmailPane extends React.Component {
12 12
13 constructor(props) { 13 constructor(props) {
14 super(props); 14 super(props);
15 15
16 this.state = { 16 this.state = {
17 email: props.user.emails[0].address, 17 email: props.user.emails[0].address,
18 form: false, 18 form: false,
19 }; 19 };
20 }; 20 };
21 21
22 onUpdate(key, val) { 22 onUpdate(key, val) {
23 this.setState({[key]: val}); 23 this.setState({[key]: val});
24 }; 24 };
25 25
26 onSetEmail() { 26 onSetEmail() {
27 startEmailVerification.call({email: this.state.email}, (err, res)=>{ 27 startEmailVerification.call({email: this.state.email}, (err, res)=>{
28 Bert.alert('New verification email sent!', 'success'); 28 Bert.alert('New verification email sent!', 'success');
29 29
30 }); 30 });
31 this.setState({form: false}); 31 this.setState({form: false});
32 }; 32 };
33 33
34 onShowForm() { 34 onShowForm() {
35 this.setState({form: true}); 35 this.setState({form: true});
36 }; 36 };
37 37
38 renderForm() { 38 renderForm() {
39 const {user} = this.props; 39 const {user} = this.props;
40 40
41 return ( 41 return (
42 <div className = "wizardPane-box1"> 42 <div className = "wizardPane-box1">
43 <div> 43 <div>
44 <i className="fa fa-envelope-o fa-3x"></i> 44 <i className="fa fa-envelope-o fa-3x"></i>
45 </div> 45 </div>
46 <div> 46 <div>
47 <Row> 47 <Row>
48 <Col md={12}> 48 <Col md={12}>
49 <FormGroup> 49 <FormGroup>
50 <ControlLabel className='subheading'>Email</ControlLabel> 50 <ControlLabel className='subheading'>Email</ControlLabel>
51 <FormControl 51 <FormControl
52 type="text" 52 type="text"
53 value = {this.state.email} 53 value = {this.state.email}
54 onChange = {(evt) => this.onUpdate('email', evt.currentTarget.value)} 54 onChange = {(evt) => this.onUpdate('email', evt.currentTarget.value)}
55 placeholder="Organisation Name" 55 placeholder="Organisation Name"
56 /> 56 />
57 </FormGroup> 57 </FormGroup>
58 </Col> 58 </Col>
59 </Row> 59 </Row>
60 </div> 60 </div>
61 <div className = "wizardPane-sectionD wizardPane-footer"> 61 <div className = "wizardPane-sectionD wizardPane-footer">
62 <Button type="submit" onClick = {() => this.onSetEmail()} className='blue'>Verify Now</Button> 62 <Button type="submit" onClick = {() => this.onSetEmail()} className='blue'>Verify Now</Button>
63 {/* <Button type="submit" onClick = {() => this.onSetEmail()} className='blue'>Sign Up</Button> */} 63 {/* <Button type="submit" onClick = {() => this.onSetEmail()} className='blue'>Sign Up</Button> */}
64 </div> 64 </div>
65 </div> 65 </div>
66 ); 66 );
67 }; 67 };
68 68
69 renderMessage() { 69 renderMessage() {
70 const {user} = this.props; 70 const {user} = this.props;
71 71
72 return ( 72 return (
73 <div className = "wizardPane-box"> 73 <div className = "wizardPane-box verifyEmailBox">
74 <div className = "wizardPane-section1"> 74 <div className = "wizardPane-section1">
75 75
76 <div className = "wizardPane-title"> 76 <div className = "wizardPane-title">
77 {/* <i className="icon-envelope icon"></i> */} 77 {/* <i className="icon-envelope icon"></i> */}
78 <h3>Hi, your email needs verification</h3> 78 <h3>Hi {user.getFullName()}, your email needs verification</h3>
79 79
80 <span>Please check your email – we sent a verification link to &nbsp; 80 <span>Please check your email – we sent a verification link to &nbsp;
81 <span className = "EmailVerify"> 81 <span className = "EmailVerify">
82 {user.emails[0].address}</span></span> 82 {user.emails[0].address}</span></span>
83 </div> 83 </div>
84 </div> 84 </div>
85 <div className = "wizardPane-sectionD wizardPane-footer"> 85 <div className = "wizardPane-sectionD wizardPane-footer">
86 <div className="btn" 86 <div className="btn"
87 className = "wizardPane-link" 87 className = "wizardPane-link"
88 onClick = {() => this.onShowForm()} 88 onClick = {() => this.onShowForm()}
89 > 89 >
90 Email did not arrive or want to use a different email? 90 Email did not arrive or want to use a different email?
91 </div> 91 </div>
92 </div> 92 </div>
93 </div> 93 </div>
94 ); 94 );
95 }; 95 };
96 96
97 render() { 97 render() {
98 return this.state.form ? this.renderForm() : this.renderMessage(); 98 return this.state.form ? this.renderForm() : this.renderMessage();
99 }; 99 };
100 100
101 }; 101 };
102 102
imports/client/views/verify/module/VerifyLayout.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 3
4 import React, { Component } from 'react'; 4 import React, { Component } from 'react';
5 import { Link } from 'react-router'; 5 import { Link } from 'react-router';
6 import { If, Case } from '/imports/client/components/Logic'; 6 import { If, Case } from '/imports/client/components/Logic';
7 import { Avatar } from '/imports/client/components/Avatar'; 7 import { Avatar } from '/imports/client/components/Avatar';
8 8
9 import { logout } from '/imports/client/app/utils/loginMethods'; 9 import { logout } from '/imports/client/app/utils/loginMethods';
10 10
11 import { EmailPane } from '/imports/client/views/verify/EmailPane'; 11 import { EmailPane } from '/imports/client/views/verify/EmailPane';
12 import ReactSVG from 'react-svg' 12 import ReactSVG from 'react-svg'
13 13
14 14
15 export class VerifyLayout extends Component { 15 export class VerifyLayout extends Component {
16 16
17 render() { 17 render() {
18 const user = this.props.data.user; 18 const user = this.props.data.user;
19 19
20 return ( 20 return (
21 <div className = "wizardLayout-box"> 21 <div className = "wizardLayout-box">
22 <div className = "wizardLayout-top">
23 <div className="container">
24 <div className = "wizardLayout-topSpace logo-space-0">
25 <ReactSVG
26 path="/files/images/svg/logo--white.svg"
27 className="enterPane__logo"
28 />
29 </div>
30 <div className = "wizardLayout-topGroup">
31 <div className = "wizardLayout-topItem">
32 <Avatar
33 user = {user}
34 size = {20}
35 small = {true}
36 />
37 &nbsp;
38 {user.getFullName()}
39 </div>
40 <div
41 className = "wizardLayout-topItem"
42 onClick = {() => logout()}
43 >
44 <i className="icon icon-simple icon-power"></i>
45 </div>
46 </div>
47 </div>
48 </div>
49
50 <div className = "wizardLayout-wrap"> 22 <div className = "wizardLayout-wrap">
51 <div className = "wizardLayout-content"> 23 <div className = "wizardLayout-content">
52 24
53 <EmailPane 25 <EmailPane
54 user = {user} 26 user = {user}
55 /> 27 />
56 28
57 </div> 29 </div>
58 </div> 30 </div>
59 </div> 31 </div>
60 ); 32 );
61 }; 33 };
62
63 };
64
65 34
35 };
imports/server/accounts/creation.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Accounts } from 'meteor/accounts-base'; 2 import { Accounts } from 'meteor/accounts-base';
3 import { SimpleSchema } from 'meteor/aldeed:simple-schema'; 3 import { SimpleSchema } from 'meteor/aldeed:simple-schema';
4 import { ValidatedMethod } from 'meteor/mdg:validated-method'; 4 import { ValidatedMethod } from 'meteor/mdg:validated-method';
5 5
6 import { Orgs } from '/imports/collections/orgs/index'; 6 import { Orgs } from '/imports/collections/orgs/index';
7 import { Users } from '/imports/collections/users/index'; 7 import { Users } from '/imports/collections/users/index';
8 8
9 9
10 Accounts.validateNewUser((user) => { 10 Accounts.validateNewUser((user) => {
11 return !!user; 11 return !!user;
12 }); 12 });
13 13
14 Accounts.onCreateUser((options, user) => { 14 Accounts.onCreateUser((options, user) => {
15 15
16 if(options.orgSlug){ 16 if(options.orgSlug){
17 orgId = Orgs.insert({ 17 orgId = Orgs.insert({
18 slug: options.orgSlug, 18 slug: options.orgSlug.replace(" ", "-").toLowerCase(),
19 name: options.orgName, 19 name: options.orgName,
20 setup: 1, 20 setup: 1,
21 users: [{ 21 users: [{
22 userId: user._id, 22 userId: user._id,
23 role: Users.roles.ADMIN, 23 role: Users.roles.ADMIN,
24 }], 24 }],
25 }); 25 });
26 } 26 }
27 console.log("options"); 27
28 console.log(options); 28 _.assign(user, {
29 console.log("user");
30 console.log(user);
31 _.assign(user, {
32 role: Users.roles.ADMIN, 29 role: Users.roles.ADMIN,
33 orgId: orgId, 30 orgId: orgId,
34 firstName: options.profile.name.first, 31 firstName: options.profile.name.first,
35 lastName: options.profile.name.last, 32 lastName: options.profile.name.last,
36 }); 33 });
37 console.log(user);
38 return user; 34 return user;
39 }); 35 });
40 36
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 import { Orgs } from '/imports/collections/orgs/index'; 3 import { Orgs } from '/imports/collections/orgs/index';
4 4
5 Accounts.config({ 5 Accounts.config({
6 sendVerificationEmail: true 6 sendVerificationEmail: true
7 }); 7 });
8 8
9 Accounts.emailTemplates.verifyEmail = { 9 Accounts.emailTemplates.verifyEmail = {
10 subject() { 10 subject() {
11 return '[YoungDesk] Verify Your Email Address'; 11 return '[YoungDesk] Verify Your Email Address';
12 }, 12 },
13 text(user, url) { 13 text(user, url) {
14 const theUrl = Meteor.absoluteUrl(`back/verifyEmail/${_.last(url.split('/'))}`); 14 const theUrl = Meteor.absoluteUrl(`back/verifyEmail/${_.last(url.split('/'))}`);
15 org = Orgs.findOne({"_id":user.orgId}); 15 org = Orgs.findOne({"_id":user.orgId});
16 16
17 OrgUrl = theUrl.replace("http://","http://"+org.slug+"."); 17 OrgUrl = encodeURI(theUrl.replace("http://","http://"+org.slug+"."));
18 return ( 18 return (
19 ` 19 `
20 Hello, ${user.firstName}! 20 Hello, ${user.firstName}!
21 21
22 22
23 To verify your email address, visit the following link: 23 To verify your email address, visit the following link:
24 24
25 ${OrgUrl} 25 ${OrgUrl}
26 26
27 If you did not request this verification, please ignore this email. 27 If you did not request this verification, please ignore this email.
28 28
29 ` 29 `
30 ); 30 );
31 }, 31 },
32 }; 32 };
33 33