-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2031 Trigger notification if a map is an old one asking for upda…
…ting it (#2039) * Added AutoMapUpdate plugin * Added auto update map on login * Added epic to update map info on login * Set false to title on map update * Added map version to state
- Loading branch information
1 parent
6a5154e
commit cda33c9
Showing
31 changed files
with
537 additions
and
24 deletions.
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
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
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,75 @@ | ||
/* | ||
* 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 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.