-
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
Add a button to open in full mapstore (see #1632) #1696
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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. | ||
*/ | ||
|
||
const React = require('react'); | ||
const {connect} = require('react-redux'); | ||
|
||
const {Button, Glyphicon, Tooltip} = require('react-bootstrap'); | ||
const OverlayTrigger = require('../components/misc/OverlayTrigger'); | ||
const Message = require('../components/I18N/Message'); | ||
const {mapSelector} = require('../selectors/map'); | ||
const {createSelector} = require('reselect'); | ||
const ConfigUtils = require('../utils/ConfigUtils'); | ||
|
||
const mapIdSelector = createSelector([(state) => {let map = mapSelector(state); return map && map.mapId; }], mapId => ({mapId})); | ||
/** | ||
* GoFull plugins. Shows a button that opens full MapStore2 in a new tab. Try to find the `originalUrl` in configuration or tries to guess the mapId and creates the proper URL. | ||
* This plugins hides automatically if the originalUrl is not present in configuration and if the urlRegex do not match. | ||
* @prop {string} cfg.glyph the glyph icon for the button | ||
* @prop {string} cfg.tooltip messageId of the tooltip to use | ||
* @prop {string} cfg.urlRegex. A regex to parse the current location.href. This regex must match if the originalUrl is not defined. | ||
* @prop {string} cfg.urlReplaceString. The template to create the url link. Uses the `urlRegex` groups to create the final URL | ||
* @memberof plugins | ||
* @class | ||
*/ | ||
const GoFull = React.createClass({ | ||
propTypes: { | ||
glyph: React.PropTypes.string, | ||
tooltip: React.PropTypes.string, | ||
urlRegex: React.PropTypes.string, | ||
urlReplaceString: React.PropTypes.string, | ||
mapId: React.PropTypes.string, | ||
originalUrl: React.PropTypes.string | ||
}, | ||
getDefaultProps() { | ||
return { | ||
glyph: "share", | ||
tooltip: "fullscreen.viewLargerMap", | ||
urlRegex: "^(.*?)embedded.html.*?#\\/(\\d?)", | ||
urlReplaceString: "\\$1#/viewer/leaflet/\\$2" | ||
}; | ||
}, | ||
|
||
render() { | ||
if (!this.display()) return <noscript></noscript>; | ||
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. return null; |
||
return (<OverlayTrigger placement="left" overlay={<Tooltip id="gofull-tooltip"><Message msgId={this.props.tooltip}/></Tooltip>}> | ||
<Button className="square-button" bsStyle="primary" onClick={() => this.openFull(this.generateUrl())}> | ||
<Glyphicon glyph={this.props.glyph}/> | ||
</Button> | ||
</OverlayTrigger>); | ||
}, | ||
display() { | ||
let regex = this.generateRegex(); | ||
return this.props.originalUrl || ConfigUtils.getConfigProp("originalUrl") || location.href.match(regex); | ||
}, | ||
openFull(url) { | ||
if (url) { | ||
window.open(url, '_blank'); | ||
} | ||
}, | ||
generateRegex() { | ||
return new RegExp(this.props.urlRegex); | ||
}, | ||
|
||
generateUrl() { | ||
let orig = this.props.originalUrl || ConfigUtils.getConfigProp("originalUrl"); | ||
if (orig) { | ||
return orig; | ||
} | ||
let regex = this.generateRegex(); | ||
if (location.href.match(regex)) { | ||
let next = location.href; | ||
return next.replace(regex, "$1#/viewer/leaflet/$2"); | ||
} | ||
} | ||
}); | ||
|
||
const GoFullPlugin = connect(mapIdSelector)(GoFull); | ||
|
||
|
||
const assign = require('object-assign'); | ||
|
||
|
||
module.exports = { | ||
GoFullPlugin: assign(GoFullPlugin, { | ||
Toolbar: { | ||
name: 'gofull', | ||
position: 1, | ||
toolStyle: "primary", | ||
tooltip: "fullscreen.viewLargerMap", | ||
tool: true, | ||
priority: 1 | ||
} | ||
}), | ||
reducers: {} | ||
}; |
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
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.
Externalize the component, please
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.
do some test also