diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-12 17:39:43 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-13 13:51:35 +0500 |
commit | a5d36c62facad98c409b9fcd4f8b92c3d47601ab (patch) | |
tree | 368a2ed169c1457a1cc2dd69a811f2dccc59ce04 /web/app/view/edit | |
parent | 31a6fed66b4f077d2b6443fdd34229befe8777c3 (diff) | |
download | trackermap-web-a5d36c62facad98c409b9fcd4f8b92c3d47601ab.tar.gz trackermap-web-a5d36c62facad98c409b9fcd4f8b92c3d47601ab.tar.bz2 trackermap-web-a5d36c62facad98c409b9fcd4f8b92c3d47601ab.zip |
Implement Saved Commands
Diffstat (limited to 'web/app/view/edit')
-rw-r--r-- | web/app/view/edit/Devices.js | 41 | ||||
-rw-r--r-- | web/app/view/edit/DevicesController.js | 46 | ||||
-rw-r--r-- | web/app/view/edit/Groups.js | 8 | ||||
-rw-r--r-- | web/app/view/edit/GroupsController.js | 31 | ||||
-rw-r--r-- | web/app/view/edit/SavedCommands.js | 66 | ||||
-rw-r--r-- | web/app/view/edit/SavedCommandsController.js | 32 | ||||
-rw-r--r-- | web/app/view/edit/Users.js | 8 | ||||
-rw-r--r-- | web/app/view/edit/UsersController.js | 45 |
8 files changed, 212 insertions, 65 deletions
diff --git a/web/app/view/edit/Devices.js b/web/app/view/edit/Devices.js index 4fdcab00..5ec452b8 100644 --- a/web/app/view/edit/Devices.js +++ b/web/app/view/edit/Devices.js @@ -37,67 +37,54 @@ Ext.define('Traccar.view.edit.Devices', { tbar: { componentCls: 'toolbar-header-style', + defaults: { + xtype: 'button', + disabled: true, + tooltipType: 'title' + }, items: [{ xtype: 'tbtext', html: Strings.deviceTitle, baseCls: 'x-panel-header-title-default' }, { - xtype: 'tbfill' + xtype: 'tbfill', + disabled: false }, { - xtype: 'button', - disabled: true, handler: 'onAddClick', reference: 'toolbarAddButton', glyph: 'xf067@FontAwesome', - tooltip: Strings.sharedAdd, - tooltipType: 'title' + tooltip: Strings.sharedAdd }, { - xtype: 'button', - disabled: true, handler: 'onEditClick', reference: 'toolbarEditButton', glyph: 'xf040@FontAwesome', - tooltip: Strings.sharedEdit, - tooltipType: 'title' + tooltip: Strings.sharedEdit }, { - xtype: 'button', - disabled: true, handler: 'onRemoveClick', reference: 'toolbarRemoveButton', glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedRemove, - tooltipType: 'title' + tooltip: Strings.sharedRemove }, { - xtype: 'button', - disabled: true, handler: 'onGeofencesClick', reference: 'toolbarGeofencesButton', glyph: 'xf21d@FontAwesome', - tooltip: Strings.sharedGeofences, - tooltipType: 'title' + tooltip: Strings.sharedGeofences }, { - xtype: 'button', - disabled: true, handler: 'onAttributesClick', reference: 'toolbarAttributesButton', glyph: 'xf0ae@FontAwesome', - tooltip: Strings.sharedComputedAttributes, - tooltipType: 'title' + tooltip: Strings.sharedComputedAttributes }, { xtype: 'button', - disabled: true, handler: 'onDriversClick', reference: 'toolbarDriversButton', glyph: 'xf2c2@FontAwesome', - tooltip: Strings.sharedDrivers, - tooltipType: 'title' + tooltip: Strings.sharedDrivers }, { - disabled: true, handler: 'onCommandClick', reference: 'deviceCommandButton', glyph: 'xf093@FontAwesome', - tooltip: Strings.deviceCommand, - tooltipType: 'title' + tooltip: Strings.deviceCommand }] }, diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index df75b1d4..43bab228 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -20,11 +20,12 @@ Ext.define('Traccar.view.edit.DevicesController', { alias: 'controller.devices', requires: [ - 'Traccar.view.dialog.Command', + 'Traccar.view.dialog.SendCommand', 'Traccar.view.dialog.Device', - 'Traccar.view.permissions.DeviceGeofences', - 'Traccar.view.permissions.DeviceAttributes', - 'Traccar.view.permissions.DeviceDrivers', + 'Traccar.view.permissions.Geofences', + 'Traccar.view.permissions.ComputedAttributes', + 'Traccar.view.permissions.Drivers', + 'Traccar.view.permissions.SavedCommands', 'Traccar.view.BaseWindow', 'Traccar.model.Device', 'Traccar.model.Command' @@ -76,7 +77,7 @@ Ext.define('Traccar.view.edit.DevicesController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedGeofences, items: { - xtype: 'deviceGeofencesView', + xtype: 'linkGeofencesView', baseObjectName: 'deviceId', linkObjectName: 'geofenceId', storeName: 'Geofences', @@ -90,7 +91,7 @@ Ext.define('Traccar.view.edit.DevicesController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedComputedAttributes, items: { - xtype: 'deviceAttributesView', + xtype: 'linkComputedAttributesView', baseObjectName: 'deviceId', linkObjectName: 'attributeId', storeName: 'ComputedAttributes', @@ -104,7 +105,7 @@ Ext.define('Traccar.view.edit.DevicesController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedDrivers, items: { - xtype: 'deviceDriversView', + xtype: 'linkDriversView', baseObjectName: 'deviceId', linkObjectName: 'driverId', storeName: 'Drivers', @@ -114,22 +115,31 @@ Ext.define('Traccar.view.edit.DevicesController', { }, onCommandClick: function () { - var device, deviceId, command, dialog, typesStore, online; + var device, deviceId, dialog, typesStore, online, commandsStore; device = this.getView().getSelectionModel().getSelection()[0]; online = device.get('status') === 'online'; deviceId = device.get('id'); - command = Ext.create('Traccar.model.Command'); - command.set('deviceId', deviceId); - command.set('textChannel', !online); - - dialog = Ext.create('Traccar.view.dialog.Command'); - - typesStore = dialog.lookupReference('commandType').getStore(); - typesStore.getProxy().setExtraParam('deviceId', deviceId); + dialog = Ext.create('Traccar.view.dialog.SendCommand'); + dialog.deviceId = deviceId; + dialog.online = online; + + commandsStore = dialog.lookupReference('commandsComboBox').getStore(); + commandsStore.getProxy().setExtraParam('deviceId', deviceId); + commandsStore.removeAll(); + if (!Traccar.app.getPreference('limitCommands', false)) { + commandsStore.add({ + id: 0, + description: Strings.sharedNew, + textChannel: !online + }); + typesStore = dialog.lookupReference('commandType').getStore(); + typesStore.getProxy().setExtraParam('deviceId', deviceId); + } + commandsStore.load({ + addRecords: true + }); - dialog.down('form').loadRecord(command); - dialog.lookupReference('textChannelCheckBox').setDisabled(!online); dialog.show(); }, diff --git a/web/app/view/edit/Groups.js b/web/app/view/edit/Groups.js index deb797f1..05c5723d 100644 --- a/web/app/view/edit/Groups.js +++ b/web/app/view/edit/Groups.js @@ -57,6 +57,14 @@ Ext.define('Traccar.view.edit.Groups', { glyph: 'xf2c2@FontAwesome', tooltip: Strings.sharedDrivers, tooltipType: 'title' + }, { + xtype: 'button', + disabled: true, + handler: 'onCommandsClick', + reference: 'toolbarCommandsButton', + glyph: 'xf093@FontAwesome', + tooltip: Strings.sharedSavedCommands, + tooltipType: 'title' }] }, diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index be26cc93..872fea4a 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -21,9 +21,10 @@ Ext.define('Traccar.view.edit.GroupsController', { requires: [ 'Traccar.view.dialog.Group', - 'Traccar.view.permissions.GroupGeofences', - 'Traccar.view.permissions.GroupAttributes', - 'Traccar.view.permissions.GroupDrivers', + 'Traccar.view.permissions.Geofences', + 'Traccar.view.permissions.ComputedAttributes', + 'Traccar.view.permissions.Drivers', + 'Traccar.view.permissions.SavedCommands', 'Traccar.view.BaseWindow', 'Traccar.model.Group' ], @@ -37,6 +38,7 @@ Ext.define('Traccar.view.edit.GroupsController', { Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('toolbarAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + this.lookupReference('toolbarCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false)); }, onGeofencesClick: function () { @@ -46,7 +48,7 @@ Ext.define('Traccar.view.edit.GroupsController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedGeofences, items: { - xtype: 'groupGeofencesView', + xtype: 'linkGeofencesView', baseObjectName: 'groupId', linkObjectName: 'geofenceId', storeName: admin ? 'AllGeofences' : 'Geofences', @@ -62,7 +64,7 @@ Ext.define('Traccar.view.edit.GroupsController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedComputedAttributes, items: { - xtype: 'groupAttributesView', + xtype: 'linkComputedAttributesView', baseObjectName: 'groupId', linkObjectName: 'attributeId', storeName: admin ? 'AllComputedAttributes' : 'ComputedAttributes', @@ -78,7 +80,7 @@ Ext.define('Traccar.view.edit.GroupsController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedDrivers, items: { - xtype: 'groupDriversView', + xtype: 'linkDriversView', baseObjectName: 'groupId', linkObjectName: 'driverId', storeName: admin ? 'AllDrivers' : 'Drivers', @@ -87,11 +89,28 @@ Ext.define('Traccar.view.edit.GroupsController', { }).show(); }, + onCommandsClick: function () { + var admin, group; + admin = Traccar.app.getUser().get('admin'); + group = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedSavedCommands, + items: { + xtype: 'linkSavedCommandsView', + baseObjectName: 'groupId', + linkObjectName: 'commandId', + storeName: admin ? 'AllCommands' : 'Commands', + baseObject: group.getId() + } + }).show(); + }, + onSelectionChange: function (selection, selected) { var disabled = selected.length === 0; this.lookupReference('toolbarGeofencesButton').setDisabled(disabled); this.lookupReference('toolbarAttributesButton').setDisabled(disabled); this.lookupReference('toolbarDriversButton').setDisabled(disabled); + this.lookupReference('toolbarCommandsButton').setDisabled(disabled); this.callParent(arguments); } }); diff --git a/web/app/view/edit/SavedCommands.js b/web/app/view/edit/SavedCommands.js new file mode 100644 index 00000000..8f1f6b38 --- /dev/null +++ b/web/app/view/edit/SavedCommands.js @@ -0,0 +1,66 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 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.SavedCommands', { + extend: 'Ext.grid.Panel', + xtype: 'savedCommandsView', + + requires: [ + 'Ext.grid.filters.Filters', + 'Traccar.view.edit.SavedCommandsController', + 'Traccar.view.edit.Toolbar' + ], + + plugins: 'gridfilters', + + controller: 'savedCommands', + store: 'Commands', + + tbar: { + xtype: 'editToolbar' + }, + + listeners: { + selectionchange: 'onSelectionChange' + }, + + columns: { + defaults: { + flex: 1, + minWidth: Traccar.Style.columnWidthNormal + }, + items: [{ + text: Strings.sharedDescription, + dataIndex: 'description', + filter: 'string' + }, { + text: Strings.sharedType, + dataIndex: 'name', + filter: { + type: 'list', + idField: 'name', + labelField: 'name', + store: 'AllCommandTypes' + } + }, { + text: Strings.notificationSms, + dataIndex: 'textChannel', + filter: 'boolean' + }] + } +}); diff --git a/web/app/view/edit/SavedCommandsController.js b/web/app/view/edit/SavedCommandsController.js new file mode 100644 index 00000000..989aeabf --- /dev/null +++ b/web/app/view/edit/SavedCommandsController.js @@ -0,0 +1,32 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 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.SavedCommandsController', { + extend: 'Traccar.view.edit.ToolbarController', + alias: 'controller.savedCommands', + + requires: [ + 'Traccar.view.dialog.SavedCommand', + 'Traccar.model.Command' + ], + + objectModel: 'Traccar.model.Command', + objectDialog: 'Traccar.view.dialog.SavedCommand', + removeTitle: Strings.sharedSavedCommand + +}); diff --git a/web/app/view/edit/Users.js b/web/app/view/edit/Users.js index bb121be2..c77ba49b 100644 --- a/web/app/view/edit/Users.js +++ b/web/app/view/edit/Users.js @@ -90,6 +90,14 @@ Ext.define('Traccar.view.edit.Users', { glyph: 'xf2c2@FontAwesome', tooltip: Strings.sharedDrivers, tooltipType: 'title' + }, { + xtype: 'button', + disabled: true, + handler: 'onCommandsClick', + reference: 'userCommandsButton', + glyph: 'xf093@FontAwesome', + tooltip: Strings.sharedSavedCommands, + tooltipType: 'title' }] }, diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index 3bc7d1c4..f710ed24 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -22,13 +22,14 @@ Ext.define('Traccar.view.edit.UsersController', { requires: [ 'Traccar.view.dialog.User', - 'Traccar.view.permissions.UserDevices', - 'Traccar.view.permissions.UserGroups', - 'Traccar.view.permissions.UserGeofences', - 'Traccar.view.permissions.UserCalendars', - 'Traccar.view.permissions.UserUsers', - 'Traccar.view.permissions.UserAttributes', - 'Traccar.view.permissions.UserDrivers', + 'Traccar.view.permissions.Devices', + 'Traccar.view.permissions.Groups', + 'Traccar.view.permissions.Geofences', + 'Traccar.view.permissions.Calendars', + 'Traccar.view.permissions.Users', + 'Traccar.view.permissions.ComputedAttributes', + 'Traccar.view.permissions.Drivers', + 'Traccar.view.permissions.SavedCommands', 'Traccar.view.Notifications', 'Traccar.view.BaseWindow', 'Traccar.model.User' @@ -47,6 +48,7 @@ Ext.define('Traccar.view.edit.UsersController', { Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); this.lookupReference('userCalendarsButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + this.lookupReference('userCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false)); }, onEditClick: function () { @@ -78,7 +80,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.deviceTitle, items: { - xtype: 'userDevicesView', + xtype: 'linkDevicesView', baseObjectName: 'userId', linkObjectName: 'deviceId', storeName: 'AllDevices', @@ -93,7 +95,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.settingsGroups, items: { - xtype: 'userGroupsView', + xtype: 'linkGroupsView', baseObjectName: 'userId', linkObjectName: 'groupId', storeName: 'AllGroups', @@ -108,7 +110,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedGeofences, items: { - xtype: 'userGeofencesView', + xtype: 'linkGeofencesView', baseObjectName: 'userId', linkObjectName: 'geofenceId', storeName: 'AllGeofences', @@ -134,7 +136,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedCalendars, items: { - xtype: 'userCalendarsView', + xtype: 'linkCalendarsView', baseObjectName: 'userId', linkObjectName: 'calendarId', storeName: 'AllCalendars', @@ -149,7 +151,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.settingsUsers, items: { - xtype: 'userUsersView', + xtype: 'linkUsersView', baseObjectName: 'userId', linkObjectName: 'managedUserId', storeName: 'Users', @@ -163,7 +165,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedComputedAttributes, items: { - xtype: 'userAttributesView', + xtype: 'linkComputedAttributesView', baseObjectName: 'userId', linkObjectName: 'attributeId', storeName: 'AllComputedAttributes', @@ -178,7 +180,7 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedDrivers, items: { - xtype: 'userDriversView', + xtype: 'linkDriversView', baseObjectName: 'userId', linkObjectName: 'driverId', storeName: 'AllDrivers', @@ -188,6 +190,20 @@ Ext.define('Traccar.view.edit.UsersController', { }).show(); }, + onCommandsClick: function () { + var user = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedSavedCommands, + items: { + xtype: 'linkSavedCommandsView', + baseObjectName: 'userId', + linkObjectName: 'commandId', + storeName: 'AllCommands', + linkStoreName: 'Commands', + baseObject: user.getId() + } + }).show(); + }, onSelectionChange: function (selection, selected) { var disabled = selected.length === 0; @@ -198,6 +214,7 @@ Ext.define('Traccar.view.edit.UsersController', { this.lookupReference('userCalendarsButton').setDisabled(disabled); this.lookupReference('userAttributesButton').setDisabled(disabled); this.lookupReference('userDriversButton').setDisabled(disabled); + this.lookupReference('userCommandsButton').setDisabled(disabled); this.lookupReference('userUsersButton').setDisabled(disabled || selected[0].get('userLimit') === 0); this.callParent(arguments); } |