Browse Source

init commit

devel
Dmitry 9 years ago
parent
commit
48de73bdc3
  1. 63
      templates/maps/dot.html
  2. 16
      templates/maps/modal_add_dot.html
  3. 67
      templates/maps/options.html
  4. 54
      templates/maps/ya_index.html

63
templates/maps/dot.html

@ -0,0 +1,63 @@
{% extends 'base.html' %}
{% block main %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li><a href="{% url 'mapapp:options' %}">Настройки карты</a></li>
<li class="active">{{ dot.title }}</li>
</ol>
{% include 'message_block.html' %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Точка топологии</h3>
</div>
<div class="panel-body">
{% if dot.id %}
<form role="form" action="{% url 'mapapp:edit_dot' dot.id %}" method="post">
{% else %}
<form role="form" action="{% url 'mapapp:add_dot' %}" method="post">
{% endif %}
{% csrf_token %}
<div class="form-group">
<label for="id_title">Название точки топологии</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-edit"></span></span>
{{ form.title }}{{ form.title.errors }}
</div>
</div>
<div class="form-group">
<label for="id_longitude">Longitude</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-globe"></span></span>
{{ form.longitude }}{{ form.longitude.errors }}
</div>
</div>
<div class="form-group">
<label for="id_latitude">Latitude</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-globe"></span></span>
{{ form.latitude }}{{ form.latitude.errors }}
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-sm btn-primary">
<span class="glyphicon glyphicon-save"></span> Сохранить
</button>
<button type="reset" class="btn btn-sm btn-default">
<span class="glyphicon glyphicon-remove-circle"></span> Сбросить
</button>
</div>
</form>
</div>
</div>
{% endblock %}

16
templates/maps/modal_add_dot.html

@ -0,0 +1,16 @@
<form action="{% url 'mapapp:modal_add_dot' %}" method="post">{% csrf_token %}
<div class="modal-body">
<h4>Координаты: {{ coords }}</h4>
<div class="form-group">
<label for="id_title">Название точки</label>
<input type="text" class="form-control" autofocus name="title" id="id_title">
</div>
<input type="hidden" name="coords" value="{{ coords }}">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-sm btn-primary">
<span class="glyphicon glyphicon-save"></span> Сохранить
</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
</div>
</form>

67
templates/maps/options.html

@ -0,0 +1,67 @@
{% extends 'base.html' %}
{% block main %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li class="active">Настройки карты</li>
</ol>
{% include 'message_block.html' %}
<h3>Точки топологии</h3>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Название</th>
<th>Longitude</th>
<th>latitude</th>
<th width="50">Ред.</th>
<th width="50">Уд.</th>
</tr>
</thead>
<tbody>
<tr>
{% for dot in dots %}
<td>{{ dot.title }}</td>
<td>{{ dot.longitude }}</td>
<td>{{ dot.latitude }}</td>
<td colspan="2" class="btn-group-xs">
{% if perms.mapapp.change_dot %}
<a href="{% url 'mapapp:edit_dot' dot.id %}"
class="btn btn-primary">
<span class="glyphicon glyphicon-edit"></span>
</a>
{% endif %}
{% if perms.mapapp.delete_dot %}
<a href="{% url 'mapapp:remove_dot' dot.id %}"
class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>
</a>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">Вы ещё не создавали точки топологии. <a href="{% url 'mapapp:add_dot' %}">Создать</a></td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="5">
<a href="{% url 'mapapp:add_dot' %}" class="btn btn-sm btn-success">
<span class="glyphicon glyphicon-plus"></span>
</a>
</td>
</tr>
</tfoot>
</table>
</div>
{% include 'toolbar_page.html' with pag=dots %}
{% endblock %}

54
templates/maps/ya_index.html

@ -0,0 +1,54 @@
{% extends 'base_no_lmenu.html' %}
{% block main %}
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<script type="text/javascript">
ymaps.ready(init);
var myMap;
function load_dots(r){
for(var n=0; n< r.length; n++){
//console.debug([r[n].fields.latitude, r[n].fields.longitude, r[n].fields.title]);
var dot = new ymaps.Placemark([r[n].fields.latitude, r[n].fields.longitude],{
hintContent: r[n].fields.title, balloonContent: r[n].fields.title});
myMap.geoObjects.add(dot);
}
}
function add_dot(e){
var coords = e.get('coords');
$.get('{% url 'mapapp:modal_add_dot' %}', {'coords': coords.join(',')}, function(r){
show_Modal('Добавить точку', r, 'primary');
});
e.preventDefault();
}
function init(){
var win = $(window);
$('#yamap')
.css('width', win.width()-5+'px')
.css('height', win.height()+'px');
myMap = new ymaps.Map("yamap", {
center: [45.449160, 34.735454],
zoom: 12
});
$.getJSON("{% url 'mapapp:get_dots' %}", load_dots);
myMap.events.add('dblclick', add_dot);
}
</script>
<div id="yamap"></div>
<style>
#yamap{
margin-left: -15px;
margin-top: -9px;
}
</style>
{% endblock %}
Loading…
Cancel
Save