From 4f0b73c769a2dce7bbdc11704606f84cf6f9fde0 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 14 Jan 2026 21:39:58 +0000 Subject: [PATCH] Add URL for Tegola to configuration Avoid cross-environment pollution. --- config/config.go | 6 +++++- sync/dash.go | 8 ++++++++ sync/template/dashboard.html | 6 ++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index 94184e6a..1b6ac507 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,7 @@ import ( "strconv" ) -var Bind, ClientID, ClientSecret, Environment, FieldseekerSchemaDirectory, MapboxToken, PGDSN, URLReport, URLSync, FilesDirectoryPublic, FilesDirectoryUser string +var Bind, ClientID, ClientSecret, Environment, FilesDirectoryPublic, FilesDirectoryUser, FieldseekerSchemaDirectory, MapboxToken, PGDSN, URLReport, URLSync, URLTegola string // Build the ArcGIS authorization URL with PKCE func BuildArcGISAuthURL(clientID string) string { @@ -59,6 +59,10 @@ func Parse() error { if URLSync == "" { return fmt.Errorf("You must specify a non-empty URL_SYNC") } + URLTegola = os.Getenv("URL_TEGOLA") + if URLTegola == "" { + return fmt.Errorf("You must specify a non-empty URL_TEGOLA") + } Bind = os.Getenv("BIND") if Bind == "" { Bind = ":9001" diff --git a/sync/dash.go b/sync/dash.go index ae855655..e66a2fe0 100644 --- a/sync/dash.go +++ b/sync/dash.go @@ -29,7 +29,12 @@ var ( sourceT = buildTemplate("source", "authenticated") ) +type Config struct { + URLTegola string +} + type ContextDashboard struct { + Config Config CountInspections int CountMosquitoSources int CountServiceRequests int @@ -233,6 +238,9 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) { return } data := ContextDashboard{ + Config: Config{ + URLTegola: config.URLTegola, + }, CountInspections: int(inspectionCount), CountMosquitoSources: int(sourceCount), CountServiceRequests: int(serviceCount), diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html index 36347afd..4dbb7ceb 100644 --- a/sync/template/dashboard.html +++ b/sync/template/dashboard.html @@ -20,8 +20,7 @@ function onLoad() { map.addSource('tegola-bonn', { 'type': 'vector', 'tiles': [ - //'https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=MLY|4142433049200173|72206abe5035850d6743b23a49c41333' - 'https://tegola.nidus.cloud/maps/bonn/{z}/{x}/{y}' + 'https://{{.Config.URLTegola}}/maps/bonn/{z}/{x}/{y}' ] //'minzoom': 6, //'maxzoom': 14 @@ -29,8 +28,7 @@ function onLoad() { map.addSource('tegola-nidus', { 'type': 'vector', 'tiles': [ - //'https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=MLY|4142433049200173|72206abe5035850d6743b23a49c41333' - 'https://tegola.nidus.cloud/maps/nidus/{z}/{x}/{y}?organization_id=1' + 'https://{{.Config.URLTegola}}/maps/nidus/{z}/{x}/{y}?organization_id={{.User.OrganizationID}}' ] //'minzoom': 6, //'maxzoom': 14