From fb0a1689fda9a06ecf5e6a9a97ba8b2b704cacb9 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 25 Jul 2016 17:47:50 +0500 Subject: Added group and server attributes --- debug.xml | 7 +++--- schema/changelog-3.7.xml | 8 +++++++ setup/unix/traccar.xml | 7 +++--- setup/windows/traccar.xml | 7 +++--- src/org/traccar/model/Group.java | 12 +--------- src/org/traccar/model/Server.java | 12 +--------- swagger.json | 6 +++-- web/app/model/Group.js | 2 ++ web/app/model/Server.js | 2 ++ web/app/view/BaseEditDialog.js | 5 +++++ web/app/view/BaseEditDialogController.js | 14 ++++++++++++ web/app/view/DeviceDialog.js | 19 +++------------- web/app/view/DeviceDialogController.js | 38 -------------------------------- web/app/view/ServerDialog.js | 2 +- web/app/view/UserDialog.js | 13 ----------- web/app/view/UserDialogController.js | 20 +---------------- 16 files changed, 54 insertions(+), 120 deletions(-) delete mode 100644 web/app/view/DeviceDialogController.js diff --git a/debug.xml b/debug.xml index 095f7d4b2..f078a7e9d 100644 --- a/debug.xml +++ b/debug.xml @@ -102,7 +102,8 @@ latitude = :latitude, longitude = :longitude, zoom = :zoom, - twelveHourFormat = :twelveHourFormat + twelveHourFormat = :twelveHourFormat, + attributes = :attributes WHERE id = :id; @@ -190,11 +191,11 @@ - INSERT INTO groups (name, groupId) VALUES (:name, :groupId); + INSERT INTO groups (name, groupId, attributes) VALUES (:name, :groupId, :attributes); - UPDATE groups SET name = :name, groupId = :groupId WHERE id = :id; + UPDATE groups SET name = :name, groupId = :groupId, attributes = :attributes WHERE id = :id; diff --git a/schema/changelog-3.7.xml b/schema/changelog-3.7.xml index c988b8bdb..ae85f69f3 100644 --- a/schema/changelog-3.7.xml +++ b/schema/changelog-3.7.xml @@ -26,6 +26,14 @@ + + + + + + + + diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml index 90cb5f74e..186e981cb 100644 --- a/setup/unix/traccar.xml +++ b/setup/unix/traccar.xml @@ -51,7 +51,8 @@ latitude = :latitude, longitude = :longitude, zoom = :zoom, - twelveHourFormat = :twelveHourFormat + twelveHourFormat = :twelveHourFormat, + attributes = :attributes WHERE id = :id; @@ -139,11 +140,11 @@ - INSERT INTO groups (name, groupId) VALUES (:name, :groupId); + INSERT INTO groups (name, groupId, attributes) VALUES (:name, :groupId, :attributes); - UPDATE groups SET name = :name, groupId = :groupId WHERE id = :id; + UPDATE groups SET name = :name, groupId = :groupId, attributes = :attributes WHERE id = :id; diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml index 25128a3e0..aa3809763 100644 --- a/setup/windows/traccar.xml +++ b/setup/windows/traccar.xml @@ -51,7 +51,8 @@ latitude = :latitude, longitude = :longitude, zoom = :zoom, - twelveHourFormat = :twelveHourFormat + twelveHourFormat = :twelveHourFormat, + attributes = :attributes WHERE id = :id; @@ -139,11 +140,11 @@ - INSERT INTO groups (name, groupId) VALUES (:name, :groupId); + INSERT INTO groups (name, groupId, attributes) VALUES (:name, :groupId, :attributes); - UPDATE groups SET name = :name, groupId = :groupId WHERE id = :id; + UPDATE groups SET name = :name, groupId = :groupId, attributes = :attributes WHERE id = :id; diff --git a/src/org/traccar/model/Group.java b/src/org/traccar/model/Group.java index 00f2b2cfc..e70b3f3d5 100644 --- a/src/org/traccar/model/Group.java +++ b/src/org/traccar/model/Group.java @@ -15,17 +15,7 @@ */ package org.traccar.model; -public class Group { - - private long id; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } +public class Group extends Extensible { private String name; diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java index 270fd61fa..b1557bf8f 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -15,17 +15,7 @@ */ package org.traccar.model; -public class Server { - - private long id; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } +public class Server extends Extensible { private boolean registration; diff --git a/swagger.json b/swagger.json index a16794a41..8b4157917 100644 --- a/swagger.json +++ b/swagger.json @@ -1235,7 +1235,8 @@ }, "twelveHourFormat": { "type": "boolean" - } + }, + "attributes": {} } }, "Command": { @@ -1286,7 +1287,8 @@ }, "groupId": { "type": "integer" - } + }, + "attributes": {} } }, "DevicePermission": { diff --git a/web/app/model/Group.js b/web/app/model/Group.js index a28897feb..bb18b5b3f 100644 --- a/web/app/model/Group.js +++ b/web/app/model/Group.js @@ -27,5 +27,7 @@ Ext.define('Traccar.model.Group', { }, { name: 'groupId', type: 'int' + }, { + name: 'attributes' }] }); diff --git a/web/app/model/Server.js b/web/app/model/Server.js index 3f6e466d9..02968c2d6 100644 --- a/web/app/model/Server.js +++ b/web/app/model/Server.js @@ -54,6 +54,8 @@ Ext.define('Traccar.model.Server', { }, { name: 'twelveHourFormat', type: 'boolean' + }, { + name: 'attributes' }], proxy: { diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js index 051dfbe93..1af095c98 100644 --- a/web/app/view/BaseEditDialog.js +++ b/web/app/view/BaseEditDialog.js @@ -18,6 +18,11 @@ Ext.define('Traccar.view.BaseEditDialog', { extend: 'Traccar.view.BaseDialog', buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + xtype: 'tbfill' + }, { text: Strings.sharedSave, handler: 'onSaveClick' }, { diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js index 33bd01bd8..511309650 100644 --- a/web/app/view/BaseEditDialogController.js +++ b/web/app/view/BaseEditDialogController.js @@ -38,5 +38,19 @@ Ext.define('Traccar.view.BaseEditDialogController', { record.save(); } button.up('window').close(); + }, + + showAttributesView: function (button) { + var dialog, record; + dialog = button.up('window').down('form'); + record = dialog.getRecord(); + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedAttributes, + modal: false, + items: { + xtype: 'attributesView', + record: record + } + }).show(); } }); diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js index 2938d5dc3..e88618fc5 100644 --- a/web/app/view/DeviceDialog.js +++ b/web/app/view/DeviceDialog.js @@ -18,10 +18,10 @@ Ext.define('Traccar.view.DeviceDialog', { extend: 'Traccar.view.BaseEditDialog', requires: [ - 'Traccar.view.DeviceDialogController' + 'Traccar.view.BaseEditDialog' ], - controller: 'deviceDialog', + controller: 'baseEditDialog', title: Strings.deviceDialog, items: { @@ -45,18 +45,5 @@ Ext.define('Traccar.view.DeviceDialog', { displayField: 'name', valueField: 'id' }] - }, - - buttons: [{ - text : Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - xtype: 'tbfill' - }, { - text: Strings.sharedSave, - handler: 'onSaveClick' - }, { - text: Strings.sharedCancel, - handler: 'closeView' - }] + } }); diff --git a/web/app/view/DeviceDialogController.js b/web/app/view/DeviceDialogController.js deleted file mode 100644 index 0a0f86883..000000000 --- a/web/app/view/DeviceDialogController.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -Ext.define('Traccar.view.DeviceDialogController', { - extend: 'Traccar.view.BaseEditDialogController', - alias: 'controller.deviceDialog', - - requires: [ - 'Traccar.view.Attributes' - ], - - showAttributesView: function (button) { - var dialog, record; - dialog = button.up('window').down('form'); - record = dialog.getRecord(); - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedAttributes, - modal: false, - items: { - xtype: 'attributesView', - record: record - } - }).show(); - } -}); diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index 67f3a7ab2..1af000042 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -31,7 +31,7 @@ Ext.define('Traccar.view.ServerDialog', { name: 'registration', fieldLabel: Strings.serverRegistration, allowBlank: false - },{ + }, { xtype: 'checkboxfield', name: 'readonly', fieldLabel: Strings.serverReadonly, diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index 378cc0681..df8a26e7e 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -89,18 +89,5 @@ Ext.define('Traccar.view.UserDialog', { fieldLabel: Strings.settingsTwelveHourFormat, allowBlank: false }] - }], - - buttons: [{ - text : Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - xtype: 'tbfill' - }, { - text: Strings.sharedSave, - handler: 'onSaveClick' - }, { - text: Strings.sharedCancel, - handler: 'closeView' }] }); diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js index 49dfd9d70..c3a4ca62d 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -15,13 +15,9 @@ */ Ext.define('Traccar.view.UserDialogController', { - extend: 'Ext.app.ViewController', + extend: 'Traccar.view.BaseEditDialogController', alias: 'controller.userDialog', - requires: [ - 'Traccar.view.Attributes' - ], - init: function () { if (Traccar.app.getUser().get('admin')) { this.lookupReference('adminField').setDisabled(false); @@ -48,19 +44,5 @@ Ext.define('Traccar.view.UserDialogController', { }); } button.up('window').close(); - }, - - showAttributesView: function (button) { - var dialog, record; - dialog = button.up('window').down('form'); - record = dialog.getRecord(); - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedAttributes, - modal: false, - items: { - xtype: 'attributesView', - record: record - } - }).show(); } }); -- cgit v1.2.3