Skip to content

Commit

Permalink
Merge pull request #1392 from pierotofy/maximg
Browse files Browse the repository at this point in the history
Check for maxImages on frontend
  • Loading branch information
pierotofy authored Sep 15, 2023
2 parents 9508530 + 9370442 commit 0de8a7e
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 114 deletions.
15 changes: 13 additions & 2 deletions app/static/app/js/components/EditTaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ class EditTaskForm extends React.Component {
this.state.selectedPreset;
}

checkFilesCount(filesCount){
if (!this.state.selectedNode) return false;
if (filesCount === 0) return true;
if (this.state.selectedNode.max_images === null) return true;
return this.state.selectedNode.max_images >= filesCount;
}

selectedNodeMaxImages(){
if (!this.state.selectedNode) return null;
return this.state.selectedNode.max_images;
}

notifyFormLoaded(){
if (this.props.onFormLoaded && this.formReady()) this.props.onFormLoaded();
}
Expand Down Expand Up @@ -115,15 +127,14 @@ class EditTaskForm extends React.Component {
return;
}

let now = new Date();

let nodes = json.map(node => {
return {
id: node.id,
key: node.id,
label: `${node.label} (queue: ${node.queue_count})`,
options: node.available_options,
queue_count: node.queue_count,
max_images: node.max_images,
enabled: node.online,
url: `http://${node.hostname}:${node.port}`
};
Expand Down
15 changes: 14 additions & 1 deletion app/static/app/js/components/NewTaskPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,24 @@ class NewTaskPanel extends React.Component {
}

render() {
let filesCountOk = true;
if (this.taskForm && !this.taskForm.checkFilesCount(this.props.filesCount)) filesCountOk = false;

return (
<div className="new-task-panel theme-background-highlight">
<div className="form-horizontal">
<div className={this.state.inReview ? "disabled" : ""}>
<p>{interpolate(_("%(count)s files selected. Please check these additional options:"), { count: this.props.filesCount})}</p>

{!filesCountOk ?
<div className="alert alert-warning">
{interpolate(_("Number of files selected exceeds the maximum of %(count)s allowed on this processing node."), { count: this.taskForm.selectedNodeMaxImages() })}
<button onClick={this.props.onCancel} type="button" className="btn btn-xs btn-primary redo">
<span><i className="glyphicon glyphicon-remove-circle"></i> {_("Cancel")}</span>
</button>
</div>
: ""}

<EditTaskForm
selectedNode={Storage.getItem("last_processing_node") || "auto"}
onFormLoaded={this.handleFormTaskLoaded}
Expand Down Expand Up @@ -186,7 +199,7 @@ class NewTaskPanel extends React.Component {
{this.state.loading ?
<button type="submit" className="btn btn-primary" disabled={true}><i className="fa fa-circle-notch fa-spin fa-fw"></i>{_("Loading…")}</button>
:
<button type="submit" className="btn btn-primary" onClick={this.save} disabled={this.props.filesCount < 1}><i className="glyphicon glyphicon-saved"></i> {!this.state.inReview ? _("Review") : _("Start Processing")}</button>
<button type="submit" className="btn btn-primary" onClick={this.save} disabled={this.props.filesCount < 1 || !filesCountOk}><i className="glyphicon glyphicon-saved"></i> {!this.state.inReview ? _("Review") : _("Start Processing")}</button>
}
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/static/app/js/css/NewTaskPanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@
opacity: 0.8;
pointer-events:none;
}

button.redo{
margin-top: 0;
margin-left: 10px;
}
}
152 changes: 76 additions & 76 deletions app/static/app/js/translations/odm_autogenerated.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/tests/test_api_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def check_default_presets(self):
self.assertTrue(Preset.objects.filter(name="Forest", system=True).exists())
self.assertTrue(Preset.objects.filter(name="Buildings", system=True).exists())
self.assertTrue(Preset.objects.filter(name="3D Model", system=True).exists())
self.assertTrue(Preset.objects.filter(name="Point of Interest", system=True).exists())
self.assertTrue(Preset.objects.filter(name="Multispectral", system=True).exists())

def test_preset(self):
Expand Down Expand Up @@ -58,7 +57,7 @@ def test_preset(self):
self.assertTrue(res.status_code == status.HTTP_200_OK)

# Only ours and global presets are available
self.assertEqual(len(res.data), 15)
self.assertTrue(len(res.data) > 0)
self.assertTrue('My Local Preset' in [preset['name'] for preset in res.data])
self.assertTrue('High Resolution' in [preset['name'] for preset in res.data])
self.assertTrue('Global Preset #1' in [preset['name'] for preset in res.data])
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.worker-memory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: '2.1'
services:
worker:
mem_limit: ${WO_WORKER_MEMORY}
2 changes: 1 addition & 1 deletion locale
Submodule locale updated 48 files
+1 −1 az/LC_MESSAGES/django.po
+330 −322 az/LC_MESSAGES/djangojs.po
+1 −1 cs/LC_MESSAGES/django.po
+570 −562 cs/LC_MESSAGES/djangojs.po
+1 −1 de/LC_MESSAGES/django.po
+618 −610 de/LC_MESSAGES/djangojs.po
+1 −1 django.pot
+307 −299 djangojs.pot
+1 −1 es/LC_MESSAGES/django.po
+594 −586 es/LC_MESSAGES/djangojs.po
+1 −1 fr/LC_MESSAGES/django.po
+447 −439 fr/LC_MESSAGES/djangojs.po
+1 −1 hu/LC_MESSAGES/django.po
+616 −608 hu/LC_MESSAGES/djangojs.po
+1 −1 id/LC_MESSAGES/django.po
+323 −315 id/LC_MESSAGES/djangojs.po
+20 −18 it/LC_MESSAGES/django.po
+587 −595 it/LC_MESSAGES/djangojs.po
+1 −1 ja/LC_MESSAGES/django.po
+584 −576 ja/LC_MESSAGES/djangojs.po
+1 −1 kn/LC_MESSAGES/django.po
+307 −299 kn/LC_MESSAGES/djangojs.po
+1 −1 ko/LC_MESSAGES/django.po
+563 −555 ko/LC_MESSAGES/djangojs.po
+1 −1 lt/LC_MESSAGES/django.po
+307 −299 lt/LC_MESSAGES/djangojs.po
+1 −1 mn/LC_MESSAGES/django.po
+307 −299 mn/LC_MESSAGES/djangojs.po
+1 −1 nb_NO/LC_MESSAGES/django.po
+307 −299 nb_NO/LC_MESSAGES/djangojs.po
+1 −1 nl/LC_MESSAGES/django.po
+307 −299 nl/LC_MESSAGES/djangojs.po
+1 −1 pl/LC_MESSAGES/django.po
+665 −657 pl/LC_MESSAGES/djangojs.po
+1 −1 pt/LC_MESSAGES/django.po
+579 −571 pt/LC_MESSAGES/djangojs.po
+1 −1 pt_BR/LC_MESSAGES/django.po
+581 −573 pt_BR/LC_MESSAGES/djangojs.po
+14 −14 ru/LC_MESSAGES/django.po
+587 −595 ru/LC_MESSAGES/djangojs.po
+1 −1 th/LC_MESSAGES/django.po
+566 −558 th/LC_MESSAGES/djangojs.po
+1 −1 tr/LC_MESSAGES/django.po
+318 −310 tr/LC_MESSAGES/djangojs.po
+1 −1 zh_Hans/LC_MESSAGES/django.po
+501 −493 zh_Hans/LC_MESSAGES/djangojs.po
+1 −1 zh_Hant/LC_MESSAGES/django.po
+397 −389 zh_Hant/LC_MESSAGES/djangojs.po
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WebODM",
"version": "2.1.1",
"version": "2.1.2",
"description": "User-friendly, extendable application and API for processing aerial imagery.",
"main": "index.js",
"scripts": {
Expand Down
84 changes: 53 additions & 31 deletions webodm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ case $key in
export WO_SETTINGS
shift # past argument
shift # past value
;;
--worker-memory)
WO_WORKER_MEMORY="$2"
export WO_WORKER_MEMORY
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
Expand All @@ -154,6 +160,7 @@ usage(){
echo " stop Stop WebODM"
echo " down Stop and remove WebODM's docker containers"
echo " update Update WebODM to the latest release"
echo " liveupdate Update WebODM to the latest release without stopping it"
echo " rebuild Rebuild all docker containers and perform cleanups"
echo " checkenv Do an environment check and install missing components"
echo " test Run the unit test suite (developers only)"
Expand All @@ -177,6 +184,8 @@ usage(){
echo " --detached Run WebODM in detached mode. This means WebODM will run in the background, without blocking the terminal (default: disabled)"
echo " --gpu Use GPU NodeODM nodes (Linux only) (default: disabled)"
echo " --settings Path to a settings.py file to enable modifications of system settings (default: None)"
echo " --worker-memory Maximum amount of memory allocated for the worker process (default: unlimited)"

exit
}

Expand Down Expand Up @@ -347,6 +356,7 @@ start(){
echo "Celery Broker: $WO_BROKER"
echo "Default Nodes: $WO_DEFAULT_NODES"
echo "Settings: $WO_SETTINGS"
echo "Worker memory limit: $WO_WORKER_MEMORY"
echo "================================"
echo "Make sure to issue a $0 down if you decide to change the environment."
echo ""
Expand Down Expand Up @@ -417,6 +427,10 @@ start(){
command+=" -f docker-compose.settings.yml"
fi

if [ ! -z "$WO_WORKER_MEMORY" ]; then
command+=" -f docker-compose.worker-memory.yml"
fi

command="$command up"

if [[ $detached = true ]]; then
Expand Down Expand Up @@ -493,6 +507,40 @@ resetpassword(){
fi
}

update(){
echo "Updating WebODM..."

hash git 2>/dev/null || git_not_found=true
if [[ $git_not_found ]]; then
echo "Skipping source update (git not found)"
else
if [[ -d .git ]]; then
run "git pull origin master"
else
echo "Skipping source update (.git directory not found)"
fi
fi

command="$docker_compose -f docker-compose.yml"

if [[ $WO_DEFAULT_NODES -gt 0 ]]; then
if [ "${GPU_NVIDIA}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.nvidia.yml"
elif [ "${GPU_INTEL}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.intel.yml"
else
command+=" -f docker-compose.nodeodm.yml"
fi
fi

if [[ $load_micmac_node = true ]]; then
command+=" -f docker-compose.nodemicmac.yml"
fi

command+=" pull"
run "$command"
}

if [[ $1 = "start" ]]; then
environment_check
start
Expand Down Expand Up @@ -528,38 +576,12 @@ elif [[ $1 = "rebuild" ]]; then
elif [[ $1 = "update" ]]; then
environment_check
down
echo "Updating WebODM..."

hash git 2>/dev/null || git_not_found=true
if [[ $git_not_found ]]; then
echo "Skipping source update (git not found)"
else
if [[ -d .git ]]; then
run "git pull origin master"
else
echo "Skipping source update (.git directory not found)"
fi
fi

command="$docker_compose -f docker-compose.yml"

if [[ $WO_DEFAULT_NODES -gt 0 ]]; then
if [ "${GPU_NVIDIA}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.nvidia.yml"
elif [ "${GPU_INTEL}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.intel.yml"
else
command+=" -f docker-compose.nodeodm.yml"
fi
fi

if [[ $load_micmac_node = true ]]; then
command+=" -f docker-compose.nodemicmac.yml"
fi

command+=" pull"
run "$command"
update
echo -e "\033[1mDone!\033[0m You can now start WebODM by running $0 start"
elif [[ $1 = "liveupdate" ]]; then
environment_check
update
echo -e "\033[1mDone!\033[0m You can now finish the update by running $0 restart"
elif [[ $1 = "checkenv" ]]; then
environment_check
elif [[ $1 = "test" ]]; then
Expand Down

0 comments on commit 0de8a7e

Please sign in to comment.