From 99d132dc78b42b6cc5833b3a7faf30d2fe56186f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 4 Oct 2015 18:23:32 +1300 Subject: Disable JavaScript strict mode --- .../traccar/protocol/TramigoProtocolDecoder.java | 19 +- web/app/Application.js | 112 ++++--- web/app/AttributeFormatter.js | 92 +++--- web/app/ErrorManager.js | 46 ++- web/app/Style.js | 56 ++-- web/app/controller/Root.js | 130 ++++---- web/app/model/Attribute.js | 30 +- web/app/model/Command.js | 30 +- web/app/model/Device.js | 32 +- web/app/model/Position.js | 96 +++--- web/app/model/Server.js | 94 +++--- web/app/model/User.js | 100 +++--- web/app/store/Attributes.js | 18 +- web/app/store/CommandTypes.js | 38 ++- web/app/store/Devices.js | 44 ++- web/app/store/DistanceUnits.js | 46 ++- web/app/store/Languages.js | 34 +-- web/app/store/LatestPositions.js | 12 +- web/app/store/MapTypes.js | 38 ++- web/app/store/Positions.js | 26 +- web/app/store/SpeedUnits.js | 46 ++- web/app/store/TimeUnits.js | 32 +- web/app/store/Users.js | 44 ++- web/app/view/BaseDialog.js | 16 +- web/app/view/BaseEditDialog.js | 24 +- web/app/view/BaseEditDialogController.js | 56 ++-- web/app/view/CommandDialog.js | 88 +++--- web/app/view/CommandDialogController.js | 82 +++-- web/app/view/Device.js | 150 +++++---- web/app/view/DeviceController.js | 214 +++++++------ web/app/view/DeviceDialog.js | 48 ++- web/app/view/Login.js | 136 ++++----- web/app/view/LoginController.js | 150 +++++---- web/app/view/Main.js | 76 +++-- web/app/view/MainMobile.js | 62 ++-- web/app/view/Map.js | 130 ++++---- web/app/view/MapController.js | 338 ++++++++++----------- web/app/view/Register.js | 74 +++-- web/app/view/RegisterController.js | 44 ++- web/app/view/Report.js | 196 ++++++------ web/app/view/ReportController.js | 104 +++---- web/app/view/ServerDialog.js | 120 ++++---- web/app/view/State.js | 42 ++- web/app/view/StateController.js | 212 +++++++------ web/app/view/User.js | 88 +++--- web/app/view/UserController.js | 126 ++++---- web/app/view/UserDialog.js | 138 ++++----- web/app/view/UserDialogController.js | 60 ++-- 48 files changed, 1917 insertions(+), 2072 deletions(-) diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java index 893e32a92..4877daa5d 100644 --- a/src/org/traccar/protocol/TramigoProtocolDecoder.java +++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java @@ -15,23 +15,22 @@ */ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.jboss.netty.channel.Channel; -import org.traccar.BaseProtocolDecoder; -import org.traccar.helper.UnitsConverter; -import org.traccar.model.Event; -import org.traccar.model.Position; - +import java.net.SocketAddress; import java.nio.charset.Charset; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.net.SocketAddress; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.helper.UnitsConverter; +import org.traccar.model.Event; +import org.traccar.model.Position; public class TramigoProtocolDecoder extends BaseProtocolDecoder { @@ -87,7 +86,7 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // GPS antenna state position.setSpeed(buf.readUnsignedShort() * 0.194384); - position.setCourse((double )buf.readUnsignedShort()); + position.setCourse((double) buf.readUnsignedShort()); buf.readUnsignedInt(); // distance diff --git a/web/app/Application.js b/web/app/Application.js index ad47caef8..36f5ca903 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -13,71 +13,67 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.Application', { - extend: 'Ext.app.Application', - name: 'Traccar', +Ext.define('Traccar.Application', { + extend: 'Ext.app.Application', + name: 'Traccar', - requires: [ - 'Traccar.Style', - 'Traccar.ErrorManager', - 'Traccar.AttributeFormatter' - ], + requires: [ + 'Traccar.Style', + 'Traccar.ErrorManager', + 'Traccar.AttributeFormatter' + ], - models: [ - 'Server', - 'User', - 'Device', - 'Position', - 'Attribute', - 'Command' - ], + models: [ + 'Server', + 'User', + 'Device', + 'Position', + 'Attribute', + 'Command' + ], - stores: [ - 'Devices', - 'Positions', - 'LatestPositions', - 'Users', - 'Attributes', - 'MapTypes', - 'DistanceUnits', - 'SpeedUnits', - 'CommandTypes', - 'TimeUnits', - 'Languages' - ], + stores: [ + 'Devices', + 'Positions', + 'LatestPositions', + 'Users', + 'Attributes', + 'MapTypes', + 'DistanceUnits', + 'SpeedUnits', + 'CommandTypes', + 'TimeUnits', + 'Languages' + ], - controllers: [ - 'Root' - ], + controllers: [ + 'Root' + ], - setUser: function (data) { - var reader = Ext.create('Ext.data.reader.Json', { - model: 'Traccar.model.User' - }); - this.user = reader.readRecords(data).getRecords()[0]; - }, + setUser: function (data) { + var reader = Ext.create('Ext.data.reader.Json', { + model: 'Traccar.model.User' + }); + this.user = reader.readRecords(data).getRecords()[0]; + }, - getUser: function () { - return this.user; - }, + getUser: function () { + return this.user; + }, - setServer: function (data) { - var reader = Ext.create('Ext.data.reader.Json', { - model: 'Traccar.model.Server' - }); - this.server = reader.readRecords(data).getRecords()[0]; - }, + setServer: function (data) { + var reader = Ext.create('Ext.data.reader.Json', { + model: 'Traccar.model.Server' + }); + this.server = reader.readRecords(data).getRecords()[0]; + }, - getServer: function () { - return this.server; - }, + getServer: function () { + return this.server; + }, - getPreference: function (key, defaultValue) { - return this.getUser().get(key) || this.getServer().get(key) || defaultValue; - } - }); - -})(); + getPreference: function (key, defaultValue) { + return this.getUser().get(key) || this.getServer().get(key) || defaultValue; + } +}); diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 3f8f346c0..b7b2d01a6 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -13,53 +13,49 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.AttributeFormatter', { - singleton: true, - - coordinateFormatter: function (value) { - return value.toFixed(6); - }, - - speedFormatter: function (value) { - return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit')); - }, - - courseFormatter: function (value) { - var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']; - return courseValues[Math.floor(value / 45)]; - }, - - distanceFormatter: function (value) { - return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit')); - }, - - defaultFormatter: function (value) { - if (typeof value === 'number') { - return value.toFixed(2); - } else if (typeof value === 'boolean') { - return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no; - } else if (value instanceof Date) { - return Ext.Date.format(value, Traccar.Style.dateTimeFormat); - } - return value; - }, - - getFormatter: function (key) { - if (key === 'latitude' || key === 'longitude') { - return this.coordinateFormatter; - } else if (key === 'speed') { - return this.speedFormatter; - } else if (key === 'course') { - return this.courseFormatter; - } else if (key === 'distance' || key === 'odometer') { - return this.distanceFormatter; - } else { - return this.defaultFormatter; - } +Ext.define('Traccar.AttributeFormatter', { + singleton: true, + + coordinateFormatter: function (value) { + return value.toFixed(6); + }, + + speedFormatter: function (value) { + return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit')); + }, + + courseFormatter: function (value) { + var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']; + return courseValues[Math.floor(value / 45)]; + }, + + distanceFormatter: function (value) { + return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit')); + }, + + defaultFormatter: function (value) { + if (typeof value === 'number') { + return value.toFixed(2); + } else if (typeof value === 'boolean') { + return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no; + } else if (value instanceof Date) { + return Ext.Date.format(value, Traccar.Style.dateTimeFormat); } - }); - -})(); + return value; + }, + + getFormatter: function (key) { + if (key === 'latitude' || key === 'longitude') { + return this.coordinateFormatter; + } else if (key === 'speed') { + return this.speedFormatter; + } else if (key === 'course') { + return this.courseFormatter; + } else if (key === 'distance' || key === 'odometer') { + return this.distanceFormatter; + } else { + return this.defaultFormatter; + } + } +}); diff --git a/web/app/ErrorManager.js b/web/app/ErrorManager.js index e98b29d0f..50fa347c2 100644 --- a/web/app/ErrorManager.js +++ b/web/app/ErrorManager.js @@ -13,36 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.ErrorManager', { - singleton: true, +Ext.define('Traccar.ErrorManager', { + singleton: true, - check: function (success, response) { - var result; - if (success) { - result = Ext.decode(response.responseText); - if (result.success || result.error === undefined) { - return true; - } else { - Ext.Msg.alert(Strings.errorTitle, result.error); - return false; - } + check: function (success, response) { + var result; + if (success) { + result = Ext.decode(response.responseText); + if (result.success || result.error === undefined) { + return true; } else { - if (response.statusText) { - Ext.Msg.alert(Strings.errorTitle, response.statusText); - } else { - Ext.Msg.alert(Strings.errorTitle, response.status.toString()); // TODO: text message - } + Ext.Msg.alert(Strings.errorTitle, result.error); return false; } - }, - - error: function (message) { - Ext.Msg.alert(Strings.errorTitle, message); + } else { + if (response.statusText) { + Ext.Msg.alert(Strings.errorTitle, response.statusText); + } else { + Ext.Msg.alert(Strings.errorTitle, response.status.toString()); // TODO: text message + } + return false; } + }, - }); + error: function (message) { + Ext.Msg.alert(Strings.errorTitle, message); + } -})(); +}); diff --git a/web/app/Style.js b/web/app/Style.js index b2a2474bd..4c7028658 100644 --- a/web/app/Style.js +++ b/web/app/Style.js @@ -13,41 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.Style', { - singleton: true, +Ext.define('Traccar.Style', { + singleton: true, - panelPadding: 10, + panelPadding: 10, - windowWidth: 640, - windowHeight: 480, + windowWidth: 640, + windowHeight: 480, - dateTimeFormat: 'Y-m-d H:i:s', - timeFormat: 'H:i', - weekStartDay: 1, + dateTimeFormat: 'Y-m-d H:i:s', + timeFormat: 'H:i', + weekStartDay: 1, - deviceWidth: 350, + deviceWidth: 350, - reportHeight: 250, - reportTime: 100, + reportHeight: 250, + reportTime: 100, - mapDefaultLat: 51.507222, - mapDefaultLon: -0.1275, - mapDefaultZoom: 6, + mapDefaultLat: 51.507222, + mapDefaultLon: -0.1275, + mapDefaultZoom: 6, - mapMaxZoom: 19, - mapSelectColor: 'rgba(0, 255, 0, 1.0)', - mapSelectRadius: 10, - mapReportColor: 'rgba(0, 0, 255, 1.0)', - mapReportRadius: 5, - mapLiveColor: 'rgba(255, 0, 0, 1.0)', - mapLiveRadius: 7, - mapStrokeColor: 'rgba(50, 50, 50, 1.0)', - mapRouteWidth: 5, - mapMarkerStroke: 2, - mapDelay: 500 - }); - -})(); + mapMaxZoom: 19, + mapSelectColor: 'rgba(0, 255, 0, 1.0)', + mapSelectRadius: 10, + mapReportColor: 'rgba(0, 0, 255, 1.0)', + mapReportRadius: 5, + mapLiveColor: 'rgba(255, 0, 0, 1.0)', + mapLiveRadius: 7, + mapStrokeColor: 'rgba(50, 50, 50, 1.0)', + mapRouteWidth: 5, + mapMarkerStroke: 2, + mapDelay: 500 +}); diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index bb67d4e86..d6dd64830 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -13,81 +13,77 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.controller.Root', { - extend: 'Ext.app.Controller', +Ext.define('Traccar.controller.Root', { + extend: 'Ext.app.Controller', - requires: [ - 'Traccar.view.Login', - 'Traccar.view.Main', - 'Traccar.view.MainMobile' - ], + requires: [ + 'Traccar.view.Login', + 'Traccar.view.Main', + 'Traccar.view.MainMobile' + ], - init: function () { - var indicator = document.createElement('div'); - indicator.className = 'state-indicator'; - document.body.appendChild(indicator); - this.isPhone = parseInt(window.getComputedStyle(indicator).getPropertyValue('z-index'), 10) !== 0; - }, + init: function () { + var indicator = document.createElement('div'); + indicator.className = 'state-indicator'; + document.body.appendChild(indicator); + this.isPhone = parseInt(window.getComputedStyle(indicator).getPropertyValue('z-index'), 10) !== 0; + }, - onLaunch: function () { - Ext.Ajax.request({ - scope: this, - url: '/api/server/get', - callback: this.onServerReturn - }); - }, + onLaunch: function () { + Ext.Ajax.request({ + scope: this, + url: '/api/server/get', + callback: this.onServerReturn + }); + }, - onServerReturn: function (options, success, response) { - var result; - if (Traccar.ErrorManager.check(success, response)) { - result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setServer(result.data); - Ext.Ajax.request({ - scope: this, - url: '/api/session', - callback: this.onSessionReturn - }); - } - } - }, - - onSessionReturn: function (options, success, response) { - var result; - if (Traccar.ErrorManager.check(success, response)) { - result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setUser(result.data); - this.loadApp(); - } else { - this.login = Ext.create('widget.login', { - listeners: { - scope: this, - login: this.onLogin - } - }); - this.login.show(); - } + onServerReturn: function (options, success, response) { + var result; + if (Traccar.ErrorManager.check(success, response)) { + result = Ext.decode(response.responseText); + if (result.success) { + Traccar.app.setServer(result.data); + Ext.Ajax.request({ + scope: this, + url: '/api/session', + callback: this.onSessionReturn + }); } - }, - - onLogin: function () { - this.login.close(); - this.loadApp(); - }, + } + }, - loadApp: function () { - Ext.getStore('Devices').load(); - Ext.getBody().empty(); - if (this.isPhone) { - Ext.create('widget.mainMobile'); + onSessionReturn: function (options, success, response) { + var result; + if (Traccar.ErrorManager.check(success, response)) { + result = Ext.decode(response.responseText); + if (result.success) { + Traccar.app.setUser(result.data); + this.loadApp(); } else { - Ext.create('widget.main'); + this.login = Ext.create('widget.login', { + listeners: { + scope: this, + login: this.onLogin + } + }); + this.login.show(); } } - }); + }, -})(); + onLogin: function () { + this.login.close(); + this.loadApp(); + }, + + loadApp: function () { + Ext.getStore('Devices').load(); + Ext.getBody().empty(); + if (this.isPhone) { + Ext.create('widget.mainMobile'); + } else { + Ext.create('widget.main'); + } + } +}); diff --git a/web/app/model/Attribute.js b/web/app/model/Attribute.js index df53d02f0..78acdb1d9 100644 --- a/web/app/model/Attribute.js +++ b/web/app/model/Attribute.js @@ -13,22 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.Attribute', { - extend: 'Ext.data.Model', +Ext.define('Traccar.model.Attribute', { + extend: 'Ext.data.Model', - fields: [{ - name: 'priority', - type: 'int' - }, { - name: 'name', - type: 'string' - }, { - name: 'value', - type: 'string' - }] - }); - -})(); + fields: [{ + name: 'priority', + type: 'int' + }, { + name: 'name', + type: 'string' + }, { + name: 'value', + type: 'string' + }] +}); diff --git a/web/app/model/Command.js b/web/app/model/Command.js index 0eb17ec40..3e848b57d 100644 --- a/web/app/model/Command.js +++ b/web/app/model/Command.js @@ -13,22 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.Command', { - extend: 'Ext.data.Model', - identifier: 'negative', +Ext.define('Traccar.model.Command', { + extend: 'Ext.data.Model', + identifier: 'negative', - fields: [{ - name: 'deviceId', - type: 'int' - }, { - name: 'type', - type: 'string' - }, { - name: 'attributes' - }] - }); - -})(); + fields: [{ + name: 'deviceId', + type: 'int' + }, { + name: 'type', + type: 'string' + }, { + name: 'attributes' + }] +}); diff --git a/web/app/model/Device.js b/web/app/model/Device.js index f3fb885ba..e9ed1f680 100644 --- a/web/app/model/Device.js +++ b/web/app/model/Device.js @@ -13,23 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.Device', { - extend: 'Ext.data.Model', - identifier: 'negative', +Ext.define('Traccar.model.Device', { + extend: 'Ext.data.Model', + identifier: 'negative', - fields: [{ - name: 'id', - type: 'int' - }, { - name: 'name', - type: 'string' - }, { - name: 'uniqueId', - type: 'string' - }] - }); - -})(); + fields: [{ + name: 'id', + type: 'int' + }, { + name: 'name', + type: 'string' + }, { + name: 'uniqueId', + type: 'string' + }] +}); diff --git a/web/app/model/Position.js b/web/app/model/Position.js index be525c1d8..365b06115 100644 --- a/web/app/model/Position.js +++ b/web/app/model/Position.js @@ -13,55 +13,51 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.Position', { - extend: 'Ext.data.Model', - identifier: 'negative', +Ext.define('Traccar.model.Position', { + extend: 'Ext.data.Model', + identifier: 'negative', - fields: [{ - name: 'id', - type: 'int' - }, { - name: 'protocol', - type: 'string' - }, { - name: 'deviceId', - type: 'int' - }, { - name: 'serverTime', - type: 'date' - }, { - name: 'deviceTime', - type: 'date' - }, { - name: 'fixTime', - type: 'date' - }, { - name: 'valid', - type: 'boolean' - }, { - name: 'latitude', - type: 'float' - }, { - name: 'longitude', - type: 'float' - }, { - name: 'altitude', - type: 'float' - }, { - name: 'speed', - type: 'float' - }, { - name: 'course', - type: 'float' - }, { - name: 'address', - type: 'string' - }, { - name: 'attributes' - }] - }); - -})(); + fields: [{ + name: 'id', + type: 'int' + }, { + name: 'protocol', + type: 'string' + }, { + name: 'deviceId', + type: 'int' + }, { + name: 'serverTime', + type: 'date' + }, { + name: 'deviceTime', + type: 'date' + }, { + name: 'fixTime', + type: 'date' + }, { + name: 'valid', + type: 'boolean' + }, { + name: 'latitude', + type: 'float' + }, { + name: 'longitude', + type: 'float' + }, { + name: 'altitude', + type: 'float' + }, { + name: 'speed', + type: 'float' + }, { + name: 'course', + type: 'float' + }, { + name: 'address', + type: 'string' + }, { + name: 'attributes' + }] +}); diff --git a/web/app/model/Server.js b/web/app/model/Server.js index 1cf687a90..2ed2c456f 100644 --- a/web/app/model/Server.js +++ b/web/app/model/Server.js @@ -13,56 +13,52 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.Server', { - extend: 'Ext.data.Model', - identifier: 'negative', +Ext.define('Traccar.model.Server', { + extend: 'Ext.data.Model', + identifier: 'negative', - fields: [{ - name: 'id', - type: 'int' - }, { - name: 'registration', - type: 'boolean' - }, { - name: 'map', - type: 'string' - }, { - name: 'bingKey', - type: 'string' - }, { - name: 'mapUrl', - type: 'string' - }, { - name: 'language', - type: 'string' - }, { - name: 'distanceUnit', - type: 'string' - }, { - name: 'speedUnit', - type: 'string' - }, { - name: 'latitude', - type: 'float' - }, { - name: 'longitude', - type: 'float' - }, { - name: 'zoom', - type: 'int' - }], + fields: [{ + name: 'id', + type: 'int' + }, { + name: 'registration', + type: 'boolean' + }, { + name: 'map', + type: 'string' + }, { + name: 'bingKey', + type: 'string' + }, { + name: 'mapUrl', + type: 'string' + }, { + name: 'language', + type: 'string' + }, { + name: 'distanceUnit', + type: 'string' + }, { + name: 'speedUnit', + type: 'string' + }, { + name: 'latitude', + type: 'float' + }, { + name: 'longitude', + type: 'float' + }, { + name: 'zoom', + type: 'int' + }], - proxy: { - type: 'ajax', - url: '/api/server/update', - writer: { - type: 'json', - writeAllFields: true - } + proxy: { + type: 'ajax', + url: '/api/server/update', + writer: { + type: 'json', + writeAllFields: true } - }); - -})(); + } +}); diff --git a/web/app/model/User.js b/web/app/model/User.js index 9d062862c..d0a6e5e14 100644 --- a/web/app/model/User.js +++ b/web/app/model/User.js @@ -13,59 +13,55 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.model.User', { - extend: 'Ext.data.Model', - identifier: 'negative', +Ext.define('Traccar.model.User', { + extend: 'Ext.data.Model', + identifier: 'negative', - fields: [{ - name: 'id', - type: 'int' - }, { - name: 'name', - type: 'string' - }, { - name: 'email', - type: 'string' - }, { - name: 'password', - type: 'string' - }, { - name: 'admin', - type: 'boolean' - }, { - name: 'map', - type: 'string' - }, { - name: 'language', - type: 'string' - }, { - name: 'distanceUnit', - type: 'string' - }, { - name: 'speedUnit', - type: 'string' - }, { - name: 'latitude', - type: 'float' - }, { - name: 'longitude', - type: 'float' - }, { - name: 'zoom', - type: 'int' - }], + fields: [{ + name: 'id', + type: 'int' + }, { + name: 'name', + type: 'string' + }, { + name: 'email', + type: 'string' + }, { + name: 'password', + type: 'string' + }, { + name: 'admin', + type: 'boolean' + }, { + name: 'map', + type: 'string' + }, { + name: 'language', + type: 'string' + }, { + name: 'distanceUnit', + type: 'string' + }, { + name: 'speedUnit', + type: 'string' + }, { + name: 'latitude', + type: 'float' + }, { + name: 'longitude', + type: 'float' + }, { + name: 'zoom', + type: 'int' + }], - proxy: { - type: 'ajax', - url: '/api/user/update', - writer: { - type: 'json', - writeAllFields: true - } + proxy: { + type: 'ajax', + url: '/api/user/update', + writer: { + type: 'json', + writeAllFields: true } - }); - -})(); + } +}); diff --git a/web/app/store/Attributes.js b/web/app/store/Attributes.js index a63701fdc..2019582e5 100644 --- a/web/app/store/Attributes.js +++ b/web/app/store/Attributes.js @@ -13,16 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.Attributes', { - extend: 'Ext.data.Store', - model: 'Traccar.model.Attribute', +Ext.define('Traccar.store.Attributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Attribute', - sorters: [{ - property: 'priority' - }] - }); - -})(); + sorters: [{ + property: 'priority' + }] +}); diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js index 52f249931..3f5094266 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/CommandTypes.js @@ -13,26 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.CommandTypes', { - extend: 'Ext.data.Store', - fields: ['key', 'name'], +Ext.define('Traccar.store.CommandTypes', { + extend: 'Ext.data.Store', + fields: ['key', 'name'], - data: [{ - key: 'positionPeriodic', - name: Strings.commandPositionPeriodic - }, { - key: 'positionStop', - name: Strings.commandPositionStop - }, { - key: 'engineStop', - name: Strings.commandEngineStop - }, { - key: 'engineResume', - name: Strings.commandEngineResume - }] - }); - -})(); + data: [{ + key: 'positionPeriodic', + name: Strings.commandPositionPeriodic + }, { + key: 'positionStop', + name: Strings.commandPositionStop + }, { + key: 'engineStop', + name: Strings.commandEngineStop + }, { + key: 'engineResume', + name: Strings.commandEngineResume + }] +}); diff --git a/web/app/store/Devices.js b/web/app/store/Devices.js index 05da6a194..24777de5a 100644 --- a/web/app/store/Devices.js +++ b/web/app/store/Devices.js @@ -13,30 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.Devices', { - extend: 'Ext.data.Store', - model: 'Traccar.model.Device', +Ext.define('Traccar.store.Devices', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Device', - proxy: { - type: 'ajax', - api: { - create: '/api/device/add', - read: '/api/device/get', - update: '/api/device/update', - destroy: '/api/device/remove' - }, - reader: { - type: 'json', - rootProperty: 'data' - }, - writer: { - type: 'json', - writeAllFields: true - } + proxy: { + type: 'ajax', + api: { + create: '/api/device/add', + read: '/api/device/get', + update: '/api/device/update', + destroy: '/api/device/remove' + }, + reader: { + type: 'json', + rootProperty: 'data' + }, + writer: { + type: 'json', + writeAllFields: true } - }); - -})(); + } +}); diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 3092eecca..20d057c1f 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -13,32 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.DistanceUnits', { - extend: 'Ext.data.Store', - fields: ['key', 'name', 'factor'], +Ext.define('Traccar.store.DistanceUnits', { + extend: 'Ext.data.Store', + fields: ['key', 'name', 'factor'], - data: [{ - key: 'km', - name: Strings.sharedKm, - factor: 0.001 - }, { - key: 'mi', - name: Strings.sharedMi, - factor: 0.00621371 - }], + data: [{ + key: 'km', + name: Strings.sharedKm, + factor: 0.001 + }, { + key: 'mi', + name: Strings.sharedMi, + factor: 0.00621371 + }], - formatValue: function (value, unit) { - var model; - if (unit) { - model = this.findRecord('key', unit); - return (value * model.get('factor')).toFixed(2) + ' ' + model.get('name'); - } else { - return value; - } + formatValue: function (value, unit) { + var model; + if (unit) { + model = this.findRecord('key', unit); + return (value * model.get('factor')).toFixed(2) + ' ' + model.get('name'); + } else { + return value; } - }); - -})(); + } +}); diff --git a/web/app/store/Languages.js b/web/app/store/Languages.js index 594953480..027c96bec 100644 --- a/web/app/store/Languages.js +++ b/web/app/store/Languages.js @@ -13,25 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.Languages', { - extend: 'Ext.data.Store', - fields: ['code', 'name'], +Ext.define('Traccar.store.Languages', { + extend: 'Ext.data.Store', + fields: ['code', 'name'], - data: (function () { - var code, data = []; - for (code in Locale.languages) { - if (Locale.languages.hasOwnProperty(code)) { - data.push({ - code: code, - name: Locale.languages[code].name - }); - } + data: (function () { + var code, data = []; + for (code in Locale.languages) { + if (Locale.languages.hasOwnProperty(code)) { + data.push({ + code: code, + name: Locale.languages[code].name + }); } - return data; - })() - }); - -})(); + } + return data; + })() +}); diff --git a/web/app/store/LatestPositions.js b/web/app/store/LatestPositions.js index 3bd58bd04..c656bdcb8 100644 --- a/web/app/store/LatestPositions.js +++ b/web/app/store/LatestPositions.js @@ -13,12 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.LatestPositions', { - extend: 'Ext.data.Store', - model: 'Traccar.model.Position' - }); - -})(); +Ext.define('Traccar.store.LatestPositions', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Position' +}); diff --git a/web/app/store/MapTypes.js b/web/app/store/MapTypes.js index 3caf117ec..4c26ad451 100644 --- a/web/app/store/MapTypes.js +++ b/web/app/store/MapTypes.js @@ -13,26 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.MapTypes', { - extend: 'Ext.data.Store', - fields: ['key', 'name'], +Ext.define('Traccar.store.MapTypes', { + extend: 'Ext.data.Store', + fields: ['key', 'name'], - data: [{ - key: 'osm', - name: Strings.mapOsm - }, { - key: 'bingRoad', - name: Strings.mapBingRoad - }, { - key: 'bingAerial', - name: Strings.mapBingAerial - }, { - key: 'custom', - name: Strings.mapCustom - }] - }); - -})(); + data: [{ + key: 'osm', + name: Strings.mapOsm + }, { + key: 'bingRoad', + name: Strings.mapBingRoad + }, { + key: 'bingAerial', + name: Strings.mapBingAerial + }, { + key: 'custom', + name: Strings.mapCustom + }] +}); diff --git a/web/app/store/Positions.js b/web/app/store/Positions.js index 415e26cbe..7de54a8d2 100644 --- a/web/app/store/Positions.js +++ b/web/app/store/Positions.js @@ -13,21 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.Positions', { - extend: 'Ext.data.Store', - model: 'Traccar.model.Position', +Ext.define('Traccar.store.Positions', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Position', - proxy: { - type: 'ajax', - url: '/api/position/get', - reader: { - type: 'json', - rootProperty: 'data' - } + proxy: { + type: 'ajax', + url: '/api/position/get', + reader: { + type: 'json', + rootProperty: 'data' } - }); - -})(); + } +}); diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js index 2238d476a..d02892a01 100644 --- a/web/app/store/SpeedUnits.js +++ b/web/app/store/SpeedUnits.js @@ -13,32 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.SpeedUnits', { - extend: 'Ext.data.Store', - fields: ['key', 'name', 'factor'], +Ext.define('Traccar.store.SpeedUnits', { + extend: 'Ext.data.Store', + fields: ['key', 'name', 'factor'], - data: [{ - key: 'kmh', - name: Strings.sharedKmh, - factor: 1.852 - }, { - key: 'mph', - name: Strings.sharedMph, - factor: 1.15078 - }], + data: [{ + key: 'kmh', + name: Strings.sharedKmh, + factor: 1.852 + }, { + key: 'mph', + name: Strings.sharedMph, + factor: 1.15078 + }], - formatValue: function (value, unit) { - var model; - if (unit) { - model = this.findRecord('key', unit); - return (value * model.get('factor')).toFixed(1) + ' ' + model.get('name'); - } else { - return value; - } + formatValue: function (value, unit) { + var model; + if (unit) { + model = this.findRecord('key', unit); + return (value * model.get('factor')).toFixed(1) + ' ' + model.get('name'); + } else { + return value; } - }); - -})(); + } +}); diff --git a/web/app/store/TimeUnits.js b/web/app/store/TimeUnits.js index 29730f2b9..e03263825 100644 --- a/web/app/store/TimeUnits.js +++ b/web/app/store/TimeUnits.js @@ -13,23 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.TimeUnits', { - extend: 'Ext.data.Store', - fields: ['name', 'factor'], +Ext.define('Traccar.store.TimeUnits', { + extend: 'Ext.data.Store', + fields: ['name', 'factor'], - data: [{ - name: Strings.sharedSecond, - factor: 1 - }, { - name: Strings.sharedMinute, - factor: 60 - }, { - name: Strings.sharedHour, - factor: 3600 - }] - }); - -})(); + data: [{ + name: Strings.sharedSecond, + factor: 1 + }, { + name: Strings.sharedMinute, + factor: 60 + }, { + name: Strings.sharedHour, + factor: 3600 + }] +}); diff --git a/web/app/store/Users.js b/web/app/store/Users.js index 908e8eaf9..004dc727e 100644 --- a/web/app/store/Users.js +++ b/web/app/store/Users.js @@ -13,30 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.store.Users', { - extend: 'Ext.data.Store', - model: 'Traccar.model.User', +Ext.define('Traccar.store.Users', { + extend: 'Ext.data.Store', + model: 'Traccar.model.User', - proxy: { - type: 'ajax', - api: { - create: '/api/user/add', - read: '/api/user/get', - update: '/api/user/update', - destroy: '/api/user/remove' - }, - reader: { - type: 'json', - rootProperty: 'data' - }, - writer: { - type: 'json', - writeAllFields: true - } + proxy: { + type: 'ajax', + api: { + create: '/api/user/add', + read: '/api/user/get', + update: '/api/user/update', + destroy: '/api/user/remove' + }, + reader: { + type: 'json', + rootProperty: 'data' + }, + writer: { + type: 'json', + writeAllFields: true } - }); - -})(); + } +}); diff --git a/web/app/view/BaseDialog.js b/web/app/view/BaseDialog.js index f5cb8ca1d..fb09f12d1 100644 --- a/web/app/view/BaseDialog.js +++ b/web/app/view/BaseDialog.js @@ -13,15 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.BaseDialog', { - extend: 'Ext.window.Window', +Ext.define('Traccar.view.BaseDialog', { + extend: 'Ext.window.Window', - bodyPadding: Traccar.Style.panelPadding, - resizable: false, - modal: true - }); - -})(); + bodyPadding: Traccar.Style.panelPadding, + resizable: false, + modal: true +}); diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js index bf1e52749..051dfbe93 100644 --- a/web/app/view/BaseEditDialog.js +++ b/web/app/view/BaseEditDialog.js @@ -13,19 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.BaseEditDialog', { - extend: 'Traccar.view.BaseDialog', +Ext.define('Traccar.view.BaseEditDialog', { + extend: 'Traccar.view.BaseDialog', - buttons: [{ - text: Strings.sharedSave, - handler: 'onSaveClick' - }, { - text: Strings.sharedCancel, - handler: 'closeView' - }] - }); - -})(); + 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 1820d9c9a..3b43cacf3 100644 --- a/web/app/view/BaseEditDialogController.js +++ b/web/app/view/BaseEditDialogController.js @@ -13,37 +13,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.BaseEditDialogController', { - extend: 'Ext.app.ViewController', - alias: 'controller.baseEditDialog', +Ext.define('Traccar.view.BaseEditDialogController', { + extend: 'Ext.app.ViewController', + alias: 'controller.baseEditDialog', - 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({ - success: function () { - store.reload(); // workaround for selection problem - }, - failure: function (batch) { - store.rejectChanges(); - Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); - } - }); - } else { - record.save(); + 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); } - button.up('window').close(); + store.sync({ + success: function () { + store.reload(); // workaround for selection problem + }, + failure: function (batch) { + store.rejectChanges(); + Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); + } + }); + } else { + record.save(); } - }); - -})(); + button.up('window').close(); + } +}); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 36024a172..66cd190ea 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -13,59 +13,55 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.CommandDialog', { - extend: 'Traccar.view.BaseDialog', +Ext.define('Traccar.view.CommandDialog', { + extend: 'Traccar.view.BaseDialog', - requires: [ - 'Traccar.view.CommandDialogController' - ], + requires: [ + 'Traccar.view.CommandDialogController' + ], - controller: 'commandDialog', - title: Strings.commandTitle, + controller: 'commandDialog', + title: Strings.commandTitle, + + items: { + xtype: 'form', + items: [{ + xtype: 'combobox', + name: 'type', + fieldLabel: Strings.commandType, + store: 'CommandTypes', + displayField: 'name', + valueField: 'key', + listeners: { + select: 'onSelect' + } + }, { + xtype: 'fieldcontainer', + reference: 'paramPositionPeriodic', + name: 'attributes', + hidden: true, - items: { - xtype: 'form', items: [{ + xtype: 'numberfield', + fieldLabel: Strings.commandFrequency, + name: 'frequency' + }, { xtype: 'combobox', - name: 'type', - fieldLabel: Strings.commandType, - store: 'CommandTypes', + fieldLabel: Strings.commandUnit, + name: 'unit', + store: 'TimeUnits', displayField: 'name', - valueField: 'key', - listeners: { - select: 'onSelect' - } - }, { - xtype: 'fieldcontainer', - reference: 'paramPositionPeriodic', - name: 'attributes', - hidden: true, - - items: [{ - xtype: 'numberfield', - fieldLabel: Strings.commandFrequency, - name: 'frequency' - }, { - xtype: 'combobox', - fieldLabel: Strings.commandUnit, - name: 'unit', - store: 'TimeUnits', - displayField: 'name', - valueField: 'factor' - }] + valueField: 'factor' }] - }, - - buttons: [{ - text: Strings.commandSend, - handler: 'onSendClick' - }, { - text: Strings.sharedCancel, - handler: 'closeView' }] - }); + }, -})(); + buttons: [{ + text: Strings.commandSend, + handler: 'onSendClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' + }] +}); diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js index 39149c5a5..94df2ec42 100644 --- a/web/app/view/CommandDialogController.js +++ b/web/app/view/CommandDialogController.js @@ -13,49 +13,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - - Ext.define('Traccar.view.CommandDialogController', { - extend: 'Ext.app.ViewController', - alias: 'controller.commandDialog', - - onSelect: function (selected) { - this.lookupReference('paramPositionPeriodic').setHidden( - selected.getValue() !== 'positionPeriodic'); - }, - - onSendClick: function (button) { - var attributes, value, record, form; - - form = button.up('window').down('form'); - form.updateRecord(); - record = form.getRecord(); - - if (record.get('type') === 'positionPeriodic') { - attributes = this.lookupReference('paramPositionPeriodic'); - value = attributes.down('numberfield[name="frequency"]').getValue(); - value *= attributes.down('combobox[name="unit"]').getValue(); - - record.set('attributes', { - frequency: value - }); - } - - Ext.Ajax.request({ - scope: this, - url: '/api/command/send', - jsonData: record.getData(), - callback: this.onSendResult - }); - }, - onSendResult: function (options, success, response) { - if (Traccar.ErrorManager.check(success, response)) { - Ext.toast(Strings.commandSent); - this.closeView(); - } +Ext.define('Traccar.view.CommandDialogController', { + extend: 'Ext.app.ViewController', + alias: 'controller.commandDialog', + + onSelect: function (selected) { + this.lookupReference('paramPositionPeriodic').setHidden( + selected.getValue() !== 'positionPeriodic'); + }, + + onSendClick: function (button) { + var attributes, value, record, form; + + form = button.up('window').down('form'); + form.updateRecord(); + record = form.getRecord(); + + if (record.get('type') === 'positionPeriodic') { + attributes = this.lookupReference('paramPositionPeriodic'); + value = attributes.down('numberfield[name="frequency"]').getValue(); + value *= attributes.down('combobox[name="unit"]').getValue(); + + record.set('attributes', { + frequency: value + }); } - }); -})(); + Ext.Ajax.request({ + scope: this, + url: '/api/command/send', + jsonData: record.getData(), + callback: this.onSendResult + }); + }, + + onSendResult: function (options, success, response) { + if (Traccar.ErrorManager.check(success, response)) { + Ext.toast(Strings.commandSent); + this.closeView(); + } + } +}); diff --git a/web/app/view/Device.js b/web/app/view/Device.js index 3feb008a2..cf7e3e473 100644 --- a/web/app/view/Device.js +++ b/web/app/view/Device.js @@ -13,85 +13,107 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Device', { - extend: 'Ext.grid.Panel', - xtype: 'deviceView', +Ext.define('Traccar.view.Device', { + extend: 'Ext.grid.Panel', + xtype: 'deviceView', - requires: [ - 'Traccar.view.DeviceController' - ], + requires: [ + 'Traccar.view.DeviceController', + 'Traccar.view.BaseEditToolbar' + ], - controller: 'device', - store: 'Devices', + controller: 'device', + store: 'Devices', - title: Strings.deviceTitle, - selType: 'rowmodel', + title: Strings.deviceTitle, + selType: 'rowmodel', - tbar: [{ - handler: 'onAddClick', - reference: 'deviceAddButton', - glyph: 'xf067@FontAwesome', - tooltip: Strings.sharedAdd, - tooltipType: 'title' - }, { - disabled: true, - handler: 'onEditClick', - reference: 'deviceEditButton', - glyph: 'xf040@FontAwesome', - tooltip: Strings.sharedEdit, - tooltipType: 'title' - }, { + dockedItems: [{ + xtype : 'baseEditToolbar', + dock : "top", + items: [{ disabled: true, - handler: 'onRemoveClick', - reference: 'deviceRemoveButton', - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedRemove, + handler: 'onCommandClick', + reference: 'deviceCommandButton', + glyph: 'xf093@FontAwesome', + tooltip: Strings.deviceCommand, tooltipType: 'title' - }, { + }] + }], + + //tbar: { + // xtype: 'baseEditToolbar', + /*items: [{ disabled: true, handler: 'onCommandClick', reference: 'deviceCommandButton', glyph: 'xf093@FontAwesome', tooltip: Strings.deviceCommand, tooltipType: 'title' - }, { - xtype: 'tbfill' - }, { - text: Strings.settingsTitle, - menu: [{ - text: Strings.settingsUser, - handler: 'onUserClick' - }, { - text: Strings.settingsServer, - hidden: true, - handler: 'onServerClick', - reference: 'settingsServerButton' - }, { - text: Strings.settingsUsers, - hidden: true, - handler: 'onUsersClick', - reference: 'settingsUsersButton' - }] - }, { - text: Strings.loginLogout, - handler: 'onLogoutClick' - }], - - listeners: { - selectionchange: 'onSelectionChange' - }, + }]*/ + //}, - columns: [{ - text: Strings.deviceName, - dataIndex: 'name', flex: 1 + /*tbar: [{ + handler: 'onAddClick', + reference: 'deviceAddButton', + glyph: 'xf067@FontAwesome', + tooltip: Strings.sharedAdd, + tooltipType: 'title' + }, { + disabled: true, + handler: 'onEditClick', + reference: 'deviceEditButton', + glyph: 'xf040@FontAwesome', + tooltip: Strings.sharedEdit, + tooltipType: 'title' + }, { + disabled: true, + handler: 'onRemoveClick', + reference: 'deviceRemoveButton', + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedRemove, + tooltipType: 'title' + }, { + disabled: true, + handler: 'onCommandClick', + reference: 'deviceCommandButton', + glyph: 'xf093@FontAwesome', + tooltip: Strings.deviceCommand, + tooltipType: 'title' + }, { + xtype: 'tbfill' + }, { + text: Strings.settingsTitle, + menu: [{ + text: Strings.settingsUser, + handler: 'onUserClick' }, { - text: Strings.deviceIdentifier, - dataIndex: 'uniqueId', flex: 1 + text: Strings.settingsServer, + hidden: true, + handler: 'onServerClick', + reference: 'settingsServerButton' + }, { + text: Strings.settingsUsers, + hidden: true, + handler: 'onUsersClick', + reference: 'settingsUsersButton' }] + }, { + text: Strings.loginLogout, + handler: 'onLogoutClick' + }],*/ + + listeners: { + selectionchange: 'onSelectionChange' + }, - }); + columns: [{ + text: Strings.deviceName, + dataIndex: 'name', flex: 1 + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', flex: 1 + }] -})(); +}); diff --git a/web/app/view/DeviceController.js b/web/app/view/DeviceController.js index 4d26f799f..a2e0aaae8 100644 --- a/web/app/view/DeviceController.js +++ b/web/app/view/DeviceController.js @@ -13,130 +13,126 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.DeviceController', { - extend: 'Ext.app.ViewController', - alias: 'controller.device', +Ext.define('Traccar.view.DeviceController', { + extend: 'Ext.app.ViewController', + alias: 'controller.device', - requires: [ - 'Traccar.view.CommandDialog', - 'Traccar.view.DeviceDialog', - 'Traccar.view.UserDialog', - 'Traccar.view.User', - 'Traccar.view.LoginController' - ], + requires: [ + 'Traccar.view.CommandDialog', + 'Traccar.view.DeviceDialog', + 'Traccar.view.UserDialog', + 'Traccar.view.User', + 'Traccar.view.LoginController' + ], - config: { - listen: { - controller: { - '*': { - selectReport: 'selectReport' - } + config: { + listen: { + controller: { + '*': { + selectReport: 'selectReport' } } - }, + } + }, - init: function () { - if (Traccar.app.getUser().get('admin')) { - this.lookupReference('settingsServerButton').setHidden(false); - this.lookupReference('settingsUsersButton').setHidden(false); - } - }, + init: function () { + if (Traccar.app.getUser().get('admin')) { + this.lookupReference('settingsServerButton').setHidden(false); + this.lookupReference('settingsUsersButton').setHidden(false); + } + }, - onLogoutClick: function () { - Ext.create('Traccar.view.LoginController').logout(); - }, + onLogoutClick: function () { + Ext.create('Traccar.view.LoginController').logout(); + }, - onAddClick: function () { - var device, dialog; - device = Ext.create('Traccar.model.Device'); - device.store = this.getView().getStore(); - dialog = Ext.create('Traccar.view.DeviceDialog'); - dialog.down('form').loadRecord(device); - dialog.show(); - }, + onAddClick: function () { + var device, dialog; + device = Ext.create('Traccar.model.Device'); + device.store = this.getView().getStore(); + dialog = Ext.create('Traccar.view.DeviceDialog'); + dialog.down('form').loadRecord(device); + dialog.show(); + }, - onEditClick: function () { - var device, dialog; - device = this.getView().getSelectionModel().getSelection()[0]; - dialog = Ext.create('Traccar.view.DeviceDialog'); - dialog.down('form').loadRecord(device); - dialog.show(); - }, + onEditClick: function () { + var device, dialog; + device = this.getView().getSelectionModel().getSelection()[0]; + dialog = Ext.create('Traccar.view.DeviceDialog'); + dialog.down('form').loadRecord(device); + dialog.show(); + }, - onRemoveClick: function () { - var device = this.getView().getSelectionModel().getSelection()[0]; - Ext.Msg.show({ - title: Strings.deviceDialog, - message: Strings.sharedRemoveConfirm, - buttons: Ext.Msg.YESNO, - buttonText: { - yes: Strings.sharedRemove, - no: Strings.sharedCancel - }, - fn: function (btn) { - var store; - if (btn === 'yes') { - store = Ext.getStore('Devices'); - store.remove(device); - store.sync(); - } + onRemoveClick: function () { + var device = this.getView().getSelectionModel().getSelection()[0]; + Ext.Msg.show({ + title: Strings.deviceDialog, + message: Strings.sharedRemoveConfirm, + buttons: Ext.Msg.YESNO, + buttonText: { + yes: Strings.sharedRemove, + no: Strings.sharedCancel + }, + fn: function (btn) { + var store; + if (btn === 'yes') { + store = Ext.getStore('Devices'); + store.remove(device); + store.sync(); } - }); - }, - - onCommandClick: function () { - var device, command, dialog; - device = this.getView().getSelectionModel().getSelection()[0]; - command = Ext.create('Traccar.model.Command'); - command.set('deviceId', device.get('id')); - dialog = Ext.create('Traccar.view.CommandDialog'); - dialog.down('form').loadRecord(command); - dialog.show(); - }, - - onSelectionChange: function (selected) { - var empty = selected.getCount() === 0; - this.lookupReference('deviceEditButton').setDisabled(empty); - this.lookupReference('deviceRemoveButton').setDisabled(empty); - this.lookupReference('deviceCommandButton').setDisabled(empty); - if (!empty) { - this.fireEvent('selectDevice', selected.getLastSelected()); } - }, + }); + }, - onUserClick: function () { - var dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(Traccar.app.getUser()); - dialog.show(); - }, + onCommandClick: function () { + var device, command, dialog; + device = this.getView().getSelectionModel().getSelection()[0]; + command = Ext.create('Traccar.model.Command'); + command.set('deviceId', device.get('id')); + dialog = Ext.create('Traccar.view.CommandDialog'); + dialog.down('form').loadRecord(command); + dialog.show(); + }, - onServerClick: function () { - var dialog = Ext.create('Traccar.view.ServerDialog'); - dialog.down('form').loadRecord(Traccar.app.getServer()); - dialog.show(); - }, + onSelectionChange: function (selected) { + var empty = selected.getCount() === 0; + this.lookupReference('deviceEditButton').setDisabled(empty); + this.lookupReference('deviceRemoveButton').setDisabled(empty); + this.lookupReference('deviceCommandButton').setDisabled(empty); + if (!empty) { + this.fireEvent('selectDevice', selected.getLastSelected()); + } + }, - onUsersClick: function () { - Ext.create('Ext.window.Window', { - title: Strings.settingsUsers, - width: Traccar.Style.windowWidth, - height: Traccar.Style.windowHeight, - layout: 'fit', - modal: true, - items: { - xtype: 'userView' - } - }).show(); - }, + onUserClick: function () { + var dialog = Ext.create('Traccar.view.UserDialog'); + dialog.down('form').loadRecord(Traccar.app.getUser()); + dialog.show(); + }, + + onServerClick: function () { + var dialog = Ext.create('Traccar.view.ServerDialog'); + dialog.down('form').loadRecord(Traccar.app.getServer()); + dialog.show(); + }, - selectReport: function (position) { - if (position !== undefined) { - this.getView().getSelectionModel().deselectAll(); + onUsersClick: function () { + Ext.create('Ext.window.Window', { + title: Strings.settingsUsers, + width: Traccar.Style.windowWidth, + height: Traccar.Style.windowHeight, + layout: 'fit', + modal: true, + items: { + xtype: 'userView' } - } - }); + }).show(); + }, -})(); + selectReport: function (position) { + if (position !== undefined) { + this.getView().getSelectionModel().deselectAll(); + } + } +}); diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js index 2349676b1..c42af95d0 100644 --- a/web/app/view/DeviceDialog.js +++ b/web/app/view/DeviceDialog.js @@ -13,33 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.DeviceDialog', { - extend: 'Traccar.view.BaseEditDialog', +Ext.define('Traccar.view.DeviceDialog', { + extend: 'Traccar.view.BaseEditDialog', - requires: [ - 'Traccar.view.BaseEditDialogController' - ], + requires: [ + 'Traccar.view.BaseEditDialogController' + ], - controller: 'baseEditDialog', - title: Strings.deviceDialog, + controller: 'baseEditDialog', + title: Strings.deviceDialog, - items: { - xtype: 'form', - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.deviceName, - allowBlank: false - }, { - xtype: 'textfield', - name: 'uniqueId', - fieldLabel: Strings.deviceIdentifier, - allowBlank: false - }] - } - }); - -})(); + items: { + xtype: 'form', + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.deviceName, + allowBlank: false + }, { + xtype: 'textfield', + name: 'uniqueId', + fieldLabel: Strings.deviceIdentifier, + allowBlank: false + }] + } +}); diff --git a/web/app/view/Login.js b/web/app/view/Login.js index 6e10a6824..a4a68843d 100644 --- a/web/app/view/Login.js +++ b/web/app/view/Login.js @@ -13,84 +13,80 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Login', { - extend: 'Traccar.view.BaseDialog', - alias: 'widget.login', +Ext.define('Traccar.view.Login', { + extend: 'Traccar.view.BaseDialog', + alias: 'widget.login', - requires: [ - 'Traccar.view.LoginController' - ], + requires: [ + 'Traccar.view.LoginController' + ], - controller: 'login', + controller: 'login', - closable: false, - modal: false, + closable: false, + modal: false, - items: { - xtype: 'form', - reference: 'form', + items: { + xtype: 'form', + reference: 'form', - autoEl: { - tag: 'form', - method: 'POST', - action: 'blank', - target: 'submitTarget' - }, - - items: [{ - xtype: 'combobox', - name: 'language', - fieldLabel: Strings.loginLanguage, - store: 'Languages', - displayField: 'name', - valueField: 'code', - submitValue: false, - listeners: { - select: 'onSelectLanguage' - }, - reference: 'languageField' - }, { - xtype: 'textfield', - name: 'email', - fieldLabel: Strings.userEmail, - allowBlank: false, - enableKeyEvents: true, - listeners: { - specialKey: 'onSpecialKey', - afterrender: 'onAfterRender' - }, - inputAttrTpl: ['autocomplete="on"'] - }, { - xtype: 'textfield', - name: 'password', - fieldLabel: Strings.userPassword, - inputType: 'password', - allowBlank: false, - enableKeyEvents: true, - listeners: { - specialKey: 'onSpecialKey' - }, - inputAttrTpl: ['autocomplete="on"'] - }, { - xtype: 'component', - html: '' - }, { - xtype: 'component', - html: '' - }] + autoEl: { + tag: 'form', + method: 'POST', + action: 'blank', + target: 'submitTarget' }, - buttons: [{ - text: Strings.loginRegister, - handler: 'onRegisterClick', - reference: 'registerButton' + items: [{ + xtype: 'combobox', + name: 'language', + fieldLabel: Strings.loginLanguage, + store: 'Languages', + displayField: 'name', + valueField: 'code', + submitValue: false, + listeners: { + select: 'onSelectLanguage' + }, + reference: 'languageField' + }, { + xtype: 'textfield', + name: 'email', + fieldLabel: Strings.userEmail, + allowBlank: false, + enableKeyEvents: true, + listeners: { + specialKey: 'onSpecialKey', + afterrender: 'onAfterRender' + }, + inputAttrTpl: ['autocomplete="on"'] + }, { + xtype: 'textfield', + name: 'password', + fieldLabel: Strings.userPassword, + inputType: 'password', + allowBlank: false, + enableKeyEvents: true, + listeners: { + specialKey: 'onSpecialKey' + }, + inputAttrTpl: ['autocomplete="on"'] + }, { + xtype: 'component', + html: '' }, { - text: Strings.loginLogin, - handler: 'onLoginClick' + xtype: 'component', + html: '' }] - }); + }, -})(); + buttons: [{ + text: Strings.loginRegister, + handler: 'onRegisterClick', + reference: 'registerButton' + }, { + text: Strings.loginLogin, + handler: 'onLoginClick' + }] +}); diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js index baf27a751..e0dbcce88 100644 --- a/web/app/view/LoginController.js +++ b/web/app/view/LoginController.js @@ -13,97 +13,93 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.LoginController', { - extend: 'Ext.app.ViewController', - alias: 'controller.login', +Ext.define('Traccar.view.LoginController', { + extend: 'Ext.app.ViewController', + alias: 'controller.login', - requires: [ - 'Traccar.view.Register' - ], + requires: [ + 'Traccar.view.Register' + ], - init: function () { - this.lookupReference('registerButton').setDisabled( - !Traccar.app.getServer().get('registration')); - this.lookupReference('languageField').setValue(Locale.language); - }, + init: function () { + this.lookupReference('registerButton').setDisabled( + !Traccar.app.getServer().get('registration')); + this.lookupReference('languageField').setValue(Locale.language); + }, - login: function () { - var form = this.lookupReference('form'); - if (form.isValid()) { - Ext.getBody().mask(Strings.sharedLoading); - Ext.Ajax.request({ - scope: this, - url: '/api/login', - params: form.getValues(), - callback: function (options, success, response) { - var result; - Ext.getBody().unmask(); - if (Traccar.ErrorManager.check(success, response)) { - result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setUser(result.data); - this.fireViewEvent('login'); - } else { - Traccar.ErrorManager.error(Strings.loginFailed); - } + login: function () { + var form = this.lookupReference('form'); + if (form.isValid()) { + Ext.getBody().mask(Strings.sharedLoading); + Ext.Ajax.request({ + scope: this, + url: '/api/login', + params: form.getValues(), + callback: function (options, success, response) { + var result; + Ext.getBody().unmask(); + if (Traccar.ErrorManager.check(success, response)) { + result = Ext.decode(response.responseText); + if (result.success) { + Traccar.app.setUser(result.data); + this.fireViewEvent('login'); + } else { + Traccar.ErrorManager.error(Strings.loginFailed); } - } - }); - } - }, - logout: function () { - Ext.Ajax.request({ - scope: this, - url: '/api/logout', - callback: function () { - window.location.reload(); } }); - }, + } + }, - onSelectLanguage: function (selected) { - var paramName = 'locale'; - var paramValue = selected.getValue(); - var url = window.location.href; - if (url.indexOf(paramName + '=') >= 0) { - var prefix = url.substring(0, url.indexOf(paramName)); - var suffix = url.substring(url.indexOf(paramName)); - suffix = suffix.substring(suffix.indexOf('=') + 1); - suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : ''; - url = prefix + paramName + '=' + paramValue + suffix; - } else { - if (url.indexOf('?') < 0) { - url += '?' + paramName + '=' + paramValue; - } else { - url += '&' + paramName + '=' + paramValue; - } + logout: function () { + Ext.Ajax.request({ + scope: this, + url: '/api/logout', + callback: function () { + window.location.reload(); } - window.location.href = url; - }, - - onAfterRender: function (field) { - field.focus(); - }, + }); + }, - onSpecialKey: function (field, e) { - if (e.getKey() === e.ENTER) { - this.login(); + onSelectLanguage: function (selected) { + var paramName = 'locale'; + var paramValue = selected.getValue(); + var url = window.location.href; + if (url.indexOf(paramName + '=') >= 0) { + var prefix = url.substring(0, url.indexOf(paramName)); + var suffix = url.substring(url.indexOf(paramName)); + suffix = suffix.substring(suffix.indexOf('=') + 1); + suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : ''; + url = prefix + paramName + '=' + paramValue + suffix; + } else { + if (url.indexOf('?') < 0) { + url += '?' + paramName + '=' + paramValue; + } else { + url += '&' + paramName + '=' + paramValue; } - }, + } + window.location.href = url; + }, - onLoginClick: function () { - Ext.getElementById('submitButton').click(); - this.login(); - }, + onAfterRender: function (field) { + field.focus(); + }, - onRegisterClick: function () { - Ext.create('Traccar.view.Register').show(); + onSpecialKey: function (field, e) { + if (e.getKey() === e.ENTER) { + this.login(); } - }); + }, + + onLoginClick: function () { + Ext.getElementById('submitButton').click(); + this.login(); + }, -})(); + onRegisterClick: function () { + Ext.create('Traccar.view.Register').show(); + } +}); diff --git a/web/app/view/Main.js b/web/app/view/Main.js index 04ad5ea48..fc29d43aa 100644 --- a/web/app/view/Main.js +++ b/web/app/view/Main.js @@ -13,55 +13,51 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Main', { - extend: 'Ext.container.Viewport', - alias: 'widget.main', +Ext.define('Traccar.view.Main', { + extend: 'Ext.container.Viewport', + alias: 'widget.main', - requires: [ - 'Traccar.view.Device', - 'Traccar.view.State', - 'Traccar.view.Report', - 'Traccar.view.Map' - ], + requires: [ + 'Traccar.view.Device', + 'Traccar.view.State', + 'Traccar.view.Report', + 'Traccar.view.Map' + ], + layout: 'border', + + defaults: { + header: false, + collapsible: true, + split: true + }, + + items: [{ + region: 'west', layout: 'border', + width: Traccar.Style.deviceWidth, defaults: { - header: false, - collapsible: true, - split: true + split: true, + flex: 1 }, items: [{ - region: 'west', - layout: 'border', - width: Traccar.Style.deviceWidth, - - defaults: { - split: true, - flex: 1 - }, - - items: [{ - region: 'center', - xtype: 'deviceView' - }, { - region: 'south', - xtype: 'stateView' - }] + region: 'center', + xtype: 'deviceView' }, { region: 'south', - xtype: 'reportView', - height: Traccar.Style.reportHeight - }, { - region: 'center', - xtype: 'mapView', - header: true, - collapsible: false + xtype: 'stateView' }] - }); - -})(); + }, { + region: 'south', + xtype: 'reportView', + height: Traccar.Style.reportHeight + }, { + region: 'center', + xtype: 'mapView', + header: true, + collapsible: false + }] +}); diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js index d822f4978..e42fc7f7f 100644 --- a/web/app/view/MainMobile.js +++ b/web/app/view/MainMobile.js @@ -13,41 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.MainMobile', { - extend: 'Ext.container.Viewport', - alias: 'widget.mainMobile', +Ext.define('Traccar.view.MainMobile', { + extend: 'Ext.container.Viewport', + alias: 'widget.mainMobile', - requires: [ - 'Traccar.view.Device', - 'Traccar.view.State', - 'Traccar.view.Map' - ], + requires: [ + 'Traccar.view.Device', + 'Traccar.view.State', + 'Traccar.view.Map' + ], - layout: 'border', + layout: 'border', - defaults: { - header: false, - collapsible: true, - split: true - }, + defaults: { + header: false, + collapsible: true, + split: true + }, - items: [{ - region: 'east', - xtype: 'stateView', - flex: 4 - }, { - region: 'center', - xtype: 'mapView', - collapsible: false, - flex: 2 - }, { - region: 'south', - xtype: 'deviceView', - flex: 1 - }] - }); - -})(); + items: [{ + region: 'east', + xtype: 'stateView', + flex: 4 + }, { + region: 'center', + xtype: 'mapView', + collapsible: false, + flex: 2 + }, { + region: 'south', + xtype: 'deviceView', + flex: 1 + }] +}); diff --git a/web/app/view/Map.js b/web/app/view/Map.js index 7165bfb56..709684e29 100644 --- a/web/app/view/Map.js +++ b/web/app/view/Map.js @@ -13,84 +13,80 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Map', { - extend: 'Ext.form.Panel', - xtype: 'mapView', +Ext.define('Traccar.view.Map', { + extend: 'Ext.form.Panel', + xtype: 'mapView', - requires: [ - 'Traccar.view.MapController' - ], + requires: [ + 'Traccar.view.MapController' + ], - controller: 'map', + controller: 'map', - title: Strings.mapTitle, - layout: 'fit', + title: Strings.mapTitle, + layout: 'fit', - listeners: { - afterrender: function () { - var user = Traccar.app.getUser(); - var server = Traccar.app.getServer(); + listeners: { + afterrender: function () { + var user = Traccar.app.getUser(); + var server = Traccar.app.getServer(); - var layer; - var mapLayer = user.get('map') || server.get('map'); + var layer; + var mapLayer = user.get('map') || server.get('map'); - var bingKey = server.get('bingKey'); + var bingKey = server.get('bingKey'); - if (mapLayer === 'custom') { - layer = new ol.layer.Tile({ - source: new ol.source.XYZ({ - url: server.get('mapUrl') - }) - }); - } else if (mapLayer === 'bingRoad') { - layer = new ol.layer.Tile({ - source: new ol.source.BingMaps({ - key: bingKey, - imagerySet: 'Road' - }) - }); - } else if (mapLayer === 'bingAerial') { - layer = new ol.layer.Tile({ - source: new ol.source.BingMaps({ - key: bingKey, - imagerySet: 'Aerial' - }) - }); - } else { - layer = new ol.layer.Tile({ - source: new ol.source.OSM({}) - }); - } - - this.vectorSource = new ol.source.Vector({}); - var vectorLayer = new ol.layer.Vector({ - source: this.vectorSource + if (mapLayer === 'custom') { + layer = new ol.layer.Tile({ + source: new ol.source.XYZ({ + url: server.get('mapUrl') + }) + }); + } else if (mapLayer === 'bingRoad') { + layer = new ol.layer.Tile({ + source: new ol.source.BingMaps({ + key: bingKey, + imagerySet: 'Road' + }) + }); + } else if (mapLayer === 'bingAerial') { + layer = new ol.layer.Tile({ + source: new ol.source.BingMaps({ + key: bingKey, + imagerySet: 'Aerial' + }) }); + } else { + layer = new ol.layer.Tile({ + source: new ol.source.OSM({}) + }); + } - var lat = user.get('latitude') || server.get('latitude') || Traccar.Style.mapDefaultLat; - var lon = user.get('longitude') || server.get('longitude') || Traccar.Style.mapDefaultLon; - var zoom = user.get('zoom') || server.get('zoom') || Traccar.Style.mapDefaultZoom; + this.vectorSource = new ol.source.Vector({}); + var vectorLayer = new ol.layer.Vector({ + source: this.vectorSource + }); - this.mapView = new ol.View({ - center: ol.proj.fromLonLat([lon, lat]), - zoom: zoom, - maxZoom: Traccar.Style.mapMaxZoom - }); + var lat = user.get('latitude') || server.get('latitude') || Traccar.Style.mapDefaultLat; + var lon = user.get('longitude') || server.get('longitude') || Traccar.Style.mapDefaultLon; + var zoom = user.get('zoom') || server.get('zoom') || Traccar.Style.mapDefaultZoom; - this.map = new ol.Map({ - target: this.body.dom.id, - layers: [layer, vectorLayer], - view: this.mapView - }); - }, + this.mapView = new ol.View({ + center: ol.proj.fromLonLat([lon, lat]), + zoom: zoom, + maxZoom: Traccar.Style.mapMaxZoom + }); - resize: function () { - this.map.updateSize(); - } - } - }); + this.map = new ol.Map({ + target: this.body.dom.id, + layers: [layer, vectorLayer], + view: this.mapView + }); + }, -})(); + resize: function () { + this.map.updateSize(); + } + } +}); diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index 7bb878241..d8177335b 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -13,205 +13,201 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - - Ext.define('Traccar.view.MapController', { - extend: 'Ext.app.ViewController', - alias: 'controller.map', - - config: { - listen: { - controller: { - '*': { - reportShow: 'reportShow', - reportClear: 'reportClear', - selectDevice: 'selectDevice', - selectReport: 'selectReport' - } + +Ext.define('Traccar.view.MapController', { + extend: 'Ext.app.ViewController', + alias: 'controller.map', + + config: { + listen: { + controller: { + '*': { + reportShow: 'reportShow', + reportClear: 'reportClear', + selectDevice: 'selectDevice', + selectReport: 'selectReport' } } - }, - - init: function () { - this.liveData = {}; - this.update(true); - }, - - update: function (first) { - Ext.Ajax.request({ - scope: this, - url: '/api/async', - params: { - first: first - }, - success: function (response) { - var data = Ext.decode(response.responseText).data; - - var i; - for (i = 0; i < data.length; i++) { - - var store = Ext.getStore('LatestPositions'); - - var found = store.query('deviceId', data[i].deviceId); - if (found.getCount() > 0) { - found.first().set(data[i]); - } else { - store.add(Ext.create('Traccar.model.Position', data[i])); - } - - var geometry = new ol.geom.Point(ol.proj.fromLonLat([ - data[i].longitude, - data[i].latitude - ])); - - if (data[i].deviceId in this.liveData) { - this.liveData[data[i].deviceId].setGeometry(geometry); - } else { - var style = this.getMarkerStyle(Traccar.Style.mapLiveRadius, Traccar.Style.mapLiveColor); - var marker = new ol.Feature({ - geometry: geometry, - originalStyle: style - }); - marker.setStyle(style); - this.getView().vectorSource.addFeature(marker); - this.liveData[data[i].deviceId] = marker; - } + } + }, + + init: function () { + this.liveData = {}; + this.update(true); + }, + + update: function (first) { + Ext.Ajax.request({ + scope: this, + url: '/api/async', + params: { + first: first + }, + success: function (response) { + var data = Ext.decode(response.responseText).data; + + var i; + for (i = 0; i < data.length; i++) { + + var store = Ext.getStore('LatestPositions'); + + var found = store.query('deviceId', data[i].deviceId); + if (found.getCount() > 0) { + found.first().set(data[i]); + } else { + store.add(Ext.create('Traccar.model.Position', data[i])); } - this.update(false); - }, - failure: function () { - // TODO: error + var geometry = new ol.geom.Point(ol.proj.fromLonLat([ + data[i].longitude, + data[i].latitude + ])); + + if (data[i].deviceId in this.liveData) { + this.liveData[data[i].deviceId].setGeometry(geometry); + } else { + var style = this.getMarkerStyle(Traccar.Style.mapLiveRadius, Traccar.Style.mapLiveColor); + var marker = new ol.Feature({ + geometry: geometry, + originalStyle: style + }); + marker.setStyle(style); + this.getView().vectorSource.addFeature(marker); + this.liveData[data[i].deviceId] = marker; + } } - }); - }, - getLineStyle: function () { - return new ol.style.Style({ + this.update(false); + }, + failure: function () { + // TODO: error + } + }); + }, + + getLineStyle: function () { + return new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: Traccar.Style.mapStrokeColor, + width: Traccar.Style.mapRouteWidth + }) + }); + }, + + getMarkerStyle: function (radius, color) { + /*return new ol.style.Style({ + text: new ol.style.Text({ + text: '\uf041', + font: 'normal 32px FontAwesome', + textBaseline: 'Bottom', + fill: new ol.style.Fill({ + color: color + }), + stroke: new ol.style.Stroke({ + color: 'black', + width: 2 + }) + }) + });*/ + return new ol.style.Style({ + image: new ol.style.Circle({ + radius: radius, + fill: new ol.style.Fill({ + color: color + }), stroke: new ol.style.Stroke({ color: Traccar.Style.mapStrokeColor, - width: Traccar.Style.mapRouteWidth - }) - }); - }, - - getMarkerStyle: function (radius, color) { - /*return new ol.style.Style({ - text: new ol.style.Text({ - text: '\uf041', - font: 'normal 32px FontAwesome', - textBaseline: 'Bottom', - fill: new ol.style.Fill({ - color: color - }), - stroke: new ol.style.Stroke({ - color: 'black', - width: 2 - }) - }) - });*/ - return new ol.style.Style({ - image: new ol.style.Circle({ - radius: radius, - fill: new ol.style.Fill({ - color: color - }), - stroke: new ol.style.Stroke({ - color: Traccar.Style.mapStrokeColor, - width: Traccar.Style.mapMarkerStroke - }) + width: Traccar.Style.mapMarkerStroke }) - }); - }, + }) + }); + }, - reportShow: function () { - this.reportClear(); + reportShow: function () { + this.reportClear(); - var vectorSource = this.getView().vectorSource; + var vectorSource = this.getView().vectorSource; - var data = Ext.getStore('Positions').getData(); + var data = Ext.getStore('Positions').getData(); - var index; - var positions = []; - this.reportRoutePoints = {}; + var index; + var positions = []; + this.reportRoutePoints = {}; - for (index = 0; index < data.getCount(); index++) { - var point = ol.proj.fromLonLat([ - data.getAt(index).data.longitude, - data.getAt(index).data.latitude - ]); - positions.push(point); - - var style = this.getMarkerStyle(Traccar.Style.mapReportRadius, Traccar.Style.mapReportColor); - var feature = new ol.Feature({ - geometry: new ol.geom.Point(positions[index]), - originalStyle: style - }); - feature.setStyle(style); - this.reportRoutePoints[data.getAt(index).get('id')] = feature; - } + for (index = 0; index < data.getCount(); index++) { + var point = ol.proj.fromLonLat([ + data.getAt(index).data.longitude, + data.getAt(index).data.latitude + ]); + positions.push(point); - this.reportRoute = new ol.Feature({ - geometry: new ol.geom.LineString(positions) + var style = this.getMarkerStyle(Traccar.Style.mapReportRadius, Traccar.Style.mapReportColor); + var feature = new ol.Feature({ + geometry: new ol.geom.Point(positions[index]), + originalStyle: style }); - this.reportRoute.setStyle(this.getLineStyle()); - vectorSource.addFeature(this.reportRoute); + feature.setStyle(style); + this.reportRoutePoints[data.getAt(index).get('id')] = feature; + } - for (var key in this.reportRoutePoints) { - if (this.reportRoutePoints.hasOwnProperty(key)) { - vectorSource.addFeature(this.reportRoutePoints[key]); - } + this.reportRoute = new ol.Feature({ + geometry: new ol.geom.LineString(positions) + }); + this.reportRoute.setStyle(this.getLineStyle()); + vectorSource.addFeature(this.reportRoute); + + for (var key in this.reportRoutePoints) { + if (this.reportRoutePoints.hasOwnProperty(key)) { + vectorSource.addFeature(this.reportRoutePoints[key]); } - }, + } + }, - reportClear: function () { - var vectorSource = this.getView().vectorSource; + reportClear: function () { + var vectorSource = this.getView().vectorSource; - if (this.reportRoute !== undefined) { - vectorSource.removeFeature(this.reportRoute); - this.reportRoute = undefined; - } + if (this.reportRoute !== undefined) { + vectorSource.removeFeature(this.reportRoute); + this.reportRoute = undefined; + } - if (this.reportRoutePoints !== undefined) { - for (var key in this.reportRoutePoints) { - if (this.reportRoutePoints.hasOwnProperty(key)) { - vectorSource.removeFeature(this.reportRoutePoints[key]); - } + if (this.reportRoutePoints !== undefined) { + for (var key in this.reportRoutePoints) { + if (this.reportRoutePoints.hasOwnProperty(key)) { + vectorSource.removeFeature(this.reportRoutePoints[key]); } - this.reportRoutePoints = {}; } - }, + this.reportRoutePoints = {}; + } + }, - selectPosition: function (feature) { - if (this.currentFeature !== undefined) { - this.currentFeature.setStyle(this.currentFeature.get('originalStyle')); - } + selectPosition: function (feature) { + if (this.currentFeature !== undefined) { + this.currentFeature.setStyle(this.currentFeature.get('originalStyle')); + } - if (feature !== undefined) { - feature.setStyle(this.getMarkerStyle(Traccar.Style.mapSelectRadius, Traccar.Style.mapSelectColor)); + if (feature !== undefined) { + feature.setStyle(this.getMarkerStyle(Traccar.Style.mapSelectRadius, Traccar.Style.mapSelectColor)); - var pan = ol.animation.pan({ - duration: Traccar.Style.mapDelay, - source: this.getView().mapView.getCenter() - }); - this.getView().map.beforeRender(pan); - this.getView().mapView.setCenter(feature.getGeometry().getCoordinates()); - } + var pan = ol.animation.pan({ + duration: Traccar.Style.mapDelay, + source: this.getView().mapView.getCenter() + }); + this.getView().map.beforeRender(pan); + this.getView().mapView.setCenter(feature.getGeometry().getCoordinates()); + } - this.currentFeature = feature; - }, + this.currentFeature = feature; + }, - selectDevice: function (device) { - this.selectPosition(this.liveData[device.get('id')]); - }, + selectDevice: function (device) { + this.selectPosition(this.liveData[device.get('id')]); + }, - selectReport: function (position) { - if (this.reportRoutePoints[position.get('id')] !== undefined) { - this.selectPosition(this.reportRoutePoints[position.get('id')]); - } + selectReport: function (position) { + if (this.reportRoutePoints[position.get('id')] !== undefined) { + this.selectPosition(this.reportRoutePoints[position.get('id')]); } + } - }); - -})(); +}); diff --git a/web/app/view/Register.js b/web/app/view/Register.js index 04975c74e..445f335f9 100644 --- a/web/app/view/Register.js +++ b/web/app/view/Register.js @@ -13,50 +13,46 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Register', { - extend: 'Traccar.view.BaseDialog', +Ext.define('Traccar.view.Register', { + extend: 'Traccar.view.BaseDialog', - requires: [ - 'Traccar.view.RegisterController' - ], + requires: [ + 'Traccar.view.RegisterController' + ], - controller: 'register', + controller: 'register', - items: { - xtype: 'form', - reference: 'form', - jsonSubmit: true, + items: { + xtype: 'form', + reference: 'form', + jsonSubmit: true, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.userName, - allowBlank: false - }, { - xtype: 'textfield', - name: 'email', - fieldLabel: Strings.userEmail, - vtype: 'email', - allowBlank: false - }, { - xtype: 'textfield', - name: 'password', - fieldLabel: Strings.userPassword, - inputType: 'password', - allowBlank: false - }] - }, - - buttons: [{ - text: Strings.sharedSave, - handler: 'onCreateClick' + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.userName, + allowBlank: false + }, { + xtype: 'textfield', + name: 'email', + fieldLabel: Strings.userEmail, + vtype: 'email', + allowBlank: false }, { - text: Strings.sharedCancel, - handler: 'closeView' + xtype: 'textfield', + name: 'password', + fieldLabel: Strings.userPassword, + inputType: 'password', + allowBlank: false }] - }); + }, -})(); + buttons: [{ + text: Strings.sharedSave, + handler: 'onCreateClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' + }] +}); diff --git a/web/app/view/RegisterController.js b/web/app/view/RegisterController.js index 36a423a30..5cf41fc65 100644 --- a/web/app/view/RegisterController.js +++ b/web/app/view/RegisterController.js @@ -13,32 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.RegisterController', { - extend: 'Ext.app.ViewController', - alias: 'controller.register', +Ext.define('Traccar.view.RegisterController', { + extend: 'Ext.app.ViewController', + alias: 'controller.register', - onCreateClick: function () { - var form = this.lookupReference('form'); - if (form.isValid()) { - Ext.Ajax.request({ - scope: this, - url: '/api/register', - jsonData: form.getValues(), - callback: this.onCreateReturn - }); - } - }, - - onCreateReturn: function (options, success, response) { - if (Traccar.ErrorManager.check(success, response)) { - this.closeView(); - Ext.toast(Strings.loginCreated); - } + onCreateClick: function () { + var form = this.lookupReference('form'); + if (form.isValid()) { + Ext.Ajax.request({ + scope: this, + url: '/api/register', + jsonData: form.getValues(), + callback: this.onCreateReturn + }); } + }, - }); + onCreateReturn: function (options, success, response) { + if (Traccar.ErrorManager.check(success, response)) { + this.closeView(); + Ext.toast(Strings.loginCreated); + } + } -})(); +}); diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 93f2ca1ee..6f2359253 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -13,110 +13,106 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.Report', { - extend: 'Ext.grid.Panel', - xtype: 'reportView', +Ext.define('Traccar.view.Report', { + extend: 'Ext.grid.Panel', + xtype: 'reportView', - requires: [ - 'Traccar.view.ReportController' - ], + requires: [ + 'Traccar.view.ReportController' + ], - controller: 'report', - store: 'Positions', + controller: 'report', + store: 'Positions', - title: Strings.reportTitle, + title: Strings.reportTitle, - tbar: [{ - xtype: 'tbtext', - html: Strings.reportDevice - }, { - xtype: 'combobox', - reference: 'deviceField', - store: 'Devices', - valueField: 'id', - displayField: 'name', - typeAhead: true, - queryMode: 'local' - }, '-', { - xtype: 'tbtext', - html: Strings.reportFrom - }, { - xtype: 'datefield', - reference: 'fromDateField', - startDay: Traccar.Style.weekStartDay, - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }, { - xtype: 'timefield', - reference: 'fromTimeField', - maxWidth: Traccar.Style.reportTime, - format: Traccar.Style.timeFormat, - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }, '-', { - xtype: 'tbtext', - html: Strings.reportTo - }, { - xtype: 'datefield', - reference: 'toDateField', - startDay: Traccar.Style.weekStartDay, - value: new Date() - }, { - xtype: 'timefield', - reference: 'toTimeField', - maxWidth: Traccar.Style.reportTime, - format: Traccar.Style.timeFormat, - value: new Date() - }, '-', { - text: Strings.reportShow, - handler: 'onShowClick' - }, { - text: Strings.reportClear, - handler: 'onClearClick' - }], + tbar: [{ + xtype: 'tbtext', + html: Strings.reportDevice + }, { + xtype: 'combobox', + reference: 'deviceField', + store: 'Devices', + valueField: 'id', + displayField: 'name', + typeAhead: true, + queryMode: 'local' + }, '-', { + xtype: 'tbtext', + html: Strings.reportFrom + }, { + xtype: 'datefield', + reference: 'fromDateField', + startDay: Traccar.Style.weekStartDay, + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }, { + xtype: 'timefield', + reference: 'fromTimeField', + maxWidth: Traccar.Style.reportTime, + format: Traccar.Style.timeFormat, + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }, '-', { + xtype: 'tbtext', + html: Strings.reportTo + }, { + xtype: 'datefield', + reference: 'toDateField', + startDay: Traccar.Style.weekStartDay, + value: new Date() + }, { + xtype: 'timefield', + reference: 'toTimeField', + maxWidth: Traccar.Style.reportTime, + format: Traccar.Style.timeFormat, + value: new Date() + }, '-', { + text: Strings.reportShow, + handler: 'onShowClick' + }, { + text: Strings.reportClear, + handler: 'onClearClick' + }], - listeners: { - selectionchange: 'onSelectionChange' - }, + listeners: { + selectionchange: 'onSelectionChange' + }, - columns: [{ - text: Strings.positionValid, - dataIndex: 'valid', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('valid') - }, { - text: Strings.positionTime, - dataIndex: 'fixTime', - flex: 1, - xtype: 'datecolumn', - renderer: Traccar.AttributeFormatter.getFormatter('fixTime') - }, { - text: Strings.positionLatitude, - dataIndex: 'latitude', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('latitude') - }, { - text: Strings.positionLongitude, - dataIndex: 'longitude', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('latitude') - }, { - text: Strings.positionAltitude, - dataIndex: 'altitude', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('altitude') - }, { - text: Strings.positionSpeed, - dataIndex: 'speed', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('speed') - }, { - text: Strings.positionAddress, - dataIndex: 'address', - flex: 1, - renderer: Traccar.AttributeFormatter.getFormatter('address') - }] - }); - -})(); + columns: [{ + text: Strings.positionValid, + dataIndex: 'valid', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('valid') + }, { + text: Strings.positionTime, + dataIndex: 'fixTime', + flex: 1, + xtype: 'datecolumn', + renderer: Traccar.AttributeFormatter.getFormatter('fixTime') + }, { + text: Strings.positionLatitude, + dataIndex: 'latitude', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('latitude') + }, { + text: Strings.positionLongitude, + dataIndex: 'longitude', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('latitude') + }, { + text: Strings.positionAltitude, + dataIndex: 'altitude', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('altitude') + }, { + text: Strings.positionSpeed, + dataIndex: 'speed', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('speed') + }, { + text: Strings.positionAddress, + dataIndex: 'address', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('address') + }] +}); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 1b226fd55..2badfea63 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -13,72 +13,68 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.ReportController', { - extend: 'Ext.app.ViewController', - alias: 'controller.report', +Ext.define('Traccar.view.ReportController', { + extend: 'Ext.app.ViewController', + alias: 'controller.report', - config: { - listen: { - controller: { - '*': { - selectDevice: 'selectDevice' - } + config: { + listen: { + controller: { + '*': { + selectDevice: 'selectDevice' } } - }, - - onShowClick: function () { - var deviceId, fromDate, fromTime, from, toDate, toTime, to, store; - - deviceId = this.lookupReference('deviceField').getValue(); + } + }, - fromDate = this.lookupReference('fromDateField').getValue(); - fromTime = this.lookupReference('fromTimeField').getValue(); + onShowClick: function () { + var deviceId, fromDate, fromTime, from, toDate, toTime, to, store; - from = new Date( - fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(), - fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds()); + deviceId = this.lookupReference('deviceField').getValue(); - toDate = this.lookupReference('toDateField').getValue(); - toTime = this.lookupReference('toTimeField').getValue(); + fromDate = this.lookupReference('fromDateField').getValue(); + fromTime = this.lookupReference('fromTimeField').getValue(); - to = new Date( - toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), - toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); + from = new Date( + fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(), + fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds()); - store = Ext.getStore('Positions'); - store.load({ - params: { - deviceId: deviceId, - from: from.toISOString(), - to: to.toISOString() - }, - scope: this, - callback: function () { - this.fireEvent('reportShow'); - } - }); - }, + toDate = this.lookupReference('toDateField').getValue(); + toTime = this.lookupReference('toTimeField').getValue(); - onClearClick: function () { - Ext.getStore('Positions').removeAll(); - this.fireEvent('reportClear'); - }, + to = new Date( + toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), + toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); - onSelectionChange: function (selected) { - if (selected.getCount() > 0) { - this.fireEvent('selectReport', selected.getLastSelected()); + store = Ext.getStore('Positions'); + store.load({ + params: { + deviceId: deviceId, + from: from.toISOString(), + to: to.toISOString() + }, + scope: this, + callback: function () { + this.fireEvent('reportShow'); } - }, + }); + }, - selectDevice: function (device) { - if (device !== undefined) { - this.getView().getSelectionModel().deselectAll(); - } + onClearClick: function () { + Ext.getStore('Positions').removeAll(); + this.fireEvent('reportClear'); + }, + + onSelectionChange: function (selected) { + if (selected.getCount() > 0) { + this.fireEvent('selectReport', selected.getLastSelected()); } - }); + }, -})(); + selectDevice: function (device) { + if (device !== undefined) { + this.getView().getSelectionModel().deselectAll(); + } + } +}); diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index fa5ede524..8f81bb9b9 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -13,69 +13,65 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.ServerDialog', { - extend: 'Traccar.view.BaseEditDialog', +Ext.define('Traccar.view.ServerDialog', { + extend: 'Traccar.view.BaseEditDialog', - requires: [ - 'Traccar.view.BaseEditDialogController' - ], + requires: [ + 'Traccar.view.BaseEditDialogController' + ], - controller: 'baseEditDialog', - title: Strings.serverTitle, + controller: 'baseEditDialog', + title: Strings.serverTitle, - items: { - xtype: 'form', - items: [{ - xtype: 'checkboxfield', - name: 'registration', - fieldLabel: Strings.serverRegistration, - allowBlank: false - }, { - xtype: 'combobox', - name: 'map', - fieldLabel: Strings.mapLayer, - store: 'MapTypes', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'textfield', - name: 'bingKey', - fieldLabel: Strings.mapBingKey - }, { - xtype: 'textfield', - name: 'mapUrl', - fieldLabel: Strings.mapCustom - }, { - xtype: 'combobox', - name: 'distanceUnit', - fieldLabel: Strings.settingsDistanceUnit, - store: 'DistanceUnits', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'combobox', - name: 'speedUnit', - fieldLabel: Strings.settingsSpeedUnit, - store: 'SpeedUnits', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'numberfield', - name: 'latitude', - fieldLabel: Strings.positionLatitude - }, { - xtype: 'numberfield', - name: 'longitude', - fieldLabel: Strings.positionLongitude - }, { - xtype: 'numberfield', - name: 'zoom', - fieldLabel: Strings.serverZoom - }] - } - }); - -})(); + items: { + xtype: 'form', + items: [{ + xtype: 'checkboxfield', + name: 'registration', + fieldLabel: Strings.serverRegistration, + allowBlank: false + }, { + xtype: 'combobox', + name: 'map', + fieldLabel: Strings.mapLayer, + store: 'MapTypes', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'textfield', + name: 'bingKey', + fieldLabel: Strings.mapBingKey + }, { + xtype: 'textfield', + name: 'mapUrl', + fieldLabel: Strings.mapCustom + }, { + xtype: 'combobox', + name: 'distanceUnit', + fieldLabel: Strings.settingsDistanceUnit, + store: 'DistanceUnits', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'combobox', + name: 'speedUnit', + fieldLabel: Strings.settingsSpeedUnit, + store: 'SpeedUnits', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'numberfield', + name: 'latitude', + fieldLabel: Strings.positionLatitude + }, { + xtype: 'numberfield', + name: 'longitude', + fieldLabel: Strings.positionLongitude + }, { + xtype: 'numberfield', + name: 'zoom', + fieldLabel: Strings.serverZoom + }] + } +}); diff --git a/web/app/view/State.js b/web/app/view/State.js index b67c9a46f..1a9f014f5 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -13,31 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.State', { - extend: 'Ext.grid.Panel', - xtype: 'stateView', +Ext.define('Traccar.view.State', { + extend: 'Ext.grid.Panel', + xtype: 'stateView', - requires: [ - 'Traccar.view.StateController' - ], + requires: [ + 'Traccar.view.StateController' + ], - controller: 'state', - store: 'Attributes', + controller: 'state', + store: 'Attributes', - title: Strings.stateTitle, + title: Strings.stateTitle, - columns: [{ - text: Strings.stateName, - dataIndex: 'name', - flex: 1 - }, { - text: Strings.stateValue, - dataIndex: 'value', - flex: 1 - }] - }); - -})(); + columns: [{ + text: Strings.stateName, + dataIndex: 'name', + flex: 1 + }, { + text: Strings.stateValue, + dataIndex: 'value', + flex: 1 + }] +}); diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 9aa23de64..a6adfc908 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -13,129 +13,125 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.StateController', { - extend: 'Ext.app.ViewController', - alias: 'controller.state', +Ext.define('Traccar.view.StateController', { + extend: 'Ext.app.ViewController', + alias: 'controller.state', - config: { - listen: { - controller: { - '*': { - selectDevice: 'selectDevice' - } + config: { + listen: { + controller: { + '*': { + selectDevice: 'selectDevice' } } - }, + } + }, - init: function () { - var store = Ext.getStore('LatestPositions'); - store.on('add', this.add, this); - store.on('update', this.update, this); - }, + init: function () { + var store = Ext.getStore('LatestPositions'); + store.on('add', this.add, this); + store.on('update', this.update, this); + }, - keys: { - fixTime: { - priority: 1, - name: Strings.positionTime - }, - latitude: { - priority: 2, - name: Strings.positionLatitude - }, - longitude: { - priority: 3, - name: Strings.positionLongitude - }, - valid: { - priority: 4, - name: Strings.positionValid - }, - altitude: { - priority: 5, - name: Strings.positionAltitude - }, - speed: { - priority: 6, - name: Strings.positionSpeed - }, - course: { - priority: 7, - name: Strings.positionCourse - }, - address: { - priority: 8, - name: Strings.positionAddress - }, - protocol: { - priority: 9, - name: Strings.positionProtocol - } + keys: { + fixTime: { + priority: 1, + name: Strings.positionTime }, - - formatValue: function (value) { - if (typeof (id) === 'number') { - return value.toFixed(2); - } else { - return value; - } + latitude: { + priority: 2, + name: Strings.positionLatitude + }, + longitude: { + priority: 3, + name: Strings.positionLongitude + }, + valid: { + priority: 4, + name: Strings.positionValid }, + altitude: { + priority: 5, + name: Strings.positionAltitude + }, + speed: { + priority: 6, + name: Strings.positionSpeed + }, + course: { + priority: 7, + name: Strings.positionCourse + }, + address: { + priority: 8, + name: Strings.positionAddress + }, + protocol: { + priority: 9, + name: Strings.positionProtocol + } + }, - updatePosition: function (position) { - var attributes, store, key; - store = Ext.getStore('Attributes'); - store.removeAll(); + formatValue: function (value) { + if (typeof (id) === 'number') { + return value.toFixed(2); + } else { + return value; + } + }, - for (key in position.data) { - if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) { - store.add(Ext.create('Traccar.model.Attribute', { - priority: this.keys[key].priority, - name: this.keys[key].name, - value: Traccar.AttributeFormatter.getFormatter(key)(position.get(key)) - })); - } - } + updatePosition: function (position) { + var attributes, store, key; + store = Ext.getStore('Attributes'); + store.removeAll(); - attributes = position.get('attributes'); - if (attributes instanceof Object) { - for (key in attributes) { - if (attributes.hasOwnProperty(key)) { - store.add(Ext.create('Traccar.model.Attribute', { - priority: 1024, - name: key.replace(/^./, function (match) { - return match.toUpperCase(); - }), - value: Traccar.AttributeFormatter.getFormatter(key)(attributes[key]) - })); - } - } + for (key in position.data) { + if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) { + store.add(Ext.create('Traccar.model.Attribute', { + priority: this.keys[key].priority, + name: this.keys[key].name, + value: Traccar.AttributeFormatter.getFormatter(key)(position.get(key)) + })); } - }, + } - selectDevice: function (device) { - var found; - this.deviceId = device.get('id'); - found = Ext.getStore('LatestPositions').query('deviceId', this.deviceId); - if (found.getCount() > 0) { - this.updatePosition(found.first()); - } else { - Ext.getStore('Attributes').removeAll(); + attributes = position.get('attributes'); + if (attributes instanceof Object) { + for (key in attributes) { + if (attributes.hasOwnProperty(key)) { + store.add(Ext.create('Traccar.model.Attribute', { + priority: 1024, + name: key.replace(/^./, function (match) { + return match.toUpperCase(); + }), + value: Traccar.AttributeFormatter.getFormatter(key)(attributes[key]) + })); + } } - }, + } + }, - add: function (store, data) { - if (this.deviceId === data[0].get('deviceId')) { - this.updatePosition(data[0]); - } - }, + selectDevice: function (device) { + var found; + this.deviceId = device.get('id'); + found = Ext.getStore('LatestPositions').query('deviceId', this.deviceId); + if (found.getCount() > 0) { + this.updatePosition(found.first()); + } else { + Ext.getStore('Attributes').removeAll(); + } + }, - update: function (store, data) { - if (this.deviceId === data.get('deviceId')) { - this.updatePosition(data); - } + add: function (store, data) { + if (this.deviceId === data[0].get('deviceId')) { + this.updatePosition(data[0]); } - }); + }, -})(); + update: function (store, data) { + if (this.deviceId === data.get('deviceId')) { + this.updatePosition(data); + } + } +}); diff --git a/web/app/view/User.js b/web/app/view/User.js index 9eb0232f7..b642b5518 100644 --- a/web/app/view/User.js +++ b/web/app/view/User.js @@ -13,52 +13,56 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.User', { - extend: 'Ext.grid.Panel', - xtype: 'userView', +Ext.define('Traccar.view.User', { + extend: 'Ext.grid.Panel', + xtype: 'userView', - requires: [ - 'Traccar.view.UserController' - ], + requires: [ + 'Traccar.view.UserController' + ], - controller: 'user', - store: 'Users', + controller: 'user', + store: 'Users', - selType: 'rowmodel', + selType: 'rowmodel', - tbar: [{ - text: Strings.sharedAdd, - handler: 'onAddClick', - reference: 'deviceAddButton' - }, { - text: Strings.sharedEdit, - disabled: true, - handler: 'onEditClick', - reference: 'userEditButton' - }, { - text: Strings.sharedRemove, - disabled: true, - handler: 'onRemoveClick', - reference: 'userRemoveButton' - }, { - text: Strings.deviceTitle, - disabled: true, - handler: 'onDevicesClick', - reference: 'userDevicesButton' - }], + tbar: [{ + text: Strings.sharedAdd, + handler: 'onAddClick', + reference: 'deviceAddButton' + }, { + text: Strings.sharedEdit, + disabled: true, + handler: 'onEditClick', + reference: 'userEditButton' + }, { + text: Strings.sharedRemove, + disabled: true, + handler: 'onRemoveClick', + reference: 'userRemoveButton' + }, { + text: Strings.deviceTitle, + disabled: true, + handler: 'onDevicesClick', + reference: 'userDevicesButton' + }], - listeners: { - selectionchange: 'onSelectionChange' - }, + listeners: { + selectionchange: 'onSelectionChange' + }, - columns: [ - {text: Strings.userName, dataIndex: 'name', flex: 1}, - {text: Strings.userEmail, dataIndex: 'email', flex: 1}, - {text: Strings.userAdmin, dataIndex: 'admin', flex: 1} - ] - }); - -})(); + columns: [{ + text: Strings.userName, + dataIndex: 'name', + flex: 1 + }, { + text: Strings.userEmail, + dataIndex: 'email', + flex: 1 + }, { + text: Strings.userAdmin, + dataIndex: 'admin', + flex: 1 + }] +}); diff --git a/web/app/view/UserController.js b/web/app/view/UserController.js index 0a6e4f553..6615c7e49 100644 --- a/web/app/view/UserController.js +++ b/web/app/view/UserController.js @@ -13,78 +13,74 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.UserController', { - extend: 'Ext.app.ViewController', - alias: 'controller.user', +Ext.define('Traccar.view.UserController', { + extend: 'Ext.app.ViewController', + alias: 'controller.user', - requires: [ - 'Traccar.view.UserDialog' - ], + requires: [ + 'Traccar.view.UserDialog' + ], - init: function () { - Ext.getStore('Users').load(); - }, + init: function () { + Ext.getStore('Users').load(); + }, - onAddClick: function () { - var user, dialog; - user = Ext.create('Traccar.model.User'), - dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(user); - dialog.show(); - }, + onAddClick: function () { + var user, dialog; + user = Ext.create('Traccar.model.User'); + dialog = Ext.create('Traccar.view.UserDialog'); + dialog.down('form').loadRecord(user); + dialog.show(); + }, - onEditClick: function () { - var user, dialog; - user = this.getView().getSelectionModel().getSelection()[0]; - dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(user); - dialog.show(); - }, + onEditClick: function () { + var user, dialog; + user = this.getView().getSelectionModel().getSelection()[0]; + dialog = Ext.create('Traccar.view.UserDialog'); + dialog.down('form').loadRecord(user); + dialog.show(); + }, - onRemoveClick: function () { - var user = this.getView().getSelectionModel().getSelection()[0]; - Ext.Msg.show({ - title: Strings.settingsUser, - message: Strings.sharedRemoveConfirm, - buttons: Ext.Msg.YESNO, - buttonText: { - yes: Strings.sharedRemove, - no: Strings.sharedCancel - }, - fn: function (btn) { - if (btn === 'yes') { - var store = Ext.getStore('Users'); - store.remove(user); - store.sync(); - } + onRemoveClick: function () { + var user = this.getView().getSelectionModel().getSelection()[0]; + Ext.Msg.show({ + title: Strings.settingsUser, + message: Strings.sharedRemoveConfirm, + buttons: Ext.Msg.YESNO, + buttonText: { + yes: Strings.sharedRemove, + no: Strings.sharedCancel + }, + fn: function (btn) { + if (btn === 'yes') { + var store = Ext.getStore('Users'); + store.remove(user); + store.sync(); } - }); - }, + } + }); + }, - onDevicesClick: function () { - // TODO show devices - /*Ext.create('Ext.window.Window', { - title: Strings.settingsUsers, - width: Traccar.Style.windowWidth, - height: Traccar.Style.windowHeight, - layout: 'fit', - modal: true, - items: { - xtype: 'userView' - } - }).show();*/ - }, + onDevicesClick: function () { + // TODO show devices + /*Ext.create('Ext.window.Window', { + title: Strings.settingsUsers, + width: Traccar.Style.windowWidth, + height: Traccar.Style.windowHeight, + layout: 'fit', + modal: true, + items: { + xtype: 'userView' + } + }).show();*/ + }, - onSelectionChange: function (selected) { - var disabled = selected.length > 0; - this.lookupReference('userEditButton').setDisabled(disabled); - this.lookupReference('userRemoveButton').setDisabled(disabled); - this.lookupReference('userDevicesButton').setDisabled(disabled); - } + onSelectionChange: function (selected) { + var disabled = selected.length > 0; + this.lookupReference('userEditButton').setDisabled(disabled); + this.lookupReference('userRemoveButton').setDisabled(disabled); + this.lookupReference('userDevicesButton').setDisabled(disabled); + } - }); - -})(); +}); diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index f66c5af02..32acd950c 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -13,79 +13,75 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.UserDialog', { - extend: 'Traccar.view.BaseEditDialog', +Ext.define('Traccar.view.UserDialog', { + extend: 'Traccar.view.BaseEditDialog', - requires: [ - 'Traccar.view.UserDialogController' - ], + requires: [ + 'Traccar.view.UserDialogController' + ], - controller: 'userDialog', + controller: 'userDialog', - title: Strings.settingsUser, + title: Strings.settingsUser, - items: { - xtype: 'form', - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.userName - }, { - xtype: 'textfield', - name: 'email', - fieldLabel: Strings.userEmail, - allowBlank: false - }, { - xtype: 'textfield', - name: 'password', - fieldLabel: Strings.userPassword, - inputType: 'password', - allowBlank: false - }, { - xtype: 'checkboxfield', - name: 'admin', - fieldLabel: Strings.userAdmin, - allowBlank: false, - disabled: true, - reference: 'adminField' - }, { - xtype: 'combobox', - name: 'map', - fieldLabel: Strings.mapLayer, - store: 'MapTypes', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'combobox', - name: 'distanceUnit', - fieldLabel: Strings.settingsDistanceUnit, - store: 'DistanceUnits', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'combobox', - name: 'speedUnit', - fieldLabel: Strings.settingsSpeedUnit, - store: 'SpeedUnits', - displayField: 'name', - valueField: 'key' - }, { - xtype: 'numberfield', - name: 'latitude', - fieldLabel: Strings.positionLatitude - }, { - xtype: 'numberfield', - name: 'longitude', - fieldLabel: Strings.positionLongitude - }, { - xtype: 'numberfield', - name: 'zoom', - fieldLabel: Strings.serverZoom - }] - } - }); - -})(); + items: { + xtype: 'form', + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.userName + }, { + xtype: 'textfield', + name: 'email', + fieldLabel: Strings.userEmail, + allowBlank: false + }, { + xtype: 'textfield', + name: 'password', + fieldLabel: Strings.userPassword, + inputType: 'password', + allowBlank: false + }, { + xtype: 'checkboxfield', + name: 'admin', + fieldLabel: Strings.userAdmin, + allowBlank: false, + disabled: true, + reference: 'adminField' + }, { + xtype: 'combobox', + name: 'map', + fieldLabel: Strings.mapLayer, + store: 'MapTypes', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'combobox', + name: 'distanceUnit', + fieldLabel: Strings.settingsDistanceUnit, + store: 'DistanceUnits', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'combobox', + name: 'speedUnit', + fieldLabel: Strings.settingsSpeedUnit, + store: 'SpeedUnits', + displayField: 'name', + valueField: 'key' + }, { + xtype: 'numberfield', + name: 'latitude', + fieldLabel: Strings.positionLatitude + }, { + xtype: 'numberfield', + name: 'longitude', + fieldLabel: Strings.positionLongitude + }, { + xtype: 'numberfield', + name: 'zoom', + fieldLabel: Strings.serverZoom + }] + } +}); diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js index 40c88a8b4..a5d045f5b 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -13,40 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function () { - 'use strict'; - Ext.define('Traccar.view.UserDialogController', { - extend: 'Ext.app.ViewController', - alias: 'controller.userDialog', +Ext.define('Traccar.view.UserDialogController', { + extend: 'Ext.app.ViewController', + alias: 'controller.userDialog', - init: function () { - if (Traccar.app.getUser().get('admin')) { - this.lookupReference('adminField').setDisabled(false); - } - }, + init: function () { + if (Traccar.app.getUser().get('admin')) { + this.lookupReference('adminField').setDisabled(false); + } + }, - onSaveClick: function (button) { - var dialog, record, store; - dialog = button.up('window').down('form'); - dialog.updateRecord(); - record = dialog.getRecord(); - if (record === Traccar.app.getUser()) { - record.save(); - } else { - store = Ext.getStore('Users'); - if (record.phantom) { - store.add(record); - } - store.sync({ - failure: function (batch) { - store.rejectChanges(); // TODO - Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); - } - }); + onSaveClick: function (button) { + var dialog, record, store; + dialog = button.up('window').down('form'); + dialog.updateRecord(); + record = dialog.getRecord(); + if (record === Traccar.app.getUser()) { + record.save(); + } else { + store = Ext.getStore('Users'); + if (record.phantom) { + store.add(record); } - button.up('window').close(); + store.sync({ + failure: function (batch) { + store.rejectChanges(); // TODO + Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); + } + }); } - }); - -})(); + button.up('window').close(); + } +}); -- cgit v1.2.3