From b2b9e4cb213023697566885340d2ff7b5a44db8b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 19 Jun 2017 11:34:01 +0500 Subject: - Added columns filters to most windows - Added more columns to UserDevices and UserGroups - Change openlayers version to 4.2.0 --- web/app/AttributeFormatter.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index aecbd8a2..f8bce1b1 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -62,6 +62,18 @@ Ext.define('Traccar.AttributeFormatter', { return Ext.getStore('Devices').getById(value).get('name'); }, + groupIdFormatter: function (value) { + var group; + if (value !== 0) { + if (Ext.getStore('AllGroups').getTotalCount() === 0) { + group = Ext.getStore('Groups').getById(value); + } else { + group = Ext.getStore('AllGroups').getById(value); + } + return group ? group.get('name') : value; + } + }, + lastUpdateFormatter: function (value) { var seconds, interval; @@ -113,6 +125,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.durationFormatter; } else if (key === 'deviceId') { return this.deviceIdFormatter; + } else if (key === 'groupId') { + return this.groupIdFormatter; } else if (key === 'lastUpdate') { return this.lastUpdateFormatter; } else { -- cgit v1.2.3 From a1e1f5a8774c9f269b5fdf3620ab28fa5140a5b0 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 19 Jun 2017 16:19:48 +0500 Subject: Optimize store selection --- web/app/AttributeFormatter.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index f8bce1b1..2ddfd61e 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -65,11 +65,7 @@ Ext.define('Traccar.AttributeFormatter', { groupIdFormatter: function (value) { var group; if (value !== 0) { - if (Ext.getStore('AllGroups').getTotalCount() === 0) { - group = Ext.getStore('Groups').getById(value); - } else { - group = Ext.getStore('AllGroups').getById(value); - } + group = Ext.getStore(Ext.getStore('AllGroups').getTotalCount() === 0 ? 'Groups' : 'AllGroups').getById(value); return group ? group.get('name') : value; } }, -- cgit v1.2.3 From 56a5de3dc50e438884c5636c11f31e48bf19a15e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 19 Jun 2017 16:35:22 +0500 Subject: Retrieve store once --- web/app/AttributeFormatter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 2ddfd61e..0c385672 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -63,9 +63,13 @@ Ext.define('Traccar.AttributeFormatter', { }, groupIdFormatter: function (value) { - var group; + var group, store; if (value !== 0) { - group = Ext.getStore(Ext.getStore('AllGroups').getTotalCount() === 0 ? 'Groups' : 'AllGroups').getById(value); + store = Ext.getStore('AllGroups'); + if (store.getTotalCount() === 0) { + store = Ext.getStore('Groups'); + } + group = store.getById(value); return group ? group.get('name') : value; } }, -- cgit v1.2.3