From cd0de70745972a3a400cf3f15098c267601b905c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 25 Jul 2016 16:49:53 +1200 Subject: Fix button id typo --- web/app/view/Devices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/view') diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index da7695229..c086827f8 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -58,7 +58,7 @@ Ext.define('Traccar.view.Devices', { }, { xtype: 'tbfill' },{ - id: 'nuteButton', + id: 'muteButton', glyph: 'xf1f7@FontAwesome', tooltip: Strings.muteButton, tooltipType: 'title', -- cgit v1.2.3 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 (limited to 'web/app/view') 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 From 0c1c9b07aafcf02d2be4129517fd0c87f01cf9d4 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 25 Jul 2016 20:46:21 +0500 Subject: Fix attribute editing --- web/app/view/AttributeController.js | 42 ++++++++++++++++++++++++++++++++ web/app/view/AttributeDialog.js | 16 +++++++++--- web/app/view/BaseEditDialogController.js | 4 +++ 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 web/app/view/AttributeController.js (limited to 'web/app/view') diff --git a/web/app/view/AttributeController.js b/web/app/view/AttributeController.js new file mode 100644 index 000000000..932a6436b --- /dev/null +++ b/web/app/view/AttributeController.js @@ -0,0 +1,42 @@ +/* + * 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.AttributeController', { + extend: 'Ext.app.ViewController', + alias: 'controller.attributeDialog', + + onSaveClick: function (button) { + var dialog, store, record; + dialog = button.up('window').down('form'); + dialog.updateRecord(); + record = dialog.getRecord(); + store = record.store; + if (store) { + if (record.phantom) { + store.add(record); + } + store.sync({ + failure: function (batch) { + store.rejectChanges(); + Traccar.app.showError(batch.exceptions[0].getError().response); + } + }); + } else { + record.save(); + } + button.up('window').close(); + } +}); diff --git a/web/app/view/AttributeDialog.js b/web/app/view/AttributeDialog.js index be06b7576..213891ecd 100644 --- a/web/app/view/AttributeDialog.js +++ b/web/app/view/AttributeDialog.js @@ -15,13 +15,13 @@ */ Ext.define('Traccar.view.AttributeDialog', { - extend: 'Traccar.view.BaseEditDialog', + extend: 'Traccar.view.BaseDialog', requires: [ - 'Traccar.view.BaseEditDialogController' + 'Traccar.view.AttributeController' ], - controller: 'baseEditDialog', + controller: 'attributeDialog', title: Strings.sharedAttribute, items: { @@ -35,5 +35,13 @@ Ext.define('Traccar.view.AttributeDialog', { name: 'value', fieldLabel: Strings.stateValue }] - } + }, + + buttons: [{ + text: Strings.sharedSave, + handler: 'onSaveClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' + }] }); diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js index 511309650..79fd8f2b4 100644 --- a/web/app/view/BaseEditDialogController.js +++ b/web/app/view/BaseEditDialogController.js @@ -18,6 +18,10 @@ Ext.define('Traccar.view.BaseEditDialogController', { extend: 'Ext.app.ViewController', alias: 'controller.baseEditDialog', + requires: [ + 'Traccar.view.Attributes' + ], + onSaveClick: function (button) { var dialog, store, record; dialog = button.up('window').down('form'); -- cgit v1.2.3 From 914abce63e9f85d13d0b6ee53ea55eb70643d71e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 26 Jul 2016 13:03:48 +1200 Subject: Handle correctly empty report --- web/app/view/MapController.js | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index eee74099f..6ef9f91e6 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -147,37 +147,39 @@ Ext.define('Traccar.view.MapController', { this.clearReport(store); - this.reportRoute = new ol.Feature({ - geometry: new ol.geom.LineString([]) - }); - this.reportRoute.setStyle(this.getRouteStyle()); - this.getView().getRouteSource().addFeature(this.reportRoute); + if (data.length > 0) { + this.reportRoute = new ol.Feature({ + geometry: new ol.geom.LineString([]) + }); + this.reportRoute.setStyle(this.getRouteStyle()); + this.getView().getRouteSource().addFeature(this.reportRoute); - for (i = 0; i < data.length; i++) { - position = data[i]; + for (i = 0; i < data.length; i++) { + position = data[i]; + + point = ol.proj.fromLonLat([ + position.get('longitude'), + position.get('latitude') + ]); + geometry = new ol.geom.Point(point); - point = ol.proj.fromLonLat([ - position.get('longitude'), - position.get('latitude') - ]); - geometry = new ol.geom.Point(point); + marker = new ol.Feature(geometry); + marker.set('record', position); + this.reportMarkers[position.get('id')] = marker; + this.getView().getReportSource().addFeature(marker); - marker = new ol.Feature(geometry); - marker.set('record', position); - this.reportMarkers[position.get('id')] = marker; - this.getView().getReportSource().addFeature(marker); + style = this.getReportMarker(); + style.getImage().setRotation(position.get('course') * Math.PI / 180); + /*style.getText().setText( + Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/ - style = this.getReportMarker(); - style.getImage().setRotation(position.get('course') * Math.PI / 180); - /*style.getText().setText( - Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/ + marker.setStyle(style); - marker.setStyle(style); + this.reportRoute.getGeometry().appendCoordinate(point); + } - this.reportRoute.getGeometry().appendCoordinate(point); + this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize()); } - - this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize()); }, clearReport: function (store) { -- cgit v1.2.3 From cd0c04a03b359dfc5b1ea3f61b93aaae8f6fec3e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 29 Jul 2016 14:06:40 +1200 Subject: Change alarm highlight logic --- web/app.css | 6 +++--- web/app/AttributeFormatter.js | 20 -------------------- web/app/view/Devices.js | 10 +++++----- web/app/view/Report.js | 5 ----- web/app/view/State.js | 8 +++++++- web/l10n/en.json | 2 +- 6 files changed, 16 insertions(+), 35 deletions(-) (limited to 'web/app/view') diff --git a/web/app.css b/web/app.css index 0dbf94ca6..95417606c 100644 --- a/web/app.css +++ b/web/app.css @@ -1,10 +1,10 @@ -.status-color-online { +.view-color-green { background-color: rgba(77, 250, 144, 0.3); } -.status-color-unknown { +.view-color-yellow { background-color: rgba(250, 190, 77, 0.3); } -.status-color-offline { +.view-color-red { background-color: rgba(255, 84, 104, 0.3); } diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index c32849101..3432ca1e0 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -34,24 +34,6 @@ Ext.define('Traccar.AttributeFormatter', { return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit')); }, - alarmFormatter: function (attributes) { - var value = ''; - if (attributes instanceof Object) {//for Traccar.view.Attributes - if (attributes.hasOwnProperty('alarm')) { - value = attributes.alarm; - if (typeof value === 'boolean') { - value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no); - } - } - } else {//for Traccar.view.Report - value = attributes; - if (typeof value === 'boolean') { - value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no); - } - } - return '' + value + ''; - }, - defaultFormatter: function (value) { if (typeof value === 'number') { return Number(value.toFixed(Traccar.Style.numberPrecision)); @@ -76,8 +58,6 @@ Ext.define('Traccar.AttributeFormatter', { return this.courseFormatter; } else if (key === 'distance' || key === 'odometer') { return this.distanceFormatter; - } else if (key === 'alarm') { - return this.alarmFormatter; } else { return this.defaultFormatter; } diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index c086827f8..ab6436ea6 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -57,10 +57,10 @@ Ext.define('Traccar.view.Devices', { tooltipType: 'title' }, { xtype: 'tbfill' - },{ + }, { id: 'muteButton', glyph: 'xf1f7@FontAwesome', - tooltip: Strings.muteButton, + tooltip: Strings.sharedMute, tooltipType: 'title', pressed : true, enableToggle: true, @@ -156,13 +156,13 @@ Ext.define('Traccar.view.Devices', { renderer: function (value, metaData, record) { switch (record.get('status')) { case 'online': - metaData.tdCls = 'status-color-online'; + metaData.tdCls = 'view-color-green'; break; case 'offline': - metaData.tdCls = 'status-color-offline'; + metaData.tdCls = 'view-color-red'; break; default: - metaData.tdCls = 'status-color-unknown'; + metaData.tdCls = 'view-color-yellow'; break; } if (Traccar.app.getPreference('twelveHourFormat', false)) { diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 78ff5d52f..4261b9040 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -115,10 +115,5 @@ Ext.define('Traccar.view.Report', { dataIndex: 'address', flex: 1, renderer: Traccar.AttributeFormatter.getFormatter('address') - }, { - text: 'Alarm', - dataIndex: 'attributes', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('alarm') }] }); diff --git a/web/app/view/State.js b/web/app/view/State.js index 1a9f014f5..547fb0cf3 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -34,6 +34,12 @@ Ext.define('Traccar.view.State', { }, { text: Strings.stateValue, dataIndex: 'value', - flex: 1 + flex: 1, + renderer: function (value, metaData, record) { + if (record.get('name') === 'Alarm') { + metaData.tdCls = 'view-color-red'; + } + return value; + } }] }); diff --git a/web/l10n/en.json b/web/l10n/en.json index 32a2a45a4..e1866fe62 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -19,11 +19,11 @@ "sharedSearch": "Search", "sharedGeofence": "Geofence", "sharedGeofences": "Geofences", - "muteButton": "Mute", "sharedNotifications": "Notifications", "sharedAttributes": "Attributes", "sharedAttribute": "Attribute", "sharedArea": "Area", + "sharedMute": "Mute", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", -- cgit v1.2.3