umap-project 1.14.0a5__py3-none-any.whl → 2.0.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/decorators.py +0 -14
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +137 -85
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +136 -84
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +136 -84
- umap/locale/en/LC_MESSAGES/django.po +128 -88
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +136 -84
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +131 -91
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +137 -85
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +136 -84
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +136 -84
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +136 -84
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +135 -83
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +143 -91
- umap/models.py +23 -1
- umap/settings/__init__.py +1 -4
- umap/settings/base.py +1 -0
- umap/static/umap/base.css +5 -0
- umap/static/umap/content.css +185 -13
- umap/static/umap/favicons/icon.svg +2 -2
- umap/static/umap/img/edit.svg +3 -3
- umap/static/umap/img/icon-delete.svg +4 -0
- umap/static/umap/img/icon-download.svg +13 -0
- umap/static/umap/img/icon-duplicate.svg +5 -0
- umap/static/umap/img/icon-edit.svg +12 -0
- umap/static/umap/img/icon-share.svg +11 -0
- umap/static/umap/img/icon-view.svg +12 -0
- umap/static/umap/img/logo.svg +2 -2
- umap/static/umap/img/logo_small.svg +2 -2
- umap/static/umap/img/marker.svg +4 -0
- umap/static/umap/img/opensource.svg +2 -2
- umap/static/umap/img/osm.svg +2 -2
- umap/static/umap/js/components/fragment.js +1 -1
- umap/static/umap/js/modules/browser.js +159 -0
- umap/static/umap/js/modules/global.js +3 -1
- umap/static/umap/js/modules/request.js +155 -0
- umap/static/umap/js/umap.autocomplete.js +28 -38
- umap/static/umap/js/umap.controls.js +73 -58
- umap/static/umap/js/umap.core.js +4 -9
- umap/static/umap/js/umap.datalayer.permissions.js +13 -12
- umap/static/umap/js/umap.features.js +51 -49
- umap/static/umap/js/umap.forms.js +19 -19
- umap/static/umap/js/umap.icon.js +17 -17
- umap/static/umap/js/umap.importer.js +2 -1
- umap/static/umap/js/umap.js +242 -291
- umap/static/umap/js/umap.layer.js +173 -141
- umap/static/umap/js/umap.permissions.js +24 -25
- umap/static/umap/js/umap.popup.js +14 -14
- umap/static/umap/js/umap.share.js +4 -4
- umap/static/umap/js/umap.slideshow.js +4 -4
- umap/static/umap/js/umap.tableeditor.js +2 -2
- umap/static/umap/js/umap.ui.js +1 -1
- umap/static/umap/locale/am_ET.js +1 -11
- umap/static/umap/locale/am_ET.json +1 -11
- umap/static/umap/locale/ar.js +1 -11
- umap/static/umap/locale/ar.json +1 -11
- umap/static/umap/locale/ast.js +1 -11
- umap/static/umap/locale/ast.json +1 -11
- umap/static/umap/locale/bg.js +1 -11
- umap/static/umap/locale/bg.json +1 -11
- umap/static/umap/locale/br.js +1 -11
- umap/static/umap/locale/br.json +1 -11
- umap/static/umap/locale/ca.js +1 -11
- umap/static/umap/locale/ca.json +1 -11
- umap/static/umap/locale/cs_CZ.js +1 -11
- umap/static/umap/locale/cs_CZ.json +1 -11
- umap/static/umap/locale/da.js +1 -11
- umap/static/umap/locale/da.json +1 -11
- umap/static/umap/locale/de.js +1 -11
- umap/static/umap/locale/de.json +1 -11
- umap/static/umap/locale/el.js +1 -11
- umap/static/umap/locale/el.json +1 -11
- umap/static/umap/locale/en.js +1 -11
- umap/static/umap/locale/en.json +1 -11
- umap/static/umap/locale/en_US.json +1 -11
- umap/static/umap/locale/es.js +1 -11
- umap/static/umap/locale/es.json +1 -11
- umap/static/umap/locale/et.js +1 -11
- umap/static/umap/locale/et.json +1 -11
- umap/static/umap/locale/fa_IR.js +6 -16
- umap/static/umap/locale/fa_IR.json +6 -16
- umap/static/umap/locale/fi.js +1 -11
- umap/static/umap/locale/fi.json +1 -11
- umap/static/umap/locale/fr.js +1 -11
- umap/static/umap/locale/fr.json +1 -11
- umap/static/umap/locale/gl.js +1 -11
- umap/static/umap/locale/gl.json +1 -11
- umap/static/umap/locale/he.js +1 -11
- umap/static/umap/locale/he.json +1 -11
- umap/static/umap/locale/hr.js +1 -11
- umap/static/umap/locale/hr.json +1 -11
- umap/static/umap/locale/hu.js +1 -11
- umap/static/umap/locale/hu.json +1 -11
- umap/static/umap/locale/id.js +1 -11
- umap/static/umap/locale/id.json +1 -11
- umap/static/umap/locale/is.js +1 -11
- umap/static/umap/locale/is.json +1 -11
- umap/static/umap/locale/it.js +1 -11
- umap/static/umap/locale/it.json +1 -11
- umap/static/umap/locale/ja.js +1 -11
- umap/static/umap/locale/ja.json +1 -11
- umap/static/umap/locale/ko.js +1 -11
- umap/static/umap/locale/ko.json +1 -11
- umap/static/umap/locale/lt.js +1 -11
- umap/static/umap/locale/lt.json +1 -11
- umap/static/umap/locale/ms.js +1 -11
- umap/static/umap/locale/ms.json +1 -11
- umap/static/umap/locale/nl.js +1 -11
- umap/static/umap/locale/nl.json +1 -11
- umap/static/umap/locale/no.js +1 -11
- umap/static/umap/locale/no.json +1 -11
- umap/static/umap/locale/pl.js +1 -11
- umap/static/umap/locale/pl.json +1 -11
- umap/static/umap/locale/pl_PL.json +1 -11
- umap/static/umap/locale/pt.js +1 -11
- umap/static/umap/locale/pt.json +1 -11
- umap/static/umap/locale/pt_BR.js +1 -11
- umap/static/umap/locale/pt_BR.json +1 -11
- umap/static/umap/locale/pt_PT.js +1 -11
- umap/static/umap/locale/pt_PT.json +1 -11
- umap/static/umap/locale/ro.js +1 -11
- umap/static/umap/locale/ro.json +1 -11
- umap/static/umap/locale/ru.js +1 -11
- umap/static/umap/locale/ru.json +1 -11
- umap/static/umap/locale/sk_SK.js +1 -11
- umap/static/umap/locale/sk_SK.json +1 -11
- umap/static/umap/locale/sl.js +1 -11
- umap/static/umap/locale/sl.json +1 -11
- umap/static/umap/locale/sr.js +1 -11
- umap/static/umap/locale/sr.json +1 -11
- umap/static/umap/locale/sv.js +1 -11
- umap/static/umap/locale/sv.json +1 -11
- umap/static/umap/locale/th_TH.js +1 -11
- umap/static/umap/locale/th_TH.json +1 -11
- umap/static/umap/locale/tr.js +1 -11
- umap/static/umap/locale/tr.json +1 -11
- umap/static/umap/locale/uk_UA.js +1 -11
- umap/static/umap/locale/uk_UA.json +1 -11
- umap/static/umap/locale/vi.js +1 -11
- umap/static/umap/locale/vi.json +1 -11
- umap/static/umap/locale/vi_VN.json +1 -11
- umap/static/umap/locale/zh.js +1 -11
- umap/static/umap/locale/zh.json +1 -11
- umap/static/umap/locale/zh_CN.json +1 -11
- umap/static/umap/locale/zh_TW.Big5.json +1 -11
- umap/static/umap/locale/zh_TW.js +17 -27
- umap/static/umap/locale/zh_TW.json +17 -27
- umap/static/umap/map.css +2 -2
- umap/static/umap/nav.css +2 -1
- umap/static/umap/test/.eslintrc +0 -1
- umap/static/umap/test/Choropleth.js +29 -27
- umap/static/umap/test/DataLayer.js +207 -239
- umap/static/umap/test/Feature.js +33 -58
- umap/static/umap/test/Map.Export.js +11 -11
- umap/static/umap/test/Map.js +66 -67
- umap/static/umap/test/Marker.js +36 -32
- umap/static/umap/test/Polygon.js +95 -95
- umap/static/umap/test/Polyline.js +31 -31
- umap/static/umap/test/TableEditor.js +29 -25
- umap/static/umap/test/_pre.js +2 -7
- umap/static/umap/test/index.html +4 -4
- umap/storage.py +2 -0
- umap/templates/auth/user_form.html +3 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +51 -36
- umap/templates/umap/about_summary.html +1 -1
- umap/templates/umap/branding.html +3 -0
- umap/templates/umap/content.html +15 -39
- umap/templates/umap/header.html +0 -0
- umap/templates/umap/home.html +4 -2
- umap/templates/umap/js.html +0 -2
- umap/templates/umap/map_detail.html +9 -0
- umap/templates/umap/map_init.html +1 -1
- umap/templates/umap/map_messages.html +4 -2
- umap/templates/umap/map_table.html +130 -69
- umap/templates/umap/navigation.html +2 -4
- umap/templates/umap/user_dashboard.html +29 -6
- umap/tests/base.py +1 -1
- umap/tests/integration/conftest.py +18 -0
- umap/tests/integration/test_anonymous_owned_map.py +6 -3
- umap/tests/integration/test_browser.py +166 -6
- umap/tests/integration/test_collaborative_editing.py +23 -5
- umap/tests/integration/test_dashboard.py +17 -0
- umap/tests/integration/test_edit_datalayer.py +4 -3
- umap/tests/integration/test_export_map.py +1 -1
- umap/tests/integration/test_import.py +9 -4
- umap/tests/integration/test_map.py +64 -0
- umap/tests/integration/test_map_preview.py +75 -0
- umap/tests/integration/test_owned_map.py +11 -25
- umap/tests/integration/test_picto.py +3 -3
- umap/tests/integration/test_querystring.py +52 -0
- umap/tests/integration/test_share.py +22 -0
- umap/tests/test_map_views.py +157 -14
- umap/tests/test_views.py +50 -11
- umap/urls.py +6 -12
- umap/views.py +170 -47
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a1.dist-info}/METADATA +13 -15
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a1.dist-info}/RECORD +212 -200
- umap/static/umap/js/umap.browser.js +0 -148
- umap/static/umap/js/umap.xhr.js +0 -304
- umap/static/umap/test/Controls.js +0 -100
- umap/static/umap/test/Map.Init.js +0 -46
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a1.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a1.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
L.U.Browser = L.Class.extend({
|
|
2
|
-
options: {
|
|
3
|
-
filter: '',
|
|
4
|
-
inBbox: false,
|
|
5
|
-
},
|
|
6
|
-
|
|
7
|
-
initialize: function (map) {
|
|
8
|
-
this.map = map
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
addFeature: function (feature) {
|
|
12
|
-
const feature_li = L.DomUtil.create('li', `${feature.getClassName()} feature`),
|
|
13
|
-
zoom_to = L.DomUtil.create('i', 'feature-zoom_to', feature_li),
|
|
14
|
-
edit = L.DomUtil.create('i', 'show-on-edit feature-edit', feature_li),
|
|
15
|
-
del = L.DomUtil.create('i', 'show-on-edit feature-delete', feature_li),
|
|
16
|
-
colorBox = L.DomUtil.create('i', 'feature-color', feature_li),
|
|
17
|
-
title = L.DomUtil.create('span', 'feature-title', feature_li),
|
|
18
|
-
symbol = feature._getIconUrl
|
|
19
|
-
? L.U.Icon.prototype.formatUrl(feature._getIconUrl(), feature)
|
|
20
|
-
: null
|
|
21
|
-
zoom_to.title = L._('Bring feature to center')
|
|
22
|
-
edit.title = L._('Edit this feature')
|
|
23
|
-
del.title = L._('Delete this feature')
|
|
24
|
-
title.textContent = feature.getDisplayName() || '—'
|
|
25
|
-
const bgcolor = feature.getOption('color')
|
|
26
|
-
colorBox.style.backgroundColor = bgcolor
|
|
27
|
-
if (symbol && symbol !== this.map.options.default_iconUrl) {
|
|
28
|
-
const icon = L.U.Icon.makeIconElement(symbol, colorBox)
|
|
29
|
-
L.U.Icon.setIconContrast(icon, colorBox, symbol, bgcolor)
|
|
30
|
-
}
|
|
31
|
-
L.DomEvent.on(
|
|
32
|
-
zoom_to,
|
|
33
|
-
'click',
|
|
34
|
-
function (e) {
|
|
35
|
-
e.callback = L.bind(this.view, this)
|
|
36
|
-
this.zoomTo(e)
|
|
37
|
-
},
|
|
38
|
-
feature
|
|
39
|
-
)
|
|
40
|
-
L.DomEvent.on(
|
|
41
|
-
title,
|
|
42
|
-
'click',
|
|
43
|
-
function (e) {
|
|
44
|
-
e.callback = L.bind(this.view, this)
|
|
45
|
-
this.zoomTo(e)
|
|
46
|
-
},
|
|
47
|
-
feature
|
|
48
|
-
)
|
|
49
|
-
L.DomEvent.on(edit, 'click', feature.edit, feature)
|
|
50
|
-
L.DomEvent.on(del, 'click', feature.confirmDelete, feature)
|
|
51
|
-
return feature_li
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
addDatalayer: function (datalayer, dataContainer) {
|
|
55
|
-
const filterKeys = this.map.getFilterKeys()
|
|
56
|
-
const container = L.DomUtil.create(
|
|
57
|
-
'div',
|
|
58
|
-
datalayer.getHidableClass(),
|
|
59
|
-
dataContainer
|
|
60
|
-
),
|
|
61
|
-
headline = L.DomUtil.create('h5', '', container)
|
|
62
|
-
container.id = `browse_data_datalayer_${datalayer.umap_id}`
|
|
63
|
-
datalayer.renderToolbox(headline)
|
|
64
|
-
L.DomUtil.add('span', '', headline, datalayer.options.name)
|
|
65
|
-
const counter = L.DomUtil.add('span', 'datalayer-counter', headline, datalayer.count())
|
|
66
|
-
counter.title = L._('{count} features in this layer', {count: datalayer.count()})
|
|
67
|
-
const ul = L.DomUtil.create('ul', '', container)
|
|
68
|
-
L.DomUtil.classIf(container, 'off', !datalayer.isVisible())
|
|
69
|
-
|
|
70
|
-
const build = () => {
|
|
71
|
-
ul.innerHTML = ''
|
|
72
|
-
const bounds = this.map.getBounds()
|
|
73
|
-
datalayer.eachFeature((feature) => {
|
|
74
|
-
if (
|
|
75
|
-
this.options.filter &&
|
|
76
|
-
!feature.matchFilter(this.options.filter, filterKeys)
|
|
77
|
-
)
|
|
78
|
-
return
|
|
79
|
-
if (this.options.inBbox && !feature.isOnScreen(bounds)) return
|
|
80
|
-
ul.appendChild(this.addFeature(feature))
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
build()
|
|
85
|
-
datalayer.on('datachanged', build)
|
|
86
|
-
datalayer.map.ui.once('panel:closed', () => {
|
|
87
|
-
datalayer.off('datachanged', build)
|
|
88
|
-
this.map.off('moveend', build)
|
|
89
|
-
})
|
|
90
|
-
datalayer.map.ui.once('panel:ready', () => {
|
|
91
|
-
datalayer.map.ui.once('panel:ready', () => {
|
|
92
|
-
datalayer.off('datachanged', build)
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
open: function () {
|
|
98
|
-
const container = L.DomUtil.create('div', 'umap-browse-data')
|
|
99
|
-
// HOTFIX. Remove when this is merged and released:
|
|
100
|
-
// https://github.com/Leaflet/Leaflet/pull/9052
|
|
101
|
-
L.DomEvent.disableClickPropagation(container)
|
|
102
|
-
|
|
103
|
-
const title = L.DomUtil.add(
|
|
104
|
-
'h3',
|
|
105
|
-
'umap-browse-title',
|
|
106
|
-
container,
|
|
107
|
-
this.map.options.name
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
const formContainer = L.DomUtil.create('div', '', container)
|
|
111
|
-
const dataContainer = L.DomUtil.create('div', 'umap-browse-features', container)
|
|
112
|
-
|
|
113
|
-
const appendAll = () => {
|
|
114
|
-
dataContainer.innerHTML = ''
|
|
115
|
-
this.map.eachBrowsableDataLayer((datalayer) => {
|
|
116
|
-
this.addDatalayer(datalayer, dataContainer)
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
const resetLayers = () => {
|
|
120
|
-
this.map.eachBrowsableDataLayer((datalayer) => {
|
|
121
|
-
datalayer.resetLayer(true)
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
const fields = [
|
|
125
|
-
['options.filter', { handler: 'Input', placeholder: L._('Filter') }],
|
|
126
|
-
['options.inBbox', { handler: 'Switch', label: L._('Current map view') }],
|
|
127
|
-
]
|
|
128
|
-
const builder = new L.U.FormBuilder(this, fields, {
|
|
129
|
-
makeDirty: false,
|
|
130
|
-
callback: (e) => {
|
|
131
|
-
if (e.helper.field === 'options.inBbox') {
|
|
132
|
-
if (this.options.inBbox) this.map.on('moveend', appendAll)
|
|
133
|
-
else this.map.off('moveend', appendAll)
|
|
134
|
-
}
|
|
135
|
-
appendAll()
|
|
136
|
-
resetLayers()
|
|
137
|
-
},
|
|
138
|
-
})
|
|
139
|
-
formContainer.appendChild(builder.build())
|
|
140
|
-
|
|
141
|
-
appendAll()
|
|
142
|
-
|
|
143
|
-
this.map.ui.openPanel({
|
|
144
|
-
data: { html: container },
|
|
145
|
-
actions: [this.map._aboutLink()],
|
|
146
|
-
})
|
|
147
|
-
},
|
|
148
|
-
})
|
umap/static/umap/js/umap.xhr.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
L.U.Xhr = L.Evented.extend({
|
|
2
|
-
initialize: function (ui) {
|
|
3
|
-
this.ui = ui
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
_wrapper: function () {
|
|
7
|
-
let wrapper
|
|
8
|
-
if (window.XMLHttpRequest === undefined) {
|
|
9
|
-
wrapper = () => {
|
|
10
|
-
try {
|
|
11
|
-
return new window.ActiveXObject('Microsoft.XMLHTTP.6.0')
|
|
12
|
-
} catch (e1) {
|
|
13
|
-
try {
|
|
14
|
-
return new window.ActiveXObject('Microsoft.XMLHTTP.3.0')
|
|
15
|
-
} catch (e2) {
|
|
16
|
-
throw new Error('XMLHttpRequest is not supported')
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
wrapper = window.XMLHttpRequest
|
|
22
|
-
}
|
|
23
|
-
return new wrapper()
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
_ajax: function (settings) {
|
|
27
|
-
const xhr = this._wrapper(),
|
|
28
|
-
id = Math.random(),
|
|
29
|
-
self = this
|
|
30
|
-
this.fire('dataloading', { id: id })
|
|
31
|
-
const loaded = () => {
|
|
32
|
-
self.fire('dataload', { id: id })
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
xhr.open(settings.verb, settings.uri, true)
|
|
37
|
-
} catch (err) {
|
|
38
|
-
// Unknown protocol?
|
|
39
|
-
this.ui.alert({
|
|
40
|
-
content: L._('Error while fetching {url}', { url: settings.uri }),
|
|
41
|
-
level: 'error',
|
|
42
|
-
})
|
|
43
|
-
loaded()
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
settings.uri.indexOf('http') !== 0 ||
|
|
49
|
-
settings.uri.indexOf(window.location.origin) === 0
|
|
50
|
-
) {
|
|
51
|
-
// "X-" mode headers cause the request to be in preflight mode,
|
|
52
|
-
// we don"t want that by default for CORS requests
|
|
53
|
-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
|
54
|
-
}
|
|
55
|
-
if (settings.headers) {
|
|
56
|
-
for (const name in settings.headers) {
|
|
57
|
-
xhr.setRequestHeader(name, settings.headers[name])
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
xhr.onreadystatechange = () => {
|
|
62
|
-
if (xhr.readyState === 4) {
|
|
63
|
-
if (xhr.status == 200) {
|
|
64
|
-
settings.callback.call(settings.context || xhr, xhr.responseText, xhr)
|
|
65
|
-
} else if (xhr.status === 403) {
|
|
66
|
-
self.ui.alert({
|
|
67
|
-
content: xhr.responseText || L._('Action not allowed :('),
|
|
68
|
-
level: 'error',
|
|
69
|
-
})
|
|
70
|
-
} else if (xhr.status === 412) {
|
|
71
|
-
const msg = L._(
|
|
72
|
-
'Woops! Someone else seems to have edited the data. You can save anyway, but this will erase the changes made by others.'
|
|
73
|
-
)
|
|
74
|
-
const actions = [
|
|
75
|
-
{
|
|
76
|
-
label: L._('Save anyway'),
|
|
77
|
-
callback: function () {
|
|
78
|
-
delete settings.headers['If-Match']
|
|
79
|
-
self._ajax(settings)
|
|
80
|
-
},
|
|
81
|
-
callbackContext: self,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
label: L._('Cancel'),
|
|
85
|
-
},
|
|
86
|
-
]
|
|
87
|
-
self.ui.alert({
|
|
88
|
-
content: msg,
|
|
89
|
-
level: 'error',
|
|
90
|
-
duration: 100000,
|
|
91
|
-
actions: actions,
|
|
92
|
-
})
|
|
93
|
-
} else {
|
|
94
|
-
if (xhr.status === 0) {
|
|
95
|
-
// 0 === request cut by user or CORS
|
|
96
|
-
self.ui.alert({
|
|
97
|
-
content: L._(
|
|
98
|
-
'Issue reaching that URL (network problem or CORS protection): {url}',
|
|
99
|
-
{ url: settings.uri }
|
|
100
|
-
),
|
|
101
|
-
level: 'error',
|
|
102
|
-
})
|
|
103
|
-
} else {
|
|
104
|
-
self.ui.alert({ content: L._('Problem in the response'), level: 'error' })
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
loaded()
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
xhr.send(settings.data)
|
|
113
|
-
} catch (e) {
|
|
114
|
-
// Pass
|
|
115
|
-
loaded()
|
|
116
|
-
console.error('Bad Request', e)
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
// supports only JSON as response data type
|
|
121
|
-
_json: function (verb, uri, options) {
|
|
122
|
-
const args = arguments,
|
|
123
|
-
self = this
|
|
124
|
-
const default_options = {
|
|
125
|
-
async: true,
|
|
126
|
-
callback: null,
|
|
127
|
-
responseType: 'text',
|
|
128
|
-
data: null,
|
|
129
|
-
listen_form: null, // optional form to listen in default callback
|
|
130
|
-
}
|
|
131
|
-
const settings = L.Util.extend({}, default_options, options)
|
|
132
|
-
|
|
133
|
-
if (verb === 'POST') {
|
|
134
|
-
// find a way not to make this django specific
|
|
135
|
-
const token = document.cookie.replace(
|
|
136
|
-
/(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/,
|
|
137
|
-
'$1'
|
|
138
|
-
)
|
|
139
|
-
if (token) {
|
|
140
|
-
settings.headers = settings.headers || {}
|
|
141
|
-
settings.headers['X-CSRFToken'] = token
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const callback = function (responseText, response) {
|
|
146
|
-
let data
|
|
147
|
-
try {
|
|
148
|
-
data = JSON.parse(responseText)
|
|
149
|
-
} catch (err) {
|
|
150
|
-
console.log(err)
|
|
151
|
-
self.ui.alert({
|
|
152
|
-
content: L._('Problem in the response format'),
|
|
153
|
-
level: 'error',
|
|
154
|
-
})
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
if (data.errors) {
|
|
158
|
-
console.log(data.errors)
|
|
159
|
-
self.ui.alert({ content: L._('An error occured'), level: 'error' })
|
|
160
|
-
} else if (data.login_required) {
|
|
161
|
-
// login_required should be an URL for the login form
|
|
162
|
-
if (settings.login_callback) settings.login_callback(data)
|
|
163
|
-
else self.login(data, args)
|
|
164
|
-
} else {
|
|
165
|
-
if (settings.callback)
|
|
166
|
-
L.bind(settings.callback, settings.context || this)(data, response)
|
|
167
|
-
else self.default_callback(data, settings, response)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this._ajax({
|
|
172
|
-
verb: verb,
|
|
173
|
-
uri: uri,
|
|
174
|
-
data: settings.data,
|
|
175
|
-
callback: callback,
|
|
176
|
-
headers: settings.headers,
|
|
177
|
-
listener: settings.listener,
|
|
178
|
-
})
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
get: function (uri, options) {
|
|
182
|
-
this._json('GET', uri, options)
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
post: function (uri, options) {
|
|
186
|
-
this._json('POST', uri, options)
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
submit_form: function (form_id, options) {
|
|
190
|
-
if (typeof options === 'undefined') options = {}
|
|
191
|
-
const form = L.DomUtil.get(form_id)
|
|
192
|
-
const formData = new FormData(form)
|
|
193
|
-
if (options.extraFormData) formData.append(options.extraFormData)
|
|
194
|
-
options.data = formData
|
|
195
|
-
this.post(form.action, options)
|
|
196
|
-
return false
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
listen_form: function (form_id, options) {
|
|
200
|
-
const form = L.DomUtil.get(form_id),
|
|
201
|
-
self = this
|
|
202
|
-
if (!form) return
|
|
203
|
-
L.DomEvent.on(form, 'submit', L.DomEvent.stopPropagation)
|
|
204
|
-
.on(form, 'submit', L.DomEvent.preventDefault)
|
|
205
|
-
.on(form, 'submit', () => {
|
|
206
|
-
self.submit_form(form_id, options)
|
|
207
|
-
})
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
listen_link: function (link_id, options) {
|
|
211
|
-
const link = L.DomUtil.get(link_id),
|
|
212
|
-
self = this
|
|
213
|
-
if (link) {
|
|
214
|
-
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
|
|
215
|
-
if (options.confirm && !confirm(options.confirm)) {
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
self.get(link.href, options)
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
default_callback: function (data, options) {
|
|
224
|
-
// default callback, to avoid boilerplate
|
|
225
|
-
if (data.redirect) {
|
|
226
|
-
const newPath = data.redirect
|
|
227
|
-
if (window.location.pathname == newPath)
|
|
228
|
-
window.location.reload() // Keep the hash, so the current view
|
|
229
|
-
else window.location = newPath
|
|
230
|
-
} else if (data.info) {
|
|
231
|
-
this.ui.alert({ content: data.info, level: 'info' })
|
|
232
|
-
this.ui.closePanel()
|
|
233
|
-
} else if (data.error) {
|
|
234
|
-
this.ui.alert({ content: data.error, level: 'error' })
|
|
235
|
-
} else if (data.html) {
|
|
236
|
-
const ui_options = { data: data }
|
|
237
|
-
let listen_options
|
|
238
|
-
if (options.className) ui_options.className = options.className
|
|
239
|
-
this.ui.openPanel(ui_options)
|
|
240
|
-
// To low boilerplate, if there is a form, listen it
|
|
241
|
-
if (options.listen_form) {
|
|
242
|
-
// Listen form again
|
|
243
|
-
listen_options = L.Util.extend({}, options, options.listen_form.options)
|
|
244
|
-
this.listen_form(options.listen_form.id, listen_options)
|
|
245
|
-
}
|
|
246
|
-
if (options.listen_link) {
|
|
247
|
-
for (let i = 0, l = options.listen_link.length; i < l; i++) {
|
|
248
|
-
// Listen link again
|
|
249
|
-
listen_options = L.Util.extend({}, options, options.listen_link[i].options)
|
|
250
|
-
this.listen_link(options.listen_link[i].id, listen_options)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
} else if (options.success) {
|
|
254
|
-
// Success is called only if data contain no msg and no html
|
|
255
|
-
options.success(data)
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
login: function (data, args) {
|
|
260
|
-
// data.html: login form
|
|
261
|
-
// args: args of the first _json call, to call again at process end
|
|
262
|
-
const self = this
|
|
263
|
-
const proceed = () => {
|
|
264
|
-
self.ui.closePanel()
|
|
265
|
-
if (typeof args !== 'undefined') self._json.apply(self, args)
|
|
266
|
-
else self.default_callback(data, {})
|
|
267
|
-
}
|
|
268
|
-
const ask_for_login = (data) => {
|
|
269
|
-
self.ui.openPanel({ data: data, className: 'login-panel' })
|
|
270
|
-
self.listen_form('login_form', {
|
|
271
|
-
callback: function (data) {
|
|
272
|
-
if (data.html) ask_for_login(data) // Problem in the login - ask again
|
|
273
|
-
else proceed()
|
|
274
|
-
},
|
|
275
|
-
})
|
|
276
|
-
// Auth links
|
|
277
|
-
const links = document.getElementsByClassName('umap-login-popup')
|
|
278
|
-
Object.keys(links).forEach((el) => {
|
|
279
|
-
const link = links[el]
|
|
280
|
-
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
|
|
281
|
-
self.ui.closePanel()
|
|
282
|
-
const win = window.open(link.href)
|
|
283
|
-
window.umap_proceed = () => {
|
|
284
|
-
proceed()
|
|
285
|
-
win.close()
|
|
286
|
-
}
|
|
287
|
-
})
|
|
288
|
-
})
|
|
289
|
-
}
|
|
290
|
-
if (data.login_required) {
|
|
291
|
-
this.get(data.login_required, {
|
|
292
|
-
callback: function (data) {
|
|
293
|
-
ask_for_login(data)
|
|
294
|
-
},
|
|
295
|
-
})
|
|
296
|
-
} else {
|
|
297
|
-
ask_for_login(data)
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
logout: function (url) {
|
|
302
|
-
this.get(url)
|
|
303
|
-
},
|
|
304
|
-
})
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
describe('L.U.Controls', function () {
|
|
2
|
-
before(function () {
|
|
3
|
-
this.server = sinon.fakeServer.create()
|
|
4
|
-
this.server.respondWith(
|
|
5
|
-
/\/datalayer\/62\/\?.*/,
|
|
6
|
-
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
|
-
)
|
|
8
|
-
this.map = initMap({ umap_id: 99 })
|
|
9
|
-
this.server.respond()
|
|
10
|
-
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
11
|
-
})
|
|
12
|
-
after(function () {
|
|
13
|
-
this.server.restore()
|
|
14
|
-
resetMap()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
describe('#databrowser()', function () {
|
|
18
|
-
let poly, marker, line
|
|
19
|
-
before(function () {
|
|
20
|
-
this.datalayer.eachLayer(function (layer) {
|
|
21
|
-
if (!poly && layer instanceof L.Polygon) {
|
|
22
|
-
poly = layer
|
|
23
|
-
} else if (!line && layer instanceof L.Polyline) {
|
|
24
|
-
line = layer
|
|
25
|
-
} else if (!marker && layer instanceof L.Marker) {
|
|
26
|
-
marker = layer
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should be opened at datalayer button click', function () {
|
|
32
|
-
var button = qs('.umap-browse-actions .umap-browse-link')
|
|
33
|
-
assert.ok(button)
|
|
34
|
-
happen.click(button)
|
|
35
|
-
assert.ok(qs('#umap-ui-container .umap-browse-data'))
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should contain datalayer section', function () {
|
|
39
|
-
assert.ok(qs('#browse_data_datalayer_62'))
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it("should contain datalayer's features list", function () {
|
|
43
|
-
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should sort feature in natural order', function () {
|
|
47
|
-
poly.properties.name = '9. a poly'
|
|
48
|
-
marker.properties.name = '1. a marker'
|
|
49
|
-
line.properties.name = '100. a line'
|
|
50
|
-
this.datalayer.reindex()
|
|
51
|
-
this.map.openBrowser()
|
|
52
|
-
const els = qsa('.umap-browse-features li')
|
|
53
|
-
assert.equal(els.length, 3)
|
|
54
|
-
assert.equal(els[0].textContent, '1. a marker')
|
|
55
|
-
assert.equal(els[1].textContent, '9. a poly')
|
|
56
|
-
assert.equal(els[2].textContent, '100. a line')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it("should redraw datalayer's features list at feature delete", function () {
|
|
60
|
-
var oldConfirm = window.confirm
|
|
61
|
-
window.confirm = function () {
|
|
62
|
-
return true
|
|
63
|
-
}
|
|
64
|
-
enableEdit()
|
|
65
|
-
happen.once(qs('path[fill="DarkBlue"]'), { type: 'contextmenu' })
|
|
66
|
-
happen.click(qs('.leaflet-contextmenu .umap-delete'))
|
|
67
|
-
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 2)
|
|
68
|
-
window.confirm = oldConfirm
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it("should redraw datalayer's features list on edit cancel", function () {
|
|
72
|
-
clickCancel()
|
|
73
|
-
happen.click(qs('.umap-browse-actions .umap-browse-link'))
|
|
74
|
-
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
describe('#exportPanel()', function () {
|
|
79
|
-
it('should be opened at datalayer button click', function () {
|
|
80
|
-
let button = qs('.leaflet-control-embed button')
|
|
81
|
-
assert.ok(button)
|
|
82
|
-
happen.click(button)
|
|
83
|
-
assert.ok(qs('#umap-ui-container .umap-share'))
|
|
84
|
-
})
|
|
85
|
-
it('should update iframe link', function () {
|
|
86
|
-
let textarea = qs('.umap-share-iframe')
|
|
87
|
-
assert.ok(textarea)
|
|
88
|
-
console.log(textarea.textContent)
|
|
89
|
-
assert.include(textarea.textContent, 'src="')
|
|
90
|
-
assert.include(textarea.textContent, 'href="')
|
|
91
|
-
// We should ave both, once for iframe link, once for full screen
|
|
92
|
-
assert.include(textarea.textContent, 'scrollWheelZoom=true')
|
|
93
|
-
assert.include(textarea.textContent, 'scrollWheelZoom=false')
|
|
94
|
-
assert.notInclude(textarea.textContent, 'datalayers=62')
|
|
95
|
-
let switcher = qs('label[title="Keep current visible layers"]')
|
|
96
|
-
happen.click(switcher)
|
|
97
|
-
assert.include(textarea.textContent, 'datalayers=62')
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
describe('L.U.Map.initialize', function () {
|
|
2
|
-
afterEach(function () {
|
|
3
|
-
resetMap()
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
describe('Controls', function () {
|
|
7
|
-
it('should not show a minimap by default', function () {
|
|
8
|
-
this.map = initMap()
|
|
9
|
-
assert.notOk(qs('.leaflet-control-minimap'))
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('should show a minimap', function () {
|
|
13
|
-
this.map = initMap({ miniMap: true })
|
|
14
|
-
assert.ok(qs('.leaflet-control-minimap'))
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('DefaultView', function () {
|
|
19
|
-
it('should set default view in default mode without data', function (done) {
|
|
20
|
-
this.map = initMap({ datalayers: [] })
|
|
21
|
-
// Did not find a better way to wait for tiles to be actually loaded
|
|
22
|
-
window.setTimeout(() => {
|
|
23
|
-
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
24
|
-
done()
|
|
25
|
-
}, 1000)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it("should set default view in 'data' mode without data", function (done) {
|
|
29
|
-
this.map = initMap({ datalayers: [], defaultView: 'data' })
|
|
30
|
-
// Did not find a better way to wait for tiles to be actually loaded
|
|
31
|
-
window.setTimeout(() => {
|
|
32
|
-
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
33
|
-
done()
|
|
34
|
-
}, 1000)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it("should set default view in 'latest' mode without data", function (done) {
|
|
38
|
-
this.map = initMap({ datalayers: [], defaultView: 'latest' })
|
|
39
|
-
// Did not find a better way to wait for tiles to be actually loaded
|
|
40
|
-
window.setTimeout(() => {
|
|
41
|
-
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
42
|
-
done()
|
|
43
|
-
}, 1000)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|