@ -56,7 +56,7 @@ function addTileUrl() {
var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/tile_servers.jag" ;
var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/tile_servers.jag" ;
// TODO: If failure happens notify user about the error message
// TODO: If failure happens notify user about the error message
$ . post ( serverUrl , data , function ( response ) {
$ . post ( serverUrl , data , function ( response ) {
noty ( { text : '<span style="color: dodgerblue">' + response + '</span>' , type : 'success' } ) ;
noty ( { text : '<span style="color: dodgerblue">' + response + '</span>' , type : 'success' } ) ;
closeAll ( ) ;
closeAll ( ) ;
} ) ;
} ) ;
}
}
@ -75,9 +75,12 @@ function getTileServers() {
} ) ; * /
} ) ; * /
$ . getJSON ( "/api/controllers/tile_servers?serverId=all" , function ( data ) {
$ . getJSON ( "/api/controllers/tile_servers?serverId=all" , function ( data ) {
console . log ( JSON . stringify ( data ) ) ;
$ . each ( data , function ( key , val ) {
$ . each ( data , function ( key , val ) {
noty ( { text : 'Loading... <span style="color: #ccfcff">' + val . NAME + '</span>' , type : 'info' } ) ;
noty ( {
text : 'Loading... <span style="color: #ccfcff">' + val . NAME + '</span>' ,
type : 'info'
} ) ;
//baseLayers[val.name]
//baseLayers[val.name]
var newTileLayer = L . tileLayer (
var newTileLayer = L . tileLayer (
val . URL , {
val . URL , {
@ -152,8 +155,10 @@ function addWmsEndPoint() {
var serverUrl = "/api/controllers/wms_endpoints" ;
var serverUrl = "/api/controllers/wms_endpoints" ;
// TODO: If failure happens notify user about the error message
// TODO: If failure happens notify user about the error message
$ . post ( serverUrl , data , function ( response ) {
$ . post ( serverUrl , data , function ( response ) {
console . log ( "------->><wms_endpoints>" + response ) ;
noty ( {
noty ( { text : '<span style="color: dodgerblue">' + response + '</span>' , type : 'success' } ) ;
text : '<span style="color: dodgerblue">' + response + '</span>' ,
type : 'success'
} ) ;
closeAll ( ) ;
closeAll ( ) ;
} ) ;
} ) ;
}
}
@ -184,7 +189,7 @@ function setSpeedAlert() {
if ( ! speedAlertValue ) {
if ( ! speedAlertValue ) {
var message = "Speed cannot be empty." ;
var message = "Speed cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
data = {
data = {
'parseData' : JSON . stringify ( { 'speedAlertValue' : speedAlertValue , 'deviceId' : deviceId } ) , // parseKey : parseValue pair , this key pair is replace with the key in the template file
'parseData' : JSON . stringify ( { 'speedAlertValue' : speedAlertValue , 'deviceId' : deviceId } ) , // parseKey : parseValue pair , this key pair is replace with the key in the template file
@ -197,7 +202,7 @@ function setSpeedAlert() {
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeAll ( ) ;
closeAll ( ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var result = ( ptrn . exec ( data ) ) ;
var result = ( ptrn . exec ( data ) ) ;
@ -207,12 +212,12 @@ function setSpeedAlert() {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . put ( serviceUrl ,
invokerUtil . put ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
}
}
@ -234,30 +239,31 @@ function setWithinAlert(leafletId) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
var message = "Area Name cannot be empty." ;
var message = "Area Name cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( areaName. indexOf ( " " ) > - 1 ) {
} else if ( $. trim ( areaName) . indexOf ( " " ) > - 1 ) {
var message = "Area Name cannot contain spaces." ;
var message = "Area Name cannot contain spaces." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
areaName = $ . trim ( areaName ) ;
var data = {
var data = {
'parseData' : JSON . stringify ( {
'parseData' : JSON . stringify ( {
'geoFenceGeoJSON' : selectedAreaGeoJson ,
'geoFenceGeoJSON' : selectedAreaGeoJson ,
'executionPlanName' : createExecutionPlanName ( queryName , "WithIn" , deviceId ) ,
'executionPlanName' : createExecutionPlanName ( queryName , "WithIn" , deviceId ) ,
'areaName' : areaName ,
'areaName' : areaName ,
'deviceId' : deviceId
'deviceId' : deviceId
} ) ,
} ) ,
'executionPlan' : 'Within' ,
'executionPlan' : 'Within' ,
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'queryName' : queryName ,
'queryName' : queryName ,
'cepAction' : 'deploy' ,
'cepAction' : 'deploy' ,
'deviceId' : deviceId
'deviceId' : deviceId
} ;
} ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Within/' + deviceType + '/' + deviceId ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Within/' + deviceType + '/' + deviceId ;
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeTools ( leafletId ) ;
closeTools ( leafletId ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var errorTxt ;
var errorTxt ;
@ -267,12 +273,12 @@ function setWithinAlert(leafletId) {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . post ( serviceUrl ,
invokerUtil . post ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
viewFenceByData ( selectedAreaGeoJson , queryName , areaName , null , 'Within' ) ;
viewFenceByData ( selectedAreaGeoJson , queryName , areaName , null , 'Within' ) ;
@ -292,30 +298,31 @@ function setExitAlert(leafletId) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
var message = "Area Name cannot be empty." ;
var message = "Area Name cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( areaName. indexOf ( " " ) > - 1 ) {
} else if ( $. trim ( areaName) . indexOf ( " " ) > - 1 ) {
var message = "Area Name cannot contain spaces." ;
var message = "Area Name cannot contain spaces." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
areaName = $ . trim ( areaName ) ;
var data = {
var data = {
'parseData' : JSON . stringify ( {
'parseData' : JSON . stringify ( {
'geoFenceGeoJSON' : selectedAreaGeoJson ,
'geoFenceGeoJSON' : selectedAreaGeoJson ,
'executionPlanName' : createExecutionPlanName ( queryName , "Exit" , deviceId ) ,
'executionPlanName' : createExecutionPlanName ( queryName , "Exit" , deviceId ) ,
'areaName' : areaName ,
'areaName' : areaName ,
'deviceId' : deviceId
'deviceId' : deviceId
} ) ,
} ) ,
'executionPlan' : 'Exit' ,
'executionPlan' : 'Exit' ,
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'queryName' : queryName ,
'queryName' : queryName ,
'cepAction' : 'deploy' ,
'cepAction' : 'deploy' ,
'deviceId' : deviceId
'deviceId' : deviceId
} ;
} ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Exit/' + deviceType + '/' + deviceId ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Exit/' + deviceType + '/' + deviceId ;
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeTools ( leafletId ) ;
closeTools ( leafletId ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var errorTxt ;
var errorTxt ;
@ -325,12 +332,12 @@ function setExitAlert(leafletId) {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . post ( serviceUrl ,
invokerUtil . post ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
viewFenceByData ( selectedAreaGeoJson , queryName , areaName , null , 'Exit' ) ;
viewFenceByData ( selectedAreaGeoJson , queryName , areaName , null , 'Exit' ) ;
@ -357,25 +364,26 @@ function setStationeryAlert(leafletId) {
if ( stationeryName == null || stationeryName === undefined || stationeryName == "" ) {
if ( stationeryName == null || stationeryName === undefined || stationeryName == "" ) {
var message = "Stationery Name cannot be empty." ;
var message = "Stationery Name cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( stationeryName. indexOf ( " " ) > - 1 ) {
} else if ( $. trim ( stationeryName) . indexOf ( " " ) > - 1 ) {
var message = "Stationery Name cannot contain spaces." ;
var message = "Stationery Name cannot contain spaces." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( fluctuationRadius == null || fluctuationRadius === undefined || fluctuationRadius == "" ) {
} else if ( fluctuationRadius == null || fluctuationRadius === undefined || fluctuationRadius == "" ) {
var message = "Fluctuation Radius cannot be empty." ;
var message = "Fluctuation Radius cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( time == null || time === undefined || time == "" ) {
} else if ( time == null || time === undefined || time == "" ) {
var message = "Time cannot be empty." ;
var message = "Time cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
stationeryName = $ . trim ( stationeryName ) ;
var data = {
var data = {
'parseData' : JSON . stringify ( {
'parseData' : JSON . stringify ( {
'geoFenceGeoJSON' : selectedProcessedAreaGeoJson ,
'geoFenceGeoJSON' : selectedProcessedAreaGeoJson ,
'executionPlanName' : createExecutionPlanName ( queryName , "Stationery" , deviceId ) ,
'executionPlanName' : createExecutionPlanName ( queryName , "Stationery" , deviceId ) ,
'stationeryName' : stationeryName ,
'stationeryName' : stationeryName ,
'stationeryTime' : time ,
'stationeryTime' : time ,
'fluctuationRadius' : fluctuationRadius
'fluctuationRadius' : fluctuationRadius
} ) ,
} ) ,
'stationeryTime' : time ,
'stationeryTime' : time ,
'fluctuationRadius' : fluctuationRadius ,
'fluctuationRadius' : fluctuationRadius ,
'executionPlan' : 'Stationery' ,
'executionPlan' : 'Stationery' ,
@ -388,7 +396,7 @@ function setStationeryAlert(leafletId) {
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeTools ( leafletId ) ;
closeTools ( leafletId ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var errorTxt ;
var errorTxt ;
@ -398,12 +406,12 @@ function setStationeryAlert(leafletId) {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . post ( serviceUrl ,
invokerUtil . post ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
viewFenceByData ( selectedProcessedAreaGeoJson , queryName , areaName , time , 'Stationery' ) ;
viewFenceByData ( selectedProcessedAreaGeoJson , queryName , areaName , time , 'Stationery' ) ;
@ -458,7 +466,6 @@ function setTrafficAlert(leafletId) {
* this is against JSON standards so has been re - replaced when getting the data from governance registry
* this is against JSON standards so has been re - replaced when getting the data from governance registry
* ( look in get _alerts for . replace ( ) method )
* ( look in get _alerts for . replace ( ) method )
* * /
* * /
console . log ( "leafletId: " + leafletId ) ;
var selectedAreaGeoJson = map . _layers [ leafletId ] . toGeoJSON ( ) . geometry ;
var selectedAreaGeoJson = map . _layers [ leafletId ] . toGeoJSON ( ) . geometry ;
//if a circle is drawn adding radius for the object
//if a circle is drawn adding radius for the object
@ -476,29 +483,30 @@ function setTrafficAlert(leafletId) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
if ( areaName == null || areaName === undefined || areaName == "" ) {
var message = "Area Name cannot be empty." ;
var message = "Area Name cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( areaName. indexOf ( " " ) > - 1 ) {
} else if ( $. trim ( areaName) . indexOf ( " " ) > - 1 ) {
var message = "Area Name cannot contain spaces." ;
var message = "Area Name cannot contain spaces." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
areaName = $ . trim ( areaName ) ;
var data = {
var data = {
'parseData' : JSON . stringify ( {
'parseData' : JSON . stringify ( {
'geoFenceGeoJSON' : selectedProcessedAreaGeoJson ,
'geoFenceGeoJSON' : selectedProcessedAreaGeoJson ,
'executionPlanName' : createExecutionPlanName ( queryName , "Traffic" , deviceId ) ,
'executionPlanName' : createExecutionPlanName ( queryName , "Traffic" , deviceId ) ,
'areaName' : areaName
'areaName' : areaName
} ) ,
} ) ,
'executionPlan' : 'Traffic' ,
'executionPlan' : 'Traffic' ,
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'customName' : areaName , // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM
'queryName' : queryName ,
'queryName' : queryName ,
'cepAction' : 'deploy' ,
'cepAction' : 'deploy' ,
'deviceId' : deviceId
'deviceId' : deviceId
} ;
} ;
console . log ( JSON . stringify ( data ) ) ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Traffic/' + deviceType + '/' + deviceId ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/Traffic/' + deviceType + '/' + deviceId ;
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeTools ( leafletId ) ;
closeTools ( leafletId ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var errorTxt ;
var errorTxt ;
@ -508,12 +516,12 @@ function setTrafficAlert(leafletId) {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . post ( serviceUrl ,
invokerUtil . post ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
}
}
@ -524,24 +532,23 @@ function removeGeoFence(geoFenceElement, id) {
var areaName = $ ( geoFenceElement ) . attr ( 'data-areaName' ) ;
var areaName = $ ( geoFenceElement ) . attr ( 'data-areaName' ) ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/' + id + '/' + deviceType + '/' + deviceId + '?queryName='
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/' + id + '/' + deviceType + '/' + deviceId + '?queryName='
+ queryName ;
+ queryName ;
invokerUtil . delete ( serviceUrl , function ( response ) {
invokerUtil . delete ( serviceUrl , function ( response ) {
noty ( {
noty ( {
text : 'Successfully removed ' + id + ' alert' ,
text : 'Successfully removed ' + id + ' alert' ,
type : 'success'
type : 'success'
} ) ;
} ) ;
closeAll ( ) ;
closeAll ( ) ;
} ,
} ,
function ( xhr ) {
function ( xhr ) {
noty ( {
noty ( {
text : 'Could not remove ' + id + ' alert' ,
text : 'Could not remove ' + id + ' alert' ,
type : 'error'
type : 'error'
} )
} )
} ) ;
} ) ;
}
}
function getAlertsHistory ( deviceType , deviceId , timeFrom , timeTo ) {
function getAlertsHistory ( deviceType , deviceId , timeFrom , timeTo ) {
var timeRange = '' ;
var timeRange = '' ;
if ( timeFrom && timeTo ) {
if ( timeFrom && timeTo ) {
@ -549,30 +556,30 @@ function getAlertsHistory(deviceType, deviceId, timeFrom, timeTo) {
}
}
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/history/' + deviceType + '/' + deviceId + timeRange ;
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/history/' + deviceType + '/' + deviceId + timeRange ;
invokerUtil . get ( serviceUrl ,
invokerUtil . get ( serviceUrl ,
function ( data ) {
function ( data ) {
geoAlertsBar . clearAllAlerts ( ) ;
geoAlertsBar . clearAllAlerts ( ) ;
var alerts = JSON . parse ( data ) ;
var alerts = JSON . parse ( data ) ;
$ . each ( alerts , function ( key , val ) {
$ . each ( alerts , function ( key , val ) {
if ( val . values ) {
if ( val . values ) {
val = val . values ;
val = val . values ;
}
}
var msg = deviceType . charAt ( 0 ) . toUpperCase ( ) + deviceType . slice ( 1 ) +
var msg = deviceType . charAt ( 0 ) . toUpperCase ( ) + deviceType . slice ( 1 ) +
" " + deviceId + " " + val . information . replace ( "Alerts: ," , "" ) + " - " + timeSince ( val . timeStamp ) ;
" " + deviceId + " " + val . information . replace ( "Alerts: ," , "" ) + " - " + timeSince ( val . timeStamp ) ;
switch ( val . state ) {
switch ( val . state ) {
case "NORMAL" :
case "NORMAL" :
return ;
return ;
case "WARNING" :
case "WARNING" :
geoAlertsBar . addAlert ( 'warn' , msg , val ) ;
geoAlertsBar . addAlert ( 'warn' , msg , val ) ;
break ;
break ;
case "ALERTED" :
case "ALERTED" :
geoAlertsBar . addAlert ( 'danger' , msg , val ) ;
geoAlertsBar . addAlert ( 'danger' , msg , val ) ;
break ;
break ;
case "OFFLINE" :
case "OFFLINE" :
geoAlertsBar . addAlert ( 'info' , msg , val ) ;
geoAlertsBar . addAlert ( 'info' , msg , val ) ;
break ;
break ;
}
}
} ) ;
} ) ;
} , function ( message ) {
} , function ( message ) {
} ) ;
} ) ;
}
}
@ -584,14 +591,16 @@ function setProximityAlert() {
if ( proximityDistance == null || proximityDistance === undefined || proximityDistance == "" ) {
if ( proximityDistance == null || proximityDistance === undefined || proximityDistance == "" ) {
var message = "Proximity distance cannot be empty." ;
var message = "Proximity distance cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else if ( proximityTime == null || proximityTime === undefined || proximityTime == "" ) {
} else if ( proximityTime == null || proximityTime === undefined || proximityTime == "" ) {
var message = "Proximity Time cannot be empty." ;
var message = "Proximity Time cannot be empty." ;
noty ( { text : message , type : 'error' } ) ;
noty ( { text : message , type : 'error' } ) ;
} else {
} else {
var data = {
var data = {
'parseData' : JSON . stringify ( { 'proximityTime' : proximityTime , 'proximityDistance' : proximityDistance } ) ,
'parseData' : JSON . stringify ( {
'proximityTime' : proximityTime ,
'proximityDistance' : proximityDistance
} ) ,
'proximityTime' : proximityTime ,
'proximityTime' : proximityTime ,
'proximityDistance' : proximityDistance ,
'proximityDistance' : proximityDistance ,
'executionPlan' : 'Proximity' ,
'executionPlan' : 'Proximity' ,
@ -603,7 +612,7 @@ function setProximityAlert() {
var responseHandler = function ( data , textStatus , xhr ) {
var responseHandler = function ( data , textStatus , xhr ) {
closeAll ( ) ;
closeAll ( ) ;
if ( xhr . status == 200 ) {
if ( xhr . status == 200 ) {
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
noty ( { text : 'Successfully added alert' , type : 'success' } ) ;
} else {
} else {
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var ptrn = /(?:<am\:description>)(.*)(?:<\/am\:description>)/g ;
var errorTxt ;
var errorTxt ;
@ -613,12 +622,12 @@ function setProximityAlert() {
} else {
} else {
errorTxt = data ;
errorTxt = data ;
}
}
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
noty ( { text : textStatus + ' : ' + errorTxt , type : 'error' } ) ;
}
}
} ;
} ;
invokerUtil . put ( serviceUrl ,
invokerUtil . put ( serviceUrl ,
data ,
data ,
responseHandler , function ( xhr ) {
responseHandler , function ( xhr ) {
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
responseHandler ( xhr . responseText , xhr . statusText , xhr ) ;
} ) ;
} ) ;
@ -630,7 +639,7 @@ function createExecutionPlanName(queryName, id, deviceId) {
if ( id == "WithIn" ) {
if ( id == "WithIn" ) {
return 'Geo-ExecutionPlan-Within' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
return 'Geo-ExecutionPlan-Within' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
} else if ( id == "Exit" ) {
} else if ( id == "Exit" ) {
return 'Geo-ExecutionPlan-Exit' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
return 'Geo-ExecutionPlan-Exit' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
} else if ( id == "Stationery" ) {
} else if ( id == "Stationery" ) {
return 'Geo-ExecutionPlan-Stationery' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
return 'Geo-ExecutionPlan-Stationery' + ( queryName ? '_' + queryName : '' ) + "---" + ( deviceId ? '_' + deviceId : '' ) + '_alert' ; // TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)