aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-15 16:28:42 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-15 16:28:42 +1300
commit9d159c880ab0fdb3f6f632dcb80577c6c2fb2f11 (patch)
tree206d945cc152c8c9e945a7ee62c40d48701b06d2
parent6ce1f7d481aec69107ef34924bda57fafbce67ed (diff)
downloadtrackermap-server-9d159c880ab0fdb3f6f632dcb80577c6c2fb2f11.tar.gz
trackermap-server-9d159c880ab0fdb3f6f632dcb80577c6c2fb2f11.tar.bz2
trackermap-server-9d159c880ab0fdb3f6f632dcb80577c6c2fb2f11.zip
Load and select user device list
-rw-r--r--src/org/traccar/web/DeviceServlet.java10
-rw-r--r--web/app/view/UserDevicesController.js24
-rw-r--r--web/app/view/UsersController.js4
3 files changed, 35 insertions, 3 deletions
diff --git a/src/org/traccar/web/DeviceServlet.java b/src/org/traccar/web/DeviceServlet.java
index cbbb41b9a..1ae94c1d0 100644
--- a/src/org/traccar/web/DeviceServlet.java
+++ b/src/org/traccar/web/DeviceServlet.java
@@ -50,8 +50,16 @@ public class DeviceServlet extends BaseServlet {
sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
Context.getDataManager().getAllDevices()));
} else {
+ long userId;
+ String userIdParam = req.getParameter("userId");
+ if (userIdParam != null) {
+ userId = Long.parseLong(userIdParam);
+ } else {
+ userId = getUserId(req);
+ }
+ Context.getPermissionsManager().checkUser(getUserId(req), userId);
sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
- Context.getDataManager().getDevices(getUserId(req))));
+ Context.getDataManager().getDevices(userId)));
}
}
diff --git a/web/app/view/UserDevicesController.js b/web/app/view/UserDevicesController.js
index a0b3de36d..aefc9d83e 100644
--- a/web/app/view/UserDevicesController.js
+++ b/web/app/view/UserDevicesController.js
@@ -19,7 +19,29 @@ Ext.define('Traccar.view.UserDevicesController', {
alias: 'controller.userDevices',
init: function () {
- this.getView().getStore().load();
+ console.log(this.getView().user.getData().id);
+ this.getView().getStore().load({
+ scope: this,
+ callback: function (records, operation, success) {
+ var userStore = Ext.create('Traccar.store.Devices');
+
+ userStore.load({
+ params: {
+ userId: this.getView().user.getData().id
+ },
+ scope: this,
+ callback: function (records, operation, success) {
+ var i, index;
+ if (success) {
+ for (i = 0; i < records.length; i++) {
+ index = this.getView().getStore().find('id', records[i].getData().id);
+ this.getView().getSelectionModel().select(index, true, true);
+ }
+ }
+ }
+ });
+ }
+ });
},
onSelectionChange: function (selected) {
diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js
index cfcf17fe1..30eb8b1a5 100644
--- a/web/app/view/UsersController.js
+++ b/web/app/view/UsersController.js
@@ -65,10 +65,12 @@ Ext.define('Traccar.view.UsersController', {
},
onDevicesClick: function () {
+ var user = this.getView().getSelectionModel().getSelection()[0];
Ext.create('Traccar.view.BaseWindow', {
title: Strings.deviceTitle,
items: {
- xtype: 'userDevicesView'
+ xtype: 'userDevicesView',
+ user: user
}
}).show();
},