ru.coon 2.7.32 → 2.7.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/package.json +1 -1
  3. package/src/common/panel/MainUploadPanel.js +16 -1
  4. package/src/nav/AppNavigationMenu.js +2 -2
  5. package/src/nav/AppNavigationMenu.scss +11 -5
  6. package/src/nav/menu/WorkspaceMenuView.js +7 -0
  7. package/src/report/component/EXTJSReportUploadForm.js +1 -0
  8. package/src/report/component/ReportPanel.js +2 -0
  9. package/src/report/plugin/configPanel/CopyRowsFromGridConfigPanel.js +1 -0
  10. package/src/security/component/RoleAccessPanel.js +5 -1
  11. package/src/security/component/ui/UiCPRestrictionEditor.js +31 -8
  12. package/src/security/component/ui/UiCPRestrictionEditorController.js +53 -18
  13. package/src/security/component/url/UrlRestrictionEditor.js +55 -0
  14. package/src/security/component/url/UrlRestrictionEditorController.js +5 -0
  15. package/src/security/securitySettingComponent/RoleEditPanel.js +83 -0
  16. package/src/security/securitySettingComponent/RoleEditPanel.scss +17 -0
  17. package/src/security/securitySettingComponent/RoleEditPanelController.js +211 -0
  18. package/src/security/securitySettingComponent/RoleListPanel.js +35 -0
  19. package/src/security/securitySettingComponent/RoleListPanelController.js +240 -0
  20. package/src/security/securitySettingComponent/command/GitOpaDownloadCommand.js +33 -0
  21. package/src/security/securitySettingComponent/menu/RoleEditMenuController.js +171 -0
  22. package/src/security/securitySettingComponent/menu/RoleEditMenuPanel.js +72 -0
  23. package/src/security/securitySettingComponent/report/RoleEditReportController.js +111 -0
  24. package/src/security/securitySettingComponent/report/RoleEditReportPanel.js +88 -0
  25. package/src/security/securitySettingComponent/uiCP/RoleEditUiCPController.js +139 -0
  26. package/src/security/securitySettingComponent/uiCP/RoleEditUiCPPanel.js +88 -0
  27. package/src/security/securitySettingComponent/url/RoleEditUrlController.js +40 -0
  28. package/src/security/securitySettingComponent/url/RoleEditUrlPanel.js +53 -0
  29. package/src/security/securitySettingComponent/user/RoleEditUserController.js +61 -0
  30. package/src/security/securitySettingComponent/user/RoleEditUserPanel.js +49 -0
  31. package/src/uielement/component/EXTJSUiPanelUploadForm.js +1 -0
  32. package/src/uielement/component/formchips/FilterConditionToolbar.js +3 -6
  33. package/src/uielement/component/formchips/FilterConditionToolbarController.js +10 -1
  34. package/src/version.js +1 -1
@@ -0,0 +1,83 @@
1
+ Ext.define('Coon.security.securitySettingComponent.RoleEditPanel', {
2
+ extend: 'Ext.panel.Panel',
3
+ requires: [],
4
+
5
+ controller: 'RoleEditPanelController',
6
+ layout: {
7
+ type: 'vbox',
8
+ align: 'stretch',
9
+ },
10
+ dockedItems: [{
11
+ xtype: 'toolbar',
12
+ dock: 'bottom',
13
+ layout: {
14
+ type: 'hbox',
15
+ },
16
+ items: [
17
+ {
18
+ xtype: 'button',
19
+ text: 'Переименовать роль',
20
+ ui: 'green-button',
21
+ handler: 'changeRoleNameHandler',
22
+ },
23
+ {
24
+ xtype: 'button',
25
+ text: 'Копировать роль',
26
+ ui: 'green-button',
27
+ handler: 'copyRoleHandler',
28
+ },
29
+ {
30
+ xtype: 'button',
31
+ text: 'Удалить роль',
32
+ ui: 'green-button',
33
+ handler: 'deleteHandler',
34
+ },
35
+ '->',
36
+ {
37
+ xtype: 'button',
38
+ text: 'Сохранить',
39
+ ui: 'orange-button',
40
+ handler: 'save',
41
+ },
42
+ {
43
+ xtype: 'button',
44
+ text: 'Закрыть',
45
+ ui: 'green-button',
46
+ handler: 'closeHandler',
47
+ }
48
+ ],
49
+ }],
50
+ items: [
51
+ {
52
+ xtype: 'tabpanel',
53
+ flex: 1,
54
+ items: [
55
+ {
56
+ xtype: 'RoleEditMenuPanel',
57
+ title: 'Навигация (меню)',
58
+ reference: 'menuGrid',
59
+ },
60
+ {
61
+ xtype: 'RoleEditReportPanel',
62
+ title: 'Репорты',
63
+ reference: 'reportsGridPanel',
64
+ },
65
+ {
66
+ xtype: 'RoleEditUiCPPanel',
67
+ title: 'Кастомные панели',
68
+ reference: 'uiCPGridPanel',
69
+ },
70
+ {
71
+ xtype: 'RoleEditUrlPanel',
72
+ title: 'Url',
73
+ reference: 'urlGrid',
74
+ },
75
+ {
76
+ xtype: 'RoleEditUserPanel',
77
+ title: 'Пользователи',
78
+ reference: 'userNameGrid',
79
+ }
80
+ ],
81
+ }
82
+ ],
83
+ });
@@ -0,0 +1,17 @@
1
+ .RoleEditPanel {
2
+ .x-grid-item {
3
+ .checked-row {
4
+ background-color: #f7f7f8;
5
+ }
6
+ }
7
+ .x-grid-item {
8
+ .unchecked-row {
9
+ background-color: white;
10
+ }
11
+ }
12
+ .x-grid-row {
13
+ &:hover {
14
+ background-color: #ebecee;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,211 @@
1
+ Ext.define('Coon.security.securitySettingComponent.RoleEditPanelController', {
2
+ extend: 'Ext.app.ViewController',
3
+ requires: [
4
+ 'Coon.report.command.GetDynamicReportDataCommand'
5
+ ],
6
+
7
+ alias: 'controller.RoleEditPanelController',
8
+
9
+ paths: {
10
+ menuByRole: 'policy/menu_by_role/data.json',
11
+ reportPlugin: 'policy/report_plugin_by_role/data.json',
12
+ uiElement: 'policy/UI_ELEMENT/data.json',
13
+ urlPattern: 'policy/url_pattern/data.json',
14
+ roleByUser: 'policy/role_by_user/data.json',
15
+ },
16
+
17
+ init(view) {
18
+ this.view = view;
19
+ },
20
+
21
+ doInit(role, isNew) {
22
+ this.role = role;
23
+ this.view.setTitle(`Редактирование роли ${role}`);
24
+ if (isNew) {
25
+ this.lookup('menuGrid').getController().loadAllMenuData([], this.role);
26
+ } else {
27
+ this.getGitData().then(this.processGitData.bind(this)).finally(() => this.view.unmask()); ;
28
+ }
29
+ },
30
+
31
+ getGitData() {
32
+ this.view.mask('Загрузка');
33
+ const params = new URLSearchParams();
34
+ const pathsArray = Object.values(this.paths);
35
+ pathsArray.forEach((path) => params.append('paths', path));
36
+ return new Promise((resolve, reject) => {
37
+ Coon.Function.doRequest(null, {
38
+ url: 'git/opa/downloadBulk',
39
+ processError: true,
40
+ params: params,
41
+ callback: (a, b, res) => resolve(res.responseText),
42
+ failure: (a, b, res) => {
43
+ reject(new Error(res.responseJSON.message));
44
+ },
45
+ });
46
+ });
47
+ },
48
+
49
+ processGitData(data) {
50
+ const gitData = JSON.parse(data);
51
+ this.menuGitDataContent = JSON.parse(gitData.find((el) => el.path === this.paths['menuByRole']).content);
52
+ this.lookup('menuGrid').getController().loadAllMenuData(this.menuGitDataContent, this.role);
53
+ this.reportGitDataContent = JSON.parse(gitData.find((el) => el.path === this.paths['reportPlugin']).content);
54
+ this.lookup('reportsGridPanel').getController().loadReportData(this.reportGitDataContent, this.role);
55
+ this.uiCpGitDataContent = JSON.parse(gitData.find((el) => el.path === this.paths['uiElement']).content);
56
+ this.lookup('uiCPGridPanel').getController().loadUiCPData(this.uiCpGitDataContent, this.role);
57
+ this.urlGitDataContent = JSON.parse(gitData.find((el) => el.path === this.paths['urlPattern']).content);
58
+ this.lookup('urlGrid').getController().loadUrlData(this.urlGitDataContent, this.role);
59
+ this.userRoleGitDataContent = JSON.parse(gitData.find((el) => el.path === this.paths['roleByUser']).content);
60
+ this.lookup('userNameGrid').getController().loadUserData(this.userRoleGitDataContent, this.role);
61
+ },
62
+
63
+ save() {
64
+ this.saveHandler();
65
+ },
66
+
67
+ saveHandler(newRoleName, shouldDeleteCurrentRole) {
68
+ const dataToSave = [
69
+ {
70
+ path: this.paths['menuByRole'],
71
+ content: this.lookup('menuGrid').getController().getData(newRoleName, shouldDeleteCurrentRole),
72
+ },
73
+ {
74
+ path: this.paths['reportPlugin'],
75
+ content: this.lookup('reportsGridPanel').getController().getData(newRoleName, shouldDeleteCurrentRole),
76
+ },
77
+ {
78
+ path: this.paths['uiElement'],
79
+ content: this.lookup('uiCPGridPanel').getController().getData(newRoleName, shouldDeleteCurrentRole),
80
+ },
81
+ {
82
+ path: this.paths['urlPattern'],
83
+ content: this.lookup('urlGrid').getController().getData(newRoleName, shouldDeleteCurrentRole),
84
+ },
85
+ {
86
+ path: this.paths['roleByUser'],
87
+ content: this.lookup('userNameGrid').getController().getData(newRoleName, shouldDeleteCurrentRole),
88
+ }
89
+ ];
90
+ this.showCommitMessageWindow(dataToSave);
91
+ },
92
+
93
+ deleteHandler() {
94
+ this.saveHandler(undefined, true);
95
+ },
96
+
97
+ createWindow(title, fieldlabel, handler) {
98
+ return Ext.widget('WindowWrap', {
99
+ items:
100
+ {
101
+ xtype: 'form',
102
+ itemId: 'form',
103
+ padding: 10,
104
+ layout: 'anchor',
105
+ items: [
106
+ {
107
+ fieldLabel: fieldlabel,
108
+ name: 'valueField',
109
+ anchor: '100%',
110
+ xtype: 'textfield',
111
+ allowBlank: false,
112
+ maxLength: 100,
113
+ }
114
+ ],
115
+ },
116
+ height: 300,
117
+ width: 400,
118
+ maximizable: false,
119
+ dockedItems: [{
120
+ xtype: 'toolbar',
121
+ dock: 'bottom',
122
+ items: ['->',
123
+ {
124
+ xtype: 'button',
125
+ ui: 'orange-button',
126
+ text: 'Сохранить',
127
+ handler,
128
+ },
129
+ {
130
+ xtype: 'button',
131
+ ui: 'orange-button',
132
+ text: 'Отмена',
133
+ handler() {
134
+ this.up('window').close();
135
+ },
136
+ }
137
+ ],
138
+ }],
139
+ title: title,
140
+ });
141
+ },
142
+
143
+ showChangeRoleNameWindow(shouldDeleteCurrentRole) {
144
+ const handler = () => {
145
+ const role = form.getValues().valueField;
146
+ if (role && this.menuGitDataContent[role]) {
147
+ Ext.Msg.alert('Предупреждение', 'Роль с таким именем уже существует.');
148
+ return;
149
+ }
150
+ win.close();
151
+ this.saveHandler(role, shouldDeleteCurrentRole);
152
+ };
153
+ const win = this.createWindow('Изменения имени роли', 'Роль', handler);
154
+ const form = win.getComponent('form');
155
+ win.show();
156
+ },
157
+
158
+
159
+ showCommitMessageWindow(data) {
160
+ const handler = () => {
161
+ const commitMessage = form.getValues().valueField;
162
+ win.close();
163
+ this.view.mask('Сохранение');
164
+ this.commitAndPushData(data, commitMessage)
165
+ .then(() => {
166
+ this.view.unmask();
167
+ this.view.fireEvent('save');
168
+ this.closeHandler();
169
+ })
170
+ .catch((error) => {
171
+ this.view.unmask();
172
+ Ext.Msg.alert('Ошибка', error.message);
173
+ });
174
+ };
175
+ const win = this.createWindow('Commit Message', 'text', handler);
176
+ const form = win.getComponent('form');
177
+ win.show();
178
+ },
179
+
180
+ commitAndPushData(data, commitMessage) {
181
+ const bean = {
182
+ elementList: data,
183
+ commitMessage: commitMessage,
184
+ };
185
+ return new Promise((resolve, reject) => {
186
+ Coon.Function.doRequest(null, {
187
+ url: 'git/opa/uploadBulk',
188
+ processError: true,
189
+ jsonData: JSON.stringify(bean),
190
+ callback: (a, b, res) => resolve(res.responseText),
191
+ failure: (a, b, res) => {
192
+ this.view.unmask();
193
+ reject(new Error(res.responseJSON.message));
194
+ },
195
+ });
196
+ });
197
+ },
198
+
199
+ changeRoleNameHandler() {
200
+ this.showChangeRoleNameWindow(true);
201
+ },
202
+
203
+ copyRoleHandler() {
204
+ this.showChangeRoleNameWindow(false);
205
+ },
206
+
207
+ closeHandler() {
208
+ this.view.close();
209
+ },
210
+
211
+ });
@@ -0,0 +1,35 @@
1
+ Ext.define('Coon.security.securitySettingComponent.RoleListPanel', {
2
+ extend: 'Ext.grid.Panel',
3
+ requires: [],
4
+ viewModel: {},
5
+
6
+ xtype: 'RoleListPanel',
7
+
8
+ controller: 'RoleListPanelController',
9
+
10
+ tbar: [
11
+ {
12
+ iconCls: 'svg-icon svg-icon-update-arrows',
13
+ handler: 'loadRoleXml',
14
+ },
15
+ {
16
+ text: 'добавить роль',
17
+ handler: 'addRole',
18
+ },
19
+ {
20
+ text: 'редактировать роль',
21
+ handler: 'editRole',
22
+ }
23
+ ],
24
+ columns: [
25
+ {
26
+ dataIndex: 'role',
27
+ flex: true,
28
+ }
29
+ ],
30
+ store: {},
31
+
32
+ listeners: {
33
+ rowdblclick: 'editRole',
34
+ },
35
+ });
@@ -0,0 +1,240 @@
1
+ Ext.define('Coon.security.securitySettingComponent.RoleListPanelController', {
2
+ extend: 'Ext.app.ViewController',
3
+
4
+ requires: [
5
+ 'Coon.Function'
6
+ ],
7
+
8
+ alias: 'controller.RoleListPanelController',
9
+
10
+ cachedRecordId: 'componentOpaData',
11
+ paths: {
12
+ menuByRole: 'policy/menu_by_role/data.json',
13
+ },
14
+
15
+ init(view) {
16
+ this.view = view;
17
+ this.verify();
18
+ this.on('validated', this.loadRoleXml, this);
19
+ },
20
+
21
+ verify() {
22
+ this.validate()
23
+ .then(() => {
24
+ this.isValid = true;
25
+ })
26
+ .catch((e) => {
27
+ this.isValid = false;
28
+ Ext.Msg.alert('Ошибка', e);
29
+ });
30
+ },
31
+
32
+ validate() {
33
+ const data = this.getCached();
34
+ const me = this;
35
+ return new Promise((resolve, reject) => {
36
+ if (data) {
37
+ Coon.Function.doRequest(null, {
38
+ url: 'personification/personify',
39
+ processError: true,
40
+ params: {
41
+ token: data,
42
+ },
43
+ callback(win, res, resp) {
44
+ me.fireEvent('validated');
45
+ resolve(resp.status === 200);
46
+ },
47
+ failure(_, __, res) {
48
+ me.clearCache();
49
+ me.verify();
50
+ reject(new Error(res.responseJSON.message));
51
+ },
52
+ });
53
+ } else {
54
+ this.generateToken();
55
+ }
56
+ });
57
+ },
58
+
59
+ loadRoleXml() {
60
+ if (!this.isValid) {
61
+ this.verify();
62
+ } else {
63
+ this.view.mask();
64
+ return Coon.util.promisifyCmd('command.GitOpaDownloadCommand', this.paths['menuByRole'])
65
+ .then((data) => {
66
+ const roles = Object.keys(data).map((role) => {
67
+ return {'role': role};
68
+ });
69
+ this.view.unmask();
70
+ this.view.getStore().loadData(roles);
71
+ })
72
+ .catch((e) => {
73
+ this.view.unmask();
74
+ Ext.Msg.show({
75
+ title: 'Ошибка',
76
+ message: `${e.message}<br>Сгенерировать токен повторно?`,
77
+ buttons: Ext.Msg.OKCANCEL,
78
+ fn: (btn) => {
79
+ if (btn === 'ok') {
80
+ this.clearCache();
81
+ this.verify();
82
+ }
83
+ },
84
+ });
85
+ });
86
+ }
87
+ },
88
+
89
+ generateToken() {
90
+ const me = this;
91
+ const generateJwt = (gitToken, email) => {
92
+ return new Promise((resolve, reject) => {
93
+ Coon.Function.doRequest(null, {
94
+ url: 'git/opa/generateToken',
95
+ params: {gitToken, email},
96
+ callback: (a, b, res) => resolve(res.responseText),
97
+ failure: () => {
98
+ reject(new Error('Token generation error.'));
99
+ },
100
+ });
101
+ });
102
+ };
103
+ const handler = () => {
104
+ const form = win.getComponent('form');
105
+ const gitToken = form.getValues().gitToken;
106
+ const email = form.getValues().email;
107
+ generateJwt(gitToken, email).then((data) => {
108
+ me.cacheToken(data);
109
+ this.validate()
110
+ .then(() => {
111
+ this.isVerified = true;
112
+ })
113
+ .catch((e) => {
114
+ Ext.Msg.alert('Ошибка', e.message);
115
+ this.generateToken();
116
+ });
117
+ win.close();
118
+ });
119
+ };
120
+ const items = [
121
+ {
122
+ fieldLabel: 'gitToken',
123
+ name: 'gitToken',
124
+ anchor: '100%',
125
+ xtype: 'textfield',
126
+ allowBlank: false,
127
+ maxLength: 100,
128
+ },
129
+ {
130
+ fieldLabel: 'email',
131
+ name: 'email',
132
+ anchor: '100%',
133
+ xtype: 'EmailField',
134
+ allowBlank: false,
135
+ maxLength: 100,
136
+ }
137
+ ];
138
+ const win = this.createWindow('Генерация jwt токена', items, handler);
139
+ win.show();
140
+ },
141
+
142
+ cacheToken(data) {
143
+ localStorage.setItem(this.cachedRecordId, Ext.encode(data));
144
+ },
145
+
146
+ getCached() {
147
+ const cachedData = localStorage.getItem(this.cachedRecordId);
148
+ return cachedData && Ext.decode(cachedData, true);
149
+ },
150
+
151
+ clearCache() {
152
+ localStorage.removeItem(this.cachedRecordId);
153
+ },
154
+
155
+ addRole() {
156
+ const handler = () => {
157
+ const role = form.getValues()['roleField'];
158
+ this.getView().getStore().add({
159
+ isNew: true,
160
+ role: role,
161
+ });
162
+ win.close();
163
+ };
164
+ const items = [
165
+ {
166
+ fieldLabel: 'Роль',
167
+ name: 'roleField',
168
+ anchor: '100%',
169
+ xtype: 'textfield',
170
+ allowBlank: false,
171
+ maxLength: 100,
172
+ }
173
+ ];
174
+ const win = this.createWindow('Создание роли', items, handler);
175
+ const form = win.getComponent('form');
176
+ win.show();
177
+ },
178
+
179
+ editRole() {
180
+ const selection = this.view.selection;
181
+ if (!selection) {
182
+ return;
183
+ }
184
+ const role = selection.get('role');
185
+ const isNew = selection.get('isNew');
186
+ const roleEditPanel = Ext.create('Coon.security.securitySettingComponent.RoleEditPanel', {});
187
+ const win = Ext.widget('WindowWrap', {
188
+ maximized: true,
189
+ maximizable: false,
190
+ items: roleEditPanel,
191
+ });
192
+ roleEditPanel.on('save', this.loadRoleXml, this);
193
+ win.show();
194
+ roleEditPanel.getController().doInit(role, isNew);
195
+ },
196
+
197
+ createWindow(title, items, handler) {
198
+ return Ext.widget('WindowWrap', {
199
+ items:
200
+ {
201
+ xtype: 'form',
202
+ itemId: 'form',
203
+ padding: 10,
204
+ layout: 'anchor',
205
+ keyMapEnabled: true,
206
+ keyMap: {
207
+ Enter: {
208
+ handler,
209
+ },
210
+ },
211
+ items: items,
212
+ },
213
+ height: 300,
214
+ width: 400,
215
+ maximizable: false,
216
+ dockedItems: [{
217
+ xtype: 'toolbar',
218
+ dock: 'bottom',
219
+ items: ['->',
220
+ {
221
+ xtype: 'button',
222
+ ui: 'orange-button',
223
+ text: 'Сохранить',
224
+ handler,
225
+ },
226
+ {
227
+ xtype: 'button',
228
+ ui: 'orange-button',
229
+ text: 'Отмена',
230
+ handler() {
231
+ this.up('window').close();
232
+ },
233
+ }
234
+ ],
235
+ }],
236
+ title: title,
237
+ });
238
+ },
239
+
240
+ });
@@ -0,0 +1,33 @@
1
+ Ext.define('Coon.security.securitySettingComponent.command.GitOpaDownloadCommand', {
2
+ extend: 'Coon.command.ASyncBaseCommand',
3
+ alias: 'command.GitOpaDownloadCommand',
4
+ requires: [],
5
+ uses: [],
6
+ url: 'git/opa/download',
7
+ maskText: 'Загрузка....',
8
+
9
+ execute: function(path, branch, commitId) {
10
+ const inputData = {
11
+ path: path,
12
+ branch: branch,
13
+ commitId: commitId,
14
+ };
15
+ const data = Object.entries(inputData).reduce((acc, [name, val]) => {
16
+ if (val) {
17
+ acc[name] = val;
18
+ }
19
+ return acc;
20
+ }, {});
21
+ this.callParent([data]);
22
+ },
23
+
24
+ description: 'Получение содержимого файла',
25
+
26
+ inputParameters: function() {
27
+ return [
28
+ {name: 'path'},
29
+ {name: 'branch'},
30
+ {name: 'commitId'}
31
+ ];
32
+ },
33
+ });