Requested changes

revert-70aa11f8
Arcane94 7 years ago
parent e778700a5e
commit 50a14e4321

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

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

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

@ -20,20 +20,23 @@
<meta charset="UTF-8">
<title></title>
<style>
.fa-trash-o:hover{color:red;}
.fa-trash-o:hover {
color: red;
}
</style>
<script>
$(".removeGeoFence").tooltip();
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'Traffic');
viewFence(this.parentElement, 'Traffic');
});
</script>
</head>
<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>
<h4 class="modal-title">
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
@ -42,8 +45,6 @@
</div>
<div class="modal-body">
<div class="row">
@ -51,23 +52,24 @@
<div class="">
<table class="table table-hover">
<thead>
<tr >
<tr>
<th>Query Name</th>
<th>Traffic Congestion Area Name</th>
<th></th>
</tr>
</thead>
<tbody>
<%
var alerts = get('traffic');
if(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 %>'
data-queryName='<%= alert.queryName %>' data-geoJson='<%= alert.geoJson %>'>
<td><%= alert.queryName %></td>
<td><%= alert.areaName %></td>
<td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence" data-toggle="tooltip" title="Remove fence" ><i class="fa fa-trash-o"></i></td>
<td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence"
data-toggle="tooltip" title="Remove fence"><i class="fa fa-trash-o"></i></td>
</tr>
<%
}
@ -84,19 +86,19 @@
</table>
</div>
<p class="text-info text-center">Select Interested Area</p>
<div style="margin-bottom: -15px" class="btn-group btn-group-justified">
<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 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 class="btn-group">-->
<!--<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>-->
<!--</div>-->
</div>
</div>
</div>

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

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

@ -34,7 +34,6 @@ function loadGeoFencing() {
map.on('draw:created', function (e) {
var type = e.layerType, layer = e.layer;
drawnItems.addLayer(layer);
console.log("created layer for "+ lastId);
createPopup(layer,lastId);
});
}
@ -48,7 +47,6 @@ function openTools(id) {
} catch(e) {
console.log("error: " + e.message);
}
console.log("removed drawControl");
}
if (removeAllControl) {
try {
@ -56,7 +54,6 @@ function openTools(id) {
} catch(e) {
console.log("error: " + e.message);
}
console.log("removed removeAllControl");
}
if (drawnItems) {
try{
@ -65,7 +62,6 @@ function openTools(id) {
} catch(e) {
console.log("error: " + e.message);
}
console.log("removed drawnItems");
}
closeAll();
@ -255,7 +251,6 @@ function openTools(id) {
map.on('draw:created', function (e) {
var type = e.layerType, layer = e.layer;
drawnItems.addLayer(layer);
console.log("created layer for "+ lastId);
createPopup(layer,lastId);
});
}
@ -273,7 +268,6 @@ function createPopup(layer,id) {
} else if (id=="Traffic") {
var popupTemplate = $('#setTrafficAlert');
popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id);
//console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id);
} else if (id=="Prediction") {
getPrediction(layer._leaflet_id);
return;
@ -283,7 +277,7 @@ function createPopup(layer,id) {
popupTemplate.find('.editGeoJson').attr('leaflet_id', layer._leaflet_id);
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)");
}
@ -305,7 +299,6 @@ function closeTools(leafletId) {
map.removeLayer(map._layers[leafletId]);
map.removeControl(drawControl);
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 ;) */
@ -421,7 +414,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#stationaryAlertForm').attr('query-name', queryName);
popupTemplate.find('#viewAreaTime').html(stationeryTime);
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)");
});
@ -435,7 +427,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#withinAlertForm').attr('area-name', areaName);
popupTemplate.find('#withinAlertForm').attr('query-name', queryName);
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)");
});
} else if (id=="Exit") {
@ -448,7 +439,6 @@ function viewFence(geoFenceElement,id) {
popupTemplate.find('#exitAlertForm').attr('area-name', areaName);
popupTemplate.find('#exitAlertForm').attr('query-name', queryName);
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)");
});
}

@ -26,9 +26,8 @@ var proximityMap = L.map("proximityMap", {
maxZoom: 20
});
var proximityDistance = $("#proximityDistance");
//TODO invoker-util
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) {
response = JSON.parse(response);
proximityDistance.val(response.proximityDistance);
@ -57,7 +56,6 @@ var measureLine = new L.Polyline(
[centerLocation, resizeIconLocation ],
{ color: "black", opacity: 0.5, stroke: true });
proximityMap.addLayer(measureLine);
measureLine._path.setAttribute("class", 'measuring-line-for-look');
@ -69,7 +67,7 @@ var options = {
displayPartialDistance: false,
className: 'measuring-label-tooltip' /*css label class name*/
};
// var totalDistancePopup = new L.Popup(options,measureLine);
var initialDistance = centerLocation.distanceTo(resizeIconLocation);
var measureCircle = L.circle(centerLocation, initialDistance).addTo(proximityMap);

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

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

@ -24,10 +24,7 @@ function showAlertInMap(alertData) {
var state = $(alertData).attr("data-state");
var information = $(alertData).attr("data-information");
console.log(information);
var alertLatLngPoint = L.latLng(latitude,longitude);
var alertOccouredArea = L.circle(alertLatLngPoint, 10, {
color: '#FF9900',
fillColor: '#FF00FF',
@ -42,5 +39,4 @@ function showAlertInMap(alertData) {
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 */
}

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

Loading…
Cancel
Save