240 lines
10 KiB
HTML
240 lines
10 KiB
HTML
{% extends "management_base.html" %}
|
|
{% load static %}
|
|
{% load mysettings %}
|
|
|
|
|
|
{% block header_link %}
|
|
<!-- Select2 -->
|
|
<link rel="stylesheet"
|
|
href="{% static 'lte/plugins/select2/css/select2.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
|
<link rel="stylesheet"
|
|
href="{% static 'lte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
|
<!-- iCheck for checkboxes and radio inputs -->
|
|
<link rel="stylesheet"
|
|
href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
|
<style>
|
|
.file-upload-label {
|
|
cursor: pointer;
|
|
border: 1px solid #ced4da;
|
|
padding: .375rem .75rem;
|
|
border-radius: .25rem;
|
|
font-weight: normal !important;
|
|
}
|
|
|
|
.custom-file {
|
|
margin-bottom: 1.5em;
|
|
}
|
|
|
|
.file-name {
|
|
margin-left: .5em;
|
|
font-size: 0.7rem;
|
|
}
|
|
</style>
|
|
{% endblock header_link %}
|
|
{% block content %}
|
|
<section class="content-header">
|
|
<div class="container-fluid">
|
|
<div class="row mb-2">
|
|
<div class="col-sm-6">
|
|
<h4>{% if form.instance.pk %}Редактирование{% else %}Добавление{% endif %} задачи</h4>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<ol class="breadcrumb float-sm-right">
|
|
<li class="breadcrumb-item"><a href="/management/general/">Главная</a></li>
|
|
<li class="breadcrumb-item">Параметры системы</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div><!-- /.container-fluid -->
|
|
</section>
|
|
|
|
<section class="content">
|
|
<form autocomplete="off" method="post" enctype="multipart/form-data" class="form-horizontal" id="form">
|
|
{% csrf_token %}
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<!-- /.col -->
|
|
<div class="col-12">
|
|
<div class="card card-outline card-primary">
|
|
<div class="card-body">
|
|
<div class="form-group row">
|
|
<label for="{{ form.name.id_for_label }}" class="col-sm-2 col-form-label">
|
|
Наименование <span class="text-danger">*</span>
|
|
</label>
|
|
<div class="col-sm-8">
|
|
{{ form.name }}
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="{{ form.interval.id_for_label }}" class="col-sm-2 col-form-label">
|
|
Периодичность <span class="text-danger">*</span>
|
|
</label>
|
|
<div class="col-sm-8">
|
|
{{ form.interval }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
<button id="saveButton" type="submit" class="btn bg-gradient-primary">Сохранить</button>
|
|
<a href="{% url 'management:manage_orthomosaic' %}" type="button" class="btn btn-default float-right">Отмена</a>
|
|
</div>
|
|
<!-- /.card -->
|
|
</div>
|
|
<!-- /.nav-tabs-custom -->
|
|
</div>
|
|
<!-- /.col -->
|
|
</div>
|
|
<!-- /.row -->
|
|
</div><!-- /.container-fluid -->
|
|
</form>
|
|
</section>
|
|
{% endblock %}
|
|
{% block script_footer %}
|
|
|
|
<script src="{% static 'js/ol/lib/OpenLayers.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/ol-ext/ol-ext.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/layersStyles.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-core.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-layer-switcher.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-marker-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-created-layer-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-time-slider.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
<script src="{% static 'js/ol/map/map-coefficients-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
|
|
|
<script>
|
|
document.getElementById("saveButton").addEventListener("click", (event) => {
|
|
$("#saveButtonIcon").hide()
|
|
event.target.insertAdjacentHTML('afterbegin', `
|
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
|
`);
|
|
event.target.disabled = true
|
|
document.getElementById("form").submit()
|
|
})
|
|
|
|
</script>
|
|
<script>
|
|
const inputArr = document.querySelectorAll('.custom-file')
|
|
for (let div of inputArr) {
|
|
div.querySelector("input").addEventListener('change', function (event) {
|
|
const fileNameDisplay = div.querySelector("span.file-name");
|
|
const file = event.target.files[0];
|
|
|
|
if (file) {
|
|
fileNameDisplay.style.display = 'block';
|
|
fileNameDisplay.innerHTML = `Сейчас выбран: <a href="#" download="${file.name}">${file.name}</a>`;
|
|
} else {
|
|
fileNameDisplay.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
// Находим все вкладки и их контент
|
|
const tabs = document.querySelectorAll('.vert-tabs-tab.nav-link');
|
|
const tabContent = document.querySelectorAll('.tab-pane');
|
|
|
|
// Функция для активации вкладки
|
|
function activateTab(tabId) {
|
|
tabs.forEach(tab => {
|
|
tab.classList.remove('active');
|
|
tab.setAttribute('aria-selected', 'false');
|
|
});
|
|
|
|
tabContent.forEach(content => {
|
|
content.classList.remove('active', 'show');
|
|
});
|
|
|
|
const selectedTab = document.querySelector(`[href="#${tabId}"]`);
|
|
if (selectedTab) {
|
|
selectedTab.classList.add('active');
|
|
selectedTab.setAttribute('aria-selected', 'true');
|
|
}
|
|
|
|
const selectedContent = document.getElementById(tabId);
|
|
if (selectedContent) {
|
|
selectedContent.classList.add('active', 'show');
|
|
}
|
|
}
|
|
|
|
// Проверяем, есть ли сохраненная вкладка в localStorage
|
|
const savedTab = localStorage.getItem('activeTab');
|
|
if (savedTab) {
|
|
activateTab(savedTab);
|
|
} else {
|
|
// Если нет сохраненной вкладки, активируем первую по умолчанию
|
|
activateTab('tiff');
|
|
}
|
|
|
|
// Добавляем обработчики событий для вкладок
|
|
tabs.forEach(tab => {
|
|
tab.addEventListener('click', function (event) {
|
|
event.preventDefault();
|
|
const tabId = this.getAttribute('href').substring(1); // Убираем символ '#'
|
|
activateTab(tabId);
|
|
|
|
// Сохраняем выбранную вкладку в localStorage
|
|
localStorage.setItem('activeTab', tabId);
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
const extent = ol.proj.transformExtent(
|
|
[
|
|
parseFloat('{{ form.instance.min_lon|safe }}'),
|
|
parseFloat('{{ form.instance.min_lat|safe }}'),
|
|
parseFloat('{{ form.instance.max_lon|safe }}'),
|
|
parseFloat('{{ form.instance.max_lat|safe }}')
|
|
],
|
|
'EPSG:4326', // Исходная проекция
|
|
'EPSG:3857' // Целевая проекция
|
|
);
|
|
const mapCore = new MapCore('map', {
|
|
center: ['{{longitude}}', '{{latitude}}'],
|
|
zoom: 12
|
|
});
|
|
await mapCore.initialize();
|
|
const scanLayer = new ol.layer.Tile({
|
|
source: new ol.source.XYZ({
|
|
url: `{{ form.instance.url }}`,
|
|
}),
|
|
extent: extent
|
|
});
|
|
scanLayer.set('title', 'Ортофотоплан')
|
|
scanLayer.set('name', 'orto')
|
|
mapCore.addLayer(scanLayer)
|
|
|
|
|
|
mapCore.map.getView().fit(extent, {
|
|
padding: [20, 20, 20, 20],
|
|
duration: 1000,
|
|
maxZoom: 15
|
|
});
|
|
|
|
const extentPolygon = ol.geom.Polygon.fromExtent(extent);
|
|
|
|
const vectorLayer = new ol.layer.Vector({
|
|
source: new ol.source.Vector({
|
|
features: [
|
|
new ol.Feature({
|
|
geometry: extentPolygon,
|
|
}),
|
|
],
|
|
}),
|
|
style: new ol.style.Style({
|
|
stroke: new ol.style.Stroke({
|
|
color: 'red',
|
|
width: 2,
|
|
}),
|
|
}),
|
|
});
|
|
mapCore.addLayer(vectorLayer)
|
|
});
|
|
</script>
|
|
|
|
|
|
{% endblock script_footer %}
|
|
|