SARBase/templates/create_sar.html

170 lines
6.8 KiB
HTML
Raw Normal View History

2023-11-01 18:46:27 +00:00
{% extends "base.html" %}
{% block title %}
Create SAR Record
{% endblock %}
{% block content %}
2023-10-30 14:48:00 +00:00
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css"/>
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
2023-11-01 18:46:27 +00:00
<div class="container mt-5">
<h2>Create SAR Call</h2>
2023-11-01 18:46:27 +00:00
<form action="{{ url_for('create_sar') }}" method="post" enctype="multipart/form-data">
2023-11-01 18:46:27 +00:00
<div class="form-group">
<label for="status">Status:</label>
<select name="status" id="status" class="form-control">
{% for status in statuses %}
<option value="{{ status.id }}">
{{ status.name }}
</option>
{% endfor %}
</select>
2023-11-01 18:46:27 +00:00
</div>
2023-11-01 18:46:27 +00:00
<div class="form-group">
<label for="start_date">Start Date:</label>
<div>
<button type="button" id="today_button" class="btn btn-secondary">Today</button>
</div>
<input type="date" name="start_date" id="start_date" class="form-control" required>
2023-11-01 18:46:27 +00:00
</div>
<div class="form-group">
<label for="category">Category:</label>
<select name="category" id="category" class="form-control">
{% for category in categories %}
<option value="{{ category.id }}">{{ category.name }}</option>
2023-11-01 18:46:27 +00:00
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="coordinates">Initial Planning Point (IPP) Coordinates:</label>
<input type="text" name="longitude" class="form-control" placeholder="e.g. 40.7128"
required>
<input type="text" name="latitude" class="form-control" placeholder="e.g. -74.0060"
2023-11-01 18:46:27 +00:00
required>
</div>
<div class="form-group">
<label for="title">Title:</label>
<input type="text" name="title" class="form-control"
placeholder="e.g. M65, London center, missing since 12.12.2022" required>
</div>
2023-11-01 18:46:27 +00:00
<div class="form-group">
<label for="description">Description:</label>
<textarea name="description" class="form-control"></textarea>
</div>
<div class="form-group">
<label for="description_hidden">Hidden Description:</label>
<textarea name="description_hidden" class="form-control"></textarea>
2023-11-01 18:46:27 +00:00
</div>
{# <!-- GPX Track Fields (You can expand upon this based on the previous discussions about multiple tracks) -->#}
{# <div class="form-group">#}
{# <label for="gpx_file">Upload GPX Track:</label>#}
{# <input type="file" name="gpx_file">#}
{# </div>#}
2023-11-01 18:46:27 +00:00
<button type="submit" class="btn btn-primary">Create</button>
</form>
2023-10-30 14:48:00 +00:00
</div>
<div id="map" style="width: 600px; height: 400px;"></div>
<script>
var map = L.map('map').setView([51.505, -0.09], 13); // Default to London, adjust as needed
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var marker;
// Add the geocoder
L.Control.geocoder({
defaultMarkGeocode: true
})
.on('markgeocode', function (e) {
if (marker) {
map.removeLayer(marker);
}
var latlng = e.geocode.center;
L.marker(latlng).addTo(map);
map.setView(latlng, map.getZoom());
// Update your form fields with the selected location
document.querySelector('input[name="latitude"]').value = latlng.lat;
document.querySelector('input[name="longitude"]').value = latlng.lng;
})
.addTo(map);
2023-10-30 14:48:00 +00:00
map.on('click', function (e) {
if (marker) {
map.removeLayer(marker);
}
marker = L.marker(e.latlng).addTo(map);
document.querySelector('input[name="latitude"]').value = e.latlng.lat;
document.querySelector('input[name="longitude"]').value = e.latlng.lng;
});
2023-11-01 18:46:27 +00:00
{#var gpxTracks = {{ gpx_data | tojson }};#}
{#gpxTracks.forEach(function (track) {#}
{# var gpxLayer = new L.GPX(track.data, {async: true, polyline_options: {color: track.color}});#}
{# gpxLayer.on('loaded', function (e) {#}
{# map.fitBounds(e.target.getBounds());#}
{# });#}
{# map.addLayer(gpxLayer);#}
{#})
#}
// If editing, set the marker to the existing coordinates
var latInput = document.querySelector('input[name="latitude"]');
var lngInput = document.querySelector('input[name="longitude"]');
if (latInput.value && lngInput.value) {
marker = L.marker([latInput.value, lngInput.value]).addTo(map);
}
2023-10-30 14:48:00 +00:00
</script>
{##}
{# <script>#}
{# function addTrack() {#}
{# let trackDiv = document.createElement('div');#}
{# trackDiv.className = 'gpx_track';#}
{# trackDiv.innerHTML = `#}
{# <label>GPX Data:</label>#}
{# <textarea name="gpx_data[]"></textarea>#}
{# <label>Color:</label>#}
{# <input type="color" name="gpx_color[]" value="#ff0000">#}
{# <button type="button" onclick="removeTrack(this)">Remove</button>#}
{# `;#}
{# document.getElementById('gpx_tracks').appendChild(trackDiv);#}
{# }#}
{##}
{# function removeTrack(button) {#}
{# let trackDiv = button.parentElement;#}
{# trackDiv.remove();#}
{# }#}
{# </script>#}
2023-10-30 14:48:00 +00:00
2023-11-01 18:46:27 +00:00
<script>
document.getElementById('today_button').addEventListener('click', function () {
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); // January is 0!
var yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
document.getElementById('start_date').value = today;
});
2023-11-01 18:46:27 +00:00
</script>
2023-10-30 14:48:00 +00:00
2023-11-01 18:46:27 +00:00
{% endblock %}