-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2031 Trigger notification if a map is an old one asking for updating it #2039
Merged
mbarto
merged 8 commits into
geosolutions-it:master
from
allyoucanmap:refresh-notification
Jul 27, 2017
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
61d6432
Added AutoMapUpdate plugin
allyoucanmap 15414ae
Merge branch 'master' into refresh-notification
allyoucanmap fd24737
Added auto update map on login
allyoucanmap 10b7fff
Merge branch 'master' into refresh-notification
allyoucanmap 95b8140
Added epic to update map info on login
allyoucanmap c528849
Merge branch 'master' into refresh-notification
allyoucanmap 607dc51
Set false to title on map update
allyoucanmap 32f9105
Added map version to state
allyoucanmap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ function logoutWithReload() { | |
|
||
function login(username, password) { | ||
return (dispatch) => { | ||
AuthenticationAPI.login(username, password).then((response) => { | ||
return AuthenticationAPI.login(username, password).then((response) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This refreshes can go easily in an epic. Doing it here can cause unwanted side effects. You should monitor the login/logout actions to reload MapInfo, until you change page. |
||
dispatch(loginSuccess(response, username, password, AuthenticationAPI.authProviderName)); | ||
dispatch(loadMaps(false, ConfigUtils.getDefaults().initialMapFilter || "*")); | ||
}).catch((e) => { | ||
|
51 changes: 51 additions & 0 deletions
51
web/client/components/misc/progressbars/OverlayProgressBar/OverlayProgressBar.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const React = require('react'); | ||
const PropTypes = require('prop-types'); | ||
const {ProgressBar, Col, Row} = require('react-bootstrap'); | ||
const Message = require('../../../../components/I18N/Message'); | ||
require('./css/overlayprogressbar.css'); | ||
|
||
class OverlayProgressBar extends React.Component { | ||
static propTypes = { | ||
loading: PropTypes.bool, | ||
count: PropTypes.number, | ||
length: PropTypes.number, | ||
label: PropTypes.string, | ||
unit: PropTypes.string | ||
}; | ||
|
||
static defaultProps = { | ||
loading: false, | ||
count: 0, | ||
length: 0, | ||
label: 'autorefresh.updating', | ||
unit: 'autorefresh.layers' | ||
}; | ||
|
||
render() { | ||
return this.props.loading ? ( | ||
<div className="overlay-spinner-container"> | ||
<div> | ||
<Row> | ||
<Col xs="12" className="text-center overlay-spinner-label"><h3><Message msgId={this.props.label}/></h3></Col> | ||
</Row> | ||
<Row> | ||
<Col xs="12"><ProgressBar active now={100 * this.props.count / this.props.length} /></Col> | ||
</Row> | ||
<Row> | ||
<Col xs="12" className="text-center overlay-spinner-label"><h3>{this.props.count + ' '} <Message msgId="autorefresh.of"/>{ ' ' + this.props.length + ' '}<Message msgId={this.props.unit}/></h3></Col> | ||
</Row> | ||
</div> | ||
</div> | ||
) : null; | ||
} | ||
} | ||
|
||
module.exports = OverlayProgressBar; |
41 changes: 41 additions & 0 deletions
41
...ient/components/misc/progressbars/OverlayProgressBar/__test__/OverlayProgressBar-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const expect = require('expect'); | ||
|
||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const OverlayProgressBar = require('../OverlayProgressBar'); | ||
|
||
describe("test the OverlayProgressBar", () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('test OverlayProgressBar starts loading', () => { | ||
const overlayProgressBar = ReactDOM.render(<OverlayProgressBar loading/>, document.getElementById("container")); | ||
expect(overlayProgressBar).toExist(); | ||
const node = ReactDOM.findDOMNode(overlayProgressBar); | ||
expect(node.children.length).toBe(1); | ||
}); | ||
|
||
it('test OverlayProgressBar stops loading', () => { | ||
const overlayProgressBar = ReactDOM.render(<OverlayProgressBar loading={false}/>, document.getElementById("container")); | ||
expect(overlayProgressBar).toExist(); | ||
const node = ReactDOM.findDOMNode(overlayProgressBar); | ||
expect(node).toBe(null); | ||
}); | ||
|
||
}); |
20 changes: 20 additions & 0 deletions
20
web/client/components/misc/progressbars/OverlayProgressBar/css/overlayprogressbar.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.overlay-spinner-container { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 9998; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.overlay-spinner-container > div { | ||
width: 80%; | ||
} | ||
|
||
.overlay-spinner-label { | ||
color: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
|
||
const configureMockStore = require('redux-mock-store').default; | ||
const {createEpicMiddleware, combineEpics } = require('redux-observable'); | ||
const {configureMap, mapInfoLoaded} = require('../../actions/config'); | ||
const {loginSuccess} = require('../../actions/security'); | ||
const {SHOW_NOTIFICATION} = require('../../actions/notifications'); | ||
|
||
const {manageAutoMapUpdate, updateMapInfoOnLogin} = require('../automapupdate'); | ||
const rootEpic = combineEpics(manageAutoMapUpdate, updateMapInfoOnLogin); | ||
const epicMiddleware = createEpicMiddleware(rootEpic); | ||
const mockStore = configureMockStore([epicMiddleware]); | ||
|
||
describe('automapupdate Epics', () => { | ||
let store; | ||
beforeEach(() => { | ||
store = mockStore(); | ||
}); | ||
|
||
afterEach(() => { | ||
epicMiddleware.replaceEpic(rootEpic); | ||
}); | ||
|
||
it('update map', (done) => { | ||
|
||
let configuration = configureMap({}, "id"); | ||
|
||
let information = mapInfoLoaded({ | ||
canEdit: true | ||
}, "id"); | ||
|
||
store.dispatch(configuration); | ||
store.dispatch(information); | ||
|
||
setTimeout( () => { | ||
try { | ||
const actions = store.getActions(); | ||
expect(actions.length).toBe(3); | ||
expect(actions[2].type).toBe(SHOW_NOTIFICATION); | ||
} catch (e) { | ||
return done(e); | ||
} | ||
done(); | ||
}, 500); | ||
|
||
}); | ||
|
||
it('update map without login', (done) => { | ||
|
||
let configuration = configureMap({ | ||
version: 2 | ||
}, "id"); | ||
|
||
let information = mapInfoLoaded({ | ||
canEdit: true | ||
}, "id"); | ||
|
||
store.dispatch(configuration); | ||
store.dispatch(information); | ||
|
||
setTimeout( () => { | ||
try { | ||
const actions = store.getActions(); | ||
expect(actions.length).toBe(2); | ||
} catch (e) { | ||
return done(e); | ||
} | ||
done(); | ||
}, 500); | ||
|
||
}); | ||
|
||
it('update map info on login success no id', (done) => { | ||
|
||
let login = loginSuccess("userDetails", "username", "password", "authProvider"); | ||
let configuration = configureMap({}, "id"); | ||
|
||
store.dispatch(configuration); | ||
store.dispatch(login); | ||
|
||
setTimeout( () => { | ||
try { | ||
const actions = store.getActions(); | ||
expect(actions.length).toBe(2); | ||
} catch (e) { | ||
return done(e); | ||
} | ||
done(); | ||
}, 500); | ||
|
||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's needed because we need to send custom action when the notification button has been toggled