Add public_edit field, controls

pull/1568/head
Piero Toffanin 2024-11-06 14:13:33 -05:00
rodzic eaf0db9461
commit 6a1473aa82
4 zmienionych plików z 82 dodań i 26 usunięć

Wyświetl plik

@ -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,

Wyświetl plik

@ -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 = `<iframe scrolling="no" title="WebODM" width="61.8033%" height="360" frameBorder="0" src="${iframeUrl}"></iframe>`;
console.log(this.state.task);
return (<div onMouseDown={e => { e.stopPropagation(); }} className={"sharePopup " + this.props.placement}>
<div className={"sharePopupContainer popover in " + this.props.placement}>
<div className="arrow"></div>
<h3 className="popover-title theme-background-highlight">{_("Share This Task")}</h3>
<div className="popover-content theme-secondary">
<ErrorMessage bind={[this, 'error']} />
<div className="checkbox">
<button type="button"
<h3 className="popover-title theme-background-highlight">{_("Share This Task")}
<button type="button" title={_("QR")}
className={"btn btn-qrcode btn-sm " +
(this.state.showQR ? "btn-primary " : "btn-default ") +
(!this.state.task.public ? "hide" : "")}
onClick={this.toggleQRCode}>
<i className="fa fa-qrcode"></i> {_("QR")}
<i className="fa fa-qrcode"></i>
</button>
</h3>
<div className="popover-content theme-secondary">
<ErrorMessage bind={[this, 'error']} />
<div className="checkboxes">
<div className="checkbox">
<label onClick={this.handleEnableSharing}>
{this.state.togglingShare ?
<i className="fa fa-sync fa-spin fa-fw"></i>
: ""}
<label onClick={this.handleEnableSharing}>
{this.state.togglingShare ?
<i className="fa fa-sync fa-spin fa-fw"></i>
: ""}
<input
className={this.state.togglingShare ? "hide" : ""}
type="checkbox"
checked={this.state.task.public}
onChange={() => {}}
/> {_("Enabled")}
</label>
</div>
{this.state.task.public ? <div className="checkbox last">
<label onClick={this.handleAllowEdits}>
{this.state.togglingEdits ?
<i className="fa fa-sync fa-spin fa-fw"></i>
: ""}
<input
className={this.state.togglingShare ? "hide" : ""}
type="checkbox"
checked={this.state.task.public}
onChange={() => {}}
/> {_("Enabled")}
</label>
<input
className={this.state.togglingEdits ? "hide" : ""}
type="checkbox"
checked={this.state.task.public_edit}
onChange={() => {}}
/> {_("Allow Edits")}
</label>
</div> : ""}
</div>
<div className={"share-links " + (this.state.task.public ? "show" : "")}>
<div className={"form-group " + (this.state.showQR ? "hide" : "")}>
@ -152,10 +197,10 @@ class SharePopup extends React.Component{
/>
</label>
</div>
<div className={(this.state.showQR ? "" : "hide")}>
<div className={(this.state.showQR ? "" : "hide") + " text-center"}>
<QRCode
value={shareLink}
size={200}
size={164}
bgColor={"#ffffff"}
fgColor={"#000000"}
level={"M"}

Wyświetl plik

@ -34,10 +34,24 @@
h3.popover-title{
padding-top: 8px;
display: flex;
justify-content: space-between;
}
.checkboxes{
display: flex;
justify-content: space-between;
}
.btn-qr{
max-height: 32px;
}
.checkbox{
margin-top: 0;
&.last{
margin-left: 12px;
}
}
.fa-sync{
@ -45,12 +59,6 @@
margin-right: 5px;
}
.btn-qrcode{
position: absolute;
right: 0px;
top: -6px;
}
.share-links{
& > div{
margin-top: 8px;

Wyświetl plik

@ -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": {