aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'web/app')
-rw-r--r--web/app/AttributeFormatter.js20
-rw-r--r--web/app/controller/Root.js2
-rw-r--r--web/app/model/Group.js2
-rw-r--r--web/app/model/Server.js2
-rw-r--r--web/app/view/AttributeController.js (renamed from web/app/view/DeviceDialogController.js)36
-rw-r--r--web/app/view/AttributeDialog.js16
-rw-r--r--web/app/view/BaseEditDialog.js5
-rw-r--r--web/app/view/BaseEditDialogController.js18
-rw-r--r--web/app/view/DeviceDialog.js19
-rw-r--r--web/app/view/Devices.js12
-rw-r--r--web/app/view/MapController.js50
-rw-r--r--web/app/view/Report.js5
-rw-r--r--web/app/view/ServerDialog.js2
-rw-r--r--web/app/view/State.js8
-rw-r--r--web/app/view/UserDialog.js13
-rw-r--r--web/app/view/UserDialogController.js20
16 files changed, 104 insertions, 126 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index c32849101..3432ca1e0 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -34,24 +34,6 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
},
- alarmFormatter: function (attributes) {
- var value = '';
- if (attributes instanceof Object) {//for Traccar.view.Attributes
- if (attributes.hasOwnProperty('alarm')) {
- value = attributes.alarm;
- if (typeof value === 'boolean') {
- value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no);
- }
- }
- } else {//for Traccar.view.Report
- value = attributes;
- if (typeof value === 'boolean') {
- value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no);
- }
- }
- return '<span style="color:red;">' + value + '</span>';
- },
-
defaultFormatter: function (value) {
if (typeof value === 'number') {
return Number(value.toFixed(Traccar.Style.numberPrecision));
@@ -76,8 +58,6 @@ Ext.define('Traccar.AttributeFormatter', {
return this.courseFormatter;
} else if (key === 'distance' || key === 'odometer') {
return this.distanceFormatter;
- } else if (key === 'alarm') {
- return this.alarmFormatter;
} else {
return this.defaultFormatter;
}
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 7070c48b0..2c565747b 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -100,7 +100,7 @@ Ext.define('Traccar.controller.Root', {
},
mutePressed: function () {
- var muteButton = Ext.getCmp('nuteButton');
+ var muteButton = Ext.getCmp('muteButton');
return muteButton && !muteButton.pressed;
},
diff --git a/web/app/model/Group.js b/web/app/model/Group.js
index a28897feb..bb18b5b3f 100644
--- a/web/app/model/Group.js
+++ b/web/app/model/Group.js
@@ -27,5 +27,7 @@ Ext.define('Traccar.model.Group', {
}, {
name: 'groupId',
type: 'int'
+ }, {
+ name: 'attributes'
}]
});
diff --git a/web/app/model/Server.js b/web/app/model/Server.js
index 3f6e466d9..02968c2d6 100644
--- a/web/app/model/Server.js
+++ b/web/app/model/Server.js
@@ -54,6 +54,8 @@ Ext.define('Traccar.model.Server', {
}, {
name: 'twelveHourFormat',
type: 'boolean'
+ }, {
+ name: 'attributes'
}],
proxy: {
diff --git a/web/app/view/DeviceDialogController.js b/web/app/view/AttributeController.js
index 0a0f86883..932a6436b 100644
--- a/web/app/view/DeviceDialogController.js
+++ b/web/app/view/AttributeController.js
@@ -14,25 +14,29 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.DeviceDialogController', {
- extend: 'Traccar.view.BaseEditDialogController',
- alias: 'controller.deviceDialog',
+Ext.define('Traccar.view.AttributeController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.attributeDialog',
- requires: [
- 'Traccar.view.Attributes'
- ],
-
- showAttributesView: function (button) {
- var dialog, record;
+ onSaveClick: function (button) {
+ var dialog, store, record;
dialog = button.up('window').down('form');
+ dialog.updateRecord();
record = dialog.getRecord();
- Ext.create('Traccar.view.BaseWindow', {
- title: Strings.sharedAttributes,
- modal: false,
- items: {
- xtype: 'attributesView',
- record: record
+ store = record.store;
+ if (store) {
+ if (record.phantom) {
+ store.add(record);
}
- }).show();
+ store.sync({
+ failure: function (batch) {
+ store.rejectChanges();
+ Traccar.app.showError(batch.exceptions[0].getError().response);
+ }
+ });
+ } else {
+ record.save();
+ }
+ button.up('window').close();
}
});
diff --git a/web/app/view/AttributeDialog.js b/web/app/view/AttributeDialog.js
index be06b7576..213891ecd 100644
--- a/web/app/view/AttributeDialog.js
+++ b/web/app/view/AttributeDialog.js
@@ -15,13 +15,13 @@
*/
Ext.define('Traccar.view.AttributeDialog', {
- extend: 'Traccar.view.BaseEditDialog',
+ extend: 'Traccar.view.BaseDialog',
requires: [
- 'Traccar.view.BaseEditDialogController'
+ 'Traccar.view.AttributeController'
],
- controller: 'baseEditDialog',
+ controller: 'attributeDialog',
title: Strings.sharedAttribute,
items: {
@@ -35,5 +35,13 @@ Ext.define('Traccar.view.AttributeDialog', {
name: 'value',
fieldLabel: Strings.stateValue
}]
- }
+ },
+
+ buttons: [{
+ text: Strings.sharedSave,
+ handler: 'onSaveClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
});
diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js
index 051dfbe93..1af095c98 100644
--- a/web/app/view/BaseEditDialog.js
+++ b/web/app/view/BaseEditDialog.js
@@ -18,6 +18,11 @@ Ext.define('Traccar.view.BaseEditDialog', {
extend: 'Traccar.view.BaseDialog',
buttons: [{
+ text: Strings.sharedAttributes,
+ handler: 'showAttributesView'
+ }, {
+ xtype: 'tbfill'
+ }, {
text: Strings.sharedSave,
handler: 'onSaveClick'
}, {
diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js
index 33bd01bd8..79fd8f2b4 100644
--- a/web/app/view/BaseEditDialogController.js
+++ b/web/app/view/BaseEditDialogController.js
@@ -18,6 +18,10 @@ Ext.define('Traccar.view.BaseEditDialogController', {
extend: 'Ext.app.ViewController',
alias: 'controller.baseEditDialog',
+ requires: [
+ 'Traccar.view.Attributes'
+ ],
+
onSaveClick: function (button) {
var dialog, store, record;
dialog = button.up('window').down('form');
@@ -38,5 +42,19 @@ Ext.define('Traccar.view.BaseEditDialogController', {
record.save();
}
button.up('window').close();
+ },
+
+ showAttributesView: function (button) {
+ var dialog, record;
+ dialog = button.up('window').down('form');
+ record = dialog.getRecord();
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedAttributes,
+ modal: false,
+ items: {
+ xtype: 'attributesView',
+ record: record
+ }
+ }).show();
}
});
diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js
index 2938d5dc3..e88618fc5 100644
--- a/web/app/view/DeviceDialog.js
+++ b/web/app/view/DeviceDialog.js
@@ -18,10 +18,10 @@ Ext.define('Traccar.view.DeviceDialog', {
extend: 'Traccar.view.BaseEditDialog',
requires: [
- 'Traccar.view.DeviceDialogController'
+ 'Traccar.view.BaseEditDialog'
],
- controller: 'deviceDialog',
+ controller: 'baseEditDialog',
title: Strings.deviceDialog,
items: {
@@ -45,18 +45,5 @@ Ext.define('Traccar.view.DeviceDialog', {
displayField: 'name',
valueField: 'id'
}]
- },
-
- buttons: [{
- text : Strings.sharedAttributes,
- handler: 'showAttributesView'
- }, {
- xtype: 'tbfill'
- }, {
- text: Strings.sharedSave,
- handler: 'onSaveClick'
- }, {
- text: Strings.sharedCancel,
- handler: 'closeView'
- }]
+ }
});
diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js
index da7695229..ab6436ea6 100644
--- a/web/app/view/Devices.js
+++ b/web/app/view/Devices.js
@@ -57,10 +57,10 @@ Ext.define('Traccar.view.Devices', {
tooltipType: 'title'
}, {
xtype: 'tbfill'
- },{
- id: 'nuteButton',
+ }, {
+ id: 'muteButton',
glyph: 'xf1f7@FontAwesome',
- tooltip: Strings.muteButton,
+ tooltip: Strings.sharedMute,
tooltipType: 'title',
pressed : true,
enableToggle: true,
@@ -156,13 +156,13 @@ Ext.define('Traccar.view.Devices', {
renderer: function (value, metaData, record) {
switch (record.get('status')) {
case 'online':
- metaData.tdCls = 'status-color-online';
+ metaData.tdCls = 'view-color-green';
break;
case 'offline':
- metaData.tdCls = 'status-color-offline';
+ metaData.tdCls = 'view-color-red';
break;
default:
- metaData.tdCls = 'status-color-unknown';
+ metaData.tdCls = 'view-color-yellow';
break;
}
if (Traccar.app.getPreference('twelveHourFormat', false)) {
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index eee74099f..6ef9f91e6 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -147,37 +147,39 @@ Ext.define('Traccar.view.MapController', {
this.clearReport(store);
- this.reportRoute = new ol.Feature({
- geometry: new ol.geom.LineString([])
- });
- this.reportRoute.setStyle(this.getRouteStyle());
- this.getView().getRouteSource().addFeature(this.reportRoute);
+ if (data.length > 0) {
+ this.reportRoute = new ol.Feature({
+ geometry: new ol.geom.LineString([])
+ });
+ this.reportRoute.setStyle(this.getRouteStyle());
+ this.getView().getRouteSource().addFeature(this.reportRoute);
- for (i = 0; i < data.length; i++) {
- position = data[i];
+ for (i = 0; i < data.length; i++) {
+ position = data[i];
+
+ point = ol.proj.fromLonLat([
+ position.get('longitude'),
+ position.get('latitude')
+ ]);
+ geometry = new ol.geom.Point(point);
- point = ol.proj.fromLonLat([
- position.get('longitude'),
- position.get('latitude')
- ]);
- geometry = new ol.geom.Point(point);
+ marker = new ol.Feature(geometry);
+ marker.set('record', position);
+ this.reportMarkers[position.get('id')] = marker;
+ this.getView().getReportSource().addFeature(marker);
- marker = new ol.Feature(geometry);
- marker.set('record', position);
- this.reportMarkers[position.get('id')] = marker;
- this.getView().getReportSource().addFeature(marker);
+ style = this.getReportMarker();
+ style.getImage().setRotation(position.get('course') * Math.PI / 180);
+ /*style.getText().setText(
+ Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/
- style = this.getReportMarker();
- style.getImage().setRotation(position.get('course') * Math.PI / 180);
- /*style.getText().setText(
- Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/
+ marker.setStyle(style);
- marker.setStyle(style);
+ this.reportRoute.getGeometry().appendCoordinate(point);
+ }
- this.reportRoute.getGeometry().appendCoordinate(point);
+ this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize());
}
-
- this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize());
},
clearReport: function (store) {
diff --git a/web/app/view/Report.js b/web/app/view/Report.js
index 78ff5d52f..4261b9040 100644
--- a/web/app/view/Report.js
+++ b/web/app/view/Report.js
@@ -115,10 +115,5 @@ Ext.define('Traccar.view.Report', {
dataIndex: 'address',
flex: 1,
renderer: Traccar.AttributeFormatter.getFormatter('address')
- }, {
- text: 'Alarm',
- dataIndex: 'attributes',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('alarm')
}]
});
diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js
index 67f3a7ab2..1af000042 100644
--- a/web/app/view/ServerDialog.js
+++ b/web/app/view/ServerDialog.js
@@ -31,7 +31,7 @@ Ext.define('Traccar.view.ServerDialog', {
name: 'registration',
fieldLabel: Strings.serverRegistration,
allowBlank: false
- },{
+ }, {
xtype: 'checkboxfield',
name: 'readonly',
fieldLabel: Strings.serverReadonly,
diff --git a/web/app/view/State.js b/web/app/view/State.js
index 1a9f014f5..547fb0cf3 100644
--- a/web/app/view/State.js
+++ b/web/app/view/State.js
@@ -34,6 +34,12 @@ Ext.define('Traccar.view.State', {
}, {
text: Strings.stateValue,
dataIndex: 'value',
- flex: 1
+ flex: 1,
+ renderer: function (value, metaData, record) {
+ if (record.get('name') === 'Alarm') {
+ metaData.tdCls = 'view-color-red';
+ }
+ return value;
+ }
}]
});
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index 378cc0681..df8a26e7e 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -89,18 +89,5 @@ Ext.define('Traccar.view.UserDialog', {
fieldLabel: Strings.settingsTwelveHourFormat,
allowBlank: false
}]
- }],
-
- buttons: [{
- text : Strings.sharedAttributes,
- handler: 'showAttributesView'
- }, {
- xtype: 'tbfill'
- }, {
- text: Strings.sharedSave,
- handler: 'onSaveClick'
- }, {
- text: Strings.sharedCancel,
- handler: 'closeView'
}]
});
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index 49dfd9d70..c3a4ca62d 100644
--- a/web/app/view/UserDialogController.js
+++ b/web/app/view/UserDialogController.js
@@ -15,13 +15,9 @@
*/
Ext.define('Traccar.view.UserDialogController', {
- extend: 'Ext.app.ViewController',
+ extend: 'Traccar.view.BaseEditDialogController',
alias: 'controller.userDialog',
- requires: [
- 'Traccar.view.Attributes'
- ],
-
init: function () {
if (Traccar.app.getUser().get('admin')) {
this.lookupReference('adminField').setDisabled(false);
@@ -48,19 +44,5 @@ Ext.define('Traccar.view.UserDialogController', {
});
}
button.up('window').close();
- },
-
- showAttributesView: function (button) {
- var dialog, record;
- dialog = button.up('window').down('form');
- record = dialog.getRecord();
- Ext.create('Traccar.view.BaseWindow', {
- title: Strings.sharedAttributes,
- modal: false,
- items: {
- xtype: 'attributesView',
- record: record
- }
- }).show();
}
});