From ca3109cce72bfc780960d468c2fcf6a75f39a859 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 22 Dec 2016 13:51:42 +0500 Subject: - Add support for custom report colors - Style fixes --- web/app/view/MapMarkerController.js | 28 ++++++++++++++++++---------- web/load.js | 14 +++++++------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index b978aafd..510e11bd 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -276,14 +276,26 @@ Ext.define('Traccar.view.MapMarkerController', { } }, - getRouteStyle: function (deviceId) { - var index = 0; - if (deviceId !== undefined) { - index = deviceId % Traccar.Style.mapRouteColor.length; + getReportColor: function (deviceId) { + var index, reportColor, device = Ext.getStore('Devices').getById(deviceId); + if (device) { + reportColor = device.get('attributes')['web.reportColor']; + } + if (reportColor) { + return reportColor; + } else { + index = 0; + if (deviceId !== undefined) { + index = deviceId % Traccar.Style.mapRouteColor.length; + } + return Traccar.Style.mapRouteColor[index]; } + }, + + getRouteStyle: function (deviceId) { return new ol.style.Style({ stroke: new ol.style.Stroke({ - color: Traccar.Style.mapRouteColor[index], + color: this.getReportColor(deviceId), width: Traccar.Style.mapRouteWidth }) }); @@ -313,11 +325,7 @@ Ext.define('Traccar.view.MapMarkerController', { }, getReportMarker: function (deviceId, angle) { - var index = 0; - if (deviceId !== undefined) { - index = deviceId % Traccar.Style.mapRouteColor.length; - } - return this.getMarkerStyle(false, Traccar.Style.mapRouteColor[index], angle, 'arrow'); + return this.getMarkerStyle(false, this.getReportColor(deviceId), angle, 'arrow'); }, resizeMarker: function (style, zoom) { diff --git a/web/load.js b/web/load.js index cd012f18..4dedd770 100644 --- a/web/load.js +++ b/web/load.js @@ -1,5 +1,5 @@ (function () { - var debugMode, touchMode, locale, localeParameter, extjsVersion, fontAwesomeVersion, olVersion; + var debugMode, touchMode, locale, localeParameter, extjsVersion, fontAwesomeVersion, olVersion, i, language, languages; function addStyleFile(file) { var link = document.createElement('link'); @@ -78,13 +78,13 @@ localeParameter = window.location.search.match(/locale=([^&#]+)/); locale.language = localeParameter && localeParameter[1]; if (!(locale.language in locale.languages)) { - var languages = window.navigator.languages !== undefined ? window.navigator.languages.slice() : []; - var language = window.navigator.userLanguage || window.navigator.language; + languages = window.navigator.languages !== undefined ? window.navigator.languages.slice() : []; + language = window.navigator.userLanguage || window.navigator.language; languages.push(language); - languages.push(language.substr(0,2)); - languages.push("en"); //default - for (var i = 0; i < languages.length; i ++) { - var language = languages[i].replace("-", "_"); + languages.push(language.substr(0, 2)); + languages.push('en'); //default + for (i = 0; i < languages.length; i++) { + language = languages[i].replace('-', '_'); if (language in locale.languages) { locale.language = language; break; -- cgit v1.2.3