From 17dc43290bb821c77eaaf196e4c6fef4d5c1a343 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Dec 2016 08:45:18 +0500 Subject: Added links to server in mail templates --- src/org/traccar/Context.java | 8 ++++++++ src/org/traccar/notification/NotificationFormatter.java | 1 + templates/mail/alarm.vm | 2 +- templates/mail/commandResult.vm | 1 + templates/mail/deviceMoving.vm | 2 +- templates/mail/deviceOffline.vm | 1 + templates/mail/deviceOnline.vm | 1 + templates/mail/deviceOverspeed.vm | 2 +- templates/mail/deviceStopped.vm | 2 +- templates/mail/deviceUnknown.vm | 1 + templates/mail/geofenceEnter.vm | 2 +- templates/mail/geofenceExit.vm | 2 +- templates/mail/ignitionOff.vm | 2 +- templates/mail/ignitionOn.vm | 2 +- templates/mail/maintenance.vm | 2 +- 15 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index ef515ad2f..62396d740 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -17,6 +17,7 @@ package org.traccar; import com.ning.http.client.AsyncHttpClient; +import java.net.InetAddress; import java.util.Properties; import org.apache.velocity.app.VelocityEngine; @@ -256,6 +257,13 @@ public final class Context { Context.getConfig().getString("mail.templatesPath", "templates/mail") + "/"); velocityProperties.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogChute"); + + String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress()); + String port = config.getString("web.port", "8082"); + String webUrl = "http://" + address + ":" + port + "/"; + webUrl = Context.getConfig().getString("web.url", webUrl); + velocityProperties.setProperty("web.url", webUrl); + velocityEngine = new VelocityEngine(); velocityEngine.init(velocityProperties); } diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index 2d580922c..819c387d1 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -45,6 +45,7 @@ public final class NotificationFormatter { if (event.getGeofenceId() != 0) { velocityContext.put("geofence", Context.getGeofenceManager().getGeofence(event.getGeofenceId())); } + velocityContext.put("webUrl", Context.getVelocityEngine().getProperty("web.url")); Template template = null; try { diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm index 57b6ba9be..03cd31646 100644 --- a/templates/mail/alarm.vm +++ b/templates/mail/alarm.vm @@ -4,7 +4,7 @@ Device: $device.name
Alarm: $position.getString("alarm")
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/commandResult.vm b/templates/mail/commandResult.vm index 084152158..4c330584d 100644 --- a/templates/mail/commandResult.vm +++ b/templates/mail/commandResult.vm @@ -5,5 +5,6 @@ Device: $device.name
Result: $position.getString("result")
Time: $event.serverTime
+Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm index 2a3c703b5..c603f8222 100644 --- a/templates/mail/deviceMoving.vm +++ b/templates/mail/deviceMoving.vm @@ -4,7 +4,7 @@ Device: $device.name
Moving
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/deviceOffline.vm b/templates/mail/deviceOffline.vm index a62133b71..ee7e96f05 100644 --- a/templates/mail/deviceOffline.vm +++ b/templates/mail/deviceOffline.vm @@ -5,5 +5,6 @@ Device: $device.name
Offline
Time: $event.serverTime
+Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOnline.vm b/templates/mail/deviceOnline.vm index c38393062..379b5cc80 100644 --- a/templates/mail/deviceOnline.vm +++ b/templates/mail/deviceOnline.vm @@ -5,5 +5,6 @@ Device: $device.name
Online
Time: $event.serverTime
+Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm index 5f8c65096..27cf1f704 100644 --- a/templates/mail/deviceOverspeed.vm +++ b/templates/mail/deviceOverspeed.vm @@ -11,7 +11,7 @@ Device: $device.name
Exceeds the speed: $speedString
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm index 003ce2e13..a831b9abb 100644 --- a/templates/mail/deviceStopped.vm +++ b/templates/mail/deviceStopped.vm @@ -4,7 +4,7 @@ Device: $device.name
Stopped
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/deviceUnknown.vm b/templates/mail/deviceUnknown.vm index 75203bdfc..40b8fbfa7 100644 --- a/templates/mail/deviceUnknown.vm +++ b/templates/mail/deviceUnknown.vm @@ -5,5 +5,6 @@ Device: $device.name
Status is unknown
Time: $event.serverTime
+Link: $webUrl?eventId=$event.id diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm index 32ee153bc..2cdd24ee4 100644 --- a/templates/mail/geofenceEnter.vm +++ b/templates/mail/geofenceEnter.vm @@ -4,7 +4,7 @@ Device: $device.name
Has entered geofence: $geofence.name
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm index b01653e49..d1a717159 100644 --- a/templates/mail/geofenceExit.vm +++ b/templates/mail/geofenceExit.vm @@ -4,7 +4,7 @@ Device: $device.name
Has exited geofence: $geofence.name
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm index b45ecfca1..9985d4ff3 100644 --- a/templates/mail/ignitionOff.vm +++ b/templates/mail/ignitionOff.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition OFF
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm index b2f1041bb..20211ce00 100644 --- a/templates/mail/ignitionOn.vm +++ b/templates/mail/ignitionOn.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition ON
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm index c7bc1a960..7a9d32fa7 100644 --- a/templates/mail/maintenance.vm +++ b/templates/mail/maintenance.vm @@ -4,7 +4,7 @@ Device: $device.name
Maintenance is required
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
Time: $event.serverTime
+Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
-- cgit v1.2.3