Implemented GPX tracks delete

This commit is contained in:
Vadim Likholetov 2023-12-10 14:58:09 +02:00
parent c142f67c3e
commit 563b5eebe6
5 changed files with 16 additions and 5 deletions

View File

@ -24,6 +24,7 @@
<orderEntry type="library" name="bootstrap" level="application" />
<orderEntry type="library" name="popper.js" level="application" />
<orderEntry type="library" name="@turf/turf" level="application" />
<orderEntry type="library" name="leaflet-gpx" level="application" />
</component>
<component name="PackageRequirementsSettings">
<option name="removeUnused" value="true" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{@turf/turf, bootstrap, jquery, leaflet, leaflet-control-geocoder, leaflet.draw, popper.js}" />
<file url="file://$PROJECT_DIR$" libraries="{@turf/turf, bootstrap, jquery, leaflet, leaflet-control-geocoder, leaflet-gpx, leaflet.draw, popper.js}" />
</component>
</project>

View File

@ -125,6 +125,16 @@ def upload_gpx():
return jsonify({'message': 'GPX file uploaded successfully'})
@app.route('/delete_gpx/<int:gpx_id>/<int:sar_id>', methods=['GET'])
@login_required
def delete_gpx(gpx_id, sar_id):
gpx_file = GPSTrack.query.get_or_404(gpx_id)
db.session.delete(gpx_file)
db.session.commit()
flash('GPX file deleted successfully!', 'success')
return redirect(url_for('sar_details', id=sar_id))
def custom_flask_response(data, status=200, headers=None, mimetype='application/json'):
# TODO: fix filename encoding -- need to support unicode

View File

@ -8,6 +8,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-control-geocoder@2.4.0/dist/Control.Geocoder.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-gpx/1.7.0/gpx.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
<script src='https://unpkg.com/@turf/turf@6/turf.min.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

View File

@ -102,10 +102,9 @@
</li>
{% set ns.drawn = true %}
<!-- Button to delete GPX Upload Modal -->
<button type="button" class="gpx-delete-button" data-toggle="modal"
data-target="#deleteGPXModal"
data-comment-id="{{ comment.id }}">
&#128465;
<button type="button" class="gpx-delete-button">
<a href="{{ url_for('delete_gpx', gpx_id=gpx_track.id, sar_id=sar.SARCall.id ) }}">
&#128465;</a>
</button>
{% endif %}
{% endfor %}