Requested changes

4.x.x
Arcane94 7 years ago
parent e778700a5e
commit 50a14e4321

@ -306,7 +306,7 @@ public interface GeoLocationBasedService {
produces = "application/json", produces = "application/json",
httpMethod = "POST", httpMethod = "POST",
value = "Create Geo alerts for geo clusters", value = "Create Geo alerts for geo clusters",
notes = "", notes = "Creating geo alerts for cluster of devices",
response = Response.class, response = Response.class,
tags = "Geo Service Management", tags = "Geo Service Management",
extensions = { extensions = {
@ -424,7 +424,7 @@ public interface GeoLocationBasedService {
produces = "application/json", produces = "application/json",
httpMethod = "GET", httpMethod = "GET",
value = "Update Geo alerts for geo clusters", value = "Update Geo alerts for geo clusters",
notes = "", notes = "Updating an existing geo alert that was defined for geo clusters",
response = Response.class, response = Response.class,
tags = "Geo Service Management", tags = "Geo Service Management",
extensions = { extensions = {
@ -541,7 +541,7 @@ public interface GeoLocationBasedService {
produces = "application/json", produces = "application/json",
httpMethod = "GET", httpMethod = "GET",
value = "Retrieve Geo alerts for geo clusters", value = "Retrieve Geo alerts for geo clusters",
notes = "", notes = "Retrieve all the defined alerts for a specific alert type",
response = Response.class, response = Response.class,
tags = "Geo Service Management", tags = "Geo Service Management",
extensions = { extensions = {
@ -663,7 +663,7 @@ public interface GeoLocationBasedService {
produces = "application/json", produces = "application/json",
httpMethod = "GET", httpMethod = "GET",
value = "Retrieve Geo alerts history for geo clusters", value = "Retrieve Geo alerts history for geo clusters",
notes = "", notes = "Retrieving geo alert history of all defined alerts for geo clusters",
response = Response.class, response = Response.class,
tags = "Geo Service Management", tags = "Geo Service Management",
extensions = { extensions = {
@ -786,8 +786,8 @@ public interface GeoLocationBasedService {
consumes = "application/json", consumes = "application/json",
produces = "application/json", produces = "application/json",
httpMethod = "DELETE", httpMethod = "DELETE",
value = "Deletes Geo alerts for the device", value = "Deletes Geo alerts for geo clusters",
notes = "", notes = "Deleting any type of a geo alert that was defined for geo clusters",
response = Response.class, response = Response.class,
tags = "Geo Service Management", tags = "Geo Service Management",
extensions = { extensions = {

@ -192,11 +192,6 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@Produces("application/json") @Produces("application/json")
public Response createGeoAlertsForGeoClusters(Alert alert, @PathParam("alertType") String alertType) { public Response createGeoAlertsForGeoClusters(Alert alert, @PathParam("alertType") String alertType) {
try { try {
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()
);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
geoService.createGeoAlert(alert, alertType); geoService.createGeoAlert(alert, alertType);
return Response.ok().build(); return Response.ok().build();
@ -255,11 +250,6 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@Produces("application/json") @Produces("application/json")
public Response updateGeoAlertsForGeoClusters(Alert alert, @PathParam("alertType") String alertType) { public Response updateGeoAlertsForGeoClusters(Alert alert, @PathParam("alertType") String alertType) {
try { try {
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()
);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
geoService.updateGeoAlert(alert, alertType); geoService.updateGeoAlert(alert, alertType);
return Response.ok().build(); return Response.ok().build();
@ -314,11 +304,6 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@Produces("application/json") @Produces("application/json")
public Response removeGeoAlertsForGeoClusters(@PathParam("alertType") String alertType, @QueryParam("queryName") String queryName) { public Response removeGeoAlertsForGeoClusters(@PathParam("alertType") String alertType, @QueryParam("queryName") String queryName) {
try { try {
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()
);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
geoService.removeGeoAlert(alertType, queryName); geoService.removeGeoAlert(alertType, queryName);
return Response.ok().build(); return Response.ok().build();
@ -387,34 +372,34 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@Produces("application/json") @Produces("application/json")
public Response getGeoAlertsForGeoClusters(@PathParam("alertType") String alertType) { public Response getGeoAlertsForGeoClusters(@PathParam("alertType") String alertType) {
try { try {
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()
);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
List<GeoFence> alerts = null;
if (GeoServices.ALERT_TYPE_WITHIN.equals(alertType)) { String result = null;
List<GeoFence> alerts = geoService.getWithinAlerts();
return Response.ok().entity(alerts).build(); switch (alertType) {
} else if (GeoServices.ALERT_TYPE_EXIT.equals(alertType)) { case GeoServices.ALERT_TYPE_WITHIN:
List<GeoFence> alerts = geoService.getExitAlerts(); alerts = geoService.getWithinAlerts();
return Response.ok().entity(alerts).build(); break;
} else if (GeoServices.ALERT_TYPE_SPEED.equals(alertType)) { case GeoServices.ALERT_TYPE_EXIT:
String result = geoService.getSpeedAlerts(); alerts = geoService.getExitAlerts();
return Response.ok().entity(result).build(); break;
} else if (GeoServices.ALERT_TYPE_PROXIMITY.equals(alertType)) { case GeoServices.ALERT_TYPE_STATIONARY:
String result = geoService.getProximityAlerts(); alerts = geoService.getStationaryAlerts();
return Response.ok().entity(result).build(); break;
} else if (GeoServices.ALERT_TYPE_STATIONARY.equals(alertType)) { case GeoServices.ALERT_TYPE_TRAFFIC:
List<GeoFence> alerts = geoService.getStationaryAlerts(); alerts = geoService.getTrafficAlerts();
return Response.ok().entity(alerts).build(); break;
} else if (GeoServices.ALERT_TYPE_TRAFFIC.equals(alertType)) { case GeoServices.ALERT_TYPE_SPEED:
List<GeoFence> alerts = geoService.getTrafficAlerts(); result = geoService.getSpeedAlerts();
return Response.ok().entity(alerts).build(); return Response.ok().entity(result).build();
case GeoServices.ALERT_TYPE_PROXIMITY:
result = geoService.getProximityAlerts();
return Response.ok().entity(result).build();
default:
throw new GeoLocationBasedServiceException("Invalid Alert Type");
} }
return null; return Response.ok().entity(alerts).build();
} catch (GeoLocationBasedServiceException e) { } catch (GeoLocationBasedServiceException e) {
String error = "Error occurred while getting the geo alerts for " + alertType + " alert"; String error = "Error occurred while getting the geo alerts for " + alertType + " alert";
log.error(error, e); log.error(error, e);
@ -493,25 +478,21 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
String authorizedUser = MultitenantUtils.getTenantAwareUsername( String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()); CarbonContext.getThreadLocalCarbonContext().getUsername());
try { String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query, 0,
0, 100,
100, sortByFields);
sortByFields); List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(), searchResults);
searchResults); return Response.ok().entity(events).build();
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) { } catch (AnalyticsException | UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException( throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
}
} catch (Exception e) {
log.error(e.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
} }
} }

@ -73,6 +73,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Collections;
import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices.DAS_PORT; import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices.DAS_PORT;
import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices.DEFAULT_HTTP_PROTOCOL; import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices.DEFAULT_HTTP_PROTOCOL;
@ -171,7 +172,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
resource = registry.get(registryPath); resource = registry.get(registryPath);
} catch (RegistryException e) { } catch (RegistryException e) {
log.error("Error while reading the registry path: " + registryPath); log.error("Error while reading the registry path: " + registryPath);
return null; return Collections.emptyList();
} }
try { try {
@ -266,7 +267,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
resource = registry.get(registryPath); resource = registry.get(registryPath);
} catch (RegistryException e) { } catch (RegistryException e) {
log.error("Error while reading the registry path: " + registryPath); log.error("Error while reading the registry path: " + registryPath);
return null; return Collections.emptyList();
} }
try { try {
@ -612,7 +613,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
if ("Traffic".equals(alertType)) { if ("Traffic".equals(alertType)) {
return "Geo-ExecutionPlan-Traffic_" + queryName + "_alert"; return "Geo-ExecutionPlan-Traffic_" + queryName + "_alert";
} else { } else {
if (alertType.equals("Speed")) { if ("Speed".equals(alertType)) {
return "Geo-ExecutionPlan-" + alertType + "---" + "_alert"; return "Geo-ExecutionPlan-" + alertType + "---" + "_alert";
} }
return "Geo-ExecutionPlan-" + alertType + "_" + queryName + "---" + "_alert"; return "Geo-ExecutionPlan-" + alertType + "_" + queryName + "---" + "_alert";
@ -891,7 +892,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
resource = registry.get(registryPath); resource = registry.get(registryPath);
} catch (RegistryException e) { } catch (RegistryException e) {
log.error("Error while reading the registry path: " + registryPath); log.error("Error while reading the registry path: " + registryPath);
return null; return Collections.emptyList();
} }
try { try {
@ -988,7 +989,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
resource = registry.get(registryPath); resource = registry.get(registryPath);
} catch (RegistryException e) { } catch (RegistryException e) {
log.error("Error while reading the registry path: " + registryPath); log.error("Error while reading the registry path: " + registryPath);
return null; return Collections.emptyList();
} }
try { try {

@ -20,20 +20,23 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <title></title>
<style> <style>
.fa-trash-o:hover{color:red;} .fa-trash-o:hover {
color: red;
}
</style> </style>
<script> <script>
$(".removeGeoFence").tooltip(); $(".removeGeoFence").tooltip();
$('.viewGeoFenceRow td:not(:last-child)').click(function () { $('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'Traffic'); viewFence(this.parentElement, 'Traffic');
}); });
</script> </script>
</head> </head>
<body> <body>
<div class="modal-header" style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);"> <div class="modal-header"
style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button> <button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"> <h4 class="modal-title">
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip --> <!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
@ -42,61 +45,60 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
<p class="text-info text-center">View current fences</p>
<div class="">
<table class="table table-hover">
<thead>
<tr >
<th>Query Name</th>
<th>Traffic Congestion Area Name</th>
<th></th>
</tr>
</thead>
<tbody>
<% <p class="text-info text-center">View current fences</p>
<div class="">
<table class="table table-hover">
<thead>
<tr>
<th>Query Name</th>
<th>Traffic Congestion Area Name</th>
<th></th>
</tr>
</thead>
<tbody>
<%
var alerts = get('traffic'); var alerts = get('traffic');
if(alerts){ if(alerts){
for each(var alert in alerts){ for each(var alert in alerts){
%> %>
<tr class="viewGeoFenceRow" style="cursor: pointer" data-areaName='<%= alert.areaName %>' data-queryName='<%= alert.queryName %>' data-geoJson='<%= alert.geoJson %>'> <tr class="viewGeoFenceRow" style="cursor: pointer" data-areaName='<%= alert.areaName %>'
<td><%= alert.queryName %></td> data-queryName='<%= alert.queryName %>' data-geoJson='<%= alert.geoJson %>'>
<td><%= alert.areaName %></td> <td><%= alert.queryName %></td>
<td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence" data-toggle="tooltip" title="Remove fence" ><i class="fa fa-trash-o"></i></td> <td><%= alert.areaName %></td>
</tr> <td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence"
<% data-toggle="tooltip" title="Remove fence"><i class="fa fa-trash-o"></i></td>
} </tr>
<%
}
} }
else{ else{
%> %>
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again. <strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
</div> </div>
<% <%
} }
%> %>
</tbody> </tbody>
</table> </table>
</div> </div>
<p class="text-info text-center">Select Interested Area</p> <p class="text-info text-center">Select Interested Area</p>
<div style="margin-bottom: -15px" class="btn-group btn-group-justified"> <div style="margin-bottom: -15px" class="btn-group btn-group-justified">
<div class="btn-group"> <div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="openTools('Traffic')">Draw area</button> <button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="openTools('Traffic')">Draw area
</button>
</div> </div>
<div class="btn-group"> <div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="$('#editWithinGeoJSON').modal('toggle')" >Enter area</button> <button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="$('#editWithinGeoJSON').modal('toggle')">Enter area
</button>
</div> </div>
<!--<div class="btn-group">-->
<!--<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>-->
<!--</div>-->
</div> </div>
</div> </div>
</div> </div>

@ -417,13 +417,12 @@ function formatDate(date) {
var ampm = hours >= 12 ? 'pm' : 'am'; var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12; hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12' hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes; minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm; var strTime = hours + ':' + minutes + ' ' + ampm;
return date.getDate() + "/" + date.getMonth()+1 + "/" + date.getFullYear() + " " + strTime; return date.getDate() + "/" + date.getMonth() + 1 + "/" + date.getFullYear() + " " + strTime;
} }
function timeSince(date) { function timeSince(date) {
if (!date) { if (!date) {
return "time is unknown"; return "time is unknown";
} }
@ -462,6 +461,5 @@ function timeSince(date) {
if (interval > 1 || interval === 0) { if (interval > 1 || interval === 0) {
intervalType += 's'; intervalType += 's';
} }
return interval + ' ' + intervalType + ' ago'; return interval + ' ' + intervalType + ' ago';
} }

@ -21,14 +21,12 @@ function initializeExit() {
$("#exit-alert > tbody").empty(); $("#exit-alert > tbody").empty();
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Exit"; var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Exit";
invokerUtil.get(serverUrl, function (response) { invokerUtil.get(serverUrl, function (response) {
if (response == "[]") { if (response) {
$(".fence-not-exist").show(); response = JSON.parse(response);
$("#exit-alert").hide();
} }
else if (response) { if (response && response.length) {
$(".fence-not-exist").hide(); $(".fence-not-exist").hide();
$("#exit-alert").show(); $("#exit-alert").show();
response = JSON.parse(response);
for (var index in response) { for (var index in response) {
var alertBean = response[index]; var alertBean = response[index];
$("#exit-alert > tbody").append( $("#exit-alert > tbody").append(

@ -34,7 +34,6 @@ function loadGeoFencing() {
map.on('draw:created', function (e) { map.on('draw:created', function (e) {
var type = e.layerType, layer = e.layer; var type = e.layerType, layer = e.layer;
drawnItems.addLayer(layer); drawnItems.addLayer(layer);
console.log("created layer for "+ lastId);
createPopup(layer,lastId); createPopup(layer,lastId);
}); });
} }
@ -48,7 +47,6 @@ function openTools(id) {
} catch(e) { } catch(e) {
console.log("error: " + e.message); console.log("error: " + e.message);
} }
console.log("removed drawControl");
} }
if (removeAllControl) { if (removeAllControl) {
try { try {
@ -56,7 +54,6 @@ function openTools(id) {
} catch(e) { } catch(e) {
console.log("error: " + e.message); console.log("error: " + e.message);
} }
console.log("removed removeAllControl");
} }
if (drawnItems) { if (drawnItems) {
try{ try{
@ -65,7 +62,6 @@ function openTools(id) {
} catch(e) { } catch(e) {
console.log("error: " + e.message); console.log("error: " + e.message);
} }
console.log("removed drawnItems");
} }
closeAll(); closeAll();
@ -255,7 +251,6 @@ function openTools(id) {
map.on('draw:created', function (e) { map.on('draw:created', function (e) {
var type = e.layerType, layer = e.layer; var type = e.layerType, layer = e.layer;
drawnItems.addLayer(layer); drawnItems.addLayer(layer);
console.log("created layer for "+ lastId);
createPopup(layer,lastId); createPopup(layer,lastId);
}); });
} }
@ -273,7 +268,6 @@ function createPopup(layer,id) {
} else if (id=="Traffic") { } else if (id=="Traffic") {
var popupTemplate = $('#setTrafficAlert'); var popupTemplate = $('#setTrafficAlert');
popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id); popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id);
//console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id);
} else if (id=="Prediction") { } else if (id=="Prediction") {
getPrediction(layer._leaflet_id); getPrediction(layer._leaflet_id);
return; return;
@ -283,7 +277,7 @@ function createPopup(layer,id) {
popupTemplate.find('.editGeoJson').attr('leaflet_id', layer._leaflet_id); popupTemplate.find('.editGeoJson').attr('leaflet_id', layer._leaflet_id);
layer.bindPopup(popupTemplate.html(), {closeOnClick: false, closeButton: false}).openPopup(); layer.bindPopup(popupTemplate.html(), {closeOnClick: false, closeButton: false}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(layer._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); $(layer._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
} }
@ -305,7 +299,6 @@ function closeTools(leafletId) {
map.removeLayer(map._layers[leafletId]); map.removeLayer(map._layers[leafletId]);
map.removeControl(drawControl); map.removeControl(drawControl);
controlDiv.remove(); controlDiv.remove();
console.log("DEBUG: closeTools(leafletId) = "+leafletId);
} }
/* Export selected area on the map as a json encoded geoJson standard file, no back-end calls simple HTML5 trick ;) */ /* Export selected area on the map as a json encoded geoJson standard file, no back-end calls simple HTML5 trick ;) */
@ -421,7 +414,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#stationaryAlertForm').attr('query-name', queryName); popupTemplate.find('#stationaryAlertForm').attr('query-name', queryName);
popupTemplate.find('#viewAreaTime').html(stationeryTime); popupTemplate.find('#viewAreaTime').html(stationeryTime);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup(); geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
}); });
@ -435,7 +427,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#withinAlertForm').attr('area-name', areaName); popupTemplate.find('#withinAlertForm').attr('area-name', areaName);
popupTemplate.find('#withinAlertForm').attr('query-name', queryName); popupTemplate.find('#withinAlertForm').attr('query-name', queryName);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup(); geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
}); });
} else if (id=="Exit") { } else if (id=="Exit") {
@ -448,7 +439,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#exitAlertForm').attr('area-name', areaName); popupTemplate.find('#exitAlertForm').attr('area-name', areaName);
popupTemplate.find('#exitAlertForm').attr('query-name', queryName); popupTemplate.find('#exitAlertForm').attr('query-name', queryName);
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup(); geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
// transparent the layer .leaflet-popup-content-wrapper
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
}); });
} }

@ -26,9 +26,8 @@ var proximityMap = L.map("proximityMap", {
maxZoom: 20 maxZoom: 20
}); });
var proximityDistance = $("#proximityDistance"); var proximityDistance = $("#proximityDistance");
//TODO invoker-util
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Proximity"; var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Proximity";
// var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts.jag?executionPlanType=Proximity&deviceId=" + deviceId;
invokerUtil.get(serverUrl, function (response) { invokerUtil.get(serverUrl, function (response) {
response = JSON.parse(response); response = JSON.parse(response);
proximityDistance.val(response.proximityDistance); proximityDistance.val(response.proximityDistance);
@ -57,7 +56,6 @@ var measureLine = new L.Polyline(
[centerLocation, resizeIconLocation ], [centerLocation, resizeIconLocation ],
{ color: "black", opacity: 0.5, stroke: true }); { color: "black", opacity: 0.5, stroke: true });
proximityMap.addLayer(measureLine); proximityMap.addLayer(measureLine);
measureLine._path.setAttribute("class", 'measuring-line-for-look'); measureLine._path.setAttribute("class", 'measuring-line-for-look');
@ -69,7 +67,7 @@ var options = {
displayPartialDistance: false, displayPartialDistance: false,
className: 'measuring-label-tooltip' /*css label class name*/ className: 'measuring-label-tooltip' /*css label class name*/
}; };
// var totalDistancePopup = new L.Popup(options,measureLine);
var initialDistance = centerLocation.distanceTo(resizeIconLocation); var initialDistance = centerLocation.distanceTo(resizeIconLocation);
var measureCircle = L.circle(centerLocation, initialDistance).addTo(proximityMap); var measureCircle = L.circle(centerLocation, initialDistance).addTo(proximityMap);

@ -23,12 +23,10 @@ function initStationaryAlert() {
$(".removeGeoFence").tooltip(); $(".removeGeoFence").tooltip();
$("#stationary-alert-table > tbody").empty(); $("#stationary-alert-table > tbody").empty();
invokerUtil.get(serverUrl, function (response) { invokerUtil.get(serverUrl, function (response) {
if (response == "[]") { if (response) {
$(".fence-not-exist").show();
$("#stationary-alert-table").hide();
}
else if (response) {
response = JSON.parse(response); response = JSON.parse(response);
}
if (response && response.length) {
$(".fence-not-exist").hide(); $(".fence-not-exist").hide();
$("#stationary-alert-table").show(); $("#stationary-alert-table").show();
for (var index in response) { for (var index in response) {
@ -42,7 +40,7 @@ function initStationaryAlert() {
" onClick=removeGeoFence(this.parentElement,'Stationery') data-toggle=" + " onClick=removeGeoFence(this.parentElement,'Stationery') data-toggle=" +
" 'tooltip' title='Remove fence' ><i class='fa fa-trash-o'></i></td></tr>") " 'tooltip' title='Remove fence' ><i class='fa fa-trash-o'></i></td></tr>")
} }
} else{ } else {
$(".fence-not-exist").show(); $(".fence-not-exist").show();
$("#stationary-alert-table").hide(); $("#stationary-alert-table").hide();
} }

@ -21,14 +21,12 @@ function initializeWithin() {
$("#within-alert > tbody").empty(); $("#within-alert > tbody").empty();
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Within"; var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Within";
invokerUtil.get(serverUrl, function (response) { invokerUtil.get(serverUrl, function (response) {
if (response == "[]") { if (response) {
$(".fence-not-exist").show(); response = JSON.parse(response);
$("#within-alert").hide();
} }
else if (response) { if (response && response.length) {
$(".fence-not-exist").hide(); $(".fence-not-exist").hide();
$("#within-alert").show(); $("#within-alert").show();
response = JSON.parse(response);
for (var index in response) { for (var index in response) {
var alertBean = response[index]; var alertBean = response[index];
$("#within-alert > tbody").append( $("#within-alert > tbody").append(

@ -24,10 +24,7 @@ function showAlertInMap(alertData) {
var state = $(alertData).attr("data-state"); var state = $(alertData).attr("data-state");
var information = $(alertData).attr("data-information"); var information = $(alertData).attr("data-information");
console.log(information);
var alertLatLngPoint = L.latLng(latitude,longitude); var alertLatLngPoint = L.latLng(latitude,longitude);
var alertOccouredArea = L.circle(alertLatLngPoint, 10, { var alertOccouredArea = L.circle(alertLatLngPoint, 10, {
color: '#FF9900', color: '#FF9900',
fillColor: '#FF00FF', fillColor: '#FF00FF',
@ -42,5 +39,4 @@ function showAlertInMap(alertData) {
map.setView(alertLatLngPoint,18); map.setView(alertLatLngPoint,18);
/* TODO: for reference <Update lib or remove if not in use>: This `R`(RaphaelLayer: https://github.com/dynmeth/RaphaelLayer) library is dam buggy can't use it reliably */ /* TODO: for reference <Update lib or remove if not in use>: This `R`(RaphaelLayer: https://github.com/dynmeth/RaphaelLayer) library is dam buggy can't use it reliably */
} }

@ -32,6 +32,7 @@ var deviceType;
var isBatchModeOn = false; var isBatchModeOn = false;
var wsToken; var wsToken;
var geoPublicUri; var geoPublicUri;
var initLoading = true;
function processPointMessage(geoJsonFeature) { function processPointMessage(geoJsonFeature) {
if (geoJsonFeature.id in currentSpatialObjects) { if (geoJsonFeature.id in currentSpatialObjects) {
@ -220,9 +221,6 @@ function Alert(type, message, level) {
} }
} }
var initLoading = true;
var webSocketOnAlertOpen = function () { var webSocketOnAlertOpen = function () {
$('#ws-alert-stream').removeClass('text-muted text-danger text-success').addClass('text-success'); $('#ws-alert-stream').removeClass('text-muted text-danger text-success').addClass('text-success');
}; };
@ -263,8 +261,6 @@ var webSocketSpatialOnMessage = function (message) {
processPointMessage(json); processPointMessage(json);
} else if (json.messageType == "Prediction") { } else if (json.messageType == "Prediction") {
//processPredictionMessage(json); //processPredictionMessage(json);
} else {
console.log("Message type not supported.");
} }
} }
}; };

Loading…
Cancel
Save