aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-12-01 17:30:50 +0500
committerAbyss777 <abyss@fox5.ru>2016-12-01 17:30:50 +0500
commit42574b6700384bd8a45d3410c4f8da644dad112e (patch)
tree6ada5763c1aea05441b02efe82ff038517cd5897
parent74072cf3ca6acf67d228287e446e3013277e7408 (diff)
downloadetbsa-traccar-web-42574b6700384bd8a45d3410c4f8da644dad112e.tar.gz
etbsa-traccar-web-42574b6700384bd8a45d3410c4f8da644dad112e.tar.bz2
etbsa-traccar-web-42574b6700384bd8a45d3410c4f8da644dad112e.zip
Implement in other way
-rw-r--r--web/app/Application.js10
-rw-r--r--web/app/controller/Root.js13
-rw-r--r--web/app/store/Positions.js5
-rw-r--r--web/app/view/MapMarkerController.js11
-rw-r--r--web/app/view/ReportController.js55
5 files changed, 51 insertions, 43 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index bae3896..8619ba9 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -141,13 +141,5 @@ Ext.define('Traccar.Application', {
} else {
Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection);
}
- },
-
- removeUrlParameter: function (param) {
- var params = Ext.Object.fromQueryString(window.location.search);
- delete params[param];
- window.history.pushState(null, null, window.location.pathname + '?' + Ext.Object.toQueryString(params));
- },
-
- hasEventId: false
+ }
});
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 5600d4e..379a0d8 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -75,7 +75,7 @@ Ext.define('Traccar.controller.Root', {
},
loadApp: function () {
- var attribution;
+ var attribution, eventId;
Ext.getStore('Groups').load();
Ext.getStore('Geofences').load();
Ext.getStore('AttributeAliases').load();
@@ -94,6 +94,11 @@ Ext.define('Traccar.controller.Root', {
} else {
Ext.create('widget.main');
}
+ eventId = Ext.Object.fromQueryString(window.location.search).eventId;
+ if (eventId) {
+ this.application.fireEvent('showSingleEvent', eventId);
+ //this.removeUrlParameter('eventId');
+ }
},
beep: function () {
@@ -108,6 +113,12 @@ Ext.define('Traccar.controller.Root', {
return muteButton && !muteButton.pressed;
},
+ removeUrlParameter: function (param) {
+ var params = Ext.Object.fromQueryString(window.location.search);
+ delete params[param];
+ window.history.pushState(null, null, window.location.pathname + '?' + Ext.Object.toQueryString(params));
+ },
+
asyncUpdate: function (first) {
var protocol, pathname, socket, self = this;
protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
diff --git a/web/app/store/Positions.js b/web/app/store/Positions.js
index 8f185af..388a332 100644
--- a/web/app/store/Positions.js
+++ b/web/app/store/Positions.js
@@ -21,6 +21,9 @@ Ext.define('Traccar.store.Positions', {
proxy: {
type: 'rest',
- url: 'api/positions'
+ url: 'api/positions',
+ headers: {
+ 'Accept': 'application/json'
+ }
}
});
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js
index 71a1583..596cffb 100644
--- a/web/app/view/MapMarkerController.js
+++ b/web/app/view/MapMarkerController.js
@@ -31,7 +31,8 @@ Ext.define('Traccar.view.MapMarkerController', {
controller: {
'*': {
selectdevice: 'selectDevice',
- selectreport: 'selectReport'
+ selectreport: 'selectReport',
+ showsingleevent: 'showSingleEvent'
}
},
store: {
@@ -65,6 +66,10 @@ Ext.define('Traccar.view.MapMarkerController', {
this.liveRouteLength = Traccar.app.getAttributePreference('web.liveRouteLength', 10);
},
+ showSingleEvent: function () {
+ this.singleEvent = true;
+ },
+
getDeviceColor: function (device) {
switch (device.get('status')) {
case 'online':
@@ -248,9 +253,9 @@ Ext.define('Traccar.view.MapMarkerController', {
} else if (geometry) {
this.getView().getMapView().fit(geometry, this.getView().getMap().getSize());
}
- if (Traccar.app.hasEventId) {
+ if (this.singleEvent) {
+ this.singleEvent = false;
this.fireEvent('selectreport', data[0], false);
- Traccar.app.hasEventId = false;
}
},
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 32a44df..e1a64e6 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -32,7 +32,8 @@ Ext.define('Traccar.view.ReportController', {
listen: {
controller: {
'*': {
- selectdevice: 'selectDevice'
+ selectdevice: 'selectDevice',
+ showsingleevent: 'showSingleEvent'
},
'map': {
selectreport: 'selectReport'
@@ -47,25 +48,6 @@ Ext.define('Traccar.view.ReportController', {
}
},
- init: function () {
- var eventId = Ext.Object.fromQueryString(window.location.search).eventId;
- if (eventId) {
- this.lookupReference('reportTypeField').setValue('events');
- Ext.getStore('Events').load({
- params: {
- id: eventId
- },
- callback: function (records, operation, success) {
- if (success) {
- Ext.getStore('ReportEvents').add(records);
- }
- }
- });
- Traccar.app.hasEventId = true;
- Traccar.app.removeUrlParameter('eventId');
- }
- },
-
hideReports: function () {
Traccar.app.showReports(false);
},
@@ -234,18 +216,33 @@ Ext.define('Traccar.view.ReportController', {
}
}
});
- } else if (Traccar.app.hasEventId && data.length > 0) {
- this.getView().getSelectionModel().select([data[0]], false, true);
- this.getView().getView().focusRow(data[0]);
- if (Traccar.app.isMobile()) {
- Traccar.app.showReports(true);
- } else {
- this.getView().expand();
- }
- Traccar.app.hasEventId = false;
}
},
+ showSingleEvent: function (eventId) {
+ this.lookupReference('reportTypeField').setValue('events');
+ Ext.getStore('Events').load({
+ id: eventId,
+ scope: this,
+ callback: function (records, operation, success) {
+ if (success) {
+ Ext.getStore('ReportEvents').add(records);
+ if (records.length > 0) {
+ if (!records[0].get('positionId')) {
+ if (Traccar.app.isMobile()) {
+ Traccar.app.showReports(true);
+ } else {
+ this.getView().expand();
+ }
+ }
+ this.getView().getSelectionModel().select([records[0]], false, true);
+ this.getView().getView().focusRow(records[0]);
+ }
+ }
+ }
+ });
+ },
+
downloadFile: function (requestUrl, requestParams) {
Ext.Ajax.request({
url: requestUrl,