smooth move
This commit is contained in:
parent
81ca841bb4
commit
0a0a399928
@ -3,324 +3,474 @@
|
||||
{% load mysettings %}
|
||||
|
||||
{% block header_link %}
|
||||
<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' %}">
|
||||
|
||||
<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>
|
||||
<link rel="stylesheet" href="https://js.api.here.com/v3/3.1/mapsjs-ui.css">
|
||||
|
||||
<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 text-sm">
|
||||
<form id="list_acs" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<input id="id_acs" type="hidden" value="None" name="id">
|
||||
<input id="cmd" type="hidden" value="None" name="cmd">
|
||||
<div class="container-fluid ">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card card-primary card-outline ">
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="row">
|
||||
<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 " 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" 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 %}
|
||||
{% if is_paginated %}
|
||||
<ul class="pagination pagination no-margin text-sm">
|
||||
{% if 1 < start_page_list %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{start_page_list|add:-1}}" aria-controls="mypaginator" data-dt-idx="{{start_page_list|add:-1}}" style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
<section class="content text-sm">
|
||||
<form id="list_acs" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<input id="id_acs" type="hidden" value="None" name="id">
|
||||
<input id="cmd" type="hidden" value="None" name="cmd">
|
||||
<div class="container-fluid ">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card card-primary card-outline ">
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="row">
|
||||
<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 " 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 %}
|
||||
{% for n in page_list %}
|
||||
{% if n == page_object.number %}
|
||||
<li class="paginate_button page-item active" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{n}}" aria-controls="mypaginator" data-dt-idx="{{n}}" style="padding: .3rem .5rem;"><span>{{n}}</span></a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{n}}" aria-controls="mypaginator" data-dt-idx="{{n}}" style="padding: .3rem .5rem;"><span>{{n}}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if end_page_list < num_pages %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{end_page_list|add:1}}" aria-controls="mypaginator" data-dt-idx="{{end_page_list|add:1}}" style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
<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" 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 %}
|
||||
{% if is_paginated %}
|
||||
<ul class="pagination pagination no-margin text-sm">
|
||||
{% if 1 < start_page_list %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link" href="?page=
|
||||
{{ start_page_list|add:-1}}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="
|
||||
{{ start_page_list|add:-1}}"
|
||||
style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
</div> <!-- /.card-header -->
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th> </th>
|
||||
<th>Наименование</th>
|
||||
<th>Государственный номер</th>
|
||||
<th>Время координат</th>
|
||||
<th>Широта</th>
|
||||
<th>Долгота</th>
|
||||
<th>Скорость</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% endif %}
|
||||
{% for n in page_list %}
|
||||
{% if n == page_object.number %}
|
||||
<li class="paginate_button page-item active"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link"
|
||||
href="?page={{ n }}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="{{ n }}"
|
||||
style="padding: .3rem .5rem;"><span>{{ n }}</span></a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link"
|
||||
href="?page={{ n }}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="{{ n }}"
|
||||
style="padding: .3rem .5rem;"><span>{{ n }}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if end_page_list < num_pages %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link"
|
||||
href="?page={{ end_page_list|add:1}}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="
|
||||
{{ end_page_list|add:1}}"
|
||||
style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% if page_object %}
|
||||
{% for catalog in page_object.object_list %}
|
||||
<tr id="tr_{{catalog.id}}">
|
||||
<td style="width:10px;cursor: pointer;">
|
||||
{% if user.profile.role == 1 %}
|
||||
<a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false" style="color:black;">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right" style="left: inherit; right: 0px;">
|
||||
<a href="object/block/?id={{catalog.id}}"" class="dropdown-item">
|
||||
<!-- Message Start -->
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<h3 class="dropdown-item-title">
|
||||
Не контролировать
|
||||
<span class="float-right text-sm text-danger"><i class="fas fa-ban"></i></span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
</div> <!-- /.card-header -->
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th></th>
|
||||
<th>Наименование</th>
|
||||
<th>Государственный номер</th>
|
||||
<th>Время координат</th>
|
||||
<th>Широта</th>
|
||||
<th>Долгота</th>
|
||||
<th>Скорость</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% if page_object %}
|
||||
{% for catalog in page_object.object_list %}
|
||||
<tr id="tr_{{ catalog.id }}">
|
||||
<td style="width:10px;cursor: pointer;">
|
||||
{% if user.profile.role == 1 %}
|
||||
<a class="nav-link"
|
||||
data-toggle="dropdown" href="#"
|
||||
aria-expanded="false"
|
||||
style="color:black;">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right"
|
||||
style="left: inherit; right: 0px;">
|
||||
<a href="object/block/?id={{ catalog.id }}""
|
||||
class="dropdown-item">
|
||||
<!-- Message Start -->
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<h3 class="dropdown-item-title">
|
||||
Не контролировать
|
||||
<span class="float-right text-sm text-danger"><i
|
||||
class="fas fa-ban"></i></span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.statenum }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.time }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.lat }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.lon }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.speed }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
</div>
|
||||
{% if user.profile.role == 1 %}
|
||||
<div class="tab-pane fade" id="custom-content-above-profile"
|
||||
role="tabpanel"
|
||||
aria-labelledby="custom-content-above-profile-tab">
|
||||
<div class="card">
|
||||
<div class="card-header text-sm">
|
||||
{% block pagination %}
|
||||
{% if is_paginated_block %}
|
||||
<ul class="pagination pagination no-margin text-sm">
|
||||
{% if 1 < start_page_list_block %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link" href="?page=
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{ start_page_list_block|add:-1}}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{ start_page_list_block|add:-1}}"
|
||||
style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
{% for n in page_list_block %}
|
||||
{% if n == page_object_block.number %}
|
||||
<li class="paginate_button page-item active"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link"
|
||||
href="?page={{ n }}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="{{ n }}"
|
||||
style="padding: .3rem .5rem;"><span>{{ n }}</span></a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link"
|
||||
href="?page={{ n }}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="{{ n }}"
|
||||
style="padding: .3rem .5rem;"><span>{{ n }}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if end_page_list_block < num_pages_block %}
|
||||
<li class="paginate_button page-item"
|
||||
id="mypaginator_next">
|
||||
<a class="page-link" href="?page=
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{ end_page_list_block|add:1}}"
|
||||
aria-controls="mypaginator"
|
||||
data-dt-idx="
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{ end_page_list_block|add:1}}"
|
||||
style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
</div> <!-- /.card-header -->
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th></th>
|
||||
<th>Наименование</th>
|
||||
<th>Государственный номер</th>
|
||||
<th>Время координат</th>
|
||||
<th>Широта</th>
|
||||
<th>Долгота</th>
|
||||
<th>Скорость</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% if page_object_block %}
|
||||
{% for catalog in page_object_block.object_list %}
|
||||
<tr id="tr_{{ catalog.id }}">
|
||||
<td style="width:10px;cursor: pointer;">
|
||||
<a class="nav-link"
|
||||
data-toggle="dropdown" href="#"
|
||||
aria-expanded="false"
|
||||
style="color:black;">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right"
|
||||
style="left: inherit; right: 0px;">
|
||||
<a href="object/block/?id={{ catalog.id }}"
|
||||
class="dropdown-item">
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<h3 class="dropdown-item-title">
|
||||
Контролировать
|
||||
<span class="float-right text-sm text-danger"><i
|
||||
class="fas fa-rss"></i></span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.statenum }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.time }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.lat }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.lon }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="object/?id={{ catalog.id }}">{{ catalog.speed }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{ catalog.name }}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.statenum}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{ catalog.time }}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.lat}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.lon}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.speed}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
</div>
|
||||
{% if user.profile.role == 1 %}
|
||||
<div class="tab-pane fade" id="custom-content-above-profile" role="tabpanel" aria-labelledby="custom-content-above-profile-tab">
|
||||
<div class="card">
|
||||
<div class="card-header text-sm">
|
||||
{% block pagination %}
|
||||
{% if is_paginated_block %}
|
||||
<ul class="pagination pagination no-margin text-sm">
|
||||
{% if 1 < start_page_list_block %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{start_page_list_block|add:-1}}" aria-controls="mypaginator" data-dt-idx="{{start_page_list_block|add:-1}}" style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
{% for n in page_list_block %}
|
||||
{% if n == page_object_block.number %}
|
||||
<li class="paginate_button page-item active" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{n}}" aria-controls="mypaginator" data-dt-idx="{{n}}" style="padding: .3rem .5rem;"><span>{{n}}</span></a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{n}}" aria-controls="mypaginator" data-dt-idx="{{n}}" style="padding: .3rem .5rem;"><span>{{n}}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if end_page_list_block < num_pages_block %}
|
||||
<li class="paginate_button page-item" id="mypaginator_next">
|
||||
<a class="page-link" href="?page={{end_page_list_block|add:1}}" aria-controls="mypaginator" data-dt-idx="{{end_page_list_block|add:1}}" style="padding: .3rem .5rem;"><span>..</span></a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
</div> <!-- /.card-header -->
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th> </th>
|
||||
<th>Наименование</th>
|
||||
<th>Государственный номер</th>
|
||||
<th>Время координат</th>
|
||||
<th>Широта</th>
|
||||
<th>Долгота</th>
|
||||
<th>Скорость</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% if page_object_block %}
|
||||
{% for catalog in page_object_block.object_list %}
|
||||
<tr id="tr_{{catalog.id}}">
|
||||
<td style="width:10px;cursor: pointer;">
|
||||
<a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false" style="color:black;">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right" style="left: inherit; right: 0px;">
|
||||
<a href="object/block/?id={{catalog.id}}"" class="dropdown-item">
|
||||
<!-- Message Start -->
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<h3 class="dropdown-item-title">
|
||||
Контролировать
|
||||
<span class="float-right text-sm text-danger"><i class="fas fa-rss"></i></span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{ catalog.name }}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.statenum}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{ catalog.time }}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.lat}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.lon}}</a></td>
|
||||
<td><a href="object/?id={{catalog.id}}">{{catalog.speed}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.card-body -->
|
||||
</div> <!-- /.card -->
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block script_footer %}
|
||||
<script>
|
||||
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 + 'update_object/',
|
||||
async: true,
|
||||
data: {
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
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) {
|
||||
marker.setGeometry(coord);
|
||||
}
|
||||
)
|
||||
<script>
|
||||
let map, ui, markers = {};
|
||||
let animatingMarkers = {}; // Для отслеживания анимаций маркеров
|
||||
|
||||
}
|
||||
},
|
||||
error: function (dataerr) {
|
||||
$('#large_' + id).modal('hide');
|
||||
$('body').removeClass('modal-open');
|
||||
$('.modal-backdrop').remove();
|
||||
alert('Ошибка выполнение команды')
|
||||
|
||||
},
|
||||
timeout: 120000
|
||||
|
||||
|
||||
});
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
function initializeMap() {
|
||||
var platform = new H.service.Platform({
|
||||
'apikey': '8hwYsYjgnywj3aNdHc9dLF7hLD3c2-ydDyY4tiawfNA'
|
||||
});
|
||||
|
||||
var defaultLayers = platform.createDefaultLayers();
|
||||
map = new H.Map(
|
||||
document.getElementById('map'),
|
||||
defaultLayers.vector.normal.map,
|
||||
{
|
||||
zoom: 14,
|
||||
center: {lat: {{lat}}, lng: {{lon}}}
|
||||
}
|
||||
);
|
||||
|
||||
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
|
||||
ui = H.ui.UI.createDefault(map, defaultLayers);
|
||||
|
||||
// Начальная загрузка маркеров
|
||||
updateMarkers();
|
||||
// Обновление каждые 5 секунд
|
||||
setInterval(updateMarkers, 5000);
|
||||
}
|
||||
|
||||
function addMarker(equipment) {
|
||||
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>`;
|
||||
var icon = new H.map.DomIcon(svg);
|
||||
var marker = new H.map.DomMarker({lat: equipment.lat, lng: equipment.lon}, {icon: icon});
|
||||
|
||||
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)},
|
||||
marker.setData(equipment);
|
||||
|
||||
// Устанавливаем плавное перемещение
|
||||
ease(
|
||||
marker.getGeometry(),
|
||||
{lat: equipment.lat, lng: equipment.lon},
|
||||
4000,
|
||||
function (coord) {
|
||||
marker.setGeometry(coord);
|
||||
}
|
||||
);
|
||||
|
||||
marker.addEventListener('tap', function (evt) {
|
||||
var equipData = evt.target.getData();
|
||||
var content = `<div style="width: 300px;">
|
||||
<strong>Имя:</strong> ${equipData.name} <br>
|
||||
<strong>Координаты:</strong><br>${equipData.lat}, ${equipData.lon}<br>
|
||||
<strong>Время координат:</strong><br>${equipment.time}
|
||||
</div>`;
|
||||
var bubble = new H.ui.InfoBubble(evt.target.getGeometry(), {content: content});
|
||||
ui.addBubble(bubble);
|
||||
});
|
||||
|
||||
map.addObject(marker);
|
||||
markers[equipment.id] = marker;
|
||||
}
|
||||
|
||||
function updateMarkers() {
|
||||
fetch('update_object/', {
|
||||
method: 'POST',
|
||||
headers: {'X-CSRFToken': csrftoken},
|
||||
mode: 'same-origin'
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
data.forEach(equipment => {
|
||||
if (markers[equipment.id]) {
|
||||
// Проверка, если маркер сейчас анимируется
|
||||
if (!animatingMarkers[equipment.id]) {
|
||||
animatingMarkers[equipment.id] = true;
|
||||
// Обновляем его координаты плавно
|
||||
ease(
|
||||
markers[equipment.id].getGeometry(),
|
||||
{lat: equipment.lat, lng: equipment.lon},
|
||||
4000,
|
||||
function (coord) {
|
||||
markers[equipment.id].setGeometry(coord);
|
||||
},
|
||||
function () {
|
||||
animatingMarkers[equipment.id] = false; // Снимаем флаг анимации
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Если маркера нет, создаем новый
|
||||
addMarker(equipment);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function ease(startCoord, endCoord, durationMs, onStep, 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,
|
||||
@ -328,84 +478,27 @@
|
||||
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();
|
||||
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);
|
||||
}
|
||||
window.onload = initializeMap;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
/**
|
||||
* 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({
|
||||
lg: 'ru'
|
||||
});
|
||||
|
||||
//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, 'ru-RU');
|
||||
moveMapTolocation(map);
|
||||
|
||||
|
||||
|
||||
createMarkers();
|
||||
// Now use the map as required...
|
||||
|
||||
window.onload = function () {
|
||||
update_object()
|
||||
setInterval('update_object()', 2000);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
|
||||
@ -12,6 +12,5 @@ urlpatterns = [
|
||||
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'),
|
||||
|
||||
]
|
||||
|
||||
|
||||
@ -3,10 +3,13 @@ import traceback
|
||||
import os
|
||||
import io
|
||||
import json
|
||||
import zoneinfo
|
||||
|
||||
import requests
|
||||
|
||||
from datetime import datetime,timedelta
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
from django.core import exceptions
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
@ -14,6 +17,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from copy import deepcopy
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import JsonResponse, HttpResponse
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.db.models import Avg, Max, Min
|
||||
from django import forms
|
||||
@ -31,31 +35,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 update_object(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)
|
||||
m_list = []
|
||||
for obj in object_list:
|
||||
m_list.append({
|
||||
'id': obj.id,
|
||||
'name': obj.name,
|
||||
'lat': obj.lat,
|
||||
'lon': obj.lon,
|
||||
'time': obj.time.astimezone(zoneinfo.ZoneInfo(settings.TIME_ZONE)).strftime('%m.%d.%Y, %H:%M:%S')
|
||||
})
|
||||
return generalmodule.ReturnJson(200, m_list)
|
||||
else:
|
||||
return HttpResponse(status=405)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def sensor_ajax(request):
|
||||
def sensor_ajax(request):
|
||||
try:
|
||||
if request.method == "POST":
|
||||
sensor_dict = dict()
|
||||
@ -63,18 +67,20 @@ def sensor_ajax(request):
|
||||
sensor = Sensors.objects.filter(id=param['id']).first()
|
||||
if sensor is None:
|
||||
m_sensor = []
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
return generalmodule.ReturnJson(200, m_sensor)
|
||||
time = sensor.time
|
||||
value = sensor.value
|
||||
end_date=sensor.time+timedelta(seconds=15)
|
||||
|
||||
value_old = 0
|
||||
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()
|
||||
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 = []
|
||||
@ -84,23 +90,25 @@ def sensor_ajax(request):
|
||||
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:
|
||||
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)
|
||||
sensor_dict.update(status=status)
|
||||
m_sensor.append(sensor_dict)
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
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')
|
||||
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')
|
||||
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 = []
|
||||
@ -109,36 +117,36 @@ def sensor_ajax(request):
|
||||
strftimeend = "%d.%m.%Y %H:%M:%S"
|
||||
time = start_date + timedelta(seconds=i)
|
||||
start_date_day = time
|
||||
|
||||
end_date_day = time+ timedelta(milliseconds=1000)
|
||||
|
||||
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)
|
||||
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)
|
||||
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))
|
||||
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)
|
||||
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:
|
||||
sensor_dict.update(value=result['value__max'])
|
||||
delta = (datetime.now() - sensor.time).total_seconds()
|
||||
if delta > 60:
|
||||
status = 1
|
||||
sensor_dict.update(status = status)
|
||||
sensor_dict.update(status=status)
|
||||
m_sensor.append(sensor_dict)
|
||||
return generalmodule.ReturnJson(200,m_sensor)
|
||||
return generalmodule.ReturnJson(200, m_sensor)
|
||||
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
@ -148,19 +156,20 @@ def sensor_ajax(request):
|
||||
@never_cache
|
||||
def sensor_edit(request):
|
||||
try:
|
||||
get_param=request.GET.dict()
|
||||
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()
|
||||
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,
|
||||
'sensor': element,
|
||||
'sensor_list': sensor_list,
|
||||
|
||||
})
|
||||
return render(request,'sensor_edit.html', context)
|
||||
})
|
||||
return render(request, 'sensor_edit.html', context)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
@ -169,51 +178,53 @@ def sensor_edit(request):
|
||||
@never_cache
|
||||
def object_edit(request):
|
||||
try:
|
||||
get_param=request.GET.dict()
|
||||
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)
|
||||
'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()
|
||||
get_param = request.GET.dict()
|
||||
element = Equipment.objects.filter(id=get_param['id']).first()
|
||||
if element.block:
|
||||
element.block=False;
|
||||
element.block = False;
|
||||
else:
|
||||
element.block=True;
|
||||
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'))) # широта
|
||||
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','')
|
||||
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':
|
||||
catalog_list = []
|
||||
if json_data['result'] == 'OK':
|
||||
for data in json_data['objects']:
|
||||
#print(data)
|
||||
objects=dict()
|
||||
# print(data)
|
||||
objects = dict()
|
||||
objects.update(id=data['id'])
|
||||
objects.update(name=data['name'])
|
||||
objects.update(lat=data['lat'])
|
||||
@ -221,115 +232,116 @@ def map_index(request):
|
||||
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)
|
||||
'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:
|
||||
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()
|
||||
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()
|
||||
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
|
||||
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())
|
||||
perv_url = 'page={}'.format(page.previous_page_number())
|
||||
else:
|
||||
perv_url=''
|
||||
perv_url = ''
|
||||
if page.has_next():
|
||||
next_url='page={}'.format(page.next_page_number())
|
||||
next_url = 'page={}'.format(page.next_page_number())
|
||||
else:
|
||||
next_url=''
|
||||
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,
|
||||
'lon':mylon.replace(',','.'),
|
||||
'lat':mylat.replace(',','.'),
|
||||
})
|
||||
'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,
|
||||
'lon': mylon.replace(',', '.'),
|
||||
'lat': mylat.replace(',', '.'),
|
||||
})
|
||||
|
||||
if request.user.profile.role==1:
|
||||
if request.user.profile.role == 1:
|
||||
context.update(main_index_block(page_number_block))
|
||||
return render(request,'gto_main.html', context)
|
||||
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 = 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
|
||||
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())
|
||||
perv_url = 'page={}'.format(page.previous_page_number())
|
||||
else:
|
||||
perv_url=''
|
||||
perv_url = ''
|
||||
if page.has_next():
|
||||
next_url='page={}'.format(page.next_page_number())
|
||||
next_url = 'page={}'.format(page.next_page_number())
|
||||
else:
|
||||
next_url=''
|
||||
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,
|
||||
})
|
||||
'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())
|
||||
|
||||
@ -138,8 +138,8 @@
|
||||
<strong>Координаты:</strong><br> ${data.latitude}, ${data.longitude}<br>
|
||||
<strong>Скорость:</strong> ${data.velocity} км/ч<br>
|
||||
<strong>Время обновления:</strong> ${data.update_time}
|
||||
</div>
|
||||
`;
|
||||
</div>`;
|
||||
|
||||
var bubble = new H.ui.InfoBubble(evt.target.getGeometry(), {
|
||||
content: content
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user