-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
237 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
/* DESCRIPTION | ||
This component contains the code and the button for copy the embedded code | ||
to the clipboard | ||
*/ | ||
|
||
// components required | ||
const React = require('react'); | ||
const CopyToClipboard = require('react-copy-to-clipboard'); | ||
const Message = require('../../components/I18N/Message'); | ||
const {Glyphicon, Col, Grid, Row, Tooltip, Button} = require('react-bootstrap'); | ||
const OverlayTrigger = require('../misc/OverlayTrigger'); | ||
|
||
|
||
// css required | ||
require('./share.css'); | ||
|
||
const codeApi = require('raw-loader!./api-template.raw'); | ||
|
||
const ShareApi = React.createClass({ | ||
propTypes: { | ||
shareUrl: React.PropTypes.string, | ||
shareConfigUrl: React.PropTypes.string | ||
}, | ||
getInitialState() { | ||
return {copied: false}; | ||
}, | ||
render() { | ||
const parsedCode = codeApi | ||
.replace('__BASE__URL__', this.props.shareUrl) | ||
.replace('__CONFIG__URL__', this.props.shareConfigUrl); | ||
const tooltip = (<Tooltip placement="bottom" className="in" id="tooltip-bottom" style={{zIndex: 2001}}> | ||
{this.state.copied ? <Message msgId="share.msgCopiedUrl"/> : <Message msgId="share.msgToCopyUrl"/>} | ||
</Tooltip>); | ||
const copyTo = (<OverlayTrigger placement="bottom" overlay={tooltip}> | ||
<CopyToClipboard text={parsedCode} onCopy={ () => this.setState({copied: true}) } > | ||
<Button className="buttonCopyTextArea" bsStyle="info" bsSize="large"> | ||
<Glyphicon glyph="copy" onMouseLeave={() => {this.setState({copied: false}); }} /> | ||
</Button> | ||
</CopyToClipboard> | ||
</OverlayTrigger>); | ||
return ( | ||
<div className="input-link"> | ||
<Grid className="embed-box" fluid={true}> | ||
<Row key="title"> | ||
<h4> | ||
<Message msgId="share.apiLinkTitle"/> | ||
</h4> | ||
</Row> | ||
<Row key="data" className="row-button"> | ||
<Col key="textarea" xs={10} sm={10} md={10}><textarea name="description" rows="6" value={parsedCode} enabled="false" readOnly /></Col> | ||
<Col key="button" xs={2} sm={2} md={2}> | ||
{copyTo} | ||
</Col> | ||
</Row> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = ShareApi; |
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,46 @@ | ||
/** | ||
* 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 ShareApi = require('../ShareApi'); | ||
const ReactTestUtils = require('react-addons-test-utils'); | ||
|
||
describe("The ShareEmbed component", () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('is created with defaults', () => { | ||
const cmpSharePanel = ReactDOM.render(<ShareApi/>, document.getElementById("container")); | ||
expect(cmpSharePanel).toExist(); | ||
|
||
}); | ||
|
||
it('should have the address url in the textarea field', () => { | ||
const url = location.href; | ||
const shareConfigUrl = 'configurl'; | ||
|
||
const cmpSharePanel = ReactDOM.render(<ShareApi shareUrl={url} shareConfigUrl={shareConfigUrl}/>, document.getElementById("container")); | ||
expect(cmpSharePanel).toExist(); | ||
|
||
const textareaEmbed = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithTag(cmpSharePanel, "textarea")[0]); | ||
expect(textareaEmbed).toExist(); | ||
expect(textareaEmbed.value.indexOf(url) !== -1).toBe(true); | ||
expect(textareaEmbed.value.indexOf(shareConfigUrl) !== -1).toBe(true); | ||
}); | ||
|
||
}); |
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Page with MapStore 2 API</title> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" type='text/css'> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css" /> | ||
<link rel="stylesheet" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/0.2.4/leaflet.draw.css" /> | ||
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" /> | ||
<script src="https://maps.google.com/maps/api/js?v=3"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script> | ||
<script src="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/0.2.4/leaflet.draw.js"></script> | ||
<style> | ||
#container { | ||
position: absolute; | ||
top: 100px; | ||
left: 100px; | ||
right: 100px; | ||
bottom: 100px; | ||
} | ||
#mapstore2-embedded, #map, .fill { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body onload="init()"> | ||
<div id="container" class="ms2"></div> | ||
<script id="ms2-api" src="__BASE__URL__dist/ms2-api.js"></script> | ||
<script type="text/javascript"> | ||
function init() { | ||
MapStore2.create('container',{ | ||
configUrl: "__CONFIG__URL__" | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -8,5 +8,4 @@ | |
line-height: 1.428571429; | ||
color: @ms2-color-text; | ||
background-color: @ms2-color-background; | ||
overflow: hidden; | ||
} |
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