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 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