From ddb97cff99d877f48523b6bd215d0356d507f543 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 1 Dec 2017 13:52:36 -0500 Subject: [PATCH] Started creating share button UI --- app/models/task.py | 7 ++- app/static/app/js/components/Map.jsx | 22 +++---- app/static/app/js/components/ShareButton.jsx | 60 ++++++++++++++++++++ app/static/app/js/components/SharePanel.jsx | 45 +++++++++++++++ app/static/app/js/css/ShareButton.scss | 9 +++ app/static/app/js/css/SharePanel.scss | 6 ++ 6 files changed, 136 insertions(+), 13 deletions(-) create mode 100644 app/static/app/js/components/ShareButton.jsx create mode 100644 app/static/app/js/components/SharePanel.jsx create mode 100644 app/static/app/js/css/ShareButton.scss create mode 100644 app/static/app/js/css/SharePanel.scss diff --git a/app/models/task.py b/app/models/task.py index acde439e..67ac9d5c 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -439,8 +439,11 @@ class Task(models.Model): return { 'tiles': [{'url': self.get_tile_json_url(t), 'type': t} for t in types], 'meta': { - 'task': str(self.id), - 'project': self.project.id + 'task': { + 'id': str(self.id), + 'project': self.project.id, + 'public': self.public + } } } diff --git a/app/static/app/js/components/Map.jsx b/app/static/app/js/components/Map.jsx index dc5cfc74..a11f00e4 100644 --- a/app/static/app/js/components/Map.jsx +++ b/app/static/app/js/components/Map.jsx @@ -14,6 +14,7 @@ import '../vendor/leaflet/Leaflet.Autolayers/leaflet-autolayers'; import $ from 'jquery'; import ErrorMessage from './ErrorMessage'; import SwitchModeButton from './SwitchModeButton'; +import ShareButton from './ShareButton'; import AssetDownloads from '../classes/AssetDownloads'; import PropTypes from 'prop-types'; @@ -40,7 +41,7 @@ class Map extends React.Component { this.state = { error: "", - switchButtonTask: null // When this is set to a task, show a switch mode button to view the 3d model + singleTask: null // When this is set to a task, show a switch mode button to view the 3d model }; this.imageryLayers = []; @@ -62,7 +63,7 @@ class Map extends React.Component { assets = AssetDownloads.excludeSeparators(), layerId = layer => { const meta = layer[Symbol.for("meta")]; - return meta.project + "_" + meta.task; + return meta.task.project + "_" + meta.task.id; }; // Remove all previous imagery layers @@ -105,13 +106,8 @@ class Map extends React.Component { } // Show 3D switch button only if we have a single orthophoto - const task = { - id: meta.task, - project: meta.project - }; - if (tiles.length === 1){ - this.setState({switchButtonTask: task}); + this.setState({singleTask: meta.task}); } // For some reason, getLatLng is not defined for tileLayer? @@ -129,12 +125,12 @@ class Map extends React.Component {
Bounds: [${layer.options.bounds.toBBoxString().split(",").join(", ")}]
+ ); + } +} + +export default ShareButton; diff --git a/app/static/app/js/components/SharePanel.jsx b/app/static/app/js/components/SharePanel.jsx new file mode 100644 index 00000000..c1dca3b9 --- /dev/null +++ b/app/static/app/js/components/SharePanel.jsx @@ -0,0 +1,45 @@ +import React from 'react'; +import '../css/SharePanel.scss'; +import PropTypes from 'prop-types'; + + +class SharePanel extends React.Component{ + static propTypes = { + sharingEnabled: PropTypes.bool + }; + static defaultProps = { + sharingEnabled: true + }; + + constructor(props){ + super(props); + + this.state = { + sharingEnabled: props.sharingEnabled + }; + + this.handleSharingEnabled = this.handleSharingEnabled.bind(this); + } + + handleSharingEnabled(e){ + this.setState({ sharingEnabled: e.target.checked }); + } + + render(){ + return (
+
+ +
+ +
); + } +} + +export default SharePanel; \ No newline at end of file diff --git a/app/static/app/js/css/ShareButton.scss b/app/static/app/js/css/ShareButton.scss new file mode 100644 index 00000000..bc14ab4d --- /dev/null +++ b/app/static/app/js/css/ShareButton.scss @@ -0,0 +1,9 @@ +.shareButton{ + border-width: 1px; + position: absolute; + z-index: 2000; + bottom: 24px; + right: 76px; + +} + diff --git a/app/static/app/js/css/SharePanel.scss b/app/static/app/js/css/SharePanel.scss new file mode 100644 index 00000000..8ad4ce19 --- /dev/null +++ b/app/static/app/js/css/SharePanel.scss @@ -0,0 +1,6 @@ +.sharePanel{ + .checkbox{ + margin-top: 0; + } +} +