/
map_detail.html
425 lines (386 loc) · 17.1 KB
/
map_detail.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
{% extends "maps/map_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load dialogos_tags %}
{% load agon_ratings_tags %}
{% load bootstrap_tags %}
{% load pagination_tags %}
{% load base_tags %}
{% load guardian_tags %}
{% load client_lib_tags %}
{% block title %}{{ resource.title }} — {{ block.super }}{% endblock %}
{% block head %}
{% if TWITTER_CARD %}
{% include "base/_resourcebase_twittercard.html" %}
{% endif %}
{% if OPENGRAPH_ENABLED %}
{% include "base/_resourcebase_opengraph.html" %}
{% endif %}
{% get_map_detail %}
{{ block.super }}
{% endblock %}
{% block body_class %}{% trans "maps" %}{% endblock %}
{% block body_outer %}
{% overall_rating resource "map" as map_rating %}
<div class="page-header">
<style>
#paneltbar {
margin-top: 1px !important;
}
</style>
<h2 class="page-title">{{ resource.title }}</h2>
</div>
<div class="row">
<div class="col-md-8">
<div id="embedded_map">
<div id="the_map"></div>
</div>
<div class="map-actions">
{% include "_actions.html" %}
</div>
<div class="tab-content">
<article id="info" class="tab-pane{% if tab == 'info' or not tab %} active{% endif %}">
{% include "base/resourcebase_info_panel.html" %}
{% if USE_GEOSERVER and DISPLAY_WMS_LINKS %}
<p>
{% if request.user.is_authenticated and 'access_token' in request.session %}
<a href="{% url 'capabilities_map' resource.id %}?access_token={{ request.session.access_token }}">
{% else %}
<a href="{% url 'capabilities_map' resource.id %}">
{% endif %}
<i class="fa fa-map"></i> {% trans 'Map layers WMS GetCapabilities document' %}</a></p>
{% endif %}
</article>
{% block social_links %}
{% if DISPLAY_SOCIAL %}
{% include "social_links.html" %}
{% endif %}
{% endblock %}
{% if DISPLAY_COMMENTS %}
<article class="tab-pane" id="comments">
{% include "_comments.html" %}
</article>
{% endif %}
{% if DISPLAY_RATINGS %}
<article class="tab-pane" id="rate">
<!-- TODO: Move this to a reusable template snippet -->
{% if request.user.is_authenticated %}
<h3>{% trans "Rate this Map" %}</h3>
{% user_rating request.user resource "map" as user_map_rating %}
<div id="user_rating" class="category-map" data-score="{{ user_map_rating }}"></div>
{% endif %}
<h3>{% trans 'Average Rating' %}</h3>
{% overall_rating resource "map" as map_rating %}
{% num_ratings resource as num_votes %}
<div class="overall_rating" style="float:left" data-score="{{ map_rating }}"></div> ({{num_votes}})
</article>
{% endif %}
{% if FAVORITE_ENABLED %}
<article class="tab-pane" id="favorite">
{% include "favorite/_favorite.html" %}
</article>
{% endif %}
</div>
</div>
<div class="col-md-4">
<ul class="list-group">
{% if "download_resourcebase" in perms_list %}
<li class="list-group-item">
<button class="btn btn-primary btn-md btn-block" data-toggle="modal" data-target="#download-map">{% trans "Download Map" %}</button>
</li>
{% endif %}
<li class="list-group-item">
<a href="{% url "map_metadata_detail" resource.id %}">
<button class="btn btn-primary btn-md btn-block" >{% trans "Metadata Detail" %}</button>
</a>
</li>
<div class="modal fade" id="download-map" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">{% trans "Download Map" %}</h4>
</div>
<div class="modal-body">
<ul>
{% if links %}
{% for link in links %}
<li><a href="{{ link.url }}">{{ link.name }}</a></li>
{% endfor %}
{% endif %}
<ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
{% if "change_resourcebase" in perms_list or "change_resourcebase_metadata" in perms_list %}
<li class="list-group-item">
<button class="btn btn-primary btn-md btn-block" data-toggle="modal" data-target="#edit-map">{% trans "Editing Tools" %}</button>
</li>
<div class="modal fade" id="edit-map" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">{% trans "Editing Tools" %}</h4>
</div>
<div class="modal-body">
<div class="row edit-modal">
{% if "change_resourcebase_metadata" in perms_list %}
<div class="col-sm-3">
<i class="fa fa-list-alt fa-3x"></i>
<h4>{% trans "Metadata" %}</h4>
<a class="btn btn-default btn-block btn-xs" href="{% url "map_metadata" resource.id %}">{% trans "Wizard" %}</a>
<a class="btn btn-default btn-block btn-xs" href="{% url "map_metadata_advanced" resource.id %}">{% trans "Advanced Edit" %}</a>
</div>
{% endif %}
{% if "change_resourcebase" in perms_list %}
<div class="col-sm-3">
<i class="fa fa-photo fa-3x"></i>
<h4>{% trans "Thumbnail" %}</h4>
<a class="btn btn-default btn-block btn-xs" href="#" id="set_thumbnail">{% trans "Set" %}</a>
<a class="btn btn-default btn-block btn-xs" href="{% url "thumbnail_upload" resource.resourcebase_ptr.id %}">{% trans "Upload" %}</a>
</div>
{% endif %}
{% if "change_resourcebase" in perms_list %}
<div class="col-sm-3">
<i class="fa fa-map-marker fa-3x"></i>
<h4>{% trans "Map" %}</h4>
<a class="btn btn-default btn-block btn-xs" href="{% url "map_edit" resource.id %}">{% trans "Edit" %}</a>
<a class="btn btn-danger btn-block btn-xs" href="{% url "map_remove" resource.id %}">{% trans "Remove" %}</a>
</div>
{% endif %}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
{% endif %}
<li class="list-group-item">
{% if "change_resourcebase" not in perms_list and "change_resourcebase_metadata" not in perms_list %}
<a href="{% url "map_view" resource.id %}" class="btn btn-default btn-md btn-block">{% trans "View Map" %}</a>
{% else %}
<a href="{% url "map_edit" resource.id %}" class="btn btn-default btn-md btn-block">{% trans "View Map" %}</a>
{% endif %}
</li>
{% comment %}
<li class="list-group-item">
<a href="#" class="btn btn-default btn-md btn-block">{% trans "Print Map" %}</a>
</li>
{% endcomment %}
<li class="list-group-item">
<h4 class="list-group-item-heading">{% trans "Map Layers" %}</h4>
<p>{% trans "This map uses the following layers:" %}</p>
<ul class="list-unstyled">
{% for layer in resource.layer_set.all %}
{% ifnotequal layer.group 'background' %}
{% if layer.local %}
<li><a href="{% url "layer_detail" layer.name %}">{{ layer.layer_title }}</a></li>
{% else %}
<li>{{ layer.layer_title }}</li>
{% endif %}
{% endifnotequal %}
{% endfor %}
</ul>
</li>
{% if documents.count > 0 %}
<li class="list-group-item">
<h4>{% trans "Documents related to this map" %}</h4>
<p>{% trans "List of documents related to this map:" %}</p>
<ul class="list-unstyled">
{% for document in documents %}
<li><a href="{{ document.get_absolute_url }}">{{ document.title }}</a></li>
{% endfor %}
</ul>
</li>
{% endif %}
{% if "change_resourcebase_permissions" in perms_list %}
<li class="list-group-item">
<h4>{% trans "Permissions" %}</h4>
<p>{% trans "Specify which users can view or modify this map" %}</p>
<button class="btn btn-primary btn-md btn-block" data-toggle="modal" data-target="#_permissions">{% trans "Change Permissions of this Map" %}</button>
</li>
{% include "_permissions_form.html" %}
{% endif %}
<li class="list-group-item">
<h4>{% trans "Copy this map" %}</h4>
<p>{% trans "Duplicate this map and modify it for your own purposes" %}</p>
<a href="{% url "new_map" %}?copy={{ resource.id }}" class="btn btn-default btn-md btn-block">{% trans "Create a New Map" %}</a>
</li>
{% if OGC_SERVER.default.BACKEND == 'geonode.qgis_server' %}
<li class="list-group-item">
<h4>{% trans "Embed this map" %}</h4>
<p>{% trans "Embed this map to your own sites" %}</p>
<div class="btn-group btn-block">
<button type="button" class="btn btn-default btn-block dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">{% trans "Embed Map" %}<span class="caret"></span></button>
<ul class="dropdown-menu btn-block" id="embed-map-list">
<li id="embed-iframe-link">
<a href="#">{% trans "Embed Iframe Link" %}</a></li>
<li id="embed-widget-link">
<a href="#">{% trans "Embed Widget Link" %}</a></li>
<li>
<a href="{% url 'map_download_leaflet' resource.id %}">{% trans "Download Leaflet page" %}</a></li>
</ul>
</div>
</li>
{% endif %}
{% include "base/_resourcebase_contact_snippet.html" %}
</ul>
</div>
</div>
<div class="modal fade" id="embed-iframe" tabindex="-1" role="dialog" aria-labelledby="Embed Iframe"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">{% trans "Embed Iframe" %}</h4>
</div>
<div class="modal-body">
<p>{% trans "To embed this map, add the following code snippet and customize its properties (scrolling, width, height) based on your needs to your site" %}:</p>
<p style="font-weight: bold">
<iframe scrolling="yes" src="{{ SITEURL|slice:":-1" }}{% url "map_embed" resource.id %}"
width="480px" height="360px"></iframe>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="embed-widget" tabindex="-1" role="dialog" aria-labelledby="Embed Widget"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">{% trans "Embed Widget" %}</h4>
</div>
<div class="modal-body">
<p>{% trans "To embed this map, copy the following code snippet into your own page" %}:</p>
<pre id="embed-widget-body" style="font-size: 0.5em"></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-clipboard-target="#embed-widget-body">{% trans "Copy to Clipboard" %}</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block extra_script %}
{{ block.super }}
{% if DISPLAY_SOCIAL %}
{% include 'facebook_sdk.html' %}
{% endif %}
{% if request.user.is_authenticated %}
{% user_rating_js request.user resource "map" %}
{% else %}
{% overall_rating resource "map" as the_map_rating %}
{% endif %}
{% include 'rating.html' %}
<script type="text/javascript">
$(document).ready(function () {
post_url = '{% url 'map_embed_widget' resource.id %}';
var formatted_data = "";
$.post(post_url, function (data) {
data = data.split("\n");
data_row = data.length;
for (var i=0; i < data_row;i++) {
formatted_data += data[i] + "\n";
}
$('#embed-widget-body').text(formatted_data);
});
});
var clipboard = new ClipboardJS('.btn');
clipboard.on('success', function(e) {
alert("Code copied");
});
clipboard.on('error', function(e) {
alert("Oops.. something went wrong");
});
$(function() {
{% verbatim %}
// Publish layer group
// TODO: this should really not be inside a script tag...
var $wmsBtn = $("#layer-group"),
layerGroupElTpl;
if ($wmsBtn.length > 0) {
$wmsBtn.on("click", function(event) {
event.preventDefault();
$.ajax({
type: "PUT",
url: $wmsBtn.attr("href")
})
.done(function(data) {
layerGroupElTpl = "<dt>WMS layer group for local map layers:</dt> \
<dd><em>{{layerGroupName}}</em> (on <a href='{{ows}}?service=WMS&request=GetCapabilities'>local OWS</a>)</dd>";
$.each(data, function(key, value) {
// client-side template hack
layerGroupElTpl = layerGroupElTpl.replace("{{"+ key + "}}", value);
});
})
.fail(function(){
layerGroupElTpl = "<dt>Error:</dt> \
<dd>Layer group could not be created.</dd>";
})
.always(function(){
$("#layer-group-dl").html(layerGroupElTpl);
});
});
};
{% endverbatim %}
});
{% if DISPLAY_SOCIAL %}
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
{% endif %}
$("#comment_submit_btn").click(function(event) {
$.ajax({
type: "POST",
url: $("#form_post_comment").attr('action'),
data: $("#form_post_comment").serialize(),
success: function() {
$('#form_post_comment_div').modal().find('form')[0].reset();
$('#form_post_comment_div').modal('hide');
$('#comments_section').load(window.location.pathname + ' #comments_section',
function(){$(this).children().unwrap()})
}
});
return false;
});
</script>
{% block thumbnail_script %}
<script type="text/javascript">
{% if preview == 'react' %}
$('#set_thumbnail').click(function(){
window.setThumbnail({{resource.id}})
$('#edit-layer').modal('toggle');
});
{% else %}
$('#set_thumbnail').click(function(){
createMapThumbnail();
$('#edit-layer').modal('toggle');
});
{% endif %}
</script>
{% endblock thumbnail_script %}
{% if GEONODE_SECURITY_ENABLED %}
{% include "_permissions_form_js.html" %}
{% endif %}
{% if FAVORITE_ENABLED %}
{% include "favorite/_favorite_js.html" %}
{% endif %}
{% endblock extra_script %}