From 6a1473aa82230527a1ae44331b2f58be7f0f9e63 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 6 Nov 2024 14:13:33 -0500 Subject: [PATCH] Add public_edit field, controls --- app/models/task.py | 3 + app/static/app/js/components/SharePopup.jsx | 83 ++++++++++++++++----- app/static/app/js/css/SharePopup.scss | 20 +++-- package.json | 2 +- 4 files changed, 82 insertions(+), 26 deletions(-) diff --git a/app/models/task.py b/app/models/task.py index 3192e5e9..8cab4e35 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -260,6 +260,8 @@ class Task(models.Model): pending_action = models.IntegerField(choices=PENDING_ACTIONS, db_index=True, null=True, blank=True, help_text=_("A requested action to be performed on the task. The selected action will be performed by the worker at the next iteration."), verbose_name=_("Pending Action")) public = models.BooleanField(default=False, help_text=_("A flag indicating whether this task is available to the public"), verbose_name=_("Public")) + public_edit = models.BooleanField(default=False, help_text=_("A flag indicating whether this public task can be edited"), verbose_name=_("Public Edit")) + resize_to = models.IntegerField(default=-1, help_text=_("When set to a value different than -1, indicates that the images for this task have been / will be resized to the size specified here before processing."), verbose_name=_("Resize To")) upload_progress = models.FloatField(default=0.0, @@ -1007,6 +1009,7 @@ class Task(models.Model): 'name': self.name, 'project': self.project.id, 'public': self.public, + 'public_edit': self.public_edit, 'camera_shots': camera_shots, 'ground_control_points': ground_control_points, 'epsg': self.epsg, diff --git a/app/static/app/js/components/SharePopup.jsx b/app/static/app/js/components/SharePopup.jsx index 812f38a7..e60aec7f 100644 --- a/app/static/app/js/components/SharePopup.jsx +++ b/app/static/app/js/components/SharePopup.jsx @@ -29,6 +29,7 @@ class SharePopup extends React.Component{ this.state = { task: props.task, togglingShare: false, + togglingEdits: false, error: "", showQR: false, linkControls: [], // coming from plugins, @@ -63,6 +64,7 @@ class SharePopup extends React.Component{ } handleEnableSharing(e){ + if (e) e.preventDefault(); const { task } = this.state; this.setState({togglingShare: true}); @@ -86,6 +88,31 @@ class SharePopup extends React.Component{ }); } + handleAllowEdits = e => { + e.preventDefault(); + const { task } = this.state; + + this.setState({togglingEdits: true}); + + return $.ajax({ + url: `/api/projects/${task.project}/tasks/${task.id}/`, + contentType: 'application/json', + data: JSON.stringify({ + public_edit: !this.state.task.public_edit + }), + dataType: 'json', + type: 'PATCH' + }) + .done((task) => { + this.setState({task}); + this.props.taskChanged(task); + }) + .fail(() => this.setState({error: _("An error occurred. Check your connection and permissions.")})) + .always(() => { + this.setState({togglingEdits: false}); + }); + } + toggleQRCode = () => { this.setState({showQR: !this.state.showQR}); } @@ -94,34 +121,52 @@ class SharePopup extends React.Component{ const shareLink = Utils.absoluteUrl(this.getRelShareLink()); const iframeUrl = Utils.absoluteUrl(`public/task/${this.state.task.id}/iframe/${this.props.linksTarget}/${Utils.toSearchQuery(this.props.queryParams)}`); const iframeCode = ``; + console.log(this.state.task); return (
{ e.stopPropagation(); }} className={"sharePopup " + this.props.placement}>
-

{_("Share This Task")}

-
- -
- + +
+ + +
+
+
+ {this.state.task.public ?
+ + {}} + /> {_("Allow Edits")} + +
: ""}
@@ -152,10 +197,10 @@ class SharePopup extends React.Component{ />
-
+
div{ margin-top: 8px; diff --git a/package.json b/package.json index 5415557c..d746074d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "WebODM", - "version": "2.5.5", + "version": "2.5.6", "description": "User-friendly, extendable application and API for processing aerial imagery.", "main": "index.js", "scripts": {