|
|
@@ -3,6 +3,7 @@ var infoWindow = false;
|
|
|
|
|
|
$(function() {
|
|
|
|
|
|
+ // On customer select
|
|
|
$("a[data-customer-id]").click(function(event) {
|
|
|
let customerId = $(this).data("customer-id");
|
|
|
|
|
|
@@ -26,6 +27,7 @@ $(function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
+ // On project select
|
|
|
$("a[data-project-id]").click(function(event) {
|
|
|
let projectId = $(this).data("project-id");
|
|
|
|
|
|
@@ -49,6 +51,7 @@ $(function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
+ // On all addresses select
|
|
|
$("a[data-all-addresses]").click(function(event) {
|
|
|
|
|
|
let key = "all-addresses";
|
|
|
@@ -75,13 +78,21 @@ $(function() {
|
|
|
|
|
|
function loadCustomerLocations(customerId) {
|
|
|
|
|
|
- if(infoWindow == false) {
|
|
|
+ if(infoWindow === false) {
|
|
|
infoWindow = new google.maps.InfoWindow();
|
|
|
}
|
|
|
|
|
|
let minDate = $("#min-date").val();
|
|
|
let maxDate = $("#max-date").val();
|
|
|
|
|
|
+ let $customerItem = $("a[data-customer-id=" + customerId + "]");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @property {Object} response
|
|
|
+ * @property {Array} response.locations
|
|
|
+ * @property {Boolean} response.success
|
|
|
+ */
|
|
|
+
|
|
|
$.get("/account/map-overview/get-customer-locations", {
|
|
|
customer_id: customerId,
|
|
|
min_date: minDate,
|
|
|
@@ -95,32 +106,36 @@ function loadCustomerLocations(customerId) {
|
|
|
|
|
|
markerGroups[key] = [];
|
|
|
|
|
|
- for(let i in response.locations) {
|
|
|
- let l = response.locations[i];
|
|
|
+ let count = response.locations.length;
|
|
|
+
|
|
|
+ for(let i = 0; i < count; ++i) {
|
|
|
+ let location = response.locations[i];
|
|
|
|
|
|
let position = {
|
|
|
- lat: l.latitude,
|
|
|
- lng: l.longitude
|
|
|
+ lat: location.latitude,
|
|
|
+ lng: location.longitude
|
|
|
};
|
|
|
|
|
|
var options = {
|
|
|
position: position,
|
|
|
- title: l.name,
|
|
|
+ title: location.name,
|
|
|
map: map
|
|
|
};
|
|
|
|
|
|
- if(l.icon) options.icon = "/img/markers/" + l.icon;
|
|
|
+ if(location.icon) options.icon = "/img/markers/" + location.icon;
|
|
|
+ if(location.doNotTest) options.icon = "/img/markers/do_not_test.png";
|
|
|
+ if(location.closed) options.icon = "/img/markers/closed.png";
|
|
|
|
|
|
infoWindow.setContent("");
|
|
|
|
|
|
let marker = new google.maps.Marker(options);
|
|
|
- addMarkerClickListenerForLocation(marker, l);
|
|
|
+ addMarkerClickListenerForLocation(marker, location);
|
|
|
|
|
|
markerGroups[key].push(marker);
|
|
|
}
|
|
|
|
|
|
- $("a[data-customer-id=" + customerId + "]").data("selected", true);
|
|
|
- $("a[data-customer-id=" + customerId + "]").find(".badge").addClass("badge-danger").text(response.locations.length);
|
|
|
+ $customerItem.data("selected", true);
|
|
|
+ $customerItem.find(".badge").addClass("badge-danger").text(response.locations.length);
|
|
|
|
|
|
});
|
|
|
|
|
|
@@ -128,13 +143,21 @@ function loadCustomerLocations(customerId) {
|
|
|
|
|
|
function loadProjectLocations(projectId) {
|
|
|
|
|
|
- if(infoWindow == false) {
|
|
|
+ if(infoWindow === false) {
|
|
|
infoWindow = new google.maps.InfoWindow();
|
|
|
}
|
|
|
|
|
|
let minDate = $("#min-date").val();
|
|
|
let maxDate = $("#max-date").val();
|
|
|
|
|
|
+ let $projectItem = $("a[data-project-id=" + projectId + "]");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @property {Object} response
|
|
|
+ * @property {Array} response.locations
|
|
|
+ * @property {Boolean} response.success
|
|
|
+ */
|
|
|
+
|
|
|
$.get("/account/map-overview/get-project-locations", {
|
|
|
project_id: projectId,
|
|
|
min_date: minDate,
|
|
|
@@ -148,42 +171,55 @@ function loadProjectLocations(projectId) {
|
|
|
|
|
|
markerGroups[key] = [];
|
|
|
|
|
|
- for(let i in response.locations) {
|
|
|
+ let count = response.locations.length;
|
|
|
+
|
|
|
+ for(let i = 0; i < count; ++i) {
|
|
|
|
|
|
- let l = response.locations[i];
|
|
|
+ let location = response.locations[i];
|
|
|
|
|
|
let position = {
|
|
|
- lat: l.latitude,
|
|
|
- lng: l.longitude
|
|
|
+ lat: location.latitude,
|
|
|
+ lng: location.longitude
|
|
|
};
|
|
|
|
|
|
var options = {
|
|
|
position: position,
|
|
|
- title: l.name,
|
|
|
+ title: location.name,
|
|
|
map: map
|
|
|
};
|
|
|
|
|
|
- if(l.icon) options.icon = "/img/markers/" + l.icon;
|
|
|
+ if(location.icon) options.icon = "/img/markers/" + location.icon;
|
|
|
+ if(location.doNotTest) options.icon = "/img/markers/do_not_test.png";
|
|
|
+ if(location.closed) options.icon = "/img/markers/closed.png";
|
|
|
+
|
|
|
|
|
|
let marker = new google.maps.Marker(options);
|
|
|
- addMarkerClickListenerForLocation(marker, l);
|
|
|
+ addMarkerClickListenerForLocation(marker, location);
|
|
|
|
|
|
markerGroups[key].push(marker);
|
|
|
|
|
|
}
|
|
|
|
|
|
- $("a[data-project-id=" + projectId + "]").data("selected", true);
|
|
|
- $("a[data-project-id=" + projectId + "]").find(".badge").addClass("badge-danger").text(response.locations.length);
|
|
|
+ $projectItem.data("selected", true);
|
|
|
+ $projectItem.find(".badge").addClass("badge-danger").text(response.locations.length);
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function loadAllAddresses() {
|
|
|
|
|
|
- if(infoWindow == false) {
|
|
|
+ if(infoWindow === false) {
|
|
|
infoWindow = new google.maps.InfoWindow();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @property {Object} response
|
|
|
+ * @property {Array} response.addresses
|
|
|
+ * @property {Boolean} response.success
|
|
|
+ */
|
|
|
+
|
|
|
+ let $allAddresses = $("a[data-all-addresses]");
|
|
|
+
|
|
|
$.get("/api/addresses/get-all", {
|
|
|
submit: $("#submit").val()
|
|
|
}, function(response) {
|
|
|
@@ -194,82 +230,93 @@ function loadAllAddresses() {
|
|
|
|
|
|
markerGroups[key] = [];
|
|
|
|
|
|
- for(let i in response.addresses) {
|
|
|
+ let addressCount = response.addresses.length;
|
|
|
+
|
|
|
+ for(let i = 0; i < addressCount; ++i) {
|
|
|
|
|
|
- let a = response.addresses[i];
|
|
|
+ let address = response.addresses[i];
|
|
|
|
|
|
let position = {
|
|
|
- lat: a.latitude,
|
|
|
- lng: a.longitude
|
|
|
+ lat: address.latitude,
|
|
|
+ lng: address.longitude
|
|
|
};
|
|
|
|
|
|
var options = {
|
|
|
position: position,
|
|
|
- title: a.name,
|
|
|
+ title: address.name,
|
|
|
map: map
|
|
|
};
|
|
|
|
|
|
let marker = new google.maps.Marker(options);
|
|
|
- addMarkerClickListenerForAddress(marker, a);
|
|
|
+ addMarkerClickListenerForAddress(marker, address);
|
|
|
|
|
|
markerGroups[key].push(marker);
|
|
|
|
|
|
}
|
|
|
|
|
|
- $("a[data-all-addresses]").data("selected", true);
|
|
|
- $("a[data-all-addresses]").find(".badge").addClass("badge-danger").text(response.addresses.length);
|
|
|
+ $allAddresses.data("selected", true);
|
|
|
+ $allAddresses.find(".badge").addClass("badge-danger").text(response.addresses.length);
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function addMarkerClickListenerForLocation(m, l) {
|
|
|
+function addMarkerClickListenerForLocation(marker, location) {
|
|
|
let map = maps["map"];
|
|
|
- m.addListener("click", function() {
|
|
|
- let content = "<strong><a href=\"/account/locations/" + l.id + "\" target=\"_blank\">" + l.name + "</a></strong><br />";
|
|
|
- if(l.internalId) {
|
|
|
- content += "<div class=\"small\"><strong>Internal ID:</strong> " + l.internalId + "</div>";
|
|
|
+ marker.addListener("click", function() {
|
|
|
+ let content = "<div><strong><a href=\"/account/locations/" + location.id + "\" target=\"_blank\">" + location.name + "</a></strong></div>";
|
|
|
+
|
|
|
+ if(location.doNotTest) {
|
|
|
+ content += "<span class=\"badge badge-warning\">Do Not Test</span>";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(location.closed) {
|
|
|
+ content += "<span class=\"badge badge-danger\">Closed</span>";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(location.internalId) {
|
|
|
+ content += "<div class=\"small\"><strong>Internal ID:</strong> " + location.internalId + "</div>";
|
|
|
}
|
|
|
- content += "<div class=\"small\"><strong>Location ID:</strong> " + l.id + "</div>";
|
|
|
+ content += "<div class=\"small\"><strong>Location ID:</strong> " + location.id + "</div>";
|
|
|
|
|
|
- if(l.test) {
|
|
|
+ if(location.test) {
|
|
|
|
|
|
content += '<hr />';
|
|
|
|
|
|
- content += '<div class="small"><strong>Test ID:</strong> <a href="/account/tests/' + l.test.id + '" target="_blank">' + l.test.id + '</a></div>';
|
|
|
+ content += '<div class="small"><strong>Test ID:</strong> <a href="/account/tests/' + location.test.id + '" target="_blank">' + location.test.id + '</a></div>';
|
|
|
|
|
|
- if(l.test.formattedStartDts) {
|
|
|
- content += '<div class="small"><strong>Date/Time:</strong> ' + l.test.formattedStartDts + '</div>';
|
|
|
+ if(location.test.formattedStartDts) {
|
|
|
+ content += '<div class="small"><strong>Date/Time:</strong> ' + location.test.formattedStartDts + '</div>';
|
|
|
}
|
|
|
|
|
|
- if(l.test.tester) {
|
|
|
- content += '<div class="small"><strong>Tester ID:</strong> ' + l.test.tester.id + '</div>';
|
|
|
- content += '<div class="small"><strong>Tester Name:</strong> <a href="/account/users/' + l.test.tester.id + '" target="_blank">' + l.test.tester.name + '</a></div>';
|
|
|
+ if(location.test.tester) {
|
|
|
+ content += '<div class="small"><strong>Tester ID:</strong> ' + location.test.tester.id + '</div>';
|
|
|
+ content += '<div class="small"><strong>Tester Name:</strong> <a href="/account/users/' + location.test.tester.id + '" target="_blank">' + location.test.tester.name + '</a></div>';
|
|
|
}
|
|
|
|
|
|
let pastDueBadge = '';
|
|
|
- if(l.test.pastDue) {
|
|
|
+ if(location.test.pastDue) {
|
|
|
pastDueBadge = '<span class="badge badge-lg badge-primary">Past Due</span>';
|
|
|
}
|
|
|
|
|
|
- if(l.test.formattedDueDts) {
|
|
|
- content += '<div class="small"><strong>Due:</strong> ' + l.test.formattedDueDts + ' ' + pastDueBadge + '</div>';
|
|
|
+ if(location.test.formattedDueDts) {
|
|
|
+ content += '<div class="small"><strong>Due:</strong> ' + location.test.formattedDueDts + ' ' + pastDueBadge + '</div>';
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
infoWindow.setContent(content);
|
|
|
- infoWindow.open(map, m);
|
|
|
+ infoWindow.open(map, marker);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function addMarkerClickListenerForAddress(m, a) {
|
|
|
+function addMarkerClickListenerForAddress(marker, address) {
|
|
|
let map = maps["map"];
|
|
|
- m.addListener("click", function() {
|
|
|
- let content = "<strong><a href=\"/account/users/" + a.userId + "\" target=\"_blank\">" + a.name + "</a></strong><br />";
|
|
|
- content += "ID: " + a.userId + "<br />";
|
|
|
+ marker.addListener("click", function() {
|
|
|
+ let content = "<strong><a href=\"/account/users/" + address.userId + "\" target=\"_blank\">" + address.name + "</a></strong><br />";
|
|
|
+ content += "ID: " + address.userId + "<br />";
|
|
|
|
|
|
infoWindow.setContent(content);
|
|
|
- infoWindow.open(map, m);
|
|
|
+ infoWindow.open(map, marker);
|
|
|
});
|
|
|
}
|