-
{% endblock content %}
@@ -84,20 +141,43 @@
Catchment Areas
mapboxgl.accessToken = "{{ MAPBOX_TOKEN }}";
const map = new mapboxgl.Map({
container: 'user-visit-map',
- style: 'mapbox://styles/mapbox/satellite-streets-v12',
+ style: 'mapbox://styles/mapbox/streets-v12',
center: [{{ lng_avg }}, {{ lat_avg }}],
zoom: 14,
});
+
const userVisits = JSON.parse(document.getElementById('userVisits').textContent);
- userVisits.forEach(loc => {
- new mapboxgl.Marker()
- .setLngLat([loc.lng, loc.lat])
- .setPopup(new mapboxgl.Popup().setHTML(`${loc.entity_name}
${loc.visit_date}`))
- .addTo(map)
- })
- addAccuracyCircles(map, userVisits);
const userCatchments = JSON.parse(document.getElementById('userCatchments').textContent);
- addCatchmentAreas(map, userCatchments)
+
+ map.on('load', () => {
+ userVisits.forEach(loc => {
+ new mapboxgl.Marker()
+ .setLngLat([loc.lng, loc.lat])
+ .setPopup(new mapboxgl.Popup().setHTML(`${loc.entity_name}
${loc.visit_date}`))
+ .addTo(map)
+ });
+
+ addAccuracyCircles(map, userVisits);
+ addCatchmentAreas(map, userCatchments);
+ });
+
+ // Watch for Alpine.js style changes
+ Alpine.effect(() => {
+ const alpineData = Alpine.$data(document.querySelector('[x-data]'));
+ const currentStyle = alpineData.currentStyle;
+ const styles = {
+ 'streets-v12': 'mapbox://styles/mapbox/streets-v12',
+ 'satellite-streets-v12': 'mapbox://styles/mapbox/satellite-streets-v12'
+ };
+ map.setStyle(styles[currentStyle]);
+
+ // Re-add circles and catchments after style changes
+ map.once('style.load', () => {
+ alpineData.currentStyle = currentStyle;
+ addAccuracyCircles(map, userVisits);
+ addCatchmentAreas(map, userCatchments);
+ });
+ });
});
{% endblock %}
diff --git a/commcare_connect/templates/program/dashboard.html b/commcare_connect/templates/program/dashboard.html
new file mode 100644
index 00000000..57f3b461
--- /dev/null
+++ b/commcare_connect/templates/program/dashboard.html
@@ -0,0 +1,78 @@
+{% extends "program/base.html" %}
+{% load static %}
+{% load i18n %}
+{% load django_tables2 %}
+{% block title %}{{ request.org }} - Programs{% endblock %}
+
+{% block breadcrumbs_inner %}
+{{ block.super }}
+
{{ program.name }}
+
{% translate "Dashboard" %}
+{% endblock %}
+{% block content %}
+
+
+
{% trans "Dashboard" %}
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+{% endblock content %}
diff --git a/commcare_connect/users/helpers.py b/commcare_connect/users/helpers.py
index 5cfbe50b..04264954 100644
--- a/commcare_connect/users/helpers.py
+++ b/commcare_connect/users/helpers.py
@@ -34,7 +34,7 @@ def create_hq_user(user, domain, api_key):
try:
hq_request.raise_for_status()
except httpx.HTTPStatusError as e:
- if e.response.status_code == 400 and "already exists" in e.response.text:
+ if e.response.status_code == 400 and "already taken" in e.response.text:
return True
raise CommCareHQAPIException(
f"{e.response.status_code} Error response {e.response.text} while creating user {user.username}"