| author | ymh <ymh.work@gmail.com> |
| Tue, 01 Aug 2017 12:20:14 +0200 | |
| changeset 132 | 906a6c7c7943 |
| parent 130 | 78246db1cbac |
| child 134 | be36eed5e6e0 |
| permissions | -rw-r--r-- |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
1 |
import PropTypes from 'prop-types'; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
2 |
import React, { Component } from 'react'; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
3 |
import { connect } from 'react-redux'; |
|
105
0a1d6560acac
Introduce authenticated routes.
Alexandre Segura <mex.zktk@gmail.com>
parents:
104
diff
changeset
|
4 |
import { withRouter } from 'react-router'; |
| 52 | 5 |
import { bindActionCreators } from 'redux'; |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
6 |
// import logo from './logo.svg'; |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
7 |
import { Navbar, Nav, NavItem, NavDropdown, MenuItem, Modal, Button } from 'react-bootstrap'; |
| 52 | 8 |
import * as authActions from '../actions/authActions'; |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
9 |
import { forceSync } from '../actions/networkActions'; |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
10 |
import { ActionEnum } from '../constants'; |
|
130
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
11 |
import './Navbar.css'; |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
12 |
|
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
13 |
const LoginNav = ({isAuthenticated, currentUser, history, authActions, onLogout}) => { |
|
65
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
14 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
15 |
const onClickSettings = (e) => { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
16 |
e.preventDefault(); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
17 |
history.push('/settings'); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
18 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
19 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
20 |
const onClickLogin = (e) => { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
21 |
e.preventDefault(); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
22 |
history.push('/login'); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
23 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
24 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
25 |
if (isAuthenticated) { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
26 |
return ( |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
27 |
<NavDropdown title={ currentUser.get('username') } id="user-dropdown"> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
28 |
<MenuItem onClick={onClickSettings}>Settings</MenuItem> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
29 |
<MenuItem onClick={onLogout}>Logout</MenuItem> |
|
65
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
30 |
</NavDropdown> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
31 |
); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
32 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
33 |
return ( |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
34 |
<NavItem onClick={onClickLogin} href="/login">Login</NavItem> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
35 |
); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
36 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
37 |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
38 |
const Online = ({ online }) => { |
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
39 |
return ( |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
40 |
<NavItem> |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
41 |
<span className="material-icons" style={{ color: online ? '#2ECC71' : '#E74C3C' }}>signal_wifi_4_bar</span> |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
42 |
</NavItem> |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
43 |
) |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
44 |
} |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
45 |
|
|
130
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
46 |
const SyncButton = ({ onSyncClick, isSynchronizing, isSynchronized, id }) => { |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
47 |
const classnames = "material-icons" |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
48 |
+ ((!isSynchronized)?" sync-button-not-synchronized":"") |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
49 |
+ ((isSynchronizing)?" sync-button-synchronizing":""); |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
50 |
let title = "Synchronize"; |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
51 |
let clickCb = onSyncClick; |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
52 |
if(isSynchronizing) { |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
53 |
title = "Synchronizing..."; |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
54 |
clickCb = () => {}; |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
55 |
} else if (!isSynchronized) { |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
56 |
title += ": not synchronized"; |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
57 |
} |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
58 |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
59 |
return ( |
|
130
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
60 |
<NavItem title={title} onClick={clickCb} id={id || null}> |
|
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
61 |
<span className={classnames}></span> |
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
62 |
</NavItem> |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
63 |
) |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
64 |
} |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
65 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
66 |
class AppNavbar extends Component { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
67 |
|
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
68 |
state = { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
69 |
showModal: false |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
70 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
71 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
72 |
closeModal = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
73 |
this.setState({ showModal: false }); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
74 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
75 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
76 |
onClickHome = (e) => { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
77 |
e.preventDefault(); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
78 |
this.props.history.push('/'); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
79 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
80 |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
81 |
isSynchronized = () => { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
82 |
return this.props.isSynchronized; |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
83 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
84 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
85 |
onClickLogout = (e) => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
86 |
e.preventDefault(); |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
87 |
const isSynchronized = this.isSynchronized(); |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
88 |
if (isSynchronized) { |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
89 |
this.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
90 |
} else { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
91 |
this.setState({ showModal: true }) |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
92 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
93 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
94 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
95 |
confirmLogout = () => { |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
96 |
const isSynchronized = this.isSynchronized(); |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
97 |
if (!isSynchronized) { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
98 |
this.props.authActions.resetAll(); |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
99 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
100 |
this.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
101 |
this.closeModal(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
102 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
103 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
104 |
logout = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
105 |
this.props.authActions.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
106 |
this.props.history.push('/'); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
107 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
108 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
109 |
onClickSessions = (e) => { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
110 |
e.preventDefault(); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
111 |
this.props.history.push('/sessions'); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
112 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
113 |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
114 |
onSyncClick = (e) => { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
115 |
e.preventDefault(); |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
116 |
this.props.networkActions.forceSync(); |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
117 |
} |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
118 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
119 |
render() { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
120 |
return ( |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
121 |
<Navbar fluid inverse fixedTop> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
122 |
<Navbar.Header> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
123 |
<Navbar.Brand> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
124 |
<a onClick={this.onClickHome} href="/">IRI Notes</a> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
125 |
</Navbar.Brand> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
126 |
<Navbar.Toggle /> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
127 |
</Navbar.Header> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
128 |
<Navbar.Collapse> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
129 |
<Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
130 |
<NavItem onClick={this.onClickSessions} href="/sessions">Sessions</NavItem> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
131 |
</Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
132 |
<Nav pullRight> |
|
130
78246db1cbac
make synchronization recurent, improve synchronization status display
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
133 |
<SyncButton id='sync-button' onSyncClick={this.onSyncClick} isSynchronizing={this.props.isSynchronizing} isSynchronized={this.props.isSynchronized} /> |
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
134 |
<Online {...this.props} /> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
135 |
<LoginNav {...this.props} onLogout={this.onClickLogout} /> |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
136 |
</Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
137 |
</Navbar.Collapse> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
138 |
<Modal show={this.state.showModal} onHide={this.closeModal}> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
139 |
<Modal.Body> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
140 |
<p className="text-center"> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
141 |
Some data is not synchronized with server. |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
142 |
<br /> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
143 |
If you continue, it will be lost. |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
144 |
</p> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
145 |
</Modal.Body> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
146 |
<Modal.Footer> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
147 |
<Button bsStyle="primary" onClick={this.confirmLogout}>Confirm</Button> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
148 |
<Button onClick={this.closeModal}>Close</Button> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
149 |
</Modal.Footer> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
150 |
</Modal> |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
151 |
</Navbar> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
152 |
); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
153 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
154 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
155 |
|
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
156 |
AppNavbar.propTypes = { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
157 |
isAuthenticated: PropTypes.bool.isRequired |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
158 |
}; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
159 |
|
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
160 |
function mapStateToProps(state, props) { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
161 |
return { |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
162 |
isAuthenticated: state.getIn(['authStatus', 'isAuthenticated']), |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
163 |
currentUser: state.getIn(['authStatus', 'currentUser']), |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
164 |
online: state.getIn(['status', 'online']), |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
165 |
isSynchronizing: state.getIn(['status', 'isSynchronizing']), |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
166 |
isSynchronized: state.get('notes').every((n) => n.get('action')===ActionEnum.NONE) && |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
167 |
state.get('sessions').every((n) => n.get('action')===ActionEnum.NONE) |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
168 |
}; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
169 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
170 |
|
| 52 | 171 |
function mapDispatchToProps(dispatch) { |
172 |
return { |
|
173 |
authActions: bindActionCreators(authActions, dispatch), |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
107
diff
changeset
|
174 |
networkActions: bindActionCreators({ forceSync }, dispatch) |
| 52 | 175 |
} |
176 |
} |
|
177 |
||
|
105
0a1d6560acac
Introduce authenticated routes.
Alexandre Segura <mex.zktk@gmail.com>
parents:
104
diff
changeset
|
178 |
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(AppNavbar)); |