aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-15 15:26:25 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-15 15:26:25 +1300
commit6ce1f7d481aec69107ef34924bda57fafbce67ed (patch)
treebbd4aaab6a22457391a6a6f99ca4dfd28704336f
parentd3ca7de349f1d8ab0d02bf783a2c7627af44c6fd (diff)
downloadtraccar-server-6ce1f7d481aec69107ef34924bda57fafbce67ed.tar.gz
traccar-server-6ce1f7d481aec69107ef34924bda57fafbce67ed.tar.bz2
traccar-server-6ce1f7d481aec69107ef34924bda57fafbce67ed.zip
Service call to get all devices
-rw-r--r--src/org/traccar/web/DeviceServlet.java8
-rw-r--r--web/app/Application.js1
-rw-r--r--web/app/store/AllDevices.js32
-rw-r--r--web/app/view/UserDevices.js3
-rw-r--r--web/app/view/UserDevicesController.js7
5 files changed, 44 insertions, 7 deletions
diff --git a/src/org/traccar/web/DeviceServlet.java b/src/org/traccar/web/DeviceServlet.java
index 3e8c7f115..cbbb41b9a 100644
--- a/src/org/traccar/web/DeviceServlet.java
+++ b/src/org/traccar/web/DeviceServlet.java
@@ -45,8 +45,14 @@ public class DeviceServlet extends BaseServlet {
}
private void get(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
+ if (Boolean.parseBoolean(req.getParameter("all"))) {
+ Context.getPermissionsManager().checkAdmin(getUserId(req));
+ sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
+ Context.getDataManager().getAllDevices()));
+ } else {
+ sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
Context.getDataManager().getDevices(getUserId(req))));
+ }
}
private void add(HttpServletRequest req, HttpServletResponse resp) throws Exception {
diff --git a/web/app/Application.js b/web/app/Application.js
index 36f5ca903..e710b7ea2 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -35,6 +35,7 @@ Ext.define('Traccar.Application', {
stores: [
'Devices',
+ 'AllDevices',
'Positions',
'LatestPositions',
'Users',
diff --git a/web/app/store/AllDevices.js b/web/app/store/AllDevices.js
new file mode 100644
index 000000000..a591b6561
--- /dev/null
+++ b/web/app/store/AllDevices.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.store.AllDevices', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.Device',
+
+ proxy: {
+ type: 'ajax',
+ url: '/api/device/get',
+ extraParams: {
+ all: true
+ },
+ reader: {
+ type: 'json',
+ rootProperty: 'data'
+ }
+ }
+});
diff --git a/web/app/view/UserDevices.js b/web/app/view/UserDevices.js
index 256168946..df03bca84 100644
--- a/web/app/view/UserDevices.js
+++ b/web/app/view/UserDevices.js
@@ -23,7 +23,7 @@ Ext.define('Traccar.view.UserDevices', {
],
controller: 'userDevices',
- store: 'Devices',
+ store: 'AllDevices',
selModel: {
selType: 'checkboxmodel',
@@ -43,3 +43,4 @@ Ext.define('Traccar.view.UserDevices', {
dataIndex: 'uniqueId', flex: 1
}]
});
+32 \ No newline at end of file
diff --git a/web/app/view/UserDevicesController.js b/web/app/view/UserDevicesController.js
index ec40fec02..a0b3de36d 100644
--- a/web/app/view/UserDevicesController.js
+++ b/web/app/view/UserDevicesController.js
@@ -19,13 +19,10 @@ Ext.define('Traccar.view.UserDevicesController', {
alias: 'controller.userDevices',
init: function () {
- //Ext.getStore('Users').load();
+ this.getView().getStore().load();
},
onSelectionChange: function (selected) {
- /*var disabled = selected.length > 0;
- this.lookupReference('toolbarEditButton').setDisabled(disabled);
- this.lookupReference('toolbarRemoveButton').setDisabled(disabled);
- this.lookupReference('userDevicesButton').setDisabled(disabled);*/
+ console.log(selected); // TODO
}
});