|
@@ -222,7 +222,6 @@ function addLocationMarker(location) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function loadAllAddresses() {
|
|
function loadAllAddresses() {
|
|
|
-
|
|
|
|
|
if(infoWindow === false) {
|
|
if(infoWindow === false) {
|
|
|
infoWindow = new google.maps.InfoWindow();
|
|
infoWindow = new google.maps.InfoWindow();
|
|
|
}
|
|
}
|
|
@@ -233,45 +232,55 @@ function loadAllAddresses() {
|
|
|
* @property {Boolean} response.success
|
|
* @property {Boolean} response.success
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
- let $allAddresses = $("a[data-all-addresses]");
|
|
|
|
|
|
|
+ const $allAddresses = $("a[data-all-addresses]");
|
|
|
|
|
|
|
|
$.get("/api/addresses/get-all", {
|
|
$.get("/api/addresses/get-all", {
|
|
|
submit: $("#submit").val()
|
|
submit: $("#submit").val()
|
|
|
}, function(response) {
|
|
}, function(response) {
|
|
|
if(!response.success) return false;
|
|
if(!response.success) return false;
|
|
|
|
|
|
|
|
- let map = maps["map"];
|
|
|
|
|
- let key = "all-addresses";
|
|
|
|
|
|
|
+ const map = maps["map"];
|
|
|
|
|
+ const key = "all-addresses";
|
|
|
|
|
|
|
|
markerGroups[key] = [];
|
|
markerGroups[key] = [];
|
|
|
|
|
|
|
|
- let addressCount = response.addresses.length;
|
|
|
|
|
|
|
+ response.addresses.forEach(address => {
|
|
|
|
|
|
|
|
- for(let i = 0; i < addressCount; ++i) {
|
|
|
|
|
|
|
+ const user = address.user;
|
|
|
|
|
+ let icon = "user-grey.png";
|
|
|
|
|
|
|
|
- let address = response.addresses[i];
|
|
|
|
|
-
|
|
|
|
|
- let position = {
|
|
|
|
|
- lat: address.latitude,
|
|
|
|
|
- lng: address.longitude
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ if(user.daysSinceLastTest !== null) {
|
|
|
|
|
+ console.log(user.daysSinceLastTest);
|
|
|
|
|
+ if(user.daysSinceLastTest > 90) {
|
|
|
|
|
+ icon = "user-grey.png";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(user.daysSinceLastTest > 60) {
|
|
|
|
|
+ icon = "user-green.png";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(user.daysSinceLastTest > 30) {
|
|
|
|
|
+ icon = "user-orange.png";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ icon = "user-red.png";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- var options = {
|
|
|
|
|
- position: position,
|
|
|
|
|
|
|
+ let marker = new google.maps.Marker({
|
|
|
|
|
+ position: {
|
|
|
|
|
+ lat: address.latitude,
|
|
|
|
|
+ lng: address.longitude
|
|
|
|
|
+ },
|
|
|
title: address.name,
|
|
title: address.name,
|
|
|
- map: map
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- let marker = new google.maps.Marker(options);
|
|
|
|
|
|
|
+ map: map,
|
|
|
|
|
+ icon: `/img/markers/${icon}`
|
|
|
|
|
+ });
|
|
|
addMarkerClickListenerForAddress(marker, address);
|
|
addMarkerClickListenerForAddress(marker, address);
|
|
|
|
|
|
|
|
markerGroups[key].push(marker);
|
|
markerGroups[key].push(marker);
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
$allAddresses.data("selected", true);
|
|
$allAddresses.data("selected", true);
|
|
|
$allAddresses.find(".badge").addClass("badge-danger").text(response.addresses.length);
|
|
$allAddresses.find(".badge").addClass("badge-danger").text(response.addresses.length);
|
|
|
-
|
|
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|