Use CSS to display no go upload errors
This commit is contained in:
parent
b116438de9
commit
a9d0b01ee2
2 changed files with 24 additions and 5 deletions
|
|
@ -457,7 +457,11 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p id="nogoError" style="display: none;"></p>
|
<p
|
||||||
|
id="nogoError"
|
||||||
|
class="invalid-feedback"
|
||||||
|
style="display: none;"
|
||||||
|
></p>
|
||||||
<form>
|
<form>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend data-i18n="loadNogos.source">
|
<legend data-i18n="loadNogos.source">
|
||||||
|
|
|
||||||
23
js/index.js
23
js/index.js
|
|
@ -425,30 +425,37 @@
|
||||||
reader.onload = function() {
|
reader.onload = function() {
|
||||||
resolve(reader.result);
|
resolve(reader.result);
|
||||||
};
|
};
|
||||||
|
reader.onerror = function() {
|
||||||
|
$('#nogoError').text(
|
||||||
|
'Cannot read file: ' + reader.error.message
|
||||||
|
);
|
||||||
|
$('#nogoError').css('display', 'block');
|
||||||
|
};
|
||||||
|
|
||||||
reader.readAsText(nogoFile);
|
reader.readAsText(nogoFile);
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
return JSON.parse(response);
|
return JSON.parse(response);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('#nogoError').text('Error: Missing file or URL.');
|
$('#nogoError').text('Missing file or URL.');
|
||||||
$('#nogoError').css('display', 'block');
|
$('#nogoError').css('display', 'block');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var nogoWeight = parseFloat($('#nogoWeight').val());
|
var nogoWeight = parseFloat($('#nogoWeight').val());
|
||||||
if (isNaN(nogoWeight)) {
|
if (isNaN(nogoWeight)) {
|
||||||
$('#nogoError').text('Error: Missing default nogo weight.');
|
$('#nogoError').text('Missing default nogo weight.');
|
||||||
$('#nogoError').css('display', 'block');
|
$('#nogoError').css('display', 'block');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var nogoRadius = parseFloat($('#nogoRadius').val());
|
var nogoRadius = parseFloat($('#nogoRadius').val());
|
||||||
if (isNaN(nogoRadius) || nogoRadius < 0) {
|
if (isNaN(nogoRadius) || nogoRadius < 0) {
|
||||||
$('#nogoError').text('Error: Invalid default nogo radius.');
|
$('#nogoError').text('Invalid default nogo radius.');
|
||||||
$('#nogoError').css('display', 'block');
|
$('#nogoError').css('display', 'block');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var nogoBuffer = parseFloat($('#nogoBuffer').val());
|
var nogoBuffer = parseFloat($('#nogoBuffer').val());
|
||||||
if (isNaN(nogoBuffer)) {
|
if (isNaN(nogoBuffer)) {
|
||||||
$('#nogoError').text('Error: Invalid nogo buffering radius.');
|
$('#nogoError').text('Invalid nogo buffering radius.');
|
||||||
$('#nogoError').css('display', 'block');
|
$('#nogoError').css('display', 'block');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -471,6 +478,14 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (cleanedGeoJSONFeatures.length === 0) {
|
||||||
|
$('#nogoError').text(
|
||||||
|
'No valid area found in provided input.'
|
||||||
|
);
|
||||||
|
$('#nogoError').css('display', 'block');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var geoJSON = L.geoJson(
|
var geoJSON = L.geoJson(
|
||||||
turf.featureCollection(cleanedGeoJSONFeatures),
|
turf.featureCollection(cleanedGeoJSONFeatures),
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue