Merge from upstream, change .eslintrc.json

This commit is contained in:
tsmgeek 2017-08-22 00:21:29 +01:00
commit fdf35488b5
57 changed files with 486 additions and 397 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
web/simple/app.js
web/load.js

60
.eslintrc.json Normal file
View File

@ -0,0 +1,60 @@
{
"extends": "eslint:all",
"env": {
"browser": true
},
"globals": {
"Ext": false,
"ol": false,
"Traccar": false,
"Strings": false,
"Locale": false,
"proj4": false
},
"rules": {
"strict": "off",
"max-lines": ["error", 1000],
"max-len": ["error", 180],
"max-statements": ["error", 35],
"max-params": ["error", 5],
"indent": ["error", 4, {
"SwitchCase": 1
}],
"quotes": ["error", "single"],
"padded-blocks": ["error", "never"],
"dot-location": ["error", "property"],
"wrap-iife": ["error", "inside"],
"dot-notation": "off",
"array-bracket-newline": "off",
"array-element-newline": "off",
"sort-keys": "off",
"sort-vars": "off",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"prefer-template": "off",
"newline-per-chained-call": "off",
"object-shorthand": "off",
"func-names": "off",
"init-declarations": "off",
"no-var": "off",
"id-length": "off",
"no-undefined": "off",
"object-curly-newline": "off",
"prefer-destructuring": "off",
"no-plusplus": "off",
"no-param-reassign": "off",
"no-ternary": "off",
"multiline-ternary": "off",
"one-var-declaration-per-line": "off",
"no-shadow": "off",
"no-else-return": "off",
"consistent-this": "off",
"quote-props": "off",
"no-negated-condition": "off",
"prefer-arrow-callback": "off",
"no-prototype-builtins": "off",
"no-multi-assign": "off",
"no-bitwise": "off",
"prefer-rest-params": "off"
}
}

47
.github/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,47 @@
# Contributing to Traccar
Please make sure you read this guide before commenting on any issue or creating a new issue or pull request.
Before asking anything, please search for an answer in:
- [Traccar documentation](https://www.traccar.org/documentation/)
- [Traccar forums](https://www.traccar.org/forums/)
- Relevant repositories (see below)
- [Google Search](https://www.google.com/)
GitHub issues should be used ONLY for feature requests, code discussions and bug reports. For general discussions please use [Traccar forums](https://www.traccar.org/forums/).
There are multiple Traccar projects. If you create a new issue you MUST do it in the relevant repository:
- [Traccar Server](https://github.com/tananaev/traccar/issues)
- [Traccar Web Interface](https://github.com/tananaev/traccar-web/issues)
- [Traccar Client for Android](https://github.com/tananaev/traccar-client-android/issues)
- [Traccar Client for iOS](https://github.com/tananaev/traccar-client-ios/issues)
- [Traccar Manager for Android](https://github.com/tananaev/traccar-manager-android/issues)
- [Traccar Manager for iOS](https://github.com/tananaev/traccar-manager-ios/issues)
If you are not sure where your issue belongs to, please use Traccar Server main repository.
If you want to discuss something that applies to both Android and iOS apps, please use Android repository.
## Bug Reports
Before creating a bug report make sure that you have tested latest official release with default configuration.
Only create a bug report issue if you are confident that there is a problem in Traccar software.
Provide as much details as possible, including log fragments, operating system and hardware information.
## Feature Requests
Before creating a feature request make sure that the feature or modification that you are requesting is not yet implemented.
Search reposiroty to ensure that there is no existing issues for your request. If there is, add a new comment on that issue.
Provide as much details as possible, including use case for your feature and any benefits that you can think of.
## Pull Requests
If you want to contribute some code to Traccar, it is recommended to discuss your solution with maintainers before starting any work.
Any code that you want to contribute must be of high quality and follow existing code patterns and styles.

7
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,7 @@
<!--
Do you want to ask a question? Traccar official forum is the best place for getting support:
https://www.traccar.org/forums/
-->

2
.gitignore vendored
View File

@ -4,3 +4,5 @@
nbproject/
web/app.min.js
sencha-error-*
node_modules
package-lock.json

View File

@ -1,11 +1,6 @@
language: node_js
node_js:
- "6"
install:
- npm install eslint eslint-config-crockford
script:
- npm run lint
- npm run build
- npm test
language: node_js
node_js:
- node
script:
- npm run lint

View File

@ -1,10 +1,11 @@
# [Traccar Web Interface](https://www.traccar.org)
[![Build Status](https://travis-ci.org/tananaev/traccar-web.svg?branch=master)](https://travis-ci.org/tananaev/traccar-web)
## Overview
Traccar is open source server for various GPS tracking devices. This repository contains web interface for the Traccar platform. For back-end checkout [main Traccar repository](https://github.com/tananaev/traccar).
Icons are generously provided by [Font Awesome](http://fontawesome.io/) and [Icons8](https://icons8.com/).
Icons are generously provided by [Font Awesome](http://fontawesome.io/) and [Icons8](https://icons8.com/). We are also using [BrowserStack](https://www.browserstack.com/) to test compatibility with various platforms and browser versions.
## Team

View File

@ -1,7 +1,9 @@
{
"scripts": {
"lint": "./node_modules/.bin/eslint web",
"build": "echo \"Warning: no build specified\" && exit 0",
"test": "echo \"Warning: no test specified\" && exit 0"
}
}
{
"name": "traccar-web",
"devDependencies": {
"eslint": "^4.4.1"
},
"scripts": {
"lint": "./node_modules/.bin/eslint web/."
}
}

View File

@ -1 +0,0 @@
simple/app.js

View File

@ -1,94 +0,0 @@
{
"extends": "crockford",
"env": {
"browser": true,
"node": true
},
// Custom Globals
"globals" : {
"Ext" : false,
"ol" : false,
"Traccar" : false,
"Strings" : false,
"Locale" : false,
"proj4" : false
},
"rules": {
"indent": ["error", 4,
{
"SwitchCase":1,
"VariableDeclarator":2,
"CallExpression":{
"arguments": 2
},
"MemberExpression": 2
}
],
"comma-spacing": [2,
{
"after": true
}
],
"no-bitwise": 0,
"camelcase": 2,
"curly": 2,
"eqeqeq": 2,
"guard-for-in": 2,
"no-extend-native": 2,
"wrap-iife": [
2,
"any"
],
"no-use-before-define": [
2,
{
"functions": false
}
],
"new-cap": 2,
"no-caller": 2,
"no-empty": 2,
"no-irregular-whitespace": 2,
"no-new": 2,
"no-plusplus": 0,
"quotes": [
2,
"single"
],
"no-undef": 2,
"no-unused-vars": 2,
"strict": 0,
"max-params": 0,
"max-depth": 0,
"max-statements": 0,
"complexity": 0,
"max-len": 0,
"no-var": 0,
"semi": 0,
"no-cond-assign": 0,
"no-debugger": 0,
"no-eq-null": 0,
"no-eval": 0,
"no-unused-expressions": 0,
"block-scoped-var": 0,
"no-iterator": 0,
"linebreak-style": 0,
"comma-style": [
2,
"last"
],
"no-loop-func": 0,
"no-multi-str": 0,
"require-yield": 0,
"valid-typeof": 0,
"no-proto": 0,
"no-script-url": 0,
"no-shadow": 2,
"dot-notation": 0,
"no-new-func": 0,
"no-new-wrappers": 0,
"no-invalid-this": 0
}
}

View File

@ -1,7 +0,0 @@
{
"preset": "crockford",
"maxErrors": 100,
"excludeFiles": ["simple/app.js"],
"requireDotNotation": false,
"requireSpaceAfterComma": true
}

View File

@ -1,2 +0,0 @@
locale.js
simple/app.js

View File

@ -1,76 +0,0 @@
{
// Enforcing
"bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"indent" : 4, // {int} Number of spaces to use for indentation
"latedef" : true, // true: Require variables/functions to be defined before being used
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` and `--`
"quotmark" : "single", // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : "vars", // Unused variables:
// true : all variables, last function parameter
// "vars" : all variables only
// "strict" : all variables, all function parameters
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.
// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function
// Environments
"browser" : true, // Web Browser (window, document, etc)
"devel" : true, // Development/debugging (alert, confirm, etc)
"node" : true, // Node.js
// Custom Globals
"globals" : {
"Ext" : false,
"ol" : false,
"Traccar" : false,
"Strings" : false,
"Locale" : false,
"proj4" : false
}
}

View File

@ -83,10 +83,12 @@ Ext.define('Traccar.Application', {
'AllTimezones',
'VisibleDevices',
'DeviceStatuses',
'CommonDeviceAttributes',
'DeviceAttributes',
'GeofenceAttributes',
'GroupAttributes',
'ServerAttributes',
'CommonUserAttributes',
'UserAttributes',
'ComputedAttributes',
'AllComputedAttributes',
@ -104,6 +106,10 @@ Ext.define('Traccar.Application', {
return window.matchMedia && window.matchMedia('(max-width: 768px)').matches;
},
getVehicleFeaturesDisabled: function () {
return this.getBooleanAttributePreference('ui.disableVehicleFetures');
},
getEventString: function (eventType) {
var key = 'event' + eventType.charAt(0).toUpperCase() + eventType.slice(1);
return Strings[key] || key;
@ -161,6 +167,10 @@ Ext.define('Traccar.Application', {
}
},
getBooleanAttributePreference: function (key) {
return this.getAttributePreference(key, false).toString() === 'true';
},
getReportColor: function (deviceId) {
var index, reportColor, device = Ext.getStore('Devices').getById(deviceId);
if (device) {

View File

@ -23,6 +23,7 @@ Ext.define('Traccar.AttributeFormatter', {
if (value !== undefined) {
return Number(value.toFixed(precision)) + ' ' + suffix;
}
return null;
};
},
@ -54,8 +55,8 @@ Ext.define('Traccar.AttributeFormatter', {
durationFormatter: function (value) {
var hours, minutes;
hours = Math.floor(value / 3600000);
minutes = Math.round((value % 3600000) / 60000);
return (hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation);
minutes = Math.round(value % 3600000 / 60000);
return hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation;
},
deviceIdFormatter: function (value) {
@ -72,6 +73,7 @@ Ext.define('Traccar.AttributeFormatter', {
group = store.getById(value);
return group ? group.get('name') : value;
}
return null;
},
geofenceIdFormatter: function (value) {
@ -84,6 +86,7 @@ Ext.define('Traccar.AttributeFormatter', {
geofence = store.getById(value);
return geofence ? geofence.get('name') : '';
}
return null;
},
driverUniqueIdFormatter: function (value) {
@ -96,11 +99,11 @@ Ext.define('Traccar.AttributeFormatter', {
driver = store.findRecord('uniqueId', value, 0, false, true, true);
return driver ? value + ' (' + driver.get('name') + ')' : value;
}
return null;
},
lastUpdateFormatter: function (value) {
var seconds, interval;
if (value) {
seconds = Math.floor((new Date() - value) / 1000);
if (seconds < 0) {
@ -116,6 +119,7 @@ Ext.define('Traccar.AttributeFormatter', {
}
return Math.floor(seconds / 60) + ' ' + Strings.sharedMinutes;
}
return null;
},
defaultFormatter: function (value) {
@ -184,6 +188,7 @@ Ext.define('Traccar.AttributeFormatter', {
getAttributeFormatter: function (key) {
var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
<<<<<<< HEAD
switch (dataType) {
case 'distance':
@ -204,11 +209,34 @@ Ext.define('Traccar.AttributeFormatter', {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
default:
return this.defaultFormatter;
=======
if (!dataType) {
return this.defaultFormatter;
} else if (dataType === 'distance') {
return this.distanceFormatter;
} else if (dataType === 'speed') {
return this.speedFormatter;
} else if (dataType === 'driverUniqueId') {
return this.driverUniqueIdFormatter;
} else if (dataType === 'voltage') {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation);
} else if (dataType === 'percentage') {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, '&#37;');
} else if (dataType === 'temperature') {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, '&deg;C');
} else if (dataType === 'volume') {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation);
} else if (dataType === 'consumption') {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
} else {
return this.defaultFormatter;
>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
}
},
getAttributeConverter: function (key) {
var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
<<<<<<< HEAD
switch (dataType){
case 'distance':
@ -219,6 +247,20 @@ Ext.define('Traccar.AttributeFormatter', {
return function (value) {
return value;
};
=======
if (!dataType) {
return function (value) {
return value;
};
} else if (dataType === 'distance') {
return this.distanceConverter;
} else if (dataType === 'speed') {
return this.speedConverter;
} else {
return function (value) {
return value;
};
>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
}
}
});

View File

@ -39,7 +39,7 @@ Ext.define('Traccar.DeviceImages', {
svg.getElementById(fill[i]).style.fill = color;
}
rotateTransform = 'rotate(' + angle + ' ' + (width / 2) + ' ' + (height / 2) + ')';
rotateTransform = 'rotate(' + angle + ' ' + width / 2 + ' ' + height / 2 + ')';
svg.getElementById(info.get('rotateId')).setAttribute('transform', rotateTransform);
if (zoom) {
@ -85,7 +85,7 @@ Ext.define('Traccar.DeviceImages', {
width = parseFloat(svg.documentElement.getAttribute('width'));
height = parseFloat(svg.documentElement.getAttribute('height'));
image = new ol.style.Icon({
image = new ol.style.Icon({
imgSize: [width, height],
src: this.formatSrc(svg)
});

View File

@ -19,10 +19,15 @@ Ext.define('Traccar.GeofenceConverter', {
singleton: true,
wktToGeometry: function (mapView, wkt) {
<<<<<<< HEAD
var geometry, projection, resolutionAtEquator, pointResolution, resolutionFactor, points = [], center, radius,
content, i, lat, lon, coordinates;
=======
var geometry, projection, resolutionAtEquator, pointResolution, resolutionFactor,
points = [], center, radius, content, i, lat, lon, coordinates;
>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
if (wkt.lastIndexOf('POLYGON', 0) === 0) {
content = wkt.match(/\([^\(\)]+\)/);
content = wkt.match(/\([^()]+\)/);
if (content !== null) {
coordinates = content[0].match(/-?\d+\.?\d*/g);
if (coordinates !== null) {
@ -36,7 +41,7 @@ Ext.define('Traccar.GeofenceConverter', {
}
}
} else if (wkt.lastIndexOf('CIRCLE', 0) === 0) {
content = wkt.match(/\([^\(\)]+\)/);
content = wkt.match(/\([^()]+\)/);
if (content !== null) {
coordinates = content[0].match(/-?\d+\.?\d*/g);
if (coordinates !== null) {
@ -45,12 +50,12 @@ Ext.define('Traccar.GeofenceConverter', {
resolutionAtEquator = mapView.getResolution();
pointResolution = ol.proj.getPointResolution(projection, resolutionAtEquator, center);
resolutionFactor = resolutionAtEquator / pointResolution;
radius = (Number(coordinates[2]) / ol.proj.METERS_PER_UNIT.m) * resolutionFactor;
radius = Number(coordinates[2]) / ol.proj.METERS_PER_UNIT.m * resolutionFactor;
geometry = new ol.geom.Circle(center, radius);
}
}
} else if (wkt.lastIndexOf('LINESTRING', 0) === 0) {
content = wkt.match(/\([^\(\)]+\)/);
content = wkt.match(/\([^()]+\)/);
if (content !== null) {
coordinates = content[0].match(/-?\d+\.?\d*/g);
if (coordinates !== null) {
@ -79,7 +84,7 @@ Ext.define('Traccar.GeofenceConverter', {
ol.proj.transform(edgeCoordinate, projection, 'EPSG:4326'));
result = 'CIRCLE (';
result += center[1] + ' ' + center[0] + ', ';
result += Number((groundRadius).toFixed(1)) + ')';
result += groundRadius.toFixed(1) + ')';
} else if (geometry instanceof ol.geom.Polygon) {
geometry.transform(projection, 'EPSG:4326');
points = geometry.getCoordinates();

View File

@ -52,6 +52,7 @@ Ext.define('Traccar.controller.Root', {
if (value !== undefined) {
return Traccar.AttributeFormatter.getAttributeConverter(this.attributeKey)(value);
}
return null;
},
onLaunch: function () {
@ -112,6 +113,13 @@ Ext.define('Traccar.controller.Root', {
Ext.getStore('AttributeAliases').load();
Ext.getStore('ComputedAttributes').load();
this.initReportEventTypesStore();
Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true);
Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonUserAttributes').getData().items, true);
Ext.getStore('UserAttributes').loadData(Ext.getStore('CommonUserAttributes').getData().items, true);
Ext.getStore('DeviceAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true);
Ext.getStore('GroupAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true);
Ext.getStore('Devices').load({
scope: this,
callback: function () {
@ -162,7 +170,7 @@ Ext.define('Traccar.controller.Root', {
pathname = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
socket = new WebSocket(protocol + '//' + window.location.host + pathname + 'api/socket');
socket.onclose = function (event) {
socket.onclose = function () {
Traccar.app.showToast(Strings.errorSocket, Strings.errorTitle);
Ext.Ajax.request({
@ -291,7 +299,10 @@ Ext.define('Traccar.controller.Root', {
if (success) {
for (i = 0; i < records.length; i++) {
value = records[i].get('type');
store.add({type: value, name: Traccar.app.getEventString(value)});
store.add({
type: value,
name: Traccar.app.getEventString(value)
});
}
}
}

View File

@ -52,15 +52,15 @@ Ext.define('Traccar.model.Event', {
} else if (rec.get('type') === 'textMessage') {
text = Strings.eventTextMessage + ': ' + rec.get('attributes')['message'];
} else if (rec.get('type') === 'driverChanged') {
text = Strings.eventDriverChanged + ': ' + Traccar.AttributeFormatter.driverUniqueIdFormatter(
rec.get('attributes')['driverUniqueId']);
text = Strings.eventDriverChanged + ': ' +
Traccar.AttributeFormatter.driverUniqueIdFormatter(rec.get('attributes')['driverUniqueId']);
} else {
text = Traccar.app.getEventString(rec.get('type'));
}
if (rec.get('geofenceId')) {
geofence = Ext.getStore('Geofences').getById(rec.get('geofenceId'));
if (geofence) {
text += ' \"' + geofence.get('name') + '"';
text += ' "' + geofence.get('name') + '"';
}
}
return text;

View File

@ -27,5 +27,8 @@ Ext.define('Traccar.store.AllNotifications', {
}
},
sortOnLoad: true,
sorters: { property: 'type', direction : 'ASC' }
sorters: {
property: 'type',
direction: 'ASC'
}
});

View File

@ -21,7 +21,7 @@ Ext.define('Traccar.store.AllTimezones', {
sorters: {
property: 'key',
direction : 'ASC'
direction: 'ASC'
},
data: [{

View File

@ -41,7 +41,7 @@ Ext.define('Traccar.store.CommandTypes', {
}
},
listeners: {
'exception' : function (proxy, response) {
'exception': function (proxy, response) {
Traccar.app.showError(response);
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright 2017 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Ext.define('Traccar.store.CommonDeviceAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
valueType: 'number',
dataType: 'speed'
}, {
key: 'report.ignoreOdometer',
name: Strings.attributeReportIgnoreOdometer,
valueType: 'boolean'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
valueType: 'number',
dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
valueType: 'number',
dataType: 'distance'
}]
});

View File

@ -0,0 +1,55 @@
/*
* Copyright 2017 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Ext.define('Traccar.store.CommonUserAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
data: [{
key: 'web.liveRouteLength',
name: Strings.attributeWebLiveRouteLength,
valueType: 'number',
allowDecimals: false
}, {
key: 'web.selectZoom',
name: Strings.attributeWebSelectZoom,
valueType: 'number',
allowDecimals: false,
minValue: Traccar.Style.mapDefaultZoom,
maxValue: Traccar.Style.mapMaxZoom
}, {
key: 'ui.disableReport',
name: Strings.attributeUiDisableReport,
valueType: 'boolean'
}, {
key: 'ui.disableVehicleFetures',
name: Strings.attributeUiDisableVehicleFetures,
valueType: 'boolean'
}, {
key: 'ui.disableDrivers',
name: Strings.attributeUiDisableDrivers,
valueType: 'boolean'
}, {
key: 'ui.disableComputedAttributes',
name: Strings.attributeUiDisableComputedAttributes,
valueType: 'boolean'
}, {
key: 'ui.disableCalendars',
name: Strings.attributeUiDisableCalendars,
valueType: 'boolean'
}]
});

View File

@ -18,28 +18,8 @@
Ext.define('Traccar.store.DeviceAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
proxy: 'memory',
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
valueType: 'number',
dataType: 'speed'
}, {
key: 'report.ignoreOdometer',
name: Strings.attributeReportIgnoreOdometer,
valueType: 'boolean'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
valueType: 'number',
dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
valueType: 'number',
dataType: 'distance'
}, {
key: 'web.reportColor',
name: Strings.attributeWebReportColor,
valueType: 'color'

View File

@ -18,28 +18,8 @@
Ext.define('Traccar.store.GroupAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
proxy: 'memory',
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
valueType: 'number',
dataType: 'speed'
}, {
key: 'report.ignoreOdometer',
name: Strings.attributeReportIgnoreOdometer,
valueType: 'boolean'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
valueType: 'number',
dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
valueType: 'number',
dataType: 'distance'
}, {
key: 'processing.copyAttributes',
name: Strings.attributeProcessingCopyAttributes,
valueType: 'string'

View File

@ -24,5 +24,8 @@ Ext.define('Traccar.store.Notifications', {
url: 'api/users/notifications'
},
sortOnLoad: true,
sorters: { property: 'type', direction : 'ASC' }
sorters: {
property: 'type',
direction: 'ASC'
}
});

View File

@ -240,14 +240,12 @@ Ext.define('Traccar.store.PositionAttributes', {
var model = this.getById(key);
if (model) {
return model.get('name');
} else if (capitalize) {
return key.replace(/^./, function (match) {
return match.toUpperCase();
});
} else {
if (capitalize) {
return key.replace(/^./, function (match) {
return match.toUpperCase();
});
} else {
return key;
}
return key;
}
},

View File

@ -18,38 +18,6 @@
Ext.define('Traccar.store.ServerAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
proxy: 'memory',
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
valueType: 'number',
dataType: 'speed'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
valueType: 'number',
dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
valueType: 'number',
dataType: 'distance'
}, {
key: 'web.liveRouteLength',
name: Strings.attributeWebLiveRouteLength,
valueType: 'number',
allowDecimals: false
}, {
key: 'web.selectZoom',
name: Strings.attributeWebSelectZoom,
valueType: 'number',
allowDecimals: false,
minValue: Traccar.Style.mapDefaultZoom,
maxValue: Traccar.Style.mapMaxZoom
}, {
key: 'ui.disableReport',
name: Strings.attributeUiDisableReport,
valueType: 'boolean'
}]
data: []
});

View File

@ -18,7 +18,6 @@
Ext.define('Traccar.store.UserAttributes', {
extend: 'Ext.data.Store',
model: 'Traccar.model.KnownAttribute',
proxy: 'memory',
data: [{
key: 'mail.smtp.host',
@ -67,21 +66,5 @@ Ext.define('Traccar.store.UserAttributes', {
key: 'mail.smtp.password',
name: Strings.attributeMailSmtpPassword,
valueType: 'string'
}, {
key: 'web.liveRouteLength',
name: Strings.attributeWebLiveRouteLength,
valueType: 'number',
allowDecimals: false
}, {
key: 'web.selectZoom',
name: Strings.attributeWebSelectZoom,
valueType: 'number',
allowDecimals: false,
minValue: Traccar.Style.mapDefaultZoom,
maxValue: Traccar.Style.mapMaxZoom
}, {
key: 'ui.disableReport',
name: Strings.attributeUiDisableReport,
valueType: 'boolean'
}]
});

View File

@ -34,10 +34,8 @@ Ext.define('Traccar.view.ArrayListFilter', {
return true;
}
}
} else {
if (value.indexOf(property) !== -1) {
return true;
}
} else if (value.indexOf(property) !== -1) {
return true;
}
return false;
});

View File

@ -37,7 +37,7 @@ Ext.define('Traccar.view.CustomNumberField', {
} else if (config.dataType === 'distance') {
config.beforeSubTpl = this.beforeEl;
unit = Traccar.app.getPreference('distanceUnit', 'km');
config.afterSubTpl = this.unitEl + Ext.getStore('DistanceUnits').findRecord('key', unit).get('name') + '</div></div>';
config.afterSubTpl = this.unitEl + Ext.getStore('DistanceUnits').findRecord('key', unit).get('name') + '</div></div>';
config.rawToValue = function (rawValue) {
return Ext.getStore('DistanceUnits').convertValue(rawValue, Traccar.app.getPreference('distanceUnit', 'km'), true);
};

View File

@ -46,7 +46,7 @@ Ext.define('Traccar.view.EventsController', {
}
},
onRemoveClick: function (button) {
onRemoveClick: function () {
var event, positionId;
event = this.getView().getSelectionModel().getSelection()[0];
if (event) {
@ -58,12 +58,12 @@ Ext.define('Traccar.view.EventsController', {
}
},
onClearClick: function (button) {
onClearClick: function () {
Ext.getStore('Events').removeAll();
Ext.getStore('EventPositions').removeAll();
},
onAddEvent: function (store, data) {
onAddEvent: function () {
if (this.lookupReference('scrollToLastButton').pressed) {
this.getView().scrollBy(0, Number.POSITIVE_INFINITY, true);
}

View File

@ -20,7 +20,6 @@ Ext.define('Traccar.view.MainController', {
alias: 'controller.mainController',
init: function () {
this.lookupReference('reportView').setHidden(
Traccar.app.getAttributePreference('ui.disableReport', false).toString() === 'true');
this.lookupReference('reportView').setHidden(Traccar.app.getBooleanAttributePreference('ui.disableReport'));
}
});

View File

@ -27,7 +27,7 @@ Ext.define('Traccar.view.NotificationsController', {
});
},
onCheckChange: function (column, rowIndex, checked, eOpts) {
onCheckChange: function (column, rowIndex) {
var record = this.getView().getStore().getAt(rowIndex);
Ext.Ajax.request({
scope: this,

View File

@ -79,6 +79,23 @@ Ext.define('Traccar.view.ReportController', {
hidden: true
});
}
if (Traccar.app.getVehicleFeaturesDisabled()) {
for (i = 0; i < this.summaryColumns.length; i++) {
if (this.summaryColumns[i].dataIndex.match('engineHours|spentFuel')) {
this.summaryColumns[i].hidden = true;
}
}
for (i = 0; i < this.tripsColumns.length; i++) {
if (this.tripsColumns[i].dataIndex.match('spentFuel|driverUniqueId')) {
this.tripsColumns[i].hidden = true;
}
}
for (i = 0; i < this.stopsColumns.length; i++) {
if (this.stopsColumns[i].dataIndex.match('engineHours|spentFuel')) {
this.stopsColumns[i].hidden = true;
}
}
}
},
onConfigureClick: function () {
@ -117,7 +134,7 @@ Ext.define('Traccar.view.ReportController', {
updateButtons: function () {
var reportType, disabled, devices, time;
reportType = this.lookupReference('reportTypeField').getValue();
devices = (this.deviceId && this.deviceId.length !== 0) || (this.groupId && this.groupId.length !== 0);
devices = this.deviceId && this.deviceId.length !== 0 || this.groupId && this.groupId.length !== 0;
time = this.fromDate && this.fromTime && this.toDate && this.toTime;
disabled = !reportType || !devices || !time;
this.lookupReference('showButton').setDisabled(disabled);
@ -204,7 +221,7 @@ Ext.define('Traccar.view.ReportController', {
}
},
selectReport: function (object, center) {
selectReport: function (object) {
var positionRelated, reportType = this.lookupReference('reportTypeField').getValue();
if (object instanceof Traccar.model.Position) {
if (reportType === 'route') {
@ -281,15 +298,15 @@ Ext.define('Traccar.view.ReportController', {
var i, deviceIds, chartSeries, deviceStore;
if (this.lookupReference('reportTypeField').getValue() === 'chart') {
this.getChart().getAxes()[0].setTitle(
Ext.getStore('ReportChartTypes').findRecord('key', this.chartType).get('name'));
Ext.getStore('ReportChartTypes').findRecord('key', this.chartType).get('name'));
chartSeries = [];
deviceIds = store.collect('deviceId');
for (i = 0; i < deviceIds.length; i++) {
deviceStore = new Ext.create('Ext.data.ChainedStore', {
deviceStore = Ext.create('Ext.data.ChainedStore', {
source: 'ReportRoute',
filters: [{
property: 'deviceId',
value : deviceIds[i]
value: deviceIds[i]
}]
});
chartSeries.push({

View File

@ -45,7 +45,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
if (admin) {
this.lookupReference('settingsServerButton').setHidden(false);
this.lookupReference('settingsStatisticsButton').setHidden(false);
this.lookupReference('settingsDeviceDistanceButton').setHidden(false);
this.lookupReference('settingsDeviceDistanceButton').setHidden(Traccar.app.getVehicleFeaturesDisabled());
}
if (admin || manager) {
this.lookupReference('settingsUsersButton').setHidden(false);
@ -55,12 +55,15 @@ Ext.define('Traccar.view.SettingsMenuController', {
this.lookupReference('settingsGroupsButton').setHidden(false);
this.lookupReference('settingsGeofencesButton').setHidden(false);
this.lookupReference('settingsNotificationsButton').setHidden(false);
this.lookupReference('settingsCalendarsButton').setHidden(false);
this.lookupReference('settingsDriversButton').setHidden(false);
this.lookupReference('settingsCalendarsButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableCalendars'));
this.lookupReference('settingsDriversButton').setHidden(
Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers'));
}
if (admin || (!deviceReadonly && !readonly)) {
if (admin || !deviceReadonly && !readonly) {
this.lookupReference('settingsAttributeAliasesButton').setHidden(false);
this.lookupReference('settingsComputedAttributesButton').setHidden(false);
this.lookupReference('settingsComputedAttributesButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
}
},

View File

@ -20,12 +20,11 @@ Ext.define('Traccar.view.StateController', {
alias: 'controller.state',
requires: [
'Traccar.AttributeFormatter',
'Traccar.model.Attribute',
'Traccar.model.AttributeAlias',
'Traccar.model.Position',
'Traccar.view.dialog.AttributeAlias'
'Traccar.AttributeFormatter',
'Traccar.model.Attribute',
'Traccar.model.AttributeAlias',
'Traccar.model.Position',
'Traccar.view.dialog.AttributeAlias'
],
config: {
@ -73,7 +72,7 @@ Ext.define('Traccar.view.StateController', {
};
}
return result;
}()),
})(),
updateLatest: function (store, data) {
var i;
@ -89,7 +88,7 @@ Ext.define('Traccar.view.StateController', {
},
formatValue: function (value) {
if (typeof (id) === 'number') {
if (typeof id === 'number') {
return Number(value.toFixed(2));
} else {
return value;
@ -169,7 +168,7 @@ Ext.define('Traccar.view.StateController', {
Ext.getStore('Attributes').removeAll();
},
clearReport: function (store) {
clearReport: function () {
if (!this.deviceId) {
this.position = null;
Ext.getStore('Attributes').removeAll();

View File

@ -26,12 +26,12 @@ Ext.define('Traccar.view.dialog.CalendarController', {
reader = new FileReader();
reader.onload = function (event) {
fileField.up('window').lookupReference('dataField').setValue(
btoa(String.fromCharCode.apply(null, new Uint8Array(event.target.result))));
event.target.result.substr(event.target.result.indexOf(',') + 1));
};
reader.onerror = function (event) {
Traccar.app.showError(event.target.error);
};
reader.readAsArrayBuffer(fileField.fileInputEl.dom.files[0]);
reader.readAsDataURL(fileField.fileInputEl.dom.files[0]);
}
}
});

View File

@ -97,6 +97,8 @@ Ext.define('Traccar.view.dialog.CommandController', {
data: value
});
break;
default:
break;
}
Ext.Ajax.request({

View File

@ -46,6 +46,7 @@ Ext.define('Traccar.view.dialog.Geofence', {
fieldLabel: Strings.sharedDescription
}, {
xtype: 'combobox',
reference: 'calendarCombo',
name: 'calendarId',
store: 'Calendars',
queryMode: 'local',

View File

@ -34,6 +34,11 @@ Ext.define('Traccar.view.dialog.GeofenceController', {
}
},
init: function () {
this.lookupReference('calendarCombo').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableCalendars'));
},
saveArea: function (value) {
this.lookupReference('areaField').setValue(value);
},

View File

@ -86,14 +86,12 @@ Ext.define('Traccar.view.dialog.LoginController', {
prefix = url.substring(0, url.indexOf(paramName));
suffix = url.substring(url.indexOf(paramName));
suffix = suffix.substring(suffix.indexOf('=') + 1);
suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
suffix = suffix.indexOf('&') >= 0 ? suffix.substring(suffix.indexOf('&')) : '';
url = prefix + paramName + '=' + paramValue + suffix;
} else if (url.indexOf('?') < 0) {
url += '?' + paramName + '=' + paramValue;
} else {
if (url.indexOf('?') < 0) {
url += '?' + paramName + '=' + paramValue;
} else {
url += '&' + paramName + '=' + paramValue;
}
url += '&' + paramName + '=' + paramValue;
}
window.location.href = url;
},

View File

@ -30,7 +30,7 @@ Ext.define('Traccar.view.dialog.MapPickerController', {
}
},
getMapState: function (button) {
getMapState: function () {
this.fireEvent('mapstaterequest');
},

View File

@ -61,13 +61,13 @@ Ext.define('Traccar.view.edit.AttributeAliasesController', {
this.lookupReference('toolbarRemoveButton').setDisabled(disabled);
},
onDeviceChange: function (combobox, newValue, oldValue) {
onDeviceChange: function (combobox, value) {
var manager = Traccar.app.getUser().get('admin') || Traccar.app.getUser().get('userLimit') > 0;
this.onSelectionChange();
if (newValue !== null) {
this.getView().getStore().filter('deviceId', newValue);
if (value !== null) {
this.getView().getStore().filter('deviceId', value);
if (manager && this.getView().getStore().getCount() === 0) {
Ext.getStore('AttributeAliases').getProxy().setExtraParam('deviceId', newValue);
Ext.getStore('AttributeAliases').getProxy().setExtraParam('deviceId', value);
Ext.getStore('AttributeAliases').load({
addRecords: true
});

View File

@ -46,7 +46,7 @@ Ext.define('Traccar.view.edit.Attributes', {
text: Strings.sharedName,
dataIndex: 'name',
filter: 'string',
renderer: function (value, metaData) {
renderer: function (value) {
var attribute;
if (this.attributesStore) {
attribute = Ext.getStore(this.attributesStore).getById(value);

View File

@ -94,6 +94,7 @@ Ext.define('Traccar.view.edit.AttributesController', {
displayField: 'name',
valueField: 'key',
allowBlank: false,
queryMode: 'local',
listeners: {
change: 'onNameChange'
}

View File

@ -111,6 +111,7 @@ Ext.define('Traccar.view.edit.Devices', {
if (status) {
return Ext.getStore('DeviceStatuses').getById(status).get('color');
}
return null;
}
},
@ -165,7 +166,7 @@ Ext.define('Traccar.view.edit.Devices', {
for (i = 0; i < value.length; i++) {
name = Traccar.AttributeFormatter.geofenceIdFormatter(value[i]);
if (name) {
result += name + ((i < value.length - 1) ? ', ' : '');
result += name + (i < value.length - 1 ? ', ' : '');
}
}
}
@ -187,6 +188,7 @@ Ext.define('Traccar.view.edit.Devices', {
return status.get('name');
}
}
return null;
}
}, {
text: Strings.deviceLastUpdate,

View File

@ -61,6 +61,10 @@ Ext.define('Traccar.view.edit.DevicesController', {
deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin');
readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin');
this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly);
this.lookupReference('toolbarDriversButton').setHidden(
Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers'));
this.lookupReference('toolbarAttributesButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
setInterval(function () {
self.getView().getView().refresh();
@ -151,7 +155,7 @@ Ext.define('Traccar.view.edit.DevicesController', {
}
},
selectDevice: function (device, center) {
selectDevice: function (device) {
this.getView().getSelectionModel().select([device], false, true);
this.updateButtons(this.getView().getSelectionModel());
this.getView().getView().focusRow(device);
@ -163,7 +167,7 @@ Ext.define('Traccar.view.edit.DevicesController', {
}
},
onUpdateDevice: function (store, data) {
onUpdateDevice: function () {
this.updateButtons(this.getView().getSelectionModel());
},

View File

@ -32,6 +32,13 @@ Ext.define('Traccar.view.edit.GroupsController', {
objectDialog: 'Traccar.view.dialog.Group',
removeTitle: Strings.groupDialog,
init: function () {
this.lookupReference('toolbarDriversButton').setHidden(
Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers'));
this.lookupReference('toolbarAttributesButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
},
onGeofencesClick: function () {
var admin, group;
admin = Traccar.app.getUser().get('admin');

View File

@ -41,6 +41,12 @@ Ext.define('Traccar.view.edit.UsersController', {
init: function () {
Ext.getStore('Users').load();
this.lookupReference('userUsersButton').setHidden(!Traccar.app.getUser().get('admin'));
this.lookupReference('userDriversButton').setHidden(
Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers'));
this.lookupReference('userAttributesButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
this.lookupReference('userCalendarsButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableCalendars'));
},
onEditClick: function () {

View File

@ -117,11 +117,45 @@ Ext.define('Traccar.view.map.BaseMap', {
262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048,
1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5
]
<<<<<<< HEAD
}),
attributions: [
new ol.Attribution({
html: '&copy; <a href="http://map.baidu.com/">Baidu</a>'
})
=======
})
]
})
});
} else if (type === 'baidu') {
layer = new ol.layer.Tile({
source: new ol.source.XYZ({
projection: 'BD-MC',
tileUrlFunction: function (tileCoord) {
var urlsLength = 5, z = tileCoord[0], x = tileCoord[1], y = tileCoord[2], hash, index;
hash = (x << z) + y;
index = hash % urlsLength;
index = index < 0 ? index + urlsLength : index;
if (x < 0) {
x = 'M' + -x;
}
if (y < 0) {
y = 'M' + -y;
}
return 'http://online{}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl'
.replace('{}', index).replace('{x}', x).replace('{y}', y).replace('{z}', z);
},
tileGrid: new ol.tilegrid.TileGrid({
extent: ol.proj.transformExtent([-180, -74, 180, 74], 'EPSG:4326', 'BD-MC'),
origin: [0, 0],
minZoom: 3,
resolutions: [
262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048,
1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5
>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
]
})
});
@ -180,7 +214,7 @@ Ext.define('Traccar.view.map.BaseMap', {
}
this.map.on('pointermove', function (e) {
var hit = this.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
var hit = this.forEachFeatureAtPixel(e.pixel, function () {
return true;
});
if (hit) {
@ -191,14 +225,15 @@ Ext.define('Traccar.view.map.BaseMap', {
});
this.map.on('click', function (e) {
if (this.map.hasFeatureAtPixel(e.pixel, {
var i, features = this.map.getFeaturesAtPixel(e.pixel, {
layerFilter: function (layer) {
return !layer.get('name');
}
})) {
this.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
this.fireEvent('selectfeature', feature);
}.bind(this));
});
if (features) {
for (i = 0; i < features.length; i++) {
this.fireEvent('selectfeature', features[i]);
}
} else {
this.fireEvent('deselectfeature');
}
@ -215,9 +250,7 @@ Ext.define('Traccar.view.map.BaseMap', {
}
}
}, function () {
proj4.defs('BD-MC', '+proj=merc +lon_0=0 +units=m +ellps=clrk66 +no_defs');
proj4.defs('EPSG:3395', '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
ol.proj.get('EPSG:3395').setExtent([-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]);
});

View File

@ -44,8 +44,8 @@ Ext.define('Traccar.view.map.MapController', {
init: function () {
this.callParent();
this.lookupReference('showReportsButton').setVisible(Traccar.app.isMobile() &&
!Traccar.app.getAttributePreference('ui.disableReport', false));
this.lookupReference('showReportsButton').setVisible(
Traccar.app.isMobile() && !Traccar.app.getBooleanAttributePreference('ui.disableReport'));
this.lookupReference('showEventsButton').setVisible(Traccar.app.isMobile());
},
@ -79,10 +79,10 @@ Ext.define('Traccar.view.map.MapController', {
this.getView().getGeofencesSource().clear();
if (this.lookupReference('showGeofencesButton').pressed) {
Ext.getStore('Geofences').each(function (geofence) {
var feature = new ol.Feature(Traccar.GeofenceConverter
.wktToGeometry(this.getView().getMapView(), geofence.get('area')));
feature.setStyle(this.getAreaStyle(geofence.get('name'),
geofence.get('attributes') ? geofence.get('attributes').color : null));
var feature = new ol.Feature(
Traccar.GeofenceConverter.wktToGeometry(this.getView().getMapView(), geofence.get('area')));
feature.setStyle(this.getAreaStyle(
geofence.get('name'), geofence.get('attributes') ? geofence.get('attributes').color : null));
this.getView().getGeofencesSource().addFeature(feature);
return true;
}, this);

View File

@ -216,7 +216,7 @@ Ext.define('Traccar.view.map.MapMarkerController', {
projection = mapView.getProjection();
center = ol.proj.fromLonLat([position.get('longitude'), position.get('latitude')]);
pointResolution = ol.proj.getPointResolution(projection, mapView.getResolution(), center);
radius = (position.get('accuracy') / ol.proj.METERS_PER_UNIT.m) * mapView.getResolution() / pointResolution;
radius = position.get('accuracy') / ol.proj.METERS_PER_UNIT.m * mapView.getResolution() / pointResolution;
if (feature) {
feature.getGeometry().setCenter(center);
@ -257,8 +257,8 @@ Ext.define('Traccar.view.map.MapMarkerController', {
marker.set('record', device);
style = this.getLatestMarker(this.getDeviceColor(device),
position.get('course'),
device.get('category'));
position.get('course'),
device.get('category'));
style.getText().setText(device.get('name'));
marker.setStyle(style);
marker.setId(device.get('id'));
@ -429,10 +429,8 @@ Ext.define('Traccar.view.map.MapMarkerController', {
resizeMarker: function (style, zoom) {
var image, text;
image = Traccar.DeviceImages.getImageIcon(style.getImage().fill,
zoom,
style.getImage().angle,
style.getImage().category);
image = Traccar.DeviceImages.getImageIcon(
style.getImage().fill, zoom, style.getImage().angle, style.getImage().category);
text = style.getText();
text.setOffsetY(-image.getSize()[1] / 2 - Traccar.Style.mapTextOffset);
style.setText(text);
@ -440,18 +438,14 @@ Ext.define('Traccar.view.map.MapMarkerController', {
},
rotateMarker: function (style, angle) {
style.setImage(Traccar.DeviceImages.getImageIcon(style.getImage().fill,
style.getImage().zoom,
angle,
style.getImage().category));
style.setImage(Traccar.DeviceImages.getImageIcon(
style.getImage().fill, style.getImage().zoom, angle, style.getImage().category));
},
updateDeviceMarker: function (style, color, category) {
var image, text;
image = Traccar.DeviceImages.getImageIcon(color,
style.getImage().zoom,
style.getImage().angle,
category);
image = Traccar.DeviceImages.getImageIcon(
color, style.getImage().zoom, style.getImage().angle, category);
text = style.getText();
text.setOffsetY(-image.getSize()[1] / 2 - Traccar.Style.mapTextOffset);
style.setText(text);
@ -608,7 +602,7 @@ Ext.define('Traccar.view.map.MapMarkerController', {
}
},
filterDevices: function (store) {
filterDevices: function () {
Ext.getStore('Devices').each(this.updateDeviceVisibility, this, false);
}
});

View File

@ -24,11 +24,11 @@ Ext.define('Traccar.view.permissions.BaseController', {
params[this.getView().baseObjectName] = this.getView().baseObject;
linkStoreName = this.getView().linkStoreName;
storeName = this.getView().storeName;
linkStoreName = (typeof linkStoreName === 'undefined') ? storeName : linkStoreName;
linkStoreName = typeof linkStoreName === 'undefined' ? storeName : linkStoreName;
this.getView().setStore(Ext.getStore(storeName));
this.getView().getStore().load({
scope: this,
callback: function (records, operation, success) {
callback: function () {
var linkStore = Ext.create('Traccar.store.' + linkStoreName);
linkStore.load({
params: params,
@ -47,7 +47,7 @@ Ext.define('Traccar.view.permissions.BaseController', {
});
},
onBeforeSelect: function (selection, record, index) {
onBeforeSelect: function (selection, record) {
var data = {};
data[this.getView().baseObjectName] = this.getView().baseObject;
data[this.getView().linkObjectName] = record.getId();
@ -64,7 +64,7 @@ Ext.define('Traccar.view.permissions.BaseController', {
});
},
onBeforeDeselect: function (selection, record, index) {
onBeforeDeselect: function (selection, record) {
var data = {};
data[this.getView().baseObjectName] = this.getView().baseObject;
data[this.getView().linkObjectName] = record.getId();

View File

@ -89,6 +89,10 @@
"attributeMailSmtpUsername": "Mail: SMTP Username",
"attributeMailSmtpPassword": "Mail: SMTP Password",
"attributeUiDisableReport": "UI: Disable Report",
"attributeUiDisableVehicleFetures": "UI: Disable Vehicle Fetures",
"attributeUiDisableDrivers": "UI: Disable Drivers",
"attributeUiDisableComputedAttributes": "UI: Disable Computed Attributes",
"attributeUiDisableCalendars": "UI: Disable Calendars",
"errorTitle": "Error",
"errorGeneral": "Invalid parameters or constraints violation",
"errorConnection": "Connection error",

View File

@ -136,7 +136,7 @@
extjsVersion = '6.2.0';
fontAwesomeVersion = '4.7.0';
olVersion = '4.2.0';
olVersion = '4.3.1';
proj4jsVersion = '2.4.3';
if (debugMode) {