update : 15.10.2024 13:12:07,87
This commit is contained in:
parent
ebf44149ac
commit
83be9dfae4
@ -17,9 +17,16 @@ def get_settings(name,default):
|
||||
Settings.objects.create(
|
||||
name = name,
|
||||
value=default)
|
||||
return default
|
||||
result = default
|
||||
else:
|
||||
return settings_token.value
|
||||
result = settings_token.value
|
||||
|
||||
if result =='False':
|
||||
return False
|
||||
elif result =='True':
|
||||
return True
|
||||
else:
|
||||
return result
|
||||
|
||||
def get_all_settings():
|
||||
settings_list = Settings.objects.values()
|
||||
|
||||
@ -4,24 +4,14 @@
|
||||
|
||||
{% block header_link %}
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
|
||||
{% endblock header_link %}
|
||||
|
||||
{% block content %}
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1>Горнотранспортное оборудование</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="/">Главная</a></li>
|
||||
<li class="breadcrumb-item active">Горнотранспортное оборудование</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
</section>
|
||||
|
||||
<section class="content text-sm">
|
||||
<form id="list_acs" method="post" class="form-horizontal">
|
||||
@ -38,16 +28,19 @@
|
||||
<div class="col-md-12">
|
||||
<ul class="nav nav-tabs" id="custom-content-above-tab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="custom-content-above-home-tab" data-toggle="pill" href="#custom-content-above-home" role="tab" aria-controls="custom-content-above-home" aria-selected="true">Оборудование в работе ( {{clients_count}} шт. )</a>
|
||||
<a class="nav-link " id="custom-content-above-home-tab" data-toggle="pill" href="#custom-content-above-home" role="tab" aria-controls="custom-content-above-home" aria-selected="false">Оборудование в работе ( {{clients_count}} шт. )</a>
|
||||
</li>
|
||||
{% if user.profile.role == 1 %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="custom-content-above-profile-tab" data-toggle="pill" href="#custom-content-above-profile" role="tab" aria-controls="custom-content-above-profile" aria-selected="false">Заблокированное оборудование ( {{clients_count_block}} шт. )</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="custom-content-above-profile-tab" data-toggle="pill" href="#custom-content-map" role="tab" aria-controls="custom-content-map" aria-selected="true">Карта</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="custom-content-above-tabContent">
|
||||
<div class="tab-pane fade active show" id="custom-content-above-home" role="tabpanel" aria-labelledby="custom-content-above-home-tab">
|
||||
<div class="tab-pane fade" id="custom-content-above-home" role="tabpanel" aria-labelledby="custom-content-above-home-tab">
|
||||
<div class="card">
|
||||
<div class="card-header text-sm">
|
||||
{% block pagination_block %}
|
||||
@ -221,8 +214,17 @@
|
||||
</div> <!-- /.card -->
|
||||
</div>
|
||||
{% endif %}
|
||||
</div> </div> <!-- /.col -->
|
||||
</div><!-- <!-- /.row -->
|
||||
<div class="tab-pane fade active show" id="custom-content-map" role="tabpanel" aria-labelledby="custom-content-map-tab">
|
||||
<div class="card">
|
||||
<div class="card-body table-responsive p-0" style="height: 85vh; padding-left: 0;">
|
||||
<div id="map"></div>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /.col -->
|
||||
</div><!--
|
||||
|
||||
</div><!-- /.card-body -->
|
||||
</div>
|
||||
</div>
|
||||
@ -236,21 +238,36 @@
|
||||
|
||||
{% block script_footer %}
|
||||
<script>
|
||||
function delete_sensor(id) {
|
||||
var svg = `<svg title="dd" xmlns="http://www.w3.org/2000/svg" class="svg-icon" width="10px" height="10px">
|
||||
<circle cx="5" cy="5" r="4" fill="rgb(250, 127, 0)" stroke-width="1" stroke="black" opacity="1"/>
|
||||
</svg>`,
|
||||
domIcon = new H.map.DomIcon(svg),
|
||||
markers = []
|
||||
markers_id = []
|
||||
function update_object() {
|
||||
var Rec = $.ajax({
|
||||
method: 'POST',
|
||||
url: window.location.pathname + '?module=acs&cmd=delete',
|
||||
url: window.location.pathname + 'update_object/',
|
||||
async: true,
|
||||
data: {
|
||||
id: id,
|
||||
cmd: 'delete',
|
||||
},
|
||||
success: function (data) {
|
||||
document.getElementById("tr_" + id).remove();
|
||||
$('#large_' + id).modal('hide');
|
||||
$('body').removeClass('modal-open');
|
||||
$('body').css({ "height": "auto", "padding-right": "0px" });
|
||||
$('.modal-backdrop').remove();
|
||||
|
||||
for (index = data.length - 1; index >= 0; --index) {
|
||||
marker_index = markers_id.indexOf(data[index].id)
|
||||
marker = markers[marker_index]
|
||||
randomPoint ={lat: data[index].lat, lng: data[index].lon}
|
||||
ease(
|
||||
marker.getGeometry(),
|
||||
randomPoint,
|
||||
4000,
|
||||
function(coord) {
|
||||
//console.log(coord)
|
||||
marker.setGeometry(coord);
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
},
|
||||
error: function (dataerr) {
|
||||
$('#large_' + id).modal('hide');
|
||||
@ -258,8 +275,8 @@
|
||||
$('.modal-backdrop').remove();
|
||||
alert('Ошибка выполнение команды')
|
||||
|
||||
}
|
||||
//timeout: 120000
|
||||
},
|
||||
timeout: 120000
|
||||
|
||||
|
||||
});
|
||||
@ -267,5 +284,165 @@
|
||||
|
||||
}
|
||||
|
||||
function createMarkers() {
|
||||
|
||||
var Rec = $.ajax({
|
||||
method: 'POST',
|
||||
url: window.location.pathname + 'update_object/',
|
||||
async: true,
|
||||
data: {
|
||||
},
|
||||
success: function (data) {
|
||||
for (index = data.length - 1; index >= 0; --index) {
|
||||
markers.push(new H.map.DomMarker({lat: data[index].lat, lng: data[index].lon}, {
|
||||
icon: domIcon
|
||||
},data[index].id));
|
||||
markers_id.push(data[index].id)
|
||||
|
||||
|
||||
}
|
||||
map.addObjects(markers);
|
||||
},
|
||||
error: function (dataerr) {
|
||||
|
||||
},
|
||||
timeout: 120000
|
||||
|
||||
|
||||
});
|
||||
|
||||
// create markers
|
||||
/*initialPositions.forEach(function(pos) {
|
||||
markers.push(new H.map.DomMarker({lat: pos[0], lng: pos[1]}, {
|
||||
icon: domIcon
|
||||
}));
|
||||
});*/
|
||||
|
||||
// add markers to map
|
||||
|
||||
|
||||
// randomly update all markers positions in intervals
|
||||
// перемещение
|
||||
//setTimeout(updateMarkerPositions, 500);
|
||||
//setInterval(updateMarkerPositions, 5000);
|
||||
|
||||
/**
|
||||
* update all markers' positions with animation using the ease function
|
||||
*/
|
||||
/* function updateMarkerPositions() {
|
||||
markers.forEach(function(marker) {
|
||||
// get random position 0 - 450km from map's center in random direction
|
||||
let randomPoint = map.getCenter().walk(Math.random() * 3, Math.random() * 4);
|
||||
|
||||
// update marker's position within ease function callback
|
||||
ease(
|
||||
marker.getGeometry(),
|
||||
randomPoint,
|
||||
4000,
|
||||
function(coord) {
|
||||
|
||||
marker.setGeometry(coord);
|
||||
}
|
||||
)
|
||||
})
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
function ease(
|
||||
startCoord = {lat: 0, lng: 0},
|
||||
endCoord = {lat: 1, lng: 1},
|
||||
durationMs = 200,
|
||||
onStep = console.log,
|
||||
onComplete = function() {},
|
||||
) {
|
||||
console.log(endCoord.lat+ ' '+endCoord.lng)
|
||||
var raf = window.requestAnimationFrame || function(f) {window.setTimeout(f, 16)},
|
||||
stepCount = durationMs / 16,
|
||||
valueIncrementLat = (endCoord.lat - startCoord.lat) / stepCount,
|
||||
valueIncrementLng = (endCoord.lng - startCoord.lng) / stepCount,
|
||||
sinValueIncrement = Math.PI / stepCount,
|
||||
currentValueLat = startCoord.lat,
|
||||
currentValueLng = startCoord.lng,
|
||||
currentSinValue = 0;
|
||||
|
||||
function step() {
|
||||
currentSinValue += sinValueIncrement;
|
||||
//currentValueLat = endCoord.lat;
|
||||
//currentValueLng = endCoord.lng;
|
||||
|
||||
currentValueLat += valueIncrementLat * (Math.sin(currentSinValue) ** 2) * 2;
|
||||
currentValueLng += valueIncrementLng * (Math.sin(currentSinValue) ** 2) * 2;
|
||||
|
||||
if (currentSinValue < Math.PI) {
|
||||
onStep({lat: currentValueLat, lng: currentValueLng});
|
||||
raf(step);
|
||||
} else {
|
||||
onStep(endCoord);
|
||||
onComplete();
|
||||
}
|
||||
//onStep(endCoord);
|
||||
//onComplete();
|
||||
|
||||
}
|
||||
|
||||
raf(step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the map to display over Berlin
|
||||
*
|
||||
* @param {H.Map} map A HERE Map instance within the application
|
||||
*/
|
||||
function moveMapTolocation(map) {
|
||||
map.setCenter({ lat: {{lat}}, lng: {{lon}} });
|
||||
map.setZoom(14);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Boilerplate map initialization code starts below:
|
||||
*/
|
||||
|
||||
//Step 1: initialize communication with the platform
|
||||
// In your own code, replace variable window.apikey with your own apikey
|
||||
var platform = new H.service.Platform({
|
||||
apikey: '8hwYsYjgnywj3aNdHc9dLF7hLD3c2-ydDyY4tiawfNA'
|
||||
});
|
||||
var defaultLayers = platform.createDefaultLayers();
|
||||
|
||||
//Step 2: initialize a map - this map is centered over Europe
|
||||
var map = new H.Map(document.getElementById('map'),
|
||||
defaultLayers.vector.normal.map, {
|
||||
center: {
|
||||
lat: {{lat}}, lng: {{lon}} },
|
||||
zoom: 4,
|
||||
pixelRatio: window.devicePixelRatio || 1
|
||||
});
|
||||
// add a resize listener to make sure that the map occupies the whole container
|
||||
window.addEventListener('resize', () => map.getViewPort().resize());
|
||||
|
||||
//Step 3: make the map interactive
|
||||
// MapEvents enables the event system
|
||||
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
|
||||
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
|
||||
|
||||
// Create the default UI components
|
||||
var ui = H.ui.UI.createDefault(map, defaultLayers);
|
||||
moveMapTolocation(map);
|
||||
console.log('map start')
|
||||
|
||||
|
||||
|
||||
|
||||
createMarkers();
|
||||
// Now use the map as required...
|
||||
|
||||
window.onload = function () {
|
||||
update_object()
|
||||
setInterval('update_object()', 2000);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
|
||||
@ -11,5 +11,7 @@ urlpatterns = [
|
||||
url(r'^object/block/$', views_main.object_block, name='object_block'),
|
||||
url(r'^object/sensor/$', views_main.sensor_edit, name='sensor_edit'),
|
||||
url(r'^object/sensor/sensor_ajax/$', views_main.sensor_ajax, name='sensor_ajax'),
|
||||
url(r'^update_object/$', views_main.update_object, name='update_object'),
|
||||
|
||||
]
|
||||
|
||||
|
||||
@ -31,9 +31,31 @@ from apps.gto.models.model_sensors import Sensors
|
||||
from apps.gto.models.model_indicators import Indicators
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def sensor_ajax(request):
|
||||
def update_object(request):
|
||||
try:
|
||||
if request.method == "POST":
|
||||
sensor_dict = dict()
|
||||
param = request.POST.dict()
|
||||
object_list = Equipment.objects.all()
|
||||
m_list=[]
|
||||
for ob in object_list:
|
||||
object_dict = dict()
|
||||
object_dict.update(id = ob.id)
|
||||
object_dict.update(name = ob.name)
|
||||
object_dict.update(lat = ob.lat)
|
||||
object_dict.update(lon = ob.lon)
|
||||
m_list.append(object_dict)
|
||||
#break
|
||||
return generalmodule.ReturnJson(200,m_list)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def sensor_ajax(request):
|
||||
try:
|
||||
if request.method == "POST":
|
||||
sensor_dict = dict()
|
||||
@ -200,9 +222,9 @@ def map_index(request):
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'catalog_list':catalog_list,
|
||||
'objects_count':len(catalog_list),
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
'objects_count':len(catalog_list),
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
})
|
||||
return render(request,'gto_main.html', context)
|
||||
except Exception as err:
|
||||
@ -212,6 +234,9 @@ def map_index(request):
|
||||
@never_cache
|
||||
def main_index(request):
|
||||
try:
|
||||
mylon = str(float(settingsmodule.get_settings('longitude','86.10111978605353'))) # долгота центра
|
||||
mylat = str(float(settingsmodule.get_settings('latitude','55.344251210827814'))) # широта
|
||||
|
||||
param=request.GET.dict()
|
||||
clients=Equipment.objects.filter(block=False).order_by("-time",'name').all()
|
||||
clients_count = clients.count()
|
||||
@ -254,6 +279,8 @@ def main_index(request):
|
||||
'end_page_list':end_page_list,
|
||||
'start_page_list':start_page_list,
|
||||
'clients_count':clients_count,
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
})
|
||||
|
||||
if request.user.profile.role==1:
|
||||
@ -291,9 +318,7 @@ def main_index_block(page_number):
|
||||
next_url='page={}'.format(page.next_page_number())
|
||||
else:
|
||||
next_url=''
|
||||
|
||||
context = generalmodule.get_context_template()
|
||||
|
||||
context.update({
|
||||
'page_object_block' : page,
|
||||
'is_paginated_block':page.has_other_pages(),
|
||||
|
||||
@ -213,13 +213,13 @@
|
||||
<div class="form-group row">
|
||||
<label for="id_organization" class="col-sm-1 col-form-label">Широта : </label>
|
||||
<div class="col-sm-4">
|
||||
<input type="Number" name="latitude" value='{{latitude}}' placeholder='Широта' class="form-control" autofocus="" id="id_latitude">
|
||||
<input type="Number" name="latitude" step="0.000001" value='{{latitude}}' placeholder='Широта' class="form-control" autofocus="" id="id_latitude">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="id_organization" class="col-sm-1 col-form-label">Долгота : </label>
|
||||
<div class="col-sm-4">
|
||||
<input type="Number" name="longitude" value='{{longitude}}' placeholder='Долгота' class="form-control" autofocus="" id="id_longitude">
|
||||
<input type="Number" name="longitude" step="0.000001"value='{{longitude}}' placeholder='Долгота' class="form-control" autofocus="" id="id_longitude">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
1
apps/workerslocation/__init__.py
Normal file
1
apps/workerslocation/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
||||
1
apps/workerslocation/admin.py
Normal file
1
apps/workerslocation/admin.py
Normal file
@ -0,0 +1 @@
|
||||
from django.contrib import admin
|
||||
6
apps/workerslocation/apps.py
Normal file
6
apps/workerslocation/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class WorkersLocationConfig(AppConfig):
|
||||
name = 'apps.workerslocation'
|
||||
verbose_name = 'местоположение персонала'
|
||||
239
apps/workerslocation/templates/wklocation_map.html
Normal file
239
apps/workerslocation/templates/wklocation_map.html
Normal file
@ -0,0 +1,239 @@
|
||||
{% extends "default.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' %}">
|
||||
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
|
||||
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
|
||||
|
||||
{% endblock header_link %}
|
||||
|
||||
{% block content %}
|
||||
<section class="content">
|
||||
<div class="container-fluid ">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-body table-responsive p-0" style="height: 85vh; padding-left: 0;">
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap text-sm">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th>Сотрудники ({{objects_count}})</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% for catalog in catalog_list %}
|
||||
<tr style="padding-left:0;">
|
||||
<td>
|
||||
<form action="/ogr/edit/?id={{catalog.id}}" id="frm_name_{{catalog.id}}" method="POST" class="floatLeft butDelUser">
|
||||
{% csrf_token %}
|
||||
<a href="#" onclick="document.getElementById('frm_name_{{catalog.id}}').submit(); return false;">
|
||||
{{ catalog.name }}
|
||||
</a>
|
||||
<input type="hidden" value="{{catalog.id}}" name="id">
|
||||
</form>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="text-muted">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
</div> <!-- /.row -->
|
||||
<div class="col-md-9">
|
||||
<div class="card">
|
||||
<div class="card-body table-responsive p-0" style="height: 85vh; padding-left: 0;">
|
||||
<div id="map"></div>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
</div> <!-- /.row -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block script_footer %}
|
||||
<script>
|
||||
|
||||
function createMarkers() {
|
||||
// create SVG Dom Icon
|
||||
var svg = `<svg xmlns="http://www.w3.org/2000/svg" class="svg-icon" width="10px" height="10px">
|
||||
<circle cx="5" cy="5" r="4" fill="rgb(250, 127, 0)" stroke-width="1" stroke="black" opacity="1"/>
|
||||
</svg>`,
|
||||
domIcon = new H.map.DomIcon(svg),
|
||||
markers = [],
|
||||
// array of initial positions of 40 markers
|
||||
initialPositions = [
|
||||
[53.9919212108278, 86.6710607860535],
|
||||
/*[50.98194, 12.50638],
|
||||
[51.83169, 12.19096],
|
||||
[52.19585, 14.58753],
|
||||
[51.30805, 13.55555],
|
||||
[51.36305, 11.94083],
|
||||
[51.55222, 12.05388],
|
||||
[51.29360, 13.35611],
|
||||
[53.30638, 12.75222],
|
||||
[52.58055, 13.91666],
|
||||
[52.20360, 13.15638],
|
||||
[54.03825, 12.71051],
|
||||
[50.91527, 11.71444],
|
||||
[52.91888, 12.42527],
|
||||
[52.07361, 11.62638],
|
||||
[51.36333, 14.94999],
|
||||
[53.83277, 13.66861],
|
||||
[51.88944, 14.53194],
|
||||
[51.29694, 14.12749],
|
||||
[52.38000, 13.52250],
|
||||
[51.13280, 13.76720],
|
||||
[50.97980, 10.95810],
|
||||
[50.02233, 8.57055],
|
||||
[52.13460, 7.68482],
|
||||
[53.63040, 9.98822],
|
||||
[52.47259, 13.40390],
|
||||
[50.86589, 7.14273],
|
||||
[51.22701, 6.76677],
|
||||
[48.35380, 11.7861],
|
||||
[49.49869, 11.07805],
|
||||
[51.42388, 12.23308],
|
||||
[49.21459, 7.10950],
|
||||
[48.68989, 9.22196],
|
||||
[52.35970, 13.28769],
|
||||
[52.46110, 9.68479],
|
||||
[53.04750, 8.78665],
|
||||
[49.69999, 8.64583],
|
||||
[49.94869, 7.26388],
|
||||
[49.47305, 8.51416],
|
||||
[51.03499, 8.68083]*/
|
||||
];
|
||||
|
||||
// create markers
|
||||
initialPositions.forEach(function(pos) {
|
||||
markers.push(new H.map.DomMarker({lat: pos[0], lng: pos[1]}, {
|
||||
icon: domIcon
|
||||
}));
|
||||
});
|
||||
|
||||
// add markers to map
|
||||
map.addObjects(markers);
|
||||
|
||||
// randomly update all markers positions in intervals
|
||||
setTimeout(updateMarkerPositions, 500);
|
||||
setInterval(updateMarkerPositions, 5000);
|
||||
|
||||
/**
|
||||
* update all markers' positions with animation using the ease function
|
||||
*/
|
||||
function updateMarkerPositions() {
|
||||
markers.forEach(function(marker) {
|
||||
// get random position 0 - 450km from map's center in random direction
|
||||
let randomPoint = map.getCenter().walk(Math.random() * 3, Math.random() * 4);
|
||||
|
||||
// update marker's position within ease function callback
|
||||
ease(
|
||||
marker.getGeometry(),
|
||||
randomPoint,
|
||||
4000,
|
||||
function(coord) {
|
||||
marker.setGeometry(coord);
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ease(
|
||||
startCoord = {lat: 0, lng: 0},
|
||||
endCoord = {lat: 1, lng: 1},
|
||||
durationMs = 200,
|
||||
onStep = console.log,
|
||||
onComplete = function() {},
|
||||
) {
|
||||
var raf = window.requestAnimationFrame || function(f) {window.setTimeout(f, 16)},
|
||||
stepCount = durationMs / 16,
|
||||
valueIncrementLat = (endCoord.lat - startCoord.lat) / stepCount,
|
||||
valueIncrementLng = (endCoord.lng - startCoord.lng) / stepCount,
|
||||
sinValueIncrement = Math.PI / stepCount,
|
||||
currentValueLat = startCoord.lat,
|
||||
currentValueLng = startCoord.lng,
|
||||
currentSinValue = 0;
|
||||
|
||||
function step() {
|
||||
currentSinValue += sinValueIncrement;
|
||||
currentValueLat += valueIncrementLat * (Math.sin(currentSinValue) ** 2) * 2;
|
||||
currentValueLng += valueIncrementLng * (Math.sin(currentSinValue) ** 2) * 2;
|
||||
|
||||
if (currentSinValue < Math.PI) {
|
||||
onStep({lat: currentValueLat, lng: currentValueLng});
|
||||
raf(step);
|
||||
} else {
|
||||
onStep(endCoord);
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
raf(step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the map to display over Berlin
|
||||
*
|
||||
* @param {H.Map} map A HERE Map instance within the application
|
||||
*/
|
||||
function moveMapTolocation(map) {
|
||||
map.setCenter({ lat: {{lat}}, lng: {{lon}} });
|
||||
map.setZoom(14);
|
||||
}
|
||||
|
||||
/**
|
||||
* Boilerplate map initialization code starts below:
|
||||
*/
|
||||
|
||||
//Step 1: initialize communication with the platform
|
||||
// In your own code, replace variable window.apikey with your own apikey
|
||||
var platform = new H.service.Platform({
|
||||
apikey: '8hwYsYjgnywj3aNdHc9dLF7hLD3c2-ydDyY4tiawfNA'
|
||||
});
|
||||
var defaultLayers = platform.createDefaultLayers();
|
||||
|
||||
//Step 2: initialize a map - this map is centered over Europe
|
||||
var map = new H.Map(document.getElementById('map'),
|
||||
defaultLayers.vector.normal.map, {
|
||||
center: {
|
||||
lat: {{lat}}, lng: {{lon}} },
|
||||
zoom: 4,
|
||||
pixelRatio: window.devicePixelRatio || 1
|
||||
});
|
||||
// add a resize listener to make sure that the map occupies the whole container
|
||||
window.addEventListener('resize', () => map.getViewPort().resize());
|
||||
|
||||
//Step 3: make the map interactive
|
||||
// MapEvents enables the event system
|
||||
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
|
||||
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
|
||||
|
||||
// Create the default UI components
|
||||
var ui = H.ui.UI.createDefault(map, defaultLayers);
|
||||
|
||||
// Now use the map as required...
|
||||
window.onload = function () {
|
||||
moveMapTolocation(map);
|
||||
}
|
||||
createMarkers();
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
15
apps/workerslocation/urls.py
Normal file
15
apps/workerslocation/urls.py
Normal file
@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.conf.urls import url
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.conf.urls import include # Используйте include() чтобы добавлять URL из каталога приложения
|
||||
|
||||
from apps.workerslocation.views import views_main
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views_main.main_index, name='main_index'),
|
||||
#url(r'^object/$', views_main.object_edit, name='object_edit'),
|
||||
#url(r'^object/block/$', views_main.object_block, name='object_block'),
|
||||
#url(r'^object/sensor/$', views_main.sensor_edit, name='sensor_edit'),
|
||||
#url(r'^object/sensor/sensor_ajax/$', views_main.sensor_ajax, name='sensor_ajax'),
|
||||
]
|
||||
|
||||
320
apps/workerslocation/views/views_main.py
Normal file
320
apps/workerslocation/views/views_main.py
Normal file
@ -0,0 +1,320 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import traceback
|
||||
import os
|
||||
import io
|
||||
import json
|
||||
import requests
|
||||
|
||||
from datetime import datetime,timedelta
|
||||
|
||||
from django.db.models import Q
|
||||
from django.core import exceptions
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.db.models import Avg, Max, Min
|
||||
from django import forms
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect
|
||||
|
||||
from sabron.util import logging
|
||||
from apps.util import generalmodule
|
||||
|
||||
from apps.general.models.model_settings import Settings
|
||||
|
||||
from apps.general.views import settingsmodule
|
||||
|
||||
from apps.gto.models.model_equipment import Equipment
|
||||
from apps.gto.models.model_sensors import Sensors
|
||||
from apps.gto.models.model_indicators import Indicators
|
||||
|
||||
from apps.workerslocation.views import views_radiusapi
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def sensor_ajax(request):
|
||||
try:
|
||||
if request.method == "POST":
|
||||
sensor_dict = dict()
|
||||
param = request.POST.dict()
|
||||
sensor = Sensors.objects.filter(id=param['id']).first()
|
||||
if sensor is None:
|
||||
m_sensor = []
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
time = sensor.time
|
||||
value = sensor.value
|
||||
end_date=sensor.time+timedelta(seconds=15)
|
||||
|
||||
value_old = 0
|
||||
if param['sensor_type'] == 'sec':
|
||||
strftime = "%d.%m.%Y %H:%M:%S"
|
||||
start_date = end_date - timedelta(seconds=30)
|
||||
sensor_links = Indicators.objects.filter(sensor=sensor).filter(time__range=[start_date,end_date-timedelta(seconds=15)]).order_by('time').order_by('id')
|
||||
if sensor_links.count()==0 :
|
||||
sensor_link = AcsIndicators.objects.filter(sensor=sensor).filter(time__lte=end_date).order_by('-time').first()
|
||||
numsec = 31
|
||||
date_list = [sensor.time - timedelta(seconds=x) for x in range(numsec)]
|
||||
m_sensor = []
|
||||
for i in range(numsec):
|
||||
status = 0
|
||||
sensor_dict = dict()
|
||||
sensor_dict.update(date_max=str(time))
|
||||
sensor_dict.update(sn=sensor.id)
|
||||
sensor_dict.update(time=sensor.time.strftime("%d.%m.%Y %H:%M:%S"))
|
||||
sensor_dict.update(time = date_list[30-i].strftime(strftime))
|
||||
sensor_dict.update(value = sensor_link.value)
|
||||
delta = (datetime.now()-sensor.time).total_seconds()
|
||||
if delta>60:
|
||||
status = 1
|
||||
sensor_dict.update(status = status)
|
||||
m_sensor.append(sensor_dict)
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
elif param['sensor_type'] == 'min':
|
||||
strftime = "%d.%m.%Y %H:%M"
|
||||
start_date = end_date - timedelta(minutes=30)
|
||||
sensor_links = Indicators.objects.filter(sensor=sensor).filter(time__range=[start_date,end_date]).order_by('time').order_by('id')
|
||||
value_old = 0
|
||||
else:
|
||||
strftime = "%d.%m.%Y %H:00"
|
||||
start_date = end_date - timedelta(hours=30)
|
||||
sensor_links = Indicators.objects.filter(sensor=sensor).filter(time__range=[start_date,end_date]).order_by('time').order_by('id')
|
||||
value_old = 0
|
||||
strftimeend = "%d.%m.%Y %H"
|
||||
m_sensor = []
|
||||
for i in range(31):
|
||||
if param['sensor_type'] == 'sec':
|
||||
strftimeend = "%d.%m.%Y %H:%M:%S"
|
||||
time = start_date + timedelta(seconds=i)
|
||||
start_date_day = time
|
||||
|
||||
end_date_day = time+ timedelta(milliseconds=1000)
|
||||
elif param['sensor_type'] == 'min':
|
||||
strftimeend = "%d.%m.%Y %H:%M"
|
||||
time = start_date + timedelta(minutes=i)
|
||||
start_date_day = datetime(time.year, time.month, time.day,time.hour,time.minute,0)
|
||||
end_date_day = datetime(time.year, time.month, time.day,time.hour,time.minute,59,9999)
|
||||
else:
|
||||
strftimeend = "%d.%m.%Y %H"
|
||||
time = start_date + timedelta(hours=i)
|
||||
start_date_day = datetime(time.year, time.month, time.day,time.hour,0,0)
|
||||
end_date_day = datetime(time.year, time.month, time.day,time.hour,59,59,9999)
|
||||
status = 0
|
||||
sensor_dict = dict()
|
||||
sensor_dict.update(sn=sensor.id)
|
||||
sensor_dict.update(date_max=str(time))
|
||||
sensor_dict.update(time=sensor.time.strftime("%d.%m.%Y %H:%M:%S"))
|
||||
result = sensor_links.filter(time__range=[start_date_day,end_date_day]).aggregate(Max('value'))
|
||||
sensor_dict.update(time = time.strftime(strftime))
|
||||
if result['value__max'] == None:
|
||||
sensor_dict.update(value = sensor.value)
|
||||
else:
|
||||
value_old = result['value__max']
|
||||
sensor_dict.update(value = result['value__max'])
|
||||
delta = (datetime.now()-sensor.time).total_seconds()
|
||||
if delta>60:
|
||||
status = 1
|
||||
sensor_dict.update(status = status)
|
||||
m_sensor.append(sensor_dict)
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def sensor_edit(request):
|
||||
try:
|
||||
get_param=request.GET.dict()
|
||||
element = Sensors.objects.filter(id=get_param['id']).first()
|
||||
now = datetime.now()
|
||||
start_date = now - timedelta(hours=0, minutes=0)
|
||||
sensor_list = Indicators.objects.filter(sensor=element).filter(time__range=[start_date, now]).order_by('-time').all()
|
||||
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'sensor':element,
|
||||
'sensor_list':sensor_list,
|
||||
|
||||
})
|
||||
return render(request,'sensor_edit.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def object_edit(request):
|
||||
try:
|
||||
get_param=request.GET.dict()
|
||||
element = Equipment.objects.filter(id=get_param['id']).first()
|
||||
|
||||
sensor_list = Sensors.objects.filter(equipment=element).order_by('name').all()
|
||||
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'sensor':element,
|
||||
'sensor_list':sensor_list,
|
||||
})
|
||||
return render(request,'object_edit.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def object_block(request):
|
||||
try:
|
||||
get_param=request.GET.dict()
|
||||
element = Equipment.objects.filter(id=get_param['id']).first()
|
||||
if element.block:
|
||||
element.block=False;
|
||||
else:
|
||||
element.block=True;
|
||||
element.save()
|
||||
return redirect('/gto/')
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def map_index(request):
|
||||
try:
|
||||
|
||||
|
||||
|
||||
mylon = str(float(settingsmodule.get_settings('longitude','86.10111978605353'))) # долгота центра
|
||||
mylat = str(float(settingsmodule.get_settings('latitude','55.344251210827814'))) # широта
|
||||
|
||||
gtoadress = settingsmodule.get_settings('gtoadress','')
|
||||
gtouid = settingsmodule.get_settings('gtouid','')
|
||||
response = requests.get(f'{gtoadress}main?func=state&uid={gtouid}&sensors&out=json')
|
||||
json_data = json.loads(response.text)
|
||||
catalog_list=[]
|
||||
if json_data['result']=='OK':
|
||||
for data in json_data['objects']:
|
||||
#print(data)
|
||||
objects=dict()
|
||||
objects.update(id=data['id'])
|
||||
objects.update(name=data['name'])
|
||||
objects.update(lat=data['lat'])
|
||||
objects.update(lon=data['lon'])
|
||||
catalog_list.append(objects)
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'catalog_list':catalog_list,
|
||||
'objects_count':len(catalog_list),
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
})
|
||||
return render(request,'gto_main.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def main_index(request):
|
||||
try:
|
||||
radiusapi = settingsmodule.get_settings('radiusapi','False')
|
||||
|
||||
if radiusapi:
|
||||
return views_radiusapi.map_index(request)
|
||||
|
||||
|
||||
param=request.GET.dict()
|
||||
clients=Equipment.objects.filter(block=False).order_by("-time",'name').all()
|
||||
clients_count = clients.count()
|
||||
paginator = Paginator(clients, 50)
|
||||
page_number = request.GET.get('page',1)
|
||||
page_number_block = request.GET.get('page_block',1)
|
||||
page=paginator.get_page(page_number)
|
||||
num_pages=page.paginator.num_pages
|
||||
num_pages_krat = num_pages//30
|
||||
list_num = int(page_number)//30
|
||||
if list_num<int(page_number)/30:
|
||||
list_num=list_num+1
|
||||
page_list_end=(list_num*30)+1
|
||||
if page_list_end>num_pages:
|
||||
page_list_end=num_pages+1
|
||||
page_list_start=((list_num*30)-30)+1
|
||||
if page_list_start<1:
|
||||
page_list_start=1
|
||||
page_list=range(page_list_start,page_list_end)
|
||||
end_page_list=list_num*30
|
||||
start_page_list=(list_num*30)-29
|
||||
if page.has_previous():
|
||||
perv_url='page={}'.format(page.previous_page_number())
|
||||
else:
|
||||
perv_url=''
|
||||
if page.has_next():
|
||||
next_url='page={}'.format(page.next_page_number())
|
||||
else:
|
||||
next_url=''
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'page_object' : page,
|
||||
'is_paginated':page.has_other_pages(),
|
||||
'perv_url':perv_url,
|
||||
'next_url':next_url,
|
||||
'num_pages':num_pages,
|
||||
'menuopen':'menu-open',
|
||||
'puti':'Главная',
|
||||
'page_list':page_list,
|
||||
'end_page_list':end_page_list,
|
||||
'start_page_list':start_page_list,
|
||||
'clients_count':clients_count,
|
||||
})
|
||||
|
||||
if request.user.profile.role==1:
|
||||
context.update(main_index_block(page_number_block))
|
||||
return render(request,'gto_main.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
def main_index_block(page_number):
|
||||
try:
|
||||
clients=Equipment.objects.filter(block=True).order_by("-time",'name').all()
|
||||
clients_count = clients.count()
|
||||
paginator = Paginator(clients, 50)
|
||||
page=paginator.get_page(page_number)
|
||||
num_pages=page.paginator.num_pages
|
||||
num_pages_krat = num_pages//30
|
||||
list_num = int(page_number)//30
|
||||
if list_num<int(page_number)/30:
|
||||
list_num=list_num+1
|
||||
page_list_end=(list_num*30)+1
|
||||
if page_list_end>num_pages:
|
||||
page_list_end=num_pages+1
|
||||
page_list_start=((list_num*30)-30)+1
|
||||
if page_list_start<1:
|
||||
page_list_start=1
|
||||
page_list=range(page_list_start,page_list_end)
|
||||
end_page_list=list_num*30
|
||||
start_page_list=(list_num*30)-29
|
||||
if page.has_previous():
|
||||
perv_url='page={}'.format(page.previous_page_number())
|
||||
else:
|
||||
perv_url=''
|
||||
if page.has_next():
|
||||
next_url='page={}'.format(page.next_page_number())
|
||||
else:
|
||||
next_url=''
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'page_object_block' : page,
|
||||
'is_paginated_block':page.has_other_pages(),
|
||||
'perv_url_block':perv_url,
|
||||
'next_url_block':next_url,
|
||||
'num_pages_block':num_pages,
|
||||
'page_list_block':page_list,
|
||||
'end_page_list_block':end_page_list,
|
||||
'start_page_list_block':start_page_list,
|
||||
'clients_count_block':clients_count,
|
||||
})
|
||||
return context
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
52
apps/workerslocation/views/views_radiusapi.py
Normal file
52
apps/workerslocation/views/views_radiusapi.py
Normal file
@ -0,0 +1,52 @@
|
||||
import traceback
|
||||
import os
|
||||
import io
|
||||
import json
|
||||
import requests
|
||||
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect
|
||||
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.decorators.cache import never_cache
|
||||
|
||||
|
||||
from sabron.util import logging
|
||||
from apps.util import generalmodule
|
||||
|
||||
from apps.general.views import settingsmodule
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def map_index(request):
|
||||
try:
|
||||
|
||||
mylon = str(float(settingsmodule.get_settings('longitude','86.10111978605353'))) # долгота центра
|
||||
mylat = str(float(settingsmodule.get_settings('latitude','55.344251210827814'))) # широта
|
||||
|
||||
gtoadress = settingsmodule.get_settings('gtoadress','')
|
||||
gtouid = settingsmodule.get_settings('gtouid','')
|
||||
response = requests.get(f'{gtoadress}main?func=state&uid={gtouid}&sensors&out=json')
|
||||
json_data = json.loads(response.text)
|
||||
catalog_list=[]
|
||||
if json_data['result']=='OK':
|
||||
for data in json_data['objects']:
|
||||
#print(data)
|
||||
objects=dict()
|
||||
objects.update(id=data['id'])
|
||||
objects.update(name=data['name'])
|
||||
objects.update(lat=data['lat'])
|
||||
objects.update(lon=data['lon'])
|
||||
catalog_list.append(objects)
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'catalog_list':catalog_list,
|
||||
'objects_count':len(catalog_list),
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
})
|
||||
return render(request,'wklocation_map.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
@ -27,10 +27,12 @@ INSTALLED_APPS = [
|
||||
|
||||
'apps.schedulers.apps.SchedulersConfig', # Планировщик
|
||||
'apps.about.apps.AboutConfig', # О системе
|
||||
#Модуль оповещения по тревогам
|
||||
#Модуль оповещения по тревогам
|
||||
'apps.pla.apps.PlaConfig',
|
||||
#Параметры системы
|
||||
'apps.general.apps.GeneralConfig',
|
||||
#Параметры системы
|
||||
'apps.general.apps.GeneralConfig',
|
||||
#Местоположение персонала
|
||||
'apps.workerslocation.apps.WorkersLocationConfig',
|
||||
|
||||
'django_cleanup.apps.CleanupConfig',
|
||||
]
|
||||
@ -38,7 +40,7 @@ INSTALLED_APPS = [
|
||||
"""Информация о приложении """
|
||||
SITE_TITLE = u'Многофункциональная система безопасности ОГР'
|
||||
SITE_TITLE_S = u'МФСБ ОГР'
|
||||
APP_VER = u'1.0.04.4'
|
||||
APP_VER = u'1.0.04.5'
|
||||
APP_VEK = u'2023 - 2024гг'
|
||||
APP_COPPIRIGHT = u'Многофункциональная система безопасности ОГР'
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ urlpatterns = [
|
||||
url(r'^ogr/', include('apps.ogr.urls')),
|
||||
url(r'^pla/', include('apps.pla.urls')),
|
||||
url(r'^management/', include('apps.management.urls')),
|
||||
|
||||
url(r'^wklocation/', include('apps.workerslocation.urls')),
|
||||
url(r'^about/', include('apps.about.urls')),
|
||||
|
||||
]
|
||||
|
||||
@ -8,78 +8,82 @@ from django.http import HttpResponseRedirect
|
||||
|
||||
from users.models import Profile
|
||||
|
||||
from apps.util import generalmodule
|
||||
from apps.util import generalmodule
|
||||
|
||||
def user_block(request,user):
|
||||
profile=Profile.objects.filter(user=user).first()
|
||||
|
||||
def user_block(request, user):
|
||||
profile = Profile.objects.filter(user=user).first()
|
||||
if not profile:
|
||||
return False;
|
||||
return False
|
||||
if profile.block:
|
||||
return False
|
||||
return True
|
||||
|
||||
def user_api(request,user):
|
||||
profile=Profile.objects.filter(user=user).first()
|
||||
|
||||
def user_api(request, user):
|
||||
profile = Profile.objects.filter(user=user).first()
|
||||
if not profile:
|
||||
return False;
|
||||
return False
|
||||
if profile.api_client:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def user_login(request):
|
||||
if request.method == 'POST':
|
||||
username = request.POST.get('username')
|
||||
password = request.POST.get('password')
|
||||
user = authenticate(username=username, password=password)
|
||||
if user:
|
||||
if user_api(request,user):
|
||||
context={
|
||||
'error' :True,
|
||||
'comment':'API пользователь не имеет доступ к Личному Кабинету',
|
||||
}
|
||||
messages.error(request,'Пользователь не имеет доступ к Личному Кабинету')
|
||||
if user_api(request, user):
|
||||
context = {
|
||||
'error': True,
|
||||
'comment': 'API пользователь не имеет доступ к Личному Кабинету',
|
||||
}
|
||||
messages.error(
|
||||
request, 'Пользователь не имеет доступ к Личному Кабинету')
|
||||
return render(request, 'registration/login.html', context)
|
||||
|
||||
if user_block(request,user):
|
||||
if user_block(request, user):
|
||||
login(request, user)
|
||||
context={
|
||||
'user' : user,
|
||||
'login' :username,
|
||||
'logout':'accounts/logout/',
|
||||
}
|
||||
context = {
|
||||
'user': user,
|
||||
'login': username,
|
||||
'logout': 'accounts/logout/',
|
||||
}
|
||||
return HttpResponseRedirect('/', context)
|
||||
else:
|
||||
context={
|
||||
'error' :True,
|
||||
'login' :username,
|
||||
'comment':'Пользователь заблокирован',
|
||||
}
|
||||
messages.error(request,'Пользователь заблокирован')
|
||||
context = {
|
||||
'error': True,
|
||||
'login': username,
|
||||
'comment': 'Пользователь заблокирован',
|
||||
}
|
||||
messages.error(request, 'Пользователь заблокирован')
|
||||
return render(request, 'registration/login.html', context)
|
||||
else:
|
||||
context={
|
||||
'error' :True,
|
||||
'login' :username,
|
||||
'comment':'Не верный логин или пароль',
|
||||
}
|
||||
messages.error(request,'Не верный логин или пароль')
|
||||
context = {
|
||||
'error': True,
|
||||
'login': username,
|
||||
'comment': 'Не верный логин или пароль',
|
||||
}
|
||||
messages.error(request, 'Не верный логин или пароль')
|
||||
return render(request, 'registration/login.html', context)
|
||||
else:
|
||||
if request.user.is_anonymous :
|
||||
context={
|
||||
'error' :False,
|
||||
'comment':'',
|
||||
}
|
||||
if request.user.is_anonymous:
|
||||
context = {
|
||||
'error': False,
|
||||
'comment': '',
|
||||
}
|
||||
return render(request, 'registration/login.html', context)
|
||||
|
||||
else:
|
||||
return redirect("/")
|
||||
|
||||
|
||||
|
||||
def user_logout(request):
|
||||
logout(request)
|
||||
context={
|
||||
'user' : '',
|
||||
'logout':'accounts/logout/',
|
||||
}
|
||||
return HttpResponseRedirect('/', context)
|
||||
context = {
|
||||
'user': '',
|
||||
'logout': 'accounts/logout/',
|
||||
}
|
||||
return HttpResponseRedirect('/', context)
|
||||
|
||||
2
start.py
2
start.py
@ -94,4 +94,4 @@ if __name__ == "__main__":
|
||||
#Indicators.objects.all().delete()
|
||||
#Sensors.objects.all().delete()
|
||||
|
||||
#tasks.load_navigation()
|
||||
tasks.load_navigation()
|
||||
|
||||
@ -1,68 +1,112 @@
|
||||
<html lang="ru">
|
||||
{% load static %}
|
||||
{% load mysettings %}
|
||||
{% load static %} {% load mysettings %}
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>{% settings_value 'SITE_TITLE_S' %} : {{ user}}</title>
|
||||
|
||||
<!-- Google Font: Source Sans Pro -->
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback"
|
||||
/>
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/fontawesome-free/css/all.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/fontawesome-free/css/all.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- Tempusdominus Bootstrap 4 -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- 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' %}">
|
||||
<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 -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- JQVMap -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/jqvmap/jqvmap.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
|
||||
<!-- <link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">-->
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/jqvmap/jqvmap.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
|
||||
<!-- <link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">-->
|
||||
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="{% static 'lte/dist/css/adminlte.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/dist/css/adminlte.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- overlayScrollbars -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- Daterange picker -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/daterangepicker/daterangepicker.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/daterangepicker/daterangepicker.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
<!-- summernote -->
|
||||
<link rel="stylesheet" href="{% static 'lte/plugins/summernote/summernote-bs4.min.css' %}?ver={% settings_value 'APP_VER' %}">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{% static 'lte/plugins/summernote/summernote-bs4.min.css' %}?ver={% settings_value 'APP_VER' %}"
|
||||
/>
|
||||
|
||||
|
||||
{% block header_link %}
|
||||
{% endblock header_link %}
|
||||
{% block header_link %} {% endblock header_link %}
|
||||
<style type="text/css">
|
||||
.adisabled {
|
||||
pointer-events: none; /* делаем ссылку некликабельной */
|
||||
cursor: default; /* устанавливаем курсор в виде стрелки */
|
||||
.adisabled {
|
||||
pointer-events: none; /* делаем ссылку некликабельной */
|
||||
cursor: default; /* устанавливаем курсор в виде стрелки */
|
||||
color: #dedada; /* цвет текста для нективной ссылки */
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="hold-transition sidebar-mini layout-fixed text-sm layout-footer-fixed">
|
||||
</head>
|
||||
<body
|
||||
class="hold-transition sidebar-mini layout-fixed text-sm layout-footer-fixed"
|
||||
>
|
||||
<div class="wrapper">
|
||||
<!-- Navbar -->
|
||||
<nav class="main-header navbar navbar-expand navbar-fixed-top text-sm bg-white" style='position:sticky; top:0px; left;0;'>
|
||||
<!-- Left navbar links -->
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Right navbar links -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown mr-3 lead">
|
||||
<a class="nav-link dropdown-toggle d-flex align-items-center" href="#" id="profileDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-user-circle mr-2 "></i>
|
||||
{{user}}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="profileDropdown">
|
||||
<!--<a class="dropdown-item" href="/dashboard/profile/">
|
||||
<!-- Navbar -->
|
||||
<nav
|
||||
class="main-header navbar navbar-expand navbar-fixed-top text-sm bg-white"
|
||||
style="position:sticky; top:0px; left;0;"
|
||||
>
|
||||
<!-- Left navbar links -->
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"
|
||||
><i class="fas fa-bars"></i
|
||||
></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Right navbar links -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown mr-3 lead">
|
||||
<a
|
||||
class="nav-link dropdown-toggle d-flex align-items-center"
|
||||
href="#"
|
||||
id="profileDropdown"
|
||||
role="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
>
|
||||
<i class="fa fa-user-circle mr-2"></i>
|
||||
{{user}}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="profileDropdown">
|
||||
<!--<a class="dropdown-item" href="/dashboard/profile/">
|
||||
<i class="fas fa-id-card"></i>
|
||||
Профиль
|
||||
</a>
|
||||
@ -70,89 +114,143 @@
|
||||
<i class="fas fa-cog"></i>
|
||||
Параметры
|
||||
</a>-->
|
||||
{% if user.profile.role == 2 %}
|
||||
<a class="dropdown-item" href="/management/">
|
||||
<i class="fas fa-cog"></i>
|
||||
Администрирование
|
||||
</a>
|
||||
{% if user.profile.role == 2 %}
|
||||
<a class="dropdown-item" href="/management/">
|
||||
<i class="fas fa-cog"></i>
|
||||
Администрирование
|
||||
</a>
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="/accounts/logout/?next=/accounts/login/" class="dropdown-item">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
Выход
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- /.navbar -->
|
||||
<!-- Main Sidebar Container -->
|
||||
<aside class="main-sidebar sidebar-light-maroon">
|
||||
<!-- Brand Logo -->
|
||||
<a href="/" class="brand-link text-black text-sm">
|
||||
<img src="{% static 'img/login_logo.png' %}?ver={% settings_value 'APP_VER' %}" alt="{% settings_value 'SITE_TITLE' %}" class="brand-image " style="opacity: .8">
|
||||
<span class="brand-text font-weight-light">МФСБ : ОГР </span>
|
||||
</a>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar">
|
||||
<div class="os-padding">
|
||||
<div class="os-viewport os-viewport-native-scrollbars-invisible" style="overflow-y: scroll;">
|
||||
<div class="os-content" style="padding: 0px 8px; height: 100%; width: 100%;">
|
||||
<!-- Sidebar Menu -->
|
||||
<nav class="mt-2">
|
||||
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item"><a href="/geoproc/" class="nav-link"><i class="nav-icon fas fa-soap"></i><p> Геомеханические процессы</p></a></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item"><a href="/seismicproc/" class="nav-link"><i class="nav-icon fas fa-globe-europe"></i><p>Сейсмические процессы</p></a></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item"><a href="/gto/" class="nav-link"><i class="nav-icon fas fa-snowplow"></i><p>Горнотранспортное оборудование</p></a></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item"><a href="/ogr/" class="nav-link"><i class="nav-icon fa fa-code-branch"></i><p>Открытые горные работы</p></a></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></li>
|
||||
<li class="nav-header "></li>
|
||||
<li class="nav-item adisabled"><a href="#" class="nav-link"><i class="nav-icon fas fa-map-marked"></i><p><del>Местоположение персонала</del></p></a></li>
|
||||
{% if user.profile.role == 1 %}
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item"><a href="/management/" class="nav-link"><i class="nav-icon fas fa-sliders-h"></i><p>Администрирование</p></a></li>
|
||||
{%endif%}
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- /.sidebar-menu -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a
|
||||
href="/accounts/logout/?next=/accounts/login/"
|
||||
class="dropdown-item"
|
||||
>
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
Выход
|
||||
</a>
|
||||
</div>
|
||||
<!-- /.sidebar -->
|
||||
</aside>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- /.navbar -->
|
||||
<!-- Main Sidebar Container -->
|
||||
<aside class="main-sidebar sidebar-light-maroon">
|
||||
<!-- Brand Logo -->
|
||||
<a href="/" class="brand-link text-black text-sm">
|
||||
<img
|
||||
src="{% static 'img/login_logo.png' %}?ver={% settings_value 'APP_VER' %}"
|
||||
alt="{% settings_value 'SITE_TITLE' %}"
|
||||
class="brand-image"
|
||||
style="opacity: 0.8"
|
||||
/>
|
||||
<span class="brand-text font-weight-light">МФСБ : ОГР </span>
|
||||
</a>
|
||||
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<div class="content">
|
||||
<div class="container-fluid">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar">
|
||||
<div class="os-padding">
|
||||
<div
|
||||
class="os-viewport os-viewport-native-scrollbars-invisible"
|
||||
style="overflow-y: scroll"
|
||||
>
|
||||
<div
|
||||
class="os-content"
|
||||
style="padding: 0px 8px; height: 100%; width: 100%"
|
||||
>
|
||||
<!-- Sidebar Menu -->
|
||||
<nav class="mt-2">
|
||||
<ul
|
||||
class="nav nav-pills nav-sidebar flex-column"
|
||||
data-widget="treeview"
|
||||
role="menu"
|
||||
data-accordion="false"
|
||||
>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item">
|
||||
<a href="/geoproc/" class="nav-link"
|
||||
><i class="nav-icon fas fa-soap"></i>
|
||||
<p>Геомеханические процессы</p></a
|
||||
>
|
||||
</li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item">
|
||||
<a href="/seismicproc/" class="nav-link"
|
||||
><i class="nav-icon fas fa-globe-europe"></i>
|
||||
<p>Сейсмические процессы</p></a
|
||||
>
|
||||
</li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item">
|
||||
<a href="/gto/" class="nav-link"
|
||||
><i class="nav-icon fas fa-snowplow"></i>
|
||||
<p>Горнотранспортное оборудование</p></a
|
||||
>
|
||||
</li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item">
|
||||
<a href="/ogr/" class="nav-link"
|
||||
><i class="nav-icon fa fa-code-branch"></i>
|
||||
<p>Открытые горные работы</p></a
|
||||
>
|
||||
</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
|
||||
>
|
||||
</li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item adisabled">
|
||||
<a href="/wklocation/" class="nav-link"
|
||||
><i class="nav-icon fas fa-map-marked"></i>
|
||||
<p><del>Местоположение персонала</del></p></a
|
||||
>
|
||||
</li>
|
||||
{% if user.profile.role == 1 %}
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-header"></li>
|
||||
<li class="nav-item">
|
||||
<a href="/management/" class="nav-link"
|
||||
><i class="nav-icon fas fa-sliders-h"></i>
|
||||
<p>Администрирование</p></a
|
||||
>
|
||||
</li>
|
||||
{%endif%}
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- /.sidebar-menu -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.content-wrapper -->
|
||||
<!-- /.sidebar -->
|
||||
</aside>
|
||||
|
||||
<footer class="main-footer">
|
||||
<div class="float-right d-none d-sm-block">
|
||||
|
||||
<b>Версия</b> {% settings_value 'APP_VER' %}
|
||||
<a href="/static/help/index.html" target="_blank" ><i class="nav-icon fas fa-question-circle"></i></a>
|
||||
</div>
|
||||
<strong>© {% settings_value 'APP_COPPIRIGHT' %} <a href="https://cybercode.pro/" target="_blank" >Киберкод</a>.</strong>
|
||||
</footer>
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<div class="content">
|
||||
<div class="container-fluid">{% block content %} {% endblock %}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.content-wrapper -->
|
||||
|
||||
<footer class="main-footer">
|
||||
<div class="float-right d-none d-sm-block">
|
||||
<b>Версия</b> {% settings_value 'APP_VER' %}
|
||||
<a href="/static/help/index.html" target="_blank"
|
||||
><i class="nav-icon fas fa-question-circle"></i
|
||||
></a>
|
||||
</div>
|
||||
<strong
|
||||
>© {% settings_value 'APP_COPPIRIGHT' %}
|
||||
<a href="https://cybercode.pro/" target="_blank">Киберкод</a>.</strong
|
||||
>
|
||||
</footer>
|
||||
</div>
|
||||
<!-- ./wrapper -->
|
||||
<!-- jQuery -->
|
||||
@ -160,7 +258,9 @@
|
||||
<!-- jQuery UI 1.11.4 -->
|
||||
<script src="{% static 'lte/plugins/jquery-ui/jquery-ui.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
|
||||
<script>$.widget.bridge('uibutton', $.ui.button)</script>
|
||||
<script>
|
||||
$.widget.bridge("uibutton", $.ui.button);
|
||||
</script>
|
||||
<!-- Bootstrap 4 -->
|
||||
<script src="{% static 'lte/plugins/bootstrap/js/bootstrap.bundle.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- DataTables & Plugins -->
|
||||
@ -202,9 +302,6 @@
|
||||
|
||||
<script src="{% static 'js/main.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
|
||||
|
||||
{% block script_footer %}
|
||||
|
||||
{% endblock script_footer %}
|
||||
</body>
|
||||
</html>
|
||||
{% block script_footer %} {% endblock script_footer %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user