From bf68718e05f811ffeb2b4b57acab56dca3e7de56 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Wed, 27 Apr 2016 22:22:08 +0200 Subject: Command framework ugly hack version --- src/org/traccar/api/resource/DeviceResource.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index a4bfc1030..90d3ef675 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -19,6 +19,7 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Collection; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -31,7 +32,12 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.traccar.helper.Log; +import org.traccar.model.Command; import org.traccar.model.Device; +import org.traccar.model.Position; +import org.traccar.model.SupportedCommand; @Path("devices") @Produces(MediaType.APPLICATION_JSON) @@ -81,4 +87,11 @@ public class DeviceResource extends BaseResource { return Response.noContent().build(); } + @Path("{id}/supportedcommands") + @GET + public Collection get(@PathParam("id") long id) throws SQLException { + Context.getPermissionsManager().checkDevice(getUserId(), id); + Position latestPosition = Context.getDataManager().getLatestPosition(id); + return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); + } } -- cgit v1.2.3 From 97c2c3d47a7e6ef094038091649c130d2de4b016 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Mon, 2 May 2016 01:08:59 +0200 Subject: Concept update + UI translation support --- src/org/traccar/ServerManager.java | 3 +- src/org/traccar/api/resource/DeviceResource.java | 7 ---- .../api/resource/SupportedCommandResource.java | 45 ++++++++++++++++++++++ src/org/traccar/web/WebServer.java | 13 ++----- web/app/store/SupportedCommands.js | 16 +++++++- 5 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 src/org/traccar/api/resource/SupportedCommandResource.java (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index dae693080..4f8e66130 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -100,7 +100,8 @@ public class ServerManager { for (String commandKey : baseProtocol.getSupportedCommands()) { SupportedCommand supportedCommand = new SupportedCommand(); supportedCommand.setKey(commandKey); - supportedCommand.setName(commandKey); + String commandName = "command" + commandKey.substring(0, 1).toUpperCase() + commandKey.substring(1); + supportedCommand.setName(commandName); result.add(supportedCommand); } } diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index 90d3ef675..f7494aa6a 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -87,11 +87,4 @@ public class DeviceResource extends BaseResource { return Response.noContent().build(); } - @Path("{id}/supportedcommands") - @GET - public Collection get(@PathParam("id") long id) throws SQLException { - Context.getPermissionsManager().checkDevice(getUserId(), id); - Position latestPosition = Context.getDataManager().getLatestPosition(id); - return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); - } } diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java new file mode 100644 index 000000000..849447060 --- /dev/null +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.api.resource; + +import org.traccar.Context; +import org.traccar.api.BaseResource; +import org.traccar.model.Position; +import org.traccar.model.SupportedCommand; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.sql.SQLException; +import java.util.Collection; +import java.util.Collections; + +@Path("supportedcommands") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class SupportedCommandResource extends BaseResource { + + @GET + public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + Context.getPermissionsManager().checkDevice(getUserId(), deviceId); + Position latestPosition = Context.getDataManager().getLatestPosition(deviceId); + if (latestPosition != null) { + return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); + } else { + return Collections.EMPTY_LIST; + } + } + +} diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index dc933aa00..3862d1384 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -41,16 +41,9 @@ import org.traccar.api.CorsResponseFilter; import org.traccar.api.ObjectMapperProvider; import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; -import org.traccar.api.resource.CommandResource; -import org.traccar.api.resource.DeviceResource; -import org.traccar.api.resource.DevicePermissionResource; -import org.traccar.api.resource.GroupPermissionResource; -import org.traccar.api.resource.GroupResource; -import org.traccar.api.resource.PositionResource; -import org.traccar.api.resource.ServerResource; -import org.traccar.api.resource.SessionResource; -import org.traccar.api.resource.UserResource; +import org.traccar.api.resource.*; import org.traccar.helper.Log; +import org.traccar.model.SupportedCommand; public class WebServer { @@ -147,7 +140,7 @@ public class WebServer { resourceConfig.register(CorsResponseFilter.class); resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class, GroupPermissionResource.class, DevicePermissionResource.class, UserResource.class, - GroupResource.class, DeviceResource.class, PositionResource.class); + GroupResource.class, DeviceResource.class, PositionResource.class, SupportedCommandResource.class); servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*"); handlers.addHandler(servletHandler); diff --git a/web/app/store/SupportedCommands.js b/web/app/store/SupportedCommands.js index 2b052b902..64e4af88d 100644 --- a/web/app/store/SupportedCommands.js +++ b/web/app/store/SupportedCommands.js @@ -19,10 +19,22 @@ Ext.define('Traccar.store.SupportedCommands', { model: 'Traccar.model.SupportedCommand', listeners: { - 'beforeload' : function(store, options) { + 'beforeload' : function(store, eOpts) { var proxy; proxy = store.getProxy(); - proxy.setUrl('/api/devices/' + proxy.extraParams.deviceId + '/supportedcommands'); + proxy.setUrl('/api/supportedcommands?deviceId' + proxy.extraParams.deviceId); + }, + 'load' : function(store, records, successful, eOpts) { + if (typeof records !== "undefined") { + records.forEach(function(entry) { + if (typeof entry !== "undefined" && typeof entry.data.name !== "undefined") { + var translatedName = Strings[entry.data.name]; + if (typeof translatedName !== "undefined") { + entry.data.name = translatedName; + } + } + }, this); + } } }, -- cgit v1.2.3 From 1a605980b1a120614ccaeb56faac37b05a81a4e9 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Tue, 3 May 2016 23:15:27 +0200 Subject: Removed database.selectLatestPosition --- setup/unix/traccar.xml | 4 ---- setup/windows/traccar.xml | 4 ---- src/org/traccar/api/resource/SupportedCommandResource.java | 6 +++--- src/org/traccar/database/DataManager.java | 6 ------ 4 files changed, 3 insertions(+), 17 deletions(-) (limited to 'src/org/traccar/api') diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml index 8dfcf6386..2ddf6551f 100644 --- a/setup/unix/traccar.xml +++ b/setup/unix/traccar.xml @@ -152,10 +152,6 @@ SELECT * FROM positions WHERE deviceId = :deviceId AND fixTime BETWEEN :from AND :to ORDER BY fixTime; - - SELECT TOP 1 * FROM positions WHERE deviceId = :deviceId AND protocol IS NOT NULL; - - INSERT INTO positions (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, attributes) VALUES (:deviceId, :protocol, :now, :deviceTime, :fixTime, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :attributes); diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml index 80351325b..bf1b216af 100644 --- a/setup/windows/traccar.xml +++ b/setup/windows/traccar.xml @@ -161,10 +161,6 @@ SELECT * FROM positions WHERE id IN (SELECT positionId FROM devices); - - SELECT TOP 1 * FROM positions WHERE deviceId = :deviceId AND protocol IS NOT NULL; - - UPDATE devices SET positionId = :id WHERE id = :deviceId; diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java index 849447060..bf4fd4969 100644 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -34,9 +34,9 @@ public class SupportedCommandResource extends BaseResource { @GET public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - Position latestPosition = Context.getDataManager().getLatestPosition(deviceId); - if (latestPosition != null) { - return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); + Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); + if (lastPosition != null) { + return Context.getServerManager().getProtocolSuppportedCommands(lastPosition.getProtocol()); } else { return Collections.EMPTY_LIST; } diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 3dba215f6..3732c82eb 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -472,12 +472,6 @@ public class DataManager implements IdentityManager { .executeQuery(Position.class); } - public Position getLatestPosition(long deviceId) throws SQLException { - return QueryBuilder.create(dataSource, getQuery("database.selectLatestPosition")) - .setLong("deviceId", deviceId) - .executeQuerySingle(Position.class); - } - public Server getServer() throws SQLException { return QueryBuilder.create(dataSource, getQuery("database.selectServers")) .executeQuerySingle(Server.class); -- cgit v1.2.3 From 1cc86f7df5704aa19d1af643c5fbf852a301858b Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Wed, 4 May 2016 12:49:23 +0200 Subject: SupportedCommand model removed --- src/org/traccar/ServerManager.java | 12 ++----- src/org/traccar/api/resource/DeviceResource.java | 5 --- .../api/resource/SupportedCommandResource.java | 3 +- src/org/traccar/model/SupportedCommand.java | 39 ---------------------- src/org/traccar/web/WebServer.java | 1 - web/app/Application.js | 3 +- web/app/model/SupportedCommand.js | 28 ---------------- web/app/store/SupportedCommands.js | 16 ++------- web/app/view/CommandDialog.js | 2 +- web/app/view/CommandDialogController.js | 3 ++ 10 files changed, 12 insertions(+), 100 deletions(-) delete mode 100644 src/org/traccar/model/SupportedCommand.java delete mode 100644 web/app/model/SupportedCommand.js (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 1fc145869..73c21599f 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -15,8 +15,6 @@ */ package org.traccar; -import org.traccar.model.SupportedCommand; - import java.io.File; import java.net.URI; import java.net.URL; @@ -92,17 +90,13 @@ public class ServerManager { } } - public Collection getProtocolSuppportedCommands(String protocol) { - ArrayList result = new ArrayList<>(); + public Collection getProtocolSuppportedCommands(String protocol) { + ArrayList result = new ArrayList<>(); if (protocol != null) { BaseProtocol baseProtocol = protocols.get(protocol); for (String commandKey : baseProtocol.getSupportedCommands()) { - SupportedCommand supportedCommand = new SupportedCommand(); - supportedCommand.setKey(commandKey); - String commandName = "command" + commandKey.substring(0, 1).toUpperCase() + commandKey.substring(1); - supportedCommand.setName(commandName); - result.add(supportedCommand); + result.add(commandKey); } } diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index f7494aa6a..5c58d3b32 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -19,7 +19,6 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Collection; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -33,11 +32,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.traccar.helper.Log; -import org.traccar.model.Command; import org.traccar.model.Device; -import org.traccar.model.Position; -import org.traccar.model.SupportedCommand; @Path("devices") @Produces(MediaType.APPLICATION_JSON) diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java index bf4fd4969..097acaa4f 100644 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -18,7 +18,6 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.model.Position; -import org.traccar.model.SupportedCommand; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -32,7 +31,7 @@ import java.util.Collections; public class SupportedCommandResource extends BaseResource { @GET - public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); if (lastPosition != null) { diff --git a/src/org/traccar/model/SupportedCommand.java b/src/org/traccar/model/SupportedCommand.java deleted file mode 100644 index a8f31ab30..000000000 --- a/src/org/traccar/model/SupportedCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.traccar.model; - -public class SupportedCommand { - - private String key; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 3862d1384..46add3a75 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -43,7 +43,6 @@ import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; import org.traccar.api.resource.*; import org.traccar.helper.Log; -import org.traccar.model.SupportedCommand; public class WebServer { diff --git a/web/app/Application.js b/web/app/Application.js index da3fdd505..f68ef981e 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -30,8 +30,7 @@ Ext.define('Traccar.Application', { 'Device', 'Position', 'Attribute', - 'Command', - 'SupportedCommand' + 'Command' ], stores: [ diff --git a/web/app/model/SupportedCommand.js b/web/app/model/SupportedCommand.js deleted file mode 100644 index 35c34c8cd..000000000 --- a/web/app/model/SupportedCommand.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.define('Traccar.model.SupportedCommand', { - extend: 'Ext.data.Model', - identifier: 'negative', - - fields: [{ - name: 'key', - type: 'string' - }, { - name: 'name', - type: 'string' - }] -}); diff --git a/web/app/store/SupportedCommands.js b/web/app/store/SupportedCommands.js index 64e4af88d..612909180 100644 --- a/web/app/store/SupportedCommands.js +++ b/web/app/store/SupportedCommands.js @@ -16,25 +16,15 @@ Ext.define('Traccar.store.SupportedCommands', { extend: 'Ext.data.Store', - model: 'Traccar.model.SupportedCommand', + fields: [ + { type: 'string', name: 'key'} + ], listeners: { 'beforeload' : function(store, eOpts) { var proxy; proxy = store.getProxy(); proxy.setUrl('/api/supportedcommands?deviceId' + proxy.extraParams.deviceId); - }, - 'load' : function(store, records, successful, eOpts) { - if (typeof records !== "undefined") { - records.forEach(function(entry) { - if (typeof entry !== "undefined" && typeof entry.data.name !== "undefined") { - var translatedName = Strings[entry.data.name]; - if (typeof translatedName !== "undefined") { - entry.data.name = translatedName; - } - } - }, this); - } } }, diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index e24105699..05412f39c 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -31,7 +31,7 @@ Ext.define('Traccar.view.CommandDialog', { name: 'type', fieldLabel: Strings.commandType, store: 'SupportedCommands', - displayField: 'name', + displayField: 'key', valueField: 'key', listeners: { select: 'onSelect' diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js index 93109a2d6..ec6b8b3b9 100644 --- a/web/app/view/CommandDialogController.js +++ b/web/app/view/CommandDialogController.js @@ -18,6 +18,9 @@ Ext.define('Traccar.view.CommandDialogController', { extend: 'Ext.app.ViewController', alias: 'controller.commandDialog', + onShow: function () { + }, + onSelect: function (selected) { this.lookupReference('paramPositionPeriodic').setHidden( selected.getValue() !== 'positionPeriodic'); -- cgit v1.2.3 From 5bf82eff1ecac7b23661cea14be26aa7a3e4d09a Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Wed, 4 May 2016 14:15:49 +0200 Subject: Checkstyle fix --- src/org/traccar/ServerManager.java | 10 ++++++++-- src/org/traccar/api/resource/SupportedCommandResource.java | 6 +++++- src/org/traccar/web/WebServer.java | 11 ++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 73c21599f..59bb88829 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -20,7 +20,13 @@ import java.net.URI; import java.net.URL; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -91,7 +97,7 @@ public class ServerManager { } public Collection getProtocolSuppportedCommands(String protocol) { - ArrayList result = new ArrayList<>(); + List result = new ArrayList<>(); if (protocol != null) { BaseProtocol baseProtocol = protocols.get(protocol); diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java index 097acaa4f..393588d9b 100644 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -19,7 +19,11 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.model.Position; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import java.sql.SQLException; import java.util.Collection; diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 46add3a75..e61bf3d45 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -41,7 +41,16 @@ import org.traccar.api.CorsResponseFilter; import org.traccar.api.ObjectMapperProvider; import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; -import org.traccar.api.resource.*; +import org.traccar.api.resource.CommandResource; +import org.traccar.api.resource.GroupPermissionResource; +import org.traccar.api.resource.ServerResource; +import org.traccar.api.resource.SessionResource; +import org.traccar.api.resource.DevicePermissionResource; +import org.traccar.api.resource.UserResource; +import org.traccar.api.resource.GroupResource; +import org.traccar.api.resource.DeviceResource; +import org.traccar.api.resource.PositionResource; +import org.traccar.api.resource.SupportedCommandResource; import org.traccar.helper.Log; public class WebServer { -- cgit v1.2.3 From be2e936c935fa8674f09ee3617b1ecfae4b90ff9 Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Wed, 4 May 2016 14:51:30 +0200 Subject: Merge failure fix --- src/org/traccar/api/resource/DeviceResource.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index 18c4cb0ce..d7ab3ba24 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -33,6 +33,9 @@ import javax.ws.rs.core.Response; import org.traccar.model.Device; +import java.sql.SQLException; +import java.util.Collection; + @Path("devices") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -- cgit v1.2.3 From be0040a7c18f5c165f1aaa27a194a189f50b1510 Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Thu, 5 May 2016 15:36:56 +0200 Subject: Backend side model put back --- src/org/traccar/ServerManager.java | 10 +++++--- .../api/resource/SupportedCommandResource.java | 3 ++- src/org/traccar/model/SupportedCommand.java | 29 ++++++++++++++++++++++ web/app/store/SupportedCommands.js | 4 +-- 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/org/traccar/model/SupportedCommand.java (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 59bb88829..f79d543ff 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -15,6 +15,8 @@ */ package org.traccar; +import org.traccar.model.SupportedCommand; + import java.io.File; import java.net.URI; import java.net.URL; @@ -96,13 +98,15 @@ public class ServerManager { } } - public Collection getProtocolSuppportedCommands(String protocol) { - List result = new ArrayList<>(); + public Collection getProtocolSuppportedCommands(String protocol) { + List result = new ArrayList<>(); if (protocol != null) { BaseProtocol baseProtocol = protocols.get(protocol); for (String commandKey : baseProtocol.getSupportedCommands()) { - result.add(commandKey); + SupportedCommand supportedCommand = new SupportedCommand(); + supportedCommand.setKey(commandKey); + result.add(supportedCommand); } } diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java index 393588d9b..1d5ce8595 100644 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -18,6 +18,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.model.Position; +import org.traccar.model.SupportedCommand; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -35,7 +36,7 @@ import java.util.Collections; public class SupportedCommandResource extends BaseResource { @GET - public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); if (lastPosition != null) { diff --git a/src/org/traccar/model/SupportedCommand.java b/src/org/traccar/model/SupportedCommand.java new file mode 100644 index 000000000..59a24d033 --- /dev/null +++ b/src/org/traccar/model/SupportedCommand.java @@ -0,0 +1,29 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +public class SupportedCommand { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/web/app/store/SupportedCommands.js b/web/app/store/SupportedCommands.js index 612909180..2bb73839b 100644 --- a/web/app/store/SupportedCommands.js +++ b/web/app/store/SupportedCommands.js @@ -16,9 +16,7 @@ Ext.define('Traccar.store.SupportedCommands', { extend: 'Ext.data.Store', - fields: [ - { type: 'string', name: 'key'} - ], + fields: ['key'], listeners: { 'beforeload' : function(store, eOpts) { -- cgit v1.2.3 From 393192ff0253e74e1ada9cb364a1c05cc7ac7e23 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Fri, 6 May 2016 00:00:33 +0200 Subject: Rename SupportedCommand to CommandType --- src/org/traccar/ServerManager.java | 12 +++--- .../traccar/api/resource/CommandTypeResource.java | 49 ++++++++++++++++++++++ .../api/resource/SupportedCommandResource.java | 49 ---------------------- src/org/traccar/model/CommandType.java | 29 +++++++++++++ src/org/traccar/model/SupportedCommand.java | 29 ------------- src/org/traccar/web/WebServer.java | 4 +- web/app/Application.js | 2 +- web/app/store/CommandTypes.js | 33 +++++++++++++++ web/app/store/SupportedCommands.js | 33 --------------- web/app/view/CommandDialog.js | 2 +- 10 files changed, 121 insertions(+), 121 deletions(-) create mode 100644 src/org/traccar/api/resource/CommandTypeResource.java delete mode 100644 src/org/traccar/api/resource/SupportedCommandResource.java create mode 100644 src/org/traccar/model/CommandType.java delete mode 100644 src/org/traccar/model/SupportedCommand.java create mode 100644 web/app/store/CommandTypes.js delete mode 100644 web/app/store/SupportedCommands.js (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 5e59851f7..cf49b3e2c 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -15,7 +15,7 @@ */ package org.traccar; -import org.traccar.model.SupportedCommand; +import org.traccar.model.CommandType; import java.io.File; import java.net.URI; @@ -98,16 +98,16 @@ public class ServerManager { } } - public Collection getProtocolSuppportedCommands(String protocol) { - List result = new ArrayList<>(); + public Collection getProtocolCommandTypes(String protocol) { + List result = new ArrayList<>(); if (protocol != null) { BaseProtocol baseProtocol = protocols.get(protocol); if (baseProtocol != null) { for (String commandKey : baseProtocol.getSupportedCommands()) { - SupportedCommand supportedCommand = new SupportedCommand(); - supportedCommand.setKey(commandKey); - result.add(supportedCommand); + CommandType commandType = new CommandType(); + commandType.setKey(commandKey); + result.add(commandType); } } } diff --git a/src/org/traccar/api/resource/CommandTypeResource.java b/src/org/traccar/api/resource/CommandTypeResource.java new file mode 100644 index 000000000..9f9ecf249 --- /dev/null +++ b/src/org/traccar/api/resource/CommandTypeResource.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.api.resource; + +import org.traccar.Context; +import org.traccar.api.BaseResource; +import org.traccar.model.Position; +import org.traccar.model.CommandType; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import java.sql.SQLException; +import java.util.Collection; +import java.util.Collections; + +@Path("commandtypes") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class CommandTypeResource extends BaseResource { + + @GET + public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + Context.getPermissionsManager().checkDevice(getUserId(), deviceId); + Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); + if (lastPosition != null) { + return Context.getServerManager().getProtocolCommandTypes(lastPosition.getProtocol()); + } else { + return Collections.EMPTY_LIST; + } + } + +} diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java deleted file mode 100644 index 1d5ce8595..000000000 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.traccar.api.resource; - -import org.traccar.Context; -import org.traccar.api.BaseResource; -import org.traccar.model.Position; -import org.traccar.model.SupportedCommand; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import java.sql.SQLException; -import java.util.Collection; -import java.util.Collections; - -@Path("supportedcommands") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class SupportedCommandResource extends BaseResource { - - @GET - public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { - Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); - if (lastPosition != null) { - return Context.getServerManager().getProtocolSuppportedCommands(lastPosition.getProtocol()); - } else { - return Collections.EMPTY_LIST; - } - } - -} diff --git a/src/org/traccar/model/CommandType.java b/src/org/traccar/model/CommandType.java new file mode 100644 index 000000000..057dda4c5 --- /dev/null +++ b/src/org/traccar/model/CommandType.java @@ -0,0 +1,29 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +public class CommandType { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/src/org/traccar/model/SupportedCommand.java b/src/org/traccar/model/SupportedCommand.java deleted file mode 100644 index 59a24d033..000000000 --- a/src/org/traccar/model/SupportedCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.traccar.model; - -public class SupportedCommand { - - private String key; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } -} diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index bcb0442f6..8144af0b6 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -43,7 +43,7 @@ import org.traccar.api.resource.UserResource; import org.traccar.api.resource.GroupResource; import org.traccar.api.resource.DeviceResource; import org.traccar.api.resource.PositionResource; -import org.traccar.api.resource.SupportedCommandResource; +import org.traccar.api.resource.CommandTypeResource; import org.traccar.helper.Log; import javax.naming.InitialContext; @@ -148,7 +148,7 @@ public class WebServer { resourceConfig.register(CorsResponseFilter.class); resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class, GroupPermissionResource.class, DevicePermissionResource.class, UserResource.class, - GroupResource.class, DeviceResource.class, PositionResource.class, SupportedCommandResource.class); + GroupResource.class, DeviceResource.class, PositionResource.class, CommandTypeResource.class); servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*"); handlers.addHandler(servletHandler); diff --git a/web/app/Application.js b/web/app/Application.js index f68ef981e..69ce8f891 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -45,7 +45,7 @@ Ext.define('Traccar.Application', { 'MapTypes', 'DistanceUnits', 'SpeedUnits', - 'SupportedCommands', + 'CommandTypes', 'TimeUnits', 'Languages' ], diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js new file mode 100644 index 000000000..d2f9b57e4 --- /dev/null +++ b/web/app/store/CommandTypes.js @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.define('Traccar.store.CommandTypes', { + extend: 'Ext.data.Store', + fields: ['key'], + + listeners: { + 'beforeload' : function(store, eOpts) { + var proxy; + proxy = store.getProxy(); + proxy.setUrl('/api/commandtypes?deviceId' + proxy.extraParams.deviceId); + } + }, + + proxy: { + type: 'rest', + url: '' + } +}); diff --git a/web/app/store/SupportedCommands.js b/web/app/store/SupportedCommands.js deleted file mode 100644 index 2bb73839b..000000000 --- a/web/app/store/SupportedCommands.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.define('Traccar.store.SupportedCommands', { - extend: 'Ext.data.Store', - fields: ['key'], - - listeners: { - 'beforeload' : function(store, eOpts) { - var proxy; - proxy = store.getProxy(); - proxy.setUrl('/api/supportedcommands?deviceId' + proxy.extraParams.deviceId); - } - }, - - proxy: { - type: 'rest', - url: '' - } -}); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 05412f39c..f2c2f5541 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -30,7 +30,7 @@ Ext.define('Traccar.view.CommandDialog', { xtype: 'combobox', name: 'type', fieldLabel: Strings.commandType, - store: 'SupportedCommands', + store: 'CommandTypess', displayField: 'key', valueField: 'key', listeners: { -- cgit v1.2.3 From 7d1e51ed2626c11cc741ad38b7492abe12df40d0 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Fri, 6 May 2016 00:07:54 +0200 Subject: Checkstyle fix --- src/org/traccar/api/resource/DeviceResource.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index d7ab3ba24..6c0ef32ca 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -31,8 +31,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.traccar.model.Device; - import java.sql.SQLException; import java.util.Collection; -- cgit v1.2.3 From 301f2d314f446410da78615ac76ce0c07571d445 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Sun, 8 May 2016 13:06:25 +0200 Subject: Review fixes --- src/org/traccar/BaseProtocol.java | 1 + src/org/traccar/Protocol.java | 3 +++ src/org/traccar/ServerManager.java | 25 ---------------------- .../traccar/api/resource/CommandTypeResource.java | 9 +------- src/org/traccar/database/ActiveDevice.java | 14 ++++++++++++ src/org/traccar/model/CommandType.java | 14 +++++++----- web/app/store/CommandTypes.js | 12 +++++------ web/app/view/CommandDialog.js | 2 +- 8 files changed, 35 insertions(+), 45 deletions(-) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index 46a3fad5f..c77e61a81 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -41,6 +41,7 @@ public abstract class BaseProtocol implements Protocol { supportedCommands.addAll(Arrays.asList(commands)); } + @Override public Collection getSupportedCommands() { return supportedCommands; } diff --git a/src/org/traccar/Protocol.java b/src/org/traccar/Protocol.java index edf9bfb36..c99fd8ecb 100644 --- a/src/org/traccar/Protocol.java +++ b/src/org/traccar/Protocol.java @@ -3,12 +3,15 @@ package org.traccar; import org.traccar.database.ActiveDevice; import org.traccar.model.Command; +import java.util.Collection; import java.util.List; public interface Protocol { String getName(); + Collection getSupportedCommands(); + void sendCommand(ActiveDevice activeDevice, Command command); void initTrackerServers(List serverList); diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index cf49b3e2c..010438a44 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -15,26 +15,19 @@ */ package org.traccar; -import org.traccar.model.CommandType; - import java.io.File; import java.net.URI; import java.net.URL; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; import java.util.Enumeration; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class ServerManager { - private final Map protocols = new HashMap<>(); private final List serverList = new LinkedList<>(); public ServerManager() throws Exception { @@ -70,7 +63,6 @@ public class ServerManager { Class protocolClass = Class.forName(packageName + '.' + name); if (BaseProtocol.class.isAssignableFrom(protocolClass)) { BaseProtocol baseProtocol = (BaseProtocol) protocolClass.newInstance(); - protocols.put(baseProtocol.getName(), baseProtocol); initProtocolServer(baseProtocol); } } @@ -98,21 +90,4 @@ public class ServerManager { } } - public Collection getProtocolCommandTypes(String protocol) { - List result = new ArrayList<>(); - - if (protocol != null) { - BaseProtocol baseProtocol = protocols.get(protocol); - if (baseProtocol != null) { - for (String commandKey : baseProtocol.getSupportedCommands()) { - CommandType commandType = new CommandType(); - commandType.setKey(commandKey); - result.add(commandType); - } - } - } - - return result; - } - } diff --git a/src/org/traccar/api/resource/CommandTypeResource.java b/src/org/traccar/api/resource/CommandTypeResource.java index 9f9ecf249..ce27f5241 100644 --- a/src/org/traccar/api/resource/CommandTypeResource.java +++ b/src/org/traccar/api/resource/CommandTypeResource.java @@ -17,7 +17,6 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; -import org.traccar.model.Position; import org.traccar.model.CommandType; import javax.ws.rs.Consumes; @@ -28,7 +27,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import java.sql.SQLException; import java.util.Collection; -import java.util.Collections; @Path("commandtypes") @Produces(MediaType.APPLICATION_JSON) @@ -38,12 +36,7 @@ public class CommandTypeResource extends BaseResource { @GET public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); - if (lastPosition != null) { - return Context.getServerManager().getProtocolCommandTypes(lastPosition.getProtocol()); - } else { - return Collections.EMPTY_LIST; - } + return Context.getConnectionManager().getActiveDevice(deviceId).getCommandTypes(); } } diff --git a/src/org/traccar/database/ActiveDevice.java b/src/org/traccar/database/ActiveDevice.java index 746d3b393..3f2510af1 100644 --- a/src/org/traccar/database/ActiveDevice.java +++ b/src/org/traccar/database/ActiveDevice.java @@ -18,8 +18,12 @@ package org.traccar.database; import org.jboss.netty.channel.Channel; import org.traccar.Protocol; import org.traccar.model.Command; +import org.traccar.model.CommandType; import java.net.SocketAddress; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; public class ActiveDevice { @@ -43,6 +47,16 @@ public class ActiveDevice { return deviceId; } + public Collection getCommandTypes() { + List result = new ArrayList<>(); + + for (String commandKey : protocol.getSupportedCommands()) { + result.add(new CommandType(commandKey)); + } + + return result; + } + public void sendCommand(Command command) { protocol.sendCommand(this, command); } diff --git a/src/org/traccar/model/CommandType.java b/src/org/traccar/model/CommandType.java index 057dda4c5..210316f71 100644 --- a/src/org/traccar/model/CommandType.java +++ b/src/org/traccar/model/CommandType.java @@ -17,13 +17,17 @@ package org.traccar.model; public class CommandType { - private String key; + private String type; - public String getKey() { - return key; + public CommandType(String type) { + this.type = type; } - public void setKey(String key) { - this.key = key; + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; } } diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js index b8cb03668..2ef190edc 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/CommandTypes.js @@ -16,7 +16,7 @@ Ext.define('Traccar.store.CommandTypes', { extend: 'Ext.data.Store', - fields: ['key', 'name'], + fields: ['type', 'name'], listeners: { 'beforeload' : function(store) { @@ -33,10 +33,10 @@ Ext.define('Traccar.store.CommandTypes', { type: 'json', getData: function(data) { Ext.each(data, function(entry) { - entry.name = entry.key; - if (typeof entry.key !== "undefined") { - var key = 'command' + entry.key.charAt(0).toUpperCase() + entry.key.slice(1); - var name = Strings[key]; + entry.name = entry.type; + if (typeof entry.type !== "undefined") { + var nameKey = 'command' + entry.type.charAt(0).toUpperCase() + entry.type.slice(1); + var name = Strings[nameKey]; if (typeof name !== "undefined") { entry.name = name; } @@ -44,6 +44,6 @@ Ext.define('Traccar.store.CommandTypes', { }); return data; } - }, + } } }); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 66cd190ea..d23b50d4c 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -32,7 +32,7 @@ Ext.define('Traccar.view.CommandDialog', { fieldLabel: Strings.commandType, store: 'CommandTypes', displayField: 'name', - valueField: 'key', + valueField: 'type', listeners: { select: 'onSelect' } -- cgit v1.2.3