Merge remote-tracking branch 'origin/main'

This commit is contained in:
zakhy 2025-02-24 08:49:20 +07:00
commit d6b1cc2f13
11 changed files with 134 additions and 18 deletions

View File

@ -42,4 +42,6 @@ def settings_install():
get_settings("susubsystem_seis","True")
get_settings("susubsystem_seis_name","Cейсмические процессы")
get_settings("plasystem", "noSystem")

View File

@ -1,14 +1,27 @@
import json
from django.contrib import admin
from apps.main.models.model_dinamic_layer import DynamicLayer
from apps.main.models.model_static_layer import StaticLayer
from django import forms
class PrettyJSONEncoder(json.JSONEncoder):
def __init__(self, *args, indent, sort_keys, **kwargs):
super().__init__(*args, indent=2, sort_keys=True, **kwargs)
class LayerModelForm(forms.ModelForm):
layer_style = forms.JSONField(encoder=PrettyJSONEncoder)
@admin.register(StaticLayer)
class StaticLayerAdmin(admin.ModelAdmin):
pass
form = LayerModelForm
@admin.register(DynamicLayer)
class DynamicLayerAdmin(admin.ModelAdmin):
pass
form = LayerModelForm

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2025-02-21 12:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0004_auto_20250219_0247'),
]
operations = [
migrations.AlterField(
model_name='staticlayer',
name='layer_style',
field=models.JSONField(blank=True, default={'fill': {'color': 'rgba(255, 255, 255, 1)'}, 'image': {'height': 20, 'opacity': 1, 'scale': 1, 'src': '/static/img/marker.png', 'width': 30}, 'stroke': {'color': 'rgba(0, 0, 0, 1)', 'lineCap': 'round', 'lineDash': None, 'lineDashOffset': 0, 'lineJoin': 'round', 'miterLimit': 10, 'width': 1}, 'text': {'backgroundFill': {'color': '#fff'}, 'backgroundStroke': {'color': '#000', 'width': 1}, 'fill': {'color': 'rgba(255, 255, 255, 1)'}, 'font': 'bold 12px/1 Arial', 'maxAngle': '0.7853981633974483', 'offsetX': 0, 'offsetY': -25, 'overflow': 'false', 'padding': [3, 3, 3, 3], 'placement': 'point', 'rotation': 0.0, 'text': 'Example', 'textAlign': 'center', 'textBaseline': 'middle'}}, null=True),
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.25 on 2025-02-21 12:09
import apps.main.models.model_static_layer
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0005_alter_staticlayer_layer_style'),
]
operations = [
migrations.AlterField(
model_name='staticlayer',
name='layer_style',
field=models.JSONField(blank=True, default=apps.main.models.model_static_layer.get_style_template, null=True),
),
]

View File

@ -1,6 +1,58 @@
from django.db import models
def get_style_template() -> dict:
return {
"fill": {
"color": "rgba(255, 255, 255, 1)"
},
"stroke": {
"color": "rgba(0, 0, 0, 1)",
"width": 1,
"lineCap": "round",
"lineJoin": "round",
"lineDash": None, # [10, 5]
"lineDashOffset": 0,
"miterLimit": 10
},
"image": {
"src": "/static/img/marker.png",
"width": 30,
"height": 20,
"opacity": 1,
# "color":
"scale": 1,
},
"text": {
"font": "bold" + " " + "12px" + "/" + "1" + " " + "Arial",
"textAlign": 'center',
"textBaseline": 'middle',
"text": "Example",
"fill": {
"color": "rgba(255, 255, 255, 1)"
},
"offsetX": 0,
"offsetY": -25,
"placement": 'point',
"maxAngle": '0.7853981633974483',
"overflow": False,
"rotation": 0.0,
"backgroundFill": {
"color": '#fff'
},
"stroke": {
"color": "rgba(0, 0, 0, 1)",
"width": 1,
},
"backgroundStroke": {
"color": '#000',
"width": 1
},
"padding": [3, 3, 3, 3]
},
}
class StaticLayer(models.Model):
"""
Модель слоев
@ -17,7 +69,8 @@ class StaticLayer(models.Model):
is_visible = models.BooleanField(default=True,
verbose_name="Видимость слоя")
layer_style = models.JSONField(blank=True,
null=True)
null=True,
default=get_style_template)
order = models.IntegerField(default=0,
verbose_name="Порядок отображения")
@ -25,9 +78,9 @@ class StaticLayer(models.Model):
return self.name
class Meta: # отображение в админики
verbose_name = u'Статический слой'
verbose_name_plural = u'Статические слои'
verbose_name = u"Статический слой"
verbose_name_plural = u"Статические слои"
indexes = [
models.Index(fields=['name']),
models.Index(fields=['is_visible'])
models.Index(fields=["name"]),
models.Index(fields=["is_visible"])
]

View File

@ -48,14 +48,14 @@
<div class="input-group d-flex flex-column">
<label for="id_layer_file_input" class="file-upload-label">Выберите файл с
расширением
.kml, .json, .dxf</label>
.kml, .json, .geojson, .dxf</label>
<span>Сейчас выбран: <span id="file_path"
style="cursor: auto; color: var(--primary);"></span></span>
<input type="file" name="layer_file_input"
class="form-control"
autofocus=""
id="id_layer_file_input" style="visibility:hidden; display: none"
accept=".kml, .json, .dxf">
accept=".kml, .json, .geojson, .dxf">
{{ form.file.as_hidden }}
</div>
</div>
@ -235,6 +235,10 @@
const kml = e.target.result;
clearVectorLayer();
addKMLToMap(kml);
} else if (fileExtension === "json" || fileExtension === "geojson") {
const geojson = JSON.parse(e.target.result)
clearVectorLayer()
addGeoJSONToMap(geojson)
}
};
reader.readAsText(file);

View File

@ -305,7 +305,7 @@
function polygonBrownStyleFunction(feature, resolution) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgb(199,136,10)',
color: feature.get("color") ? feature.get("color") :'rgb(199,136,10)',
width: 2,
}),
fill: new ol.style.Fill({
@ -472,7 +472,7 @@
function createLayer(layer) {
let newLayer;
console.log(layer)
if (layer.layer_type === 'Tile') {
newLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
@ -487,7 +487,7 @@
format: new ol.format.GeoJSON(),
}),
visible: layer.is_visible,
style: polygonBrownStyleFunction,
style: polygonBrownStyleFunction
});
}
newLayer.set('title', layer.name)

View File

@ -439,7 +439,7 @@
<label for="id_plasystem" class="col-sm-1 col-form-label">Система оповещения : </label>
<div class="col-sm-4">
<select id = "id_plasystem" name="plasystem" class="form-control select2" style="width: 100%;">
<option {% if plasystem == "Не используется" %} selected {% endif %}>Не используется</option>
<option value="noSystem" {% if plasystem == "Не используется" %} selected {% endif %}>Не используется</option>
<option {% if plasystem == "Asterisk" %} selected {% endif %}>Asterisk</option>
<option {% if plasystem == "Radiusip" %} selected {% endif %}>Radiusip</option>
</select>

View File

@ -19,6 +19,8 @@ def main_index(request):
return redirect("radiusip_main_index")
elif plasystem == "Asterisk":
return redirect("asterisk_main_index")
else:
return redirect("mainindex")
except Exception as err:
logging.error(traceback.format_exc())
return redirect("/main/")

View File

@ -38,7 +38,7 @@ const getColorByColorTable = function (index) {
}, {
"aci": 7,
"hex": "#FFFFFF",
"rgb": "rgb(255,255,255)"
"rgb": "rgb(0,0,0)"
}, {
"aci": 8,
"hex": "#414141",

View File

@ -231,10 +231,15 @@
</li>
<li class="nav-header"></li>
<li class="nav-item">
<a href="/pla/" class="nav-link"
><i class="nav-icon fas fa-volume-up"></i>
<p>Система оповещения</p></a
>
{% if plasystem != "noSystem" %}
<a href="/pla/" class="nav-link">
<i class="nav-icon fas fa-volume-up"></i>
<p>Система оповещения</p></a>
{% else %}
<a href="#" class="nav-link nav-item adisabled" >
<i class="nav-icon fas fa-volume-up"></i>
<p><del>Система оповещения</del></p></a>
{% endif %}
</li>
<li class="nav-header"></li>
<li class="nav-item">