diff --git a/web/client/components/mapcontrols/Snapshot/SnapshotPanel.jsx b/web/client/components/mapcontrols/Snapshot/SnapshotPanel.jsx index 7912dca64f..246b5a82f2 100644 --- a/web/client/components/mapcontrols/Snapshot/SnapshotPanel.jsx +++ b/web/client/components/mapcontrols/Snapshot/SnapshotPanel.jsx @@ -9,14 +9,14 @@ import './css/snapshot.css'; -import { isEqual } from 'lodash'; +import {isEqual} from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; -import { Alert, Col, Glyphicon, Grid, Image, Panel, Row, Table } from 'react-bootstrap'; +import {Alert, Col, Glyphicon, Grid, Image, Panel, Row, Table} from 'react-bootstrap'; import ConfigUtils from '../../../utils/ConfigUtils'; import Button from '../../misc/Button'; -import { DateFormat } from '../../I18N/I18N'; +import {DateFormat} from '../../I18N/I18N'; import Message from '../../I18N/Message'; import Dialog from '../../misc/Dialog'; import Portal from '../../misc/Portal'; @@ -24,12 +24,13 @@ import BasicSpinner from '../../misc/spinners/BasicSpinner/BasicSpinner'; import notAvailable from './not-available.png'; import shotingImg from './shoting.gif'; import snapshotSupportComp from './SnapshotSupport'; +import PanelHeader from "../../misc/panels/PanelHeader"; let SnapshotSupport; /** * SnapshotPanel allow to export a snapshot of the current map, showing a * preview of the snapshot, with some info about the map. - * It prevent the user to Export snapshot with Google or Bing backgrounds. + * It prevents the user to Export snapshot with Google or Bing backgrounds. * It shows also the status of the current snapshot generation queue. */ class SnapshotPanel extends React.Component { @@ -53,8 +54,7 @@ class SnapshotPanel extends React.Component { downloadingMsg: PropTypes.node, timeout: PropTypes.number, mapType: PropTypes.string, - wrap: PropTypes.bool, - wrapWithPanel: PropTypes.bool, + floatingPanel: PropTypes.bool, panelStyle: PropTypes.object, panelClassName: PropTypes.string, toggleControl: PropTypes.func, @@ -80,17 +80,17 @@ class SnapshotPanel extends React.Component { downloadingMsg: "snapshot.downloadingSnapshots", timeout: 1000, mapType: 'leaflet', - wrap: false, - wrapWithPanel: false, + floatingPanel: true, panelStyle: { - minWidth: "720px", + minWidth: "600px", + maxWidth: "100%", zIndex: 100, position: "absolute", overflow: "auto", top: "60px", right: "100px" }, - panelClassName: "snapshot-panel", + panelClassName: "snapshot-panel ms-side-panel", closeGlyph: "1-close", buttonStyle: "primary", bounds: '#container' @@ -111,13 +111,12 @@ class SnapshotPanel extends React.Component { } renderLayers = () => { - let items = this.props.layers.map((layer, i) => { + return this.props.layers.map((layer, i) => { if (layer.visibility) { return
  • {layer.title}
  • ; } return null; }); - return items; }; renderButton = (enabled) => { @@ -194,12 +193,7 @@ class SnapshotPanel extends React.Component { }; wrap = (panel) => { - if (this.props.wrap) { - if (this.props.wrapWithPanel) { - return (} style={this.props.panelStyle} className={this.props.panelClassName}> - {panel} - ); - } + if (this.props.floatingPanel) { return ( @@ -209,7 +203,14 @@ class SnapshotPanel extends React.Component { ); } - return panel; + return ( + } glyph="camera" onClose={this.props.toggleControl} />} + style={this.props.panelStyle} + className={this.props.panelClassName}> + {panel} + ); }; renderTaintedMessage = () => { @@ -223,7 +224,7 @@ class SnapshotPanel extends React.Component { let bingOrGoogle = this.isBingOrGoogle(); let snapshotReady = this.isSnapshotReady(); return this.props.active ? this.wrap( - + {this.renderPreview()} diff --git a/web/client/components/mapcontrols/Snapshot/css/snapshot.css b/web/client/components/mapcontrols/Snapshot/css/snapshot.css index 36a4909ae9..b642252484 100644 --- a/web/client/components/mapcontrols/Snapshot/css/snapshot.css +++ b/web/client/components/mapcontrols/Snapshot/css/snapshot.css @@ -1,7 +1,7 @@ - .snapshot-panel { - width: 700px; +.snapshot-inner-panel{ + width: 100%; } -.snapshot-panel ul { +.snapshot-inner-panel ul { list-style:none; padding-left:0; } @@ -11,3 +11,7 @@ right: 200px; min-width: 725px; } + +.snapshot-panel .panel-heading { + padding: 0; +} diff --git a/web/client/plugins/Snapshot.jsx b/web/client/plugins/Snapshot.jsx index 298d7567c1..2df92ea629 100644 --- a/web/client/plugins/Snapshot.jsx +++ b/web/client/plugins/Snapshot.jsx @@ -6,26 +6,20 @@ * LICENSE file in the root directory of this source tree. */ -import assign from 'object-assign'; import React from 'react'; -import { Glyphicon } from 'react-bootstrap'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; +import {Glyphicon} from 'react-bootstrap'; +import {connect} from 'react-redux'; +import {createSelector} from 'reselect'; -import { toggleControl } from '../actions/controls'; -import { - changeSnapshotState, - onCreateSnapshot, - onRemoveSnapshot, - onSnapshotError, - saveImage -} from '../actions/snapshot'; +import {createPlugin} from "../utils/PluginsUtils"; +import {toggleControl} from '../actions/controls'; +import {changeSnapshotState, onCreateSnapshot, onRemoveSnapshot, onSnapshotError, saveImage} from '../actions/snapshot'; import SnapshotPanelComp from "../components/mapcontrols/Snapshot/SnapshotPanel"; import SnapshotQueueComp from "../components/mapcontrols/Snapshot/SnapshotQueue"; import snapshotReducers from '../reducers/snapshot'; -import { layersSelector } from '../selectors/layers'; -import { mapSelector } from '../selectors/map'; -import { mapTypeSelector } from '../selectors/maptype'; +import {layersSelector} from '../selectors/layers'; +import {mapSelector} from '../selectors/map'; +import {mapTypeSelector} from '../selectors/maptype'; import Message from './locale/Message'; const snapshotSelector = createSelector([ @@ -51,7 +45,7 @@ const SnapshotPanel = connect(snapshotSelector, { toggleControl: toggleControl.bind(null, 'snapshot', null) })(SnapshotPanelComp); -const SnapshotPlugin = connect((state) => ({ +const SnapshotQueue = connect((state) => ({ queue: state.snapshot && state.snapshot.queue || [] }), { downloadImg: saveImage, @@ -59,44 +53,62 @@ const SnapshotPlugin = connect((state) => ({ onRemoveSnapshot })(SnapshotQueueComp); +const SnapshotContainer = props => ( + <> + + + +); -export default { - SnapshotPlugin: assign(SnapshotPlugin, { +/** + * Tool to create snapshots from the active map viewport. + * @example + * { + * "name": "Snapshot", + * "cfg": { + * "floatingPanel": true + * } + * } + * @prop {boolean} [cfg.floatingPanel=true] show plugin UI in a floating dialog rather than inside the static panel + * @name Snapshot + * @class + * @memberof plugins + */ +export default createPlugin('SnapshotPlugin', { + component: SnapshotContainer, + containers: { Toolbar: { name: 'snapshot', position: 8, - panel: SnapshotPanel, help: , tooltip: "snapshot.tooltip", icon: , - wrap: true, + toggle: true, + doNotHide: true, title: "snapshot.title", - exclusive: true, priority: 1 }, BurgerMenu: { name: 'snapshot', position: 3, - panel: SnapshotPanel, text: , icon: , action: toggleControl.bind(null, 'snapshot', null), - tools: [SnapshotPlugin], - priority: 2 + priority: 3 }, SidebarMenu: { name: 'snapshot', position: 3, - panel: SnapshotPanel, text: , icon: , tooltip: "snapshot.tooltip", action: toggleControl.bind(null, 'snapshot', null), + doNotHide: true, toggle: true, - priority: 1 + priority: 2 } - }), + }, reducers: { snapshot: snapshotReducers } -}; +});