@ -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 ( ) ;
} ) ;
} ) ;
}
}
@ -182,12 +187,9 @@ function setSpeedAlert() {
//TODO: get the device Id from the URL
//TODO: get the device Id from the URL
var speedAlertValue = $ ( "#speedAlertValue" ) . val ( ) ;
var speedAlertValue = $ ( "#speedAlertValue" ) . val ( ) ;
if ( speedAlertValue == null || speedAlertValue === undefined || 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 if ( areaName . indexOf ( " " ) > - 1 ) {
var message = "Area Name cannot contain spaces." ;
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
@ -238,10 +240,11 @@ 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 ,
@ -296,10 +299,11 @@ 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 ,
@ -361,7 +365,7 @@ 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 == "" ) {
@ -371,6 +375,7 @@ function setStationeryAlert(leafletId) {
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 ,
@ -461,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
@ -480,10 +484,11 @@ 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 ,
@ -496,7 +501,7 @@ function setTrafficAlert(leafletId) {
'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 ) ;
@ -544,7 +549,6 @@ function removeGeoFence(geoFenceElement, id) {
}
}
function getAlertsHistory ( deviceType , deviceId , timeFrom , timeTo ) {
function getAlertsHistory ( deviceType , deviceId , timeFrom , timeTo ) {
var timeRange = '' ;
var timeRange = '' ;
if ( timeFrom && timeTo ) {
if ( timeFrom && timeTo ) {
@ -592,9 +596,11 @@ function setProximityAlert() {
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' ,