From b392a4af78e01c8e0f50aad5468e9583675b24be Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Apr 2024 09:17:52 -0700 Subject: Move to the legacy folder --- legacy/web/app/view/permissions/Base.js | 37 ++++++++++ legacy/web/app/view/permissions/BaseController.js | 84 ++++++++++++++++++++++ legacy/web/app/view/permissions/Calendars.js | 32 +++++++++ .../web/app/view/permissions/ComputedAttributes.js | 45 ++++++++++++ legacy/web/app/view/permissions/Devices.js | 82 +++++++++++++++++++++ legacy/web/app/view/permissions/Drivers.js | 38 ++++++++++ legacy/web/app/view/permissions/Geofences.js | 43 +++++++++++ legacy/web/app/view/permissions/Groups.js | 47 ++++++++++++ legacy/web/app/view/permissions/Maintenances.js | 65 +++++++++++++++++ legacy/web/app/view/permissions/Notifications.js | 78 ++++++++++++++++++++ legacy/web/app/view/permissions/SavedCommands.js | 50 +++++++++++++ legacy/web/app/view/permissions/Users.js | 32 +++++++++ 12 files changed, 633 insertions(+) create mode 100644 legacy/web/app/view/permissions/Base.js create mode 100644 legacy/web/app/view/permissions/BaseController.js create mode 100644 legacy/web/app/view/permissions/Calendars.js create mode 100644 legacy/web/app/view/permissions/ComputedAttributes.js create mode 100644 legacy/web/app/view/permissions/Devices.js create mode 100644 legacy/web/app/view/permissions/Drivers.js create mode 100644 legacy/web/app/view/permissions/Geofences.js create mode 100644 legacy/web/app/view/permissions/Groups.js create mode 100644 legacy/web/app/view/permissions/Maintenances.js create mode 100644 legacy/web/app/view/permissions/Notifications.js create mode 100644 legacy/web/app/view/permissions/SavedCommands.js create mode 100644 legacy/web/app/view/permissions/Users.js (limited to 'legacy/web/app/view/permissions') diff --git a/legacy/web/app/view/permissions/Base.js b/legacy/web/app/view/permissions/Base.js new file mode 100644 index 00000000..57017531 --- /dev/null +++ b/legacy/web/app/view/permissions/Base.js @@ -0,0 +1,37 @@ +/* + * 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 . + */ +Ext.define('Traccar.view.permissions.Base', { + extend: 'Traccar.view.GridPanel', + + requires: [ + 'Traccar.view.permissions.BaseController' + ], + + controller: 'base', + + selModel: { + selType: 'checkboxmodel', + checkOnly: true, + showHeaderCheckbox: false + }, + + listeners: { + beforedeselect: 'onBeforeDeselect', + beforeselect: 'onBeforeSelect' + } +}); diff --git a/legacy/web/app/view/permissions/BaseController.js b/legacy/web/app/view/permissions/BaseController.js new file mode 100644 index 00000000..5cb9c302 --- /dev/null +++ b/legacy/web/app/view/permissions/BaseController.js @@ -0,0 +1,84 @@ +/* + * Copyright 2016 - 2017 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 + * 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 . + */ + +Ext.define('Traccar.view.permissions.BaseController', { + extend: 'Ext.app.ViewController', + alias: 'controller.base', + + init: function () { + var params = {}, linkStoreName, storeName; + params[this.getView().baseObjectName] = this.getView().baseObject; + linkStoreName = this.getView().linkStoreName; + storeName = this.getView().storeName; + linkStoreName = typeof linkStoreName === 'undefined' ? storeName : linkStoreName; + this.getView().setStore(Ext.getStore(storeName)); + this.getView().getStore().load({ + scope: this, + callback: function () { + var linkStore = Ext.create('Traccar.store.' + linkStoreName); + linkStore.load({ + params: params, + scope: this, + callback: function (records, operation, success) { + var i, index; + if (success) { + for (i = 0; i < records.length; i++) { + index = this.getView().getStore().getById(records[i].getId()); + this.getView().getSelectionModel().select(index, true, true); + } + } + } + }); + } + }); + }, + + onBeforeSelect: function (selection, record) { + var data = {}; + data[this.getView().baseObjectName] = this.getView().baseObject; + data[this.getView().linkObjectName] = record.getId(); + Ext.Ajax.request({ + scope: this, + url: 'api/permissions', + jsonData: Ext.util.JSON.encode(data), + callback: function (options, success, response) { + if (!success) { + selection.deselect(record, true); + Traccar.app.showError(response); + } + } + }); + }, + + onBeforeDeselect: function (selection, record) { + var data = {}; + data[this.getView().baseObjectName] = this.getView().baseObject; + data[this.getView().linkObjectName] = record.getId(); + Ext.Ajax.request({ + scope: this, + method: 'DELETE', + url: 'api/permissions', + jsonData: Ext.util.JSON.encode(data), + callback: function (options, success, response) { + if (!success) { + selection.select(record, true, true); + Traccar.app.showError(response); + } + } + }); + } +}); diff --git a/legacy/web/app/view/permissions/Calendars.js b/legacy/web/app/view/permissions/Calendars.js new file mode 100644 index 00000000..3d08efca --- /dev/null +++ b/legacy/web/app/view/permissions/Calendars.js @@ -0,0 +1,32 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 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 . + */ + +Ext.define('Traccar.view.permissions.Calendars', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkCalendarsView', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); diff --git a/legacy/web/app/view/permissions/ComputedAttributes.js b/legacy/web/app/view/permissions/ComputedAttributes.js new file mode 100644 index 00000000..19af72ad --- /dev/null +++ b/legacy/web/app/view/permissions/ComputedAttributes.js @@ -0,0 +1,45 @@ +/* + * 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 . + */ + +Ext.define('Traccar.view.permissions.ComputedAttributes', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkComputedAttributesView', + + columns: { + items: [{ + text: Strings.sharedDescription, + dataIndex: 'description', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.sharedAttribute, + dataIndex: 'attribute', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: { + type: 'list', + labelField: 'name', + store: 'PositionAttributes' + }, + renderer: function (value) { + return Ext.getStore('PositionAttributes').getAttributeName(value); + } + }] + } +}); diff --git a/legacy/web/app/view/permissions/Devices.js b/legacy/web/app/view/permissions/Devices.js new file mode 100644 index 00000000..3180b107 --- /dev/null +++ b/legacy/web/app/view/permissions/Devices.js @@ -0,0 +1,82 @@ +/* + * Copyright 2015 - 2017 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 + * 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 . + */ + +Ext.define('Traccar.view.permissions.Devices', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkDevicesView', + + requires: [ + 'Traccar.AttributeFormatter' + ], + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.sharedPhone, + dataIndex: 'phone', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: 'string' + }, { + text: Strings.deviceModel, + dataIndex: 'model', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: 'string' + }, { + text: Strings.deviceContact, + dataIndex: 'contact', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: 'string' + }, { + text: Strings.sharedDisabled, + dataIndex: 'disabled', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + renderer: Traccar.AttributeFormatter.getFormatter('disabled'), + hidden: true, + filter: 'boolean' + }, { + text: Strings.groupDialog, + dataIndex: 'groupId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: { + type: 'list', + labelField: 'name', + store: 'AllGroups' + }, + renderer: Traccar.AttributeFormatter.getFormatter('groupId') + }] + } +}); diff --git a/legacy/web/app/view/permissions/Drivers.js b/legacy/web/app/view/permissions/Drivers.js new file mode 100644 index 00000000..33cf2f76 --- /dev/null +++ b/legacy/web/app/view/permissions/Drivers.js @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +Ext.define('Traccar.view.permissions.Drivers', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkDriversView', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); diff --git a/legacy/web/app/view/permissions/Geofences.js b/legacy/web/app/view/permissions/Geofences.js new file mode 100644 index 00000000..e2e85a36 --- /dev/null +++ b/legacy/web/app/view/permissions/Geofences.js @@ -0,0 +1,43 @@ +/* + * 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 + * 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 . + */ + +Ext.define('Traccar.view.permissions.Geofences', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkGeofencesView', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.sharedCalendar, + dataIndex: 'calendarId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: { + type: 'list', + labelField: 'name', + store: 'AllCalendars' + }, + renderer: Traccar.AttributeFormatter.getFormatter('calendarId') + }] + } +}); diff --git a/legacy/web/app/view/permissions/Groups.js b/legacy/web/app/view/permissions/Groups.js new file mode 100644 index 00000000..91a639c0 --- /dev/null +++ b/legacy/web/app/view/permissions/Groups.js @@ -0,0 +1,47 @@ +/* + * Copyright 2016 - 2017 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 + * 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 . + */ + +Ext.define('Traccar.view.permissions.Groups', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkGroupsView', + + requires: [ + 'Traccar.AttributeFormatter' + ], + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.groupDialog, + dataIndex: 'groupId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: { + type: 'list', + labelField: 'name', + store: 'AllGroups' + }, + renderer: Traccar.AttributeFormatter.getFormatter('groupId') + }] + } +}); diff --git a/legacy/web/app/view/permissions/Maintenances.js b/legacy/web/app/view/permissions/Maintenances.js new file mode 100644 index 00000000..c5255769 --- /dev/null +++ b/legacy/web/app/view/permissions/Maintenances.js @@ -0,0 +1,65 @@ +/* + * 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 . + */ + +Ext.define('Traccar.view.permissions.Maintenances', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkMaintenancesView', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.sharedType, + dataIndex: 'type', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: { + type: 'list', + idField: 'key', + labelField: 'name', + store: 'MaintenanceTypes' + }, + renderer: function (value) { + var attribute = Ext.getStore('MaintenanceTypes').getById(value); + return attribute && attribute.get('name') || value; + } + }, { + text: Strings.maintenanceStart, + dataIndex: 'start', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + renderer: function (value, metaData, record) { + return Traccar.AttributeFormatter.renderAttribute( + value, Ext.getStore('MaintenanceTypes').getById(record.get('type'))); + } + }, { + text: Strings.maintenancePeriod, + dataIndex: 'period', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + renderer: function (value, metaData, record) { + return Traccar.AttributeFormatter.renderAttribute( + value, Ext.getStore('MaintenanceTypes').getById(record.get('type'))); + } + }] + } +}); diff --git a/legacy/web/app/view/permissions/Notifications.js b/legacy/web/app/view/permissions/Notifications.js new file mode 100644 index 00000000..a8570fea --- /dev/null +++ b/legacy/web/app/view/permissions/Notifications.js @@ -0,0 +1,78 @@ +/* + * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 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 . + */ + +Ext.define('Traccar.view.permissions.Notifications', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkNotificationsView', + + columns: { + items: [{ + text: Strings.notificationType, + dataIndex: 'type', + flex: 2, + renderer: function (value) { + return Traccar.app.getEventString(value); + }, + filter: { + type: 'list', + idField: 'type', + labelField: 'name', + store: 'AllNotificationTypes' + } + }, { + text: Strings.notificationAlways, + dataIndex: 'always', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + renderer: Traccar.AttributeFormatter.getFormatter('always'), + filter: 'boolean' + }, { + text: Strings.notificationNotificators, + dataIndex: 'notificators', + flex: 2, + filter: { + type: 'arraylist', + idField: 'type', + labelField: 'name', + store: 'AllNotificators' + }, + renderer: function (value) { + var result = '', i, notificators; + if (value) { + notificators = value.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < notificators.length; i++) { + result += Traccar.app.getNotificatorString(notificators[i]) + (i < notificators.length - 1 ? ', ' : ''); + } + } + return result; + } + }, { + text: Strings.sharedCalendar, + dataIndex: 'calendarId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + hidden: true, + filter: { + type: 'list', + labelField: 'name', + store: 'AllCalendars' + }, + renderer: Traccar.AttributeFormatter.getFormatter('calendarId') + }] + } +}); diff --git a/legacy/web/app/view/permissions/SavedCommands.js b/legacy/web/app/view/permissions/SavedCommands.js new file mode 100644 index 00000000..b57c07a0 --- /dev/null +++ b/legacy/web/app/view/permissions/SavedCommands.js @@ -0,0 +1,50 @@ +/* + * 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 . + */ + +Ext.define('Traccar.view.permissions.SavedCommands', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkSavedCommandsView', + + columns: { + items: [{ + text: Strings.sharedDescription, + dataIndex: 'description', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.sharedType, + dataIndex: 'type', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: { + type: 'list', + idField: 'type', + labelField: 'name', + store: 'AllCommandTypes' + }, + renderer: Traccar.AttributeFormatter.getFormatter('commandType') + }, { + text: Strings.commandSendSms, + dataIndex: 'textChannel', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'boolean' + }] + } +}); diff --git a/legacy/web/app/view/permissions/Users.js b/legacy/web/app/view/permissions/Users.js new file mode 100644 index 00000000..66cf5d62 --- /dev/null +++ b/legacy/web/app/view/permissions/Users.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 . + */ + +Ext.define('Traccar.view.permissions.Users', { + extend: 'Traccar.view.permissions.Base', + xtype: 'linkUsersView', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); -- cgit v1.2.3