aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-05-14 15:07:15 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-05-14 15:07:15 +1200
commitb512fa18b7ff40cacce09aa5db02f9c29b3e9250 (patch)
treee4ba762f1fd350698b641bc1f0f24be7a19e6724
parentf01ebc2af707bccfd29049afad7d081c58e7f771 (diff)
downloadtraccar-server-b512fa18b7ff40cacce09aa5db02f9c29b3e9250.tar.gz
traccar-server-b512fa18b7ff40cacce09aa5db02f9c29b3e9250.tar.bz2
traccar-server-b512fa18b7ff40cacce09aa5db02f9c29b3e9250.zip
Add mobile web interface
-rw-r--r--default.cfg1
-rw-r--r--src/org/traccar/http/WebServer.java11
-rw-r--r--webm/app.js47
-rw-r--r--webm/index.html13
4 files changed, 70 insertions, 2 deletions
diff --git a/default.cfg b/default.cfg
index 3bc523bf1..6bbaf8ce3 100644
--- a/default.cfg
+++ b/default.cfg
@@ -51,6 +51,7 @@
<entry key='http.application'>../traccar-web/traccar-web.war</entry>
<entry key='http.new'>true</entry>
<entry key='http.path'>web</entry>
+ <entry key='http.mobile'>webm</entry>
<!-- Geocoder options -->
<entry key='geocoder.enable'>false</entry>
diff --git a/src/org/traccar/http/WebServer.java b/src/org/traccar/http/WebServer.java
index 15c8527e8..268b53856 100644
--- a/src/org/traccar/http/WebServer.java
+++ b/src/org/traccar/http/WebServer.java
@@ -21,6 +21,7 @@ import javax.naming.InitialContext;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -55,12 +56,18 @@ public class WebServer {
servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/device/*");
servletHandler.addServlet(new ServletHolder(new MainServlet()), "/*");
+ ResourceHandler mobileResourceHandler = new ResourceHandler();
+ mobileResourceHandler.setResourceBase(properties.getProperty("http.mobile"));
+ mobileResourceHandler.setWelcomeFiles(new String[] {"index.html"});
+ ContextHandler mobileContext = new ContextHandler("/m");
+ mobileContext.setHandler(mobileResourceHandler);
+
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(properties.getProperty("http.path"));
- resourceHandler.setWelcomeFiles(new String[] {"index.html"});
+ resourceHandler.setWelcomeFiles(new String[]{"index.html"});
HandlerList handlerList = new HandlerList();
- handlerList.setHandlers(new Handler[] {servletHandler, resourceHandler});
+ handlerList.setHandlers(new Handler[] {servletHandler, mobileContext, resourceHandler});
server.setHandler(handlerList);
diff --git a/webm/app.js b/webm/app.js
new file mode 100644
index 000000000..744bd22bf
--- /dev/null
+++ b/webm/app.js
@@ -0,0 +1,47 @@
+var mapPanel, toolbar, map;
+
+Ext.application({
+ name: "Traccar",
+
+ launch: function() {
+
+ toolbar = Ext.create('Ext.Toolbar', {
+ docked: 'top',
+ ui: 'light',
+ title: 'Traccar'
+ });
+
+ mapPanel = Ext.create('Ext.Panel', {
+ listeners: {
+ painted: function() {
+
+ var layer = new ol.layer.Tile({ source: new ol.source.OSM({
+ })});
+
+ var view = new ol.View({
+ center: ol.proj.fromLonLat([ -0.1275, 51.507222 ]),
+ zoom: 6,
+ maxZoom: 16
+ });
+
+ map = new ol.Map({
+ target: this.bodyElement.dom.id,
+ layers: [ layer ],
+ view: view
+ });
+ },
+
+ resize: function() {
+ map.updateSize();
+ }
+ }
+ });
+
+ Ext.create('Ext.Panel', {
+ fullscreen: true,
+ layout: 'fit',
+ items: [toolbar, mapPanel]
+ });
+
+ }
+});
diff --git a/webm/index.html b/webm/index.html
new file mode 100644
index 000000000..aa7930ff0
--- /dev/null
+++ b/webm/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Traccar</title>
+<link rel="stylesheet" href="//cdn.sencha.com/touch/sencha-touch-2.4.1/resources/css/sencha-touch.css">
+<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol.css">
+<script type="text/javascript" src="//cdn.sencha.com/touch/sencha-touch-2.4.1/sencha-touch-all-debug.js"></script>
+<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol-debug.js"></script>
+<script type="text/javascript" src="app.js"></script>
+</head>
+<body>
+</body>
+</html>