From 2bcaeff435d1e1fa10ab253241e3d722ad29b153 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 24 Feb 2016 22:46:32 +1300 Subject: Decode additional GL200 protocol data --- src/org/traccar/model/Event.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org/traccar/model') diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index a9f6f9204..221536530 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -29,6 +29,7 @@ public abstract class Event extends Extensible { public static final String KEY_ALARM = "alarm"; public static final String KEY_STATUS = "status"; public static final String KEY_ODOMETER = "odometer"; + public static final String KEY_HOURS = "hours"; public static final String KEY_INPUT = "input"; public static final String KEY_OUTPUT = "output"; public static final String KEY_POWER = "power"; -- cgit v1.2.3 From 1f2328bd8f4e341dda897fcd52418beb6cf1b83a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 8 Mar 2016 22:05:40 +1300 Subject: Add new and update old data models --- .../traccar/api/resource/PermissionResource.java | 6 +-- src/org/traccar/database/DataManager.java | 6 +-- src/org/traccar/database/PermissionsManager.java | 4 +- src/org/traccar/model/Device.java | 12 ++++- src/org/traccar/model/DevicePermission.java | 40 +++++++++++++++++ src/org/traccar/model/Group.java | 52 ++++++++++++++++++++++ src/org/traccar/model/GroupPermission.java | 40 +++++++++++++++++ src/org/traccar/model/Permission.java | 40 ----------------- 8 files changed, 151 insertions(+), 49 deletions(-) create mode 100644 src/org/traccar/model/DevicePermission.java create mode 100644 src/org/traccar/model/Group.java create mode 100644 src/org/traccar/model/GroupPermission.java delete mode 100644 src/org/traccar/model/Permission.java (limited to 'src/org/traccar/model') diff --git a/src/org/traccar/api/resource/PermissionResource.java b/src/org/traccar/api/resource/PermissionResource.java index 50deb77c2..7cf2b4ed9 100644 --- a/src/org/traccar/api/resource/PermissionResource.java +++ b/src/org/traccar/api/resource/PermissionResource.java @@ -17,7 +17,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; -import org.traccar.model.Permission; +import org.traccar.model.DevicePermission; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -34,7 +34,7 @@ import java.sql.SQLException; public class PermissionResource extends BaseResource { @POST - public Response add(Permission entity) throws SQLException { + public Response add(DevicePermission entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getDataManager().linkDevice(entity.getUserId(), entity.getDeviceId()); Context.getPermissionsManager().refresh(); @@ -42,7 +42,7 @@ public class PermissionResource extends BaseResource { } @DELETE - public Response remove(Permission entity) throws SQLException { + public Response remove(DevicePermission entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getDataManager().unlinkDevice(entity.getUserId(), entity.getDeviceId()); Context.getPermissionsManager().refresh(); diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 73984952e..f040ecd20 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -39,7 +39,7 @@ import org.traccar.Config; import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.MiscFormatter; -import org.traccar.model.Permission; +import org.traccar.model.DevicePermission; import org.traccar.model.Position; import org.traccar.model.Server; import org.traccar.model.User; @@ -221,9 +221,9 @@ public class DataManager implements IdentityManager { .executeUpdate(); } - public Collection getPermissions() throws SQLException { + public Collection getPermissions() throws SQLException { return QueryBuilder.create(dataSource, getQuery("database.getPermissionsAll")) - .executeQuery(Permission.class); + .executeQuery(DevicePermission.class); } public Collection getAllDevices() throws SQLException { diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index c676dea23..29228ceeb 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.traccar.helper.Log; -import org.traccar.model.Permission; +import org.traccar.model.DevicePermission; import org.traccar.model.Server; import org.traccar.model.User; @@ -56,7 +56,7 @@ public class PermissionsManager { for (User user : dataManager.getUsers()) { users.put(user.getId(), user); } - for (Permission permission : dataManager.getPermissions()) { + for (DevicePermission permission : dataManager.getPermissions()) { getPermissions(permission.getUserId()).add(permission.getDeviceId()); } } catch (SQLException error) { diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java index 7ca9fc843..934e753b1 100644 --- a/src/org/traccar/model/Device.java +++ b/src/org/traccar/model/Device.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,4 +91,14 @@ public class Device { this.positionId = positionId; } + private long groupId; + + public long getGroupId() { + return groupId; + } + + public void setGroupId(long groupId) { + this.groupId = groupId; + } + } diff --git a/src/org/traccar/model/DevicePermission.java b/src/org/traccar/model/DevicePermission.java new file mode 100644 index 000000000..b3bc0cae0 --- /dev/null +++ b/src/org/traccar/model/DevicePermission.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@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 DevicePermission { + + private long userId; + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + private long deviceId; + + public long getDeviceId() { + return deviceId; + } + + public void setDeviceId(long deviceId) { + this.deviceId = deviceId; + } + +} diff --git a/src/org/traccar/model/Group.java b/src/org/traccar/model/Group.java new file mode 100644 index 000000000..24f7973c8 --- /dev/null +++ b/src/org/traccar/model/Group.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Anton Tananaev (anton.tananaev@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; + +import java.util.Date; + +public class Group { + + private long id; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + private long groupId; + + public long getGroupId() { + return groupId; + } + + public void setGroupId(long groupId) { + this.groupId = groupId; + } + +} diff --git a/src/org/traccar/model/GroupPermission.java b/src/org/traccar/model/GroupPermission.java new file mode 100644 index 000000000..9b0011575 --- /dev/null +++ b/src/org/traccar/model/GroupPermission.java @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Anton Tananaev (anton.tananaev@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 GroupPermission { + + private long userId; + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + private long groupId; + + public long getGroupId() { + return groupId; + } + + public void setGroupId(long groupId) { + this.groupId = groupId; + } + +} diff --git a/src/org/traccar/model/Permission.java b/src/org/traccar/model/Permission.java deleted file mode 100644 index 393de2359..000000000 --- a/src/org/traccar/model/Permission.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Anton Tananaev (anton.tananaev@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 Permission { - - private long userId; - - public long getUserId() { - return userId; - } - - public void setUserId(long userId) { - this.userId = userId; - } - - private long deviceId; - - public long getDeviceId() { - return deviceId; - } - - public void setDeviceId(long deviceId) { - this.deviceId = deviceId; - } - -} -- cgit v1.2.3 From 5634860cbe5c43007df354acba79d5051c1eb987 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 9 Mar 2016 23:13:06 +1300 Subject: Add parent field for device and group --- debug.xml | 4 ++-- src/org/traccar/model/Group.java | 2 -- web/app/controller/Root.js | 1 + web/app/model/Device.js | 3 +++ web/app/model/Group.js | 3 +++ web/app/view/DeviceDialog.js | 7 +++++++ web/app/view/GroupDialog.js | 7 +++++++ web/app/view/GroupsController.js | 4 ---- web/l10n/en.json | 1 + 9 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src/org/traccar/model') diff --git a/debug.xml b/debug.xml index ce7c3190a..45c475a91 100644 --- a/debug.xml +++ b/debug.xml @@ -130,7 +130,7 @@ - UPDATE devices SET name = :name, uniqueId = :uniqueId WHERE id = :id; + UPDATE devices SET name = :name, uniqueId = :uniqueId, groupId = :groupId WHERE id = :id; @@ -158,7 +158,7 @@ - UPDATE groups SET name = :name WHERE id = :id; + UPDATE groups SET name = :name, groupId = :groupId WHERE id = :id; diff --git a/src/org/traccar/model/Group.java b/src/org/traccar/model/Group.java index 24f7973c8..00f2b2cfc 100644 --- a/src/org/traccar/model/Group.java +++ b/src/org/traccar/model/Group.java @@ -15,8 +15,6 @@ */ package org.traccar.model; -import java.util.Date; - public class Group { private long id; diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index a1026d3c5..5bd567619 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -73,6 +73,7 @@ Ext.define('Traccar.controller.Root', { }, loadApp: function () { + Ext.getStore('Groups').load(); Ext.getStore('Devices').load(); Ext.get('attribution').remove(); if (this.isPhone) { diff --git a/web/app/model/Device.js b/web/app/model/Device.js index 709d51953..588d53c1f 100644 --- a/web/app/model/Device.js +++ b/web/app/model/Device.js @@ -34,5 +34,8 @@ Ext.define('Traccar.model.Device', { name: 'lastUpdate', type: 'date', dateFormat: 'c' + }, { + name: 'groupId', + type: 'int' }] }); diff --git a/web/app/model/Group.js b/web/app/model/Group.js index 22e160315..a28897feb 100644 --- a/web/app/model/Group.js +++ b/web/app/model/Group.js @@ -24,5 +24,8 @@ Ext.define('Traccar.model.Group', { }, { name: 'name', type: 'string' + }, { + name: 'groupId', + type: 'int' }] }); diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js index 318ac4ffe..4a22ca008 100644 --- a/web/app/view/DeviceDialog.js +++ b/web/app/view/DeviceDialog.js @@ -36,6 +36,13 @@ Ext.define('Traccar.view.DeviceDialog', { name: 'uniqueId', fieldLabel: Strings.deviceIdentifier, allowBlank: false + }, { + xtype: 'combobox', + name: 'groupId', + fieldLabel: Strings.groupParent, + store: 'Groups', + displayField: 'name', + valueField: 'id' }] } }); diff --git a/web/app/view/GroupDialog.js b/web/app/view/GroupDialog.js index a34e33aa0..2cca61ef5 100644 --- a/web/app/view/GroupDialog.js +++ b/web/app/view/GroupDialog.js @@ -31,6 +31,13 @@ Ext.define('Traccar.view.GroupDialog', { name: 'name', fieldLabel: Strings.sharedName, allowBlank: false + }, { + xtype: 'combobox', + name: 'groupId', + fieldLabel: Strings.groupParent, + store: 'Groups', + displayField: 'name', + valueField: 'id' }] } }); diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js index 34b259658..6cc568ea2 100644 --- a/web/app/view/GroupsController.js +++ b/web/app/view/GroupsController.js @@ -18,10 +18,6 @@ Ext.define('Traccar.view.GroupsController', { extend: 'Ext.app.ViewController', alias: 'controller.groups', - init: function () { - Ext.getStore('Groups').load(); - }, - onAddClick: function () { var group, dialog; group = Ext.create('Traccar.model.Group'); diff --git a/web/l10n/en.json b/web/l10n/en.json index 715dce3a7..cabd76362 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -35,6 +35,7 @@ "deviceCommand": "Command", "deviceFollow": "Follow", "groupDialog": "Group", + "groupParent": "Group", "settingsTitle": "Settings", "settingsUser": "Account", "settingsGroups": "Groups", -- cgit v1.2.3