aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/edit
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-04-11 14:31:42 +0500
committerAbyss777 <abyss@fox5.ru>2018-04-19 12:15:59 +0500
commit19a9155d988dcee7698a65a45b0558aa0ff279d4 (patch)
treecea9ae5c73a625d01bc06df5742228b5cbbd1def /web/app/view/edit
parent4e7d2b8fdb41390205d69997d61db536545f5564 (diff)
downloadetbsa-traccar-web-19a9155d988dcee7698a65a45b0558aa0ff279d4.tar.gz
etbsa-traccar-web-19a9155d988dcee7698a65a45b0558aa0ff279d4.tar.bz2
etbsa-traccar-web-19a9155d988dcee7698a65a45b0558aa0ff279d4.zip
Implement Maintenances
Diffstat (limited to 'web/app/view/edit')
-rw-r--r--web/app/view/edit/Attributes.js8
-rw-r--r--web/app/view/edit/Groups.js10
-rw-r--r--web/app/view/edit/GroupsController.js18
-rw-r--r--web/app/view/edit/Maintenances.js77
-rw-r--r--web/app/view/edit/MaintenancesController.js31
-rw-r--r--web/app/view/edit/Users.js12
-rw-r--r--web/app/view/edit/UsersController.js19
7 files changed, 165 insertions, 10 deletions
diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js
index cb07eda..cb0503d 100644
--- a/web/app/view/edit/Attributes.js
+++ b/web/app/view/edit/Attributes.js
@@ -58,13 +58,7 @@ Ext.define('Traccar.view.edit.Attributes', {
if (this.attributesStore) {
attribute = Ext.getStore(this.attributesStore).getById(record.get('name'));
}
- if (attribute && attribute.get('dataType') === 'speed') {
- return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getAttributePreference('speedUnit', 'kn'), true);
- } else if (attribute && attribute.get('dataType') === 'distance') {
- return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getAttributePreference('distanceUnit', 'km'), true);
- } else {
- return value;
- }
+ return Traccar.AttributeFormatter.renderAttribute(value, attribute);
}
}]
}
diff --git a/web/app/view/edit/Groups.js b/web/app/view/edit/Groups.js
index 0808201..1ff4de8 100644
--- a/web/app/view/edit/Groups.js
+++ b/web/app/view/edit/Groups.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -70,6 +70,14 @@ Ext.define('Traccar.view.edit.Groups', {
glyph: 'xf003@FontAwesome',
tooltip: Strings.sharedNotifications,
tooltipType: 'title'
+ }, {
+ xtype: 'button',
+ disabled: true,
+ handler: 'onMaintenancesClick',
+ reference: 'toolbarMaintenancesButton',
+ glyph: 'xf0ad@FontAwesome',
+ tooltip: Strings.sharedMaintenances,
+ tooltipType: 'title'
}]
},
diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js
index 04c9692..2e62a28 100644
--- a/web/app/view/edit/GroupsController.js
+++ b/web/app/view/edit/GroupsController.js
@@ -25,6 +25,7 @@ Ext.define('Traccar.view.edit.GroupsController', {
'Traccar.view.permissions.ComputedAttributes',
'Traccar.view.permissions.Drivers',
'Traccar.view.permissions.SavedCommands',
+ 'Traccar.view.permissions.Maintenances',
'Traccar.view.BaseWindow',
'Traccar.model.Group'
],
@@ -39,6 +40,8 @@ Ext.define('Traccar.view.edit.GroupsController', {
this.lookupReference('toolbarAttributesButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
this.lookupReference('toolbarCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false));
+ this.lookupReference('toolbarMaintenancesButton').setHidden(
+ Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableMaintenances'));
},
onGeofencesClick: function () {
@@ -111,6 +114,20 @@ Ext.define('Traccar.view.edit.GroupsController', {
}).show();
},
+ onMaintenancesClick: function () {
+ var group = this.getView().getSelectionModel().getSelection()[0];
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedMaintenances,
+ items: {
+ xtype: 'linkMaintenancesView',
+ baseObjectName: 'groupId',
+ linkObjectName: 'maintenanceId',
+ storeName: 'Maintenances',
+ baseObject: group.getId()
+ }
+ }).show();
+ },
+
onSelectionChange: function (selection, selected) {
var disabled = selected.length === 0;
this.lookupReference('toolbarGeofencesButton').setDisabled(disabled);
@@ -118,6 +135,7 @@ Ext.define('Traccar.view.edit.GroupsController', {
this.lookupReference('toolbarDriversButton').setDisabled(disabled);
this.lookupReference('toolbarCommandsButton').setDisabled(disabled);
this.lookupReference('toolbarNotificationsButton').setDisabled(disabled);
+ this.lookupReference('toolbarMaintenancesButton').setDisabled(disabled);
this.callParent(arguments);
}
});
diff --git a/web/app/view/edit/Maintenances.js b/web/app/view/edit/Maintenances.js
new file mode 100644
index 0000000..f7b4762
--- /dev/null
+++ b/web/app/view/edit/Maintenances.js
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.edit.Maintenances', {
+ extend: 'Traccar.view.GridPanel',
+ xtype: 'maintenancesView',
+
+ requires: [
+ 'Traccar.view.edit.MaintenancesController',
+ 'Traccar.view.edit.Toolbar'
+ ],
+
+ controller: 'maintenances',
+ store: 'Maintenances',
+
+ tbar: {
+ xtype: 'editToolbar'
+ },
+
+ listeners: {
+ selectionchange: 'onSelectionChange'
+ },
+
+ columns: {
+ defaults: {
+ flex: 1,
+ minWidth: Traccar.Style.columnWidthNormal
+ },
+ items: [{
+ text: Strings.sharedName,
+ dataIndex: 'name',
+ filter: 'string'
+ }, {
+ text: Strings.sharedType,
+ dataIndex: 'type',
+ filter: {
+ type: 'list',
+ idField: 'key',
+ labelField: 'name',
+ store: 'MaintenanceTypes'
+ },
+ renderer: function (value) {
+ var attribute = Ext.getStore('MaintenanceTypes').getById(value);
+ return attribute && attribute.get('name') ? attribute.get('name') : value;
+ }
+ }, {
+ text: Strings.maintenanceStart,
+ dataIndex: 'start',
+ renderer: function (value, metaData, record) {
+ return Traccar.AttributeFormatter.renderAttribute(
+ value, Ext.getStore('MaintenanceTypes').getById(record.get('type')));
+ }
+ }, {
+ text: Strings.maintenancePeriod,
+ dataIndex: 'period',
+ renderer: function (value, metaData, record) {
+ return Traccar.AttributeFormatter.renderAttribute(
+ value, Ext.getStore('MaintenanceTypes').getById(record.get('type')));
+ }
+ }]
+ }
+});
diff --git a/web/app/view/edit/MaintenancesController.js b/web/app/view/edit/MaintenancesController.js
new file mode 100644
index 0000000..19762e6
--- /dev/null
+++ b/web/app/view/edit/MaintenancesController.js
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.edit.MaintenancesController', {
+ extend: 'Traccar.view.edit.ToolbarController',
+ alias: 'controller.maintenances',
+
+ requires: [
+ 'Traccar.view.dialog.Maintenance',
+ 'Traccar.model.Maintenance'
+ ],
+
+ objectModel: 'Traccar.model.Maintenance',
+ objectDialog: 'Traccar.view.dialog.Maintenance',
+ removeTitle: Strings.sharedMaintenance
+});
diff --git a/web/app/view/edit/Users.js b/web/app/view/edit/Users.js
index b0a67ff..3629e82 100644
--- a/web/app/view/edit/Users.js
+++ b/web/app/view/edit/Users.js
@@ -1,6 +1,6 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
- * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -95,6 +95,14 @@ Ext.define('Traccar.view.edit.Users', {
glyph: 'xf093@FontAwesome',
tooltip: Strings.sharedSavedCommands,
tooltipType: 'title'
+ }, {
+ xtype: 'button',
+ disabled: true,
+ handler: 'onMaintenancesClick',
+ reference: 'userMaintenancesButton',
+ glyph: 'xf0ad@FontAwesome',
+ tooltip: Strings.sharedMaintenances,
+ tooltipType: 'title'
}]
},
diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js
index db82b4f..f3154b1 100644
--- a/web/app/view/edit/UsersController.js
+++ b/web/app/view/edit/UsersController.js
@@ -31,6 +31,7 @@ Ext.define('Traccar.view.edit.UsersController', {
'Traccar.view.permissions.Drivers',
'Traccar.view.permissions.SavedCommands',
'Traccar.view.permissions.Notifications',
+ 'Traccar.view.permissions.Maintenances',
'Traccar.view.BaseWindow',
'Traccar.model.User'
],
@@ -49,6 +50,8 @@ Ext.define('Traccar.view.edit.UsersController', {
this.lookupReference('userCalendarsButton').setHidden(
Traccar.app.getBooleanAttributePreference('ui.disableCalendars'));
this.lookupReference('userCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false));
+ this.lookupReference('userMaintenancesButton').setHidden(
+ Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableMaintenances'));
},
onEditClick: function () {
@@ -209,6 +212,21 @@ Ext.define('Traccar.view.edit.UsersController', {
}).show();
},
+ onMaintenancesClick: function () {
+ var user = this.getView().getSelectionModel().getSelection()[0];
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedMaintenances,
+ items: {
+ xtype: 'linkMaintenancesView',
+ baseObjectName: 'userId',
+ linkObjectName: 'maintenanceId',
+ storeName: 'AllMaintenances',
+ linkStoreName: 'Maintenances',
+ baseObject: user.getId()
+ }
+ }).show();
+ },
+
onSelectionChange: function (selection, selected) {
var disabled = selected.length === 0;
this.lookupReference('userDevicesButton').setDisabled(disabled);
@@ -219,6 +237,7 @@ Ext.define('Traccar.view.edit.UsersController', {
this.lookupReference('userAttributesButton').setDisabled(disabled);
this.lookupReference('userDriversButton').setDisabled(disabled);
this.lookupReference('userCommandsButton').setDisabled(disabled);
+ this.lookupReference('userMaintenancesButton').setDisabled(disabled);
this.lookupReference('userUsersButton').setDisabled(disabled || selected[0].get('userLimit') === 0);
this.callParent(arguments);
}