diff --git a/apps/general/views/settingsmodule.py b/apps/general/views/settingsmodule.py index 9f5eee8..a40db06 100644 --- a/apps/general/views/settingsmodule.py +++ b/apps/general/views/settingsmodule.py @@ -42,4 +42,6 @@ def settings_install(): get_settings("susubsystem_seis","True") get_settings("susubsystem_seis_name","Cейсмические процессы") + + get_settings("plasystem", "noSystem") diff --git a/apps/main/admin.py b/apps/main/admin.py index f917d09..05ad847 100644 --- a/apps/main/admin.py +++ b/apps/main/admin.py @@ -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 diff --git a/apps/main/migrations/0005_alter_staticlayer_layer_style.py b/apps/main/migrations/0005_alter_staticlayer_layer_style.py new file mode 100644 index 0000000..f0483e0 --- /dev/null +++ b/apps/main/migrations/0005_alter_staticlayer_layer_style.py @@ -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), + ), + ] diff --git a/apps/main/migrations/0006_alter_staticlayer_layer_style.py b/apps/main/migrations/0006_alter_staticlayer_layer_style.py new file mode 100644 index 0000000..cbdbdae --- /dev/null +++ b/apps/main/migrations/0006_alter_staticlayer_layer_style.py @@ -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), + ), + ] diff --git a/apps/main/models/model_static_layer.py b/apps/main/models/model_static_layer.py index 2f353a4..60c0ac9 100644 --- a/apps/main/models/model_static_layer.py +++ b/apps/main/models/model_static_layer.py @@ -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"]) ] diff --git a/apps/main/templates/create_layer.html b/apps/main/templates/create_layer.html index 60812d0..2a146f4 100644 --- a/apps/main/templates/create_layer.html +++ b/apps/main/templates/create_layer.html @@ -48,14 +48,14 @@
+ .kml, .json, .geojson, .dxf Сейчас выбран: + accept=".kml, .json, .geojson, .dxf"> {{ form.file.as_hidden }}
@@ -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); diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html index 4bb634b..e633145 100644 --- a/apps/main/templates/main_index.html +++ b/apps/main/templates/main_index.html @@ -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) diff --git a/apps/management/templates/settings.html b/apps/management/templates/settings.html index eedb241..6be303b 100644 --- a/apps/management/templates/settings.html +++ b/apps/management/templates/settings.html @@ -439,7 +439,7 @@
diff --git a/apps/pla/views/views_pla.py b/apps/pla/views/views_pla.py index ca7258b..88374bc 100644 --- a/apps/pla/views/views_pla.py +++ b/apps/pla/views/views_pla.py @@ -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/") diff --git a/static/js/ol/dxf-parser.js b/static/js/ol/dxf-parser.js index da97bbe..03a477f 100644 --- a/static/js/ol/dxf-parser.js +++ b/static/js/ol/dxf-parser.js @@ -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", diff --git a/templates/default.html b/templates/default.html index bfeabcc..fb309e9 100644 --- a/templates/default.html +++ b/templates/default.html @@ -231,10 +231,15 @@