mirror of
https://github.com/umap-project/umap.git
synced 2025-05-08 07:11:49 +02:00
Compare commits
No commits in common. "d0156bc7a626c8c6b82ee7c8866cde47780f4df7" and "a7b714c887abb3abf5dd632310030e5b5b2a7c8d" have entirely different histories.
d0156bc7a6
...
a7b714c887
5 changed files with 18 additions and 16 deletions
|
@ -55,6 +55,7 @@ export class DataLayerUpdater extends BaseUpdater {
|
||||||
upsert({ value }) {
|
upsert({ value }) {
|
||||||
// Upsert only happens when a new datalayer is created.
|
// Upsert only happens when a new datalayer is created.
|
||||||
this._umap.createDataLayer(value, false)
|
this._umap.createDataLayer(value, false)
|
||||||
|
this._umap.render([])
|
||||||
}
|
}
|
||||||
|
|
||||||
update({ key, metadata, value }) {
|
update({ key, metadata, value }) {
|
||||||
|
|
|
@ -1261,10 +1261,9 @@ export default class Umap extends ServerStored {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(fields = []) {
|
render(fields) {
|
||||||
// Propagate will remove the fields it has already
|
const impacted = this.propagate(fields)
|
||||||
// processed
|
if (impacted) return // No need to run a wider reflow
|
||||||
fields = this.propagate(fields)
|
|
||||||
|
|
||||||
const impacts = Utils.getImpactsFromSchema(fields)
|
const impacts = Utils.getImpactsFromSchema(fields)
|
||||||
for (const impact of impacts) {
|
for (const impact of impacts) {
|
||||||
|
@ -1328,13 +1327,14 @@ export default class Umap extends ServerStored {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
let impacted = false
|
||||||
for (const [field, impact] of Object.entries(impacts)) {
|
for (const [field, impact] of Object.entries(impacts)) {
|
||||||
if (!fields.length || fields.includes(field)) {
|
if (!fields.length || fields.includes(field)) {
|
||||||
impact()
|
impact()
|
||||||
fields = fields.filter((item) => item !== field)
|
impacted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fields
|
return impacted
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: allow to control the default datalayer
|
// TODO: allow to control the default datalayer
|
||||||
|
@ -1537,6 +1537,7 @@ export default class Umap extends ServerStored {
|
||||||
|
|
||||||
importRaw(rawData) {
|
importRaw(rawData) {
|
||||||
const importedData = JSON.parse(rawData)
|
const importedData = JSON.parse(rawData)
|
||||||
|
const mustReindex = 'sortKey' in Object.keys(importedData.properties)
|
||||||
|
|
||||||
this.setProperties(importedData.properties)
|
this.setProperties(importedData.properties)
|
||||||
|
|
||||||
|
@ -1553,12 +1554,12 @@ export default class Umap extends ServerStored {
|
||||||
dataLayer.fromUmapGeoJSON(geojson)
|
dataLayer.fromUmapGeoJSON(geojson)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now render->propagate expect a `properties.` prefix.
|
this._leafletMap.renderUI()
|
||||||
// Remove this when we have refactored schema and render.
|
this.eachDataLayer((datalayer) => {
|
||||||
const fields = Object.keys(importedData.properties).map(
|
if (mustReindex) datalayer.reindex()
|
||||||
(field) => `properties.${field}`
|
datalayer.redraw()
|
||||||
)
|
})
|
||||||
this.render(fields)
|
this.propagate()
|
||||||
this._leafletMap._setDefaultCenter()
|
this._leafletMap._setDefaultCenter()
|
||||||
this.isDirty = true
|
this.isDirty = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class LicenceFactory(factory.django.DjangoModelFactory):
|
||||||
|
|
||||||
class TileLayerFactory(factory.django.DjangoModelFactory):
|
class TileLayerFactory(factory.django.DjangoModelFactory):
|
||||||
name = "Test zoom layer"
|
name = "Test zoom layer"
|
||||||
url_template = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
url_template = "https://{s}.test.org/osmfr/{z}/{x}/{y}.png"
|
||||||
attribution = "Test layer attribution"
|
attribution = "Test layer attribution"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -156,6 +156,5 @@ def login_required(response):
|
||||||
|
|
||||||
|
|
||||||
def mock_tiles(route):
|
def mock_tiles(route):
|
||||||
print("Intercepted route", route.request.url)
|
|
||||||
path = Path(__file__).parent / "fixtures/empty_tile.png"
|
path = Path(__file__).parent / "fixtures/empty_tile.png"
|
||||||
route.fulfill(path=path)
|
route.fulfill(path=path)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -26,7 +25,7 @@ def set_timeout(context):
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_osm_tiles(page):
|
def mock_osm_tiles(page):
|
||||||
if not bool(os.environ.get("PWDEBUG", False)):
|
if not bool(os.environ.get("PWDEBUG", False)):
|
||||||
page.route(re.compile(r".*tile\..*"), mock_tiles)
|
page.route("*/**/osmfr/**", mock_tiles)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
@ -72,6 +72,8 @@ def test_umap_import_from_file(live_server, tilelayer, page):
|
||||||
|
|
||||||
|
|
||||||
def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
|
def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
|
||||||
|
page.route("https://tile.openstreetmap.fr/hot/**", mock_tiles)
|
||||||
|
|
||||||
settings.UMAP_ALLOW_ANONYMOUS = True
|
settings.UMAP_ALLOW_ANONYMOUS = True
|
||||||
page.goto(f"{live_server.url}/map/new/")
|
page.goto(f"{live_server.url}/map/new/")
|
||||||
page.get_by_role("button", name="Open browser").click()
|
page.get_by_role("button", name="Open browser").click()
|
||||||
|
|
Loading…
Reference in a new issue