aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-25 12:14:16 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-25 12:14:16 +1300
commit4fabe3d644f96b1477490f289adb39949523fa6d (patch)
tree18fc524a0123b4b6cfce59aff8f2e905615d7933
parent49eeee0e2b73799d7b9ba1c70b4519d0561338c0 (diff)
downloadtraccar-server-4fabe3d644f96b1477490f289adb39949523fa6d.tar.gz
traccar-server-4fabe3d644f96b1477490f289adb39949523fa6d.tar.bz2
traccar-server-4fabe3d644f96b1477490f289adb39949523fa6d.zip
Fix device tree display issues
-rw-r--r--web/app/view/Devices.js2
-rw-r--r--web/app/view/DevicesController.js21
2 files changed, 14 insertions, 9 deletions
diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js
index e43dcd2bc..83d5eacd1 100644
--- a/web/app/view/Devices.js
+++ b/web/app/view/Devices.js
@@ -103,7 +103,7 @@ Ext.define('Traccar.view.Devices', {
dataIndex: 'lastUpdate',
flex: 1,
renderer: function (value, metaData, record) {
- if (record.get('leaf')) {
+ if (record.get('original') instanceof Traccar.model.Device) {
switch (record.get('status')) {
case 'online':
metaData.tdCls = 'status-color-online';
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js
index 4d8231d94..d45fd50a8 100644
--- a/web/app/view/DevicesController.js
+++ b/web/app/view/DevicesController.js
@@ -45,20 +45,24 @@ Ext.define('Traccar.view.DevicesController', {
},
storeUpdate: function () {
- var nodes = [];
- Ext.getStore('Groups').each(function (record) {
+ var groupsStore, devicesStore, nodes = [];
+ groupsStore = Ext.getStore('Groups');
+ devicesStore = Ext.getStore('Devices');
+
+ groupsStore.each(function (record) {
var groupId, node = {
id: 'g' + record.get('id'),
original: record,
- name: record.get('name')
+ name: record.get('name'),
+ leaf: true
};
groupId = record.get('groupId');
- if (groupId !== 0) {
+ if (groupId !== 0 && groupsStore.indexOfId(groupId) !== -1) {
node.groupId = 'g' + groupId;
}
nodes.push(node);
}, this);
- Ext.getStore('Devices').each(function (record) {
+ devicesStore.each(function (record) {
var groupId, node = {
id: 'd' + record.get('id'),
original: record,
@@ -68,11 +72,12 @@ Ext.define('Traccar.view.DevicesController', {
leaf: true
};
groupId = record.get('groupId');
- if (groupId !== 0) {
+ if (groupId !== 0 && groupsStore.indexOfId(groupId) !== -1) {
node.groupId = 'g' + groupId;
}
nodes.push(node);
}, this);
+
this.getView().getStore().getProxy().setData(nodes);
this.getView().getStore().load();
this.getView().expandAll();
@@ -134,7 +139,7 @@ Ext.define('Traccar.view.DevicesController', {
},
onSelectionChange: function (selected) {
- var empty = selected.getCount() === 0 || !this.getView().getSelectionModel().getSelection()[0].get('leaf');
+ var empty = selected.getCount() === 0;
this.lookupReference('toolbarEditButton').setDisabled(empty);
this.lookupReference('toolbarRemoveButton').setDisabled(empty);
this.lookupReference('deviceCommandButton').setDisabled(empty);
@@ -144,7 +149,7 @@ Ext.define('Traccar.view.DevicesController', {
},
onBeforeSelect: function (row, record) {
- return record.get('leaf');
+ return record.get('original') instanceof Traccar.model.Device;
},
selectDevice: function (device, center) {