@kuzntsv/uikit 1.0.25 → 1.0.27
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.
- package/fesm2022/kuzntsv-uikit-interceptors.mjs +75 -186
- package/fesm2022/kuzntsv-uikit-interceptors.mjs.map +1 -1
- package/fesm2022/kuzntsv-uikit-ui.mjs +4897 -2028
- package/fesm2022/kuzntsv-uikit-ui.mjs.map +1 -1
- package/fesm2022/kuzntsv-uikit.mjs +288 -304
- package/fesm2022/kuzntsv-uikit.mjs.map +1 -1
- package/package.json +3 -2
- package/types/kuzntsv-uikit-interceptors.d.ts +6 -11
- package/types/kuzntsv-uikit-ui.d.ts +1238 -904
- package/types/kuzntsv-uikit.d.ts +165 -180
|
@@ -1,310 +1,294 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { HttpContextToken, HttpHeaders,
|
|
4
|
-
import { Subject,
|
|
5
|
-
import { Router } from
|
|
6
|
-
import { takeUntilDestroyed } from
|
|
7
|
-
import { MatSnackBar } from
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* Специальный маркер-роль в массиве ограничений,
|
|
13
|
-
* который полностью скрывает элемент от обычных пользователей.
|
|
14
|
-
*/
|
|
15
|
-
const HIDE_ROLE_MARKER = 'HIDE';
|
|
16
|
-
/**
|
|
17
|
-
* Системная роль Администратора, которая игнорирует любые ограничения прав.
|
|
18
|
-
*/
|
|
19
|
-
const ADMIN_ROLE = 'ADMIN';
|
|
20
|
-
|
|
21
|
-
// Токен, в который мы будем передавать строку-идентификатор нужного API
|
|
22
|
-
// По умолчанию пустая строка означает "использовать дефолтное (основное) API"
|
|
23
|
-
const API_NAME = new HttpContextToken(() => '');
|
|
24
|
-
// Иногда внутри сервиса нужно сделать один специфический запрос (например, стянуть публичный JSON-файл конфигурации), не добавляя его глобально в publicUrls.
|
|
25
|
-
// Используя подход с HttpContext, мы можем добавить в библиотеку маркер пропуска авторизации:
|
|
26
|
-
// А в коде приложения вызывать так:
|
|
27
|
-
// this.http.get('/assets/config.json', {
|
|
28
|
-
// context: new HttpContext().set(BYPASS_AUTH, true)
|
|
29
|
-
// });
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { DestroyRef, Injectable, InjectionToken, inject, signal } from "@angular/core";
|
|
3
|
+
import { HttpClient, HttpContextToken, HttpHeaders, HttpParams } from "@angular/common/http";
|
|
4
|
+
import { Subject, catchError, tap, throwError } from "rxjs";
|
|
5
|
+
import { Router } from "@angular/router";
|
|
6
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
7
|
+
import { MatSnackBar } from "@angular/material/snack-bar";
|
|
8
|
+
const UIKIT_CONFIG = new InjectionToken("UIKIT_CONFIG");
|
|
9
|
+
const HIDE_ROLE_MARKER = "HIDE";
|
|
10
|
+
const ADMIN_ROLE = "ADMIN";
|
|
11
|
+
const API_NAME = new HttpContextToken(() => "");
|
|
30
12
|
const BYPASS_AUTH = new HttpContextToken(() => false);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
factory: () => 10000 // Запасной дефолт (10 сек), если в appConfig ничего не указали
|
|
13
|
+
const DEFAULT_TIMEOUT = new InjectionToken("DEFAULT_TIMEOUT", {
|
|
14
|
+
providedIn: "root",
|
|
15
|
+
factory: () => 1e4
|
|
35
16
|
});
|
|
36
|
-
// Если для каких-то тяжелых запросов (например, загрузка больших файлов или генерация отчетов)
|
|
37
|
-
// вам нужно увеличить таймаут, вы можете передавать его значение прямо в запросе через HttpContext.
|
|
38
17
|
const REQUEST_TIMEOUT = new HttpContextToken(() => inject(DEFAULT_TIMEOUT));
|
|
39
|
-
|
|
40
|
-
;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Проверяет, пересекаются ли два массива (есть ли хотя бы один общий элемент).
|
|
221
|
-
*/
|
|
18
|
+
const APP_ENVIRONMENT = new InjectionToken("ApplicationEnvironment");
|
|
19
|
+
const UIKIT_NOTIFICATION_TOKEN = new InjectionToken("UikitNotificationToken");
|
|
20
|
+
var AuthEventService = class AuthEventService {
|
|
21
|
+
authErrorSource = new Subject();
|
|
22
|
+
authError$ = this.authErrorSource.asObservable();
|
|
23
|
+
notify401() {
|
|
24
|
+
this.authErrorSource.next();
|
|
25
|
+
}
|
|
26
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
27
|
+
minVersion: "12.0.0",
|
|
28
|
+
version: "22.2.2",
|
|
29
|
+
ngImport: i0,
|
|
30
|
+
type: AuthEventService,
|
|
31
|
+
deps: [],
|
|
32
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
33
|
+
});
|
|
34
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
35
|
+
minVersion: "12.0.0",
|
|
36
|
+
version: "22.2.2",
|
|
37
|
+
ngImport: i0,
|
|
38
|
+
type: AuthEventService,
|
|
39
|
+
providedIn: "root"
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
43
|
+
minVersion: "12.0.0",
|
|
44
|
+
version: "22.2.2",
|
|
45
|
+
ngImport: i0,
|
|
46
|
+
type: AuthEventService,
|
|
47
|
+
decorators: [{
|
|
48
|
+
type: Injectable,
|
|
49
|
+
args: [{ providedIn: "root" }]
|
|
50
|
+
}]
|
|
51
|
+
});
|
|
52
|
+
var User = class {
|
|
53
|
+
id = 0;
|
|
54
|
+
username = "";
|
|
55
|
+
firstName = "";
|
|
56
|
+
lastName = "";
|
|
57
|
+
prof = "";
|
|
58
|
+
depart = 0;
|
|
59
|
+
area = "";
|
|
60
|
+
tabnum = "";
|
|
61
|
+
mail = "";
|
|
62
|
+
phone = "";
|
|
63
|
+
roles = "";
|
|
64
|
+
rolesArray = [];
|
|
65
|
+
roleList = [];
|
|
66
|
+
idHuman = "";
|
|
67
|
+
token = "";
|
|
68
|
+
expires_in = 0;
|
|
69
|
+
};
|
|
70
|
+
var UserService = class UserService {
|
|
71
|
+
user;
|
|
72
|
+
config = inject(UIKIT_CONFIG);
|
|
73
|
+
constructor() {
|
|
74
|
+
const saved = localStorage.getItem(this.config.auth.userStorageKey);
|
|
75
|
+
this.user = saved ? JSON.parse(saved) : new User();
|
|
76
|
+
}
|
|
77
|
+
get dept() {
|
|
78
|
+
return this.user?.depart;
|
|
79
|
+
}
|
|
80
|
+
get userData() {
|
|
81
|
+
return this.user;
|
|
82
|
+
}
|
|
83
|
+
set userData(user) {
|
|
84
|
+
this.user = user;
|
|
85
|
+
localStorage.setItem(this.config.auth.userStorageKey, JSON.stringify(user));
|
|
86
|
+
}
|
|
87
|
+
removeUser() {
|
|
88
|
+
localStorage.removeItem(this.config.auth.userStorageKey);
|
|
89
|
+
}
|
|
90
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
91
|
+
minVersion: "12.0.0",
|
|
92
|
+
version: "22.2.2",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: UserService,
|
|
95
|
+
deps: [],
|
|
96
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
97
|
+
});
|
|
98
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
99
|
+
minVersion: "12.0.0",
|
|
100
|
+
version: "22.2.2",
|
|
101
|
+
ngImport: i0,
|
|
102
|
+
type: UserService,
|
|
103
|
+
providedIn: "root"
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
107
|
+
minVersion: "12.0.0",
|
|
108
|
+
version: "22.2.2",
|
|
109
|
+
ngImport: i0,
|
|
110
|
+
type: UserService,
|
|
111
|
+
decorators: [{
|
|
112
|
+
type: Injectable,
|
|
113
|
+
args: [{ providedIn: "root" }]
|
|
114
|
+
}],
|
|
115
|
+
ctorParameters: () => []
|
|
116
|
+
});
|
|
117
|
+
var AuthService = class AuthService {
|
|
118
|
+
_roles = signal([], ...ngDevMode ? [{ debugName: "_roles" }] : /* istanbul ignore next */ []);
|
|
119
|
+
_loggedIn = signal(false, ...ngDevMode ? [{ debugName: "_loggedIn" }] : /* istanbul ignore next */ []);
|
|
120
|
+
roles = this._roles.asReadonly();
|
|
121
|
+
loggedIn = this._loggedIn.asReadonly();
|
|
122
|
+
defaultOptions = { headers: new HttpHeaders().set("content-type", "application/x-www-form-urlencoded") };
|
|
123
|
+
notificationService = inject(UIKIT_NOTIFICATION_TOKEN);
|
|
124
|
+
userService = inject(UserService);
|
|
125
|
+
eventService = inject(AuthEventService);
|
|
126
|
+
destroyRef = inject(DestroyRef);
|
|
127
|
+
http = inject(HttpClient);
|
|
128
|
+
config = inject(UIKIT_CONFIG);
|
|
129
|
+
router = inject(Router, { optional: true });
|
|
130
|
+
constructor() {
|
|
131
|
+
const initialUser = this.userService.userData;
|
|
132
|
+
if (initialUser?.token) {
|
|
133
|
+
this._loggedIn.set(true);
|
|
134
|
+
this._roles.set(initialUser.roleList ?? []);
|
|
135
|
+
}
|
|
136
|
+
this.eventService.authError$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.logout());
|
|
137
|
+
}
|
|
138
|
+
login(username, password, idCas) {
|
|
139
|
+
let params = new HttpParams().set("username", username).set("password", password);
|
|
140
|
+
if (idCas) params = params.set("idcas", idCas.toString());
|
|
141
|
+
const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
|
|
142
|
+
return this.http.post(url, params.toString(), this.defaultOptions).pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
|
|
143
|
+
console.log("Login error:", error);
|
|
144
|
+
return throwError(() => error);
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
loginByPermit(permit, idCas) {
|
|
148
|
+
let params = new HttpParams().set("permit", permit);
|
|
149
|
+
if (idCas) params = params.set("idcas", idCas.toString());
|
|
150
|
+
const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
|
|
151
|
+
return this.http.post(url, params.toString(), this.defaultOptions).pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
|
|
152
|
+
console.log("Permit login error:", error);
|
|
153
|
+
return throwError(() => error);
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
logout() {
|
|
157
|
+
this.userService.removeUser();
|
|
158
|
+
this._loggedIn.set(false);
|
|
159
|
+
this._roles.set([]);
|
|
160
|
+
if (this.router) {
|
|
161
|
+
const currentUrl = this.router.url;
|
|
162
|
+
if (currentUrl.includes(this.config.auth.loginRoute)) return;
|
|
163
|
+
this.router.navigate([this.config.auth.loginRoute], { queryParams: { returnUrl: encodeURIComponent(currentUrl) } });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
successLoginAction(user) {
|
|
167
|
+
this.userService.userData = user;
|
|
168
|
+
this._loggedIn.set(true);
|
|
169
|
+
this._roles.set(user.roleList ?? []);
|
|
170
|
+
}
|
|
171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
172
|
+
minVersion: "12.0.0",
|
|
173
|
+
version: "22.2.2",
|
|
174
|
+
ngImport: i0,
|
|
175
|
+
type: AuthService,
|
|
176
|
+
deps: [],
|
|
177
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
178
|
+
});
|
|
179
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
180
|
+
minVersion: "12.0.0",
|
|
181
|
+
version: "22.2.2",
|
|
182
|
+
ngImport: i0,
|
|
183
|
+
type: AuthService,
|
|
184
|
+
providedIn: "root"
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
188
|
+
minVersion: "12.0.0",
|
|
189
|
+
version: "22.2.2",
|
|
190
|
+
ngImport: i0,
|
|
191
|
+
type: AuthService,
|
|
192
|
+
decorators: [{
|
|
193
|
+
type: Injectable,
|
|
194
|
+
args: [{ providedIn: "root" }]
|
|
195
|
+
}],
|
|
196
|
+
ctorParameters: () => []
|
|
197
|
+
});
|
|
222
198
|
function hasArrayIntersection(arrayA, arrayB) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return arrayA.some(item => arrayB.includes(item));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** Вычисление разрешений по ролям */
|
|
229
|
-
class RoleService {
|
|
230
|
-
authService = inject(AuthService);
|
|
231
|
-
/**
|
|
232
|
-
* Проверяет, заблокирован ли доступ к элементу на основе списка ограничений.
|
|
233
|
-
* Возвращает true, если у пользователя есть запрещенная роль или передан маркер 'HIDE'.
|
|
234
|
-
* Администратор (ADMIN) всегда игнорирует любые запреты и маркер 'HIDE'.
|
|
235
|
-
*/
|
|
236
|
-
hasForbiddenRole(forbiddenRoles) {
|
|
237
|
-
if (!forbiddenRoles || forbiddenRoles.length === 0)
|
|
238
|
-
return false;
|
|
239
|
-
const userRoles = this.authService.roles() ?? [];
|
|
240
|
-
// Если пользователь ADMIN — он игнорирует списки запретов
|
|
241
|
-
if (userRoles.includes(ADMIN_ROLE))
|
|
242
|
-
return false;
|
|
243
|
-
// Если в условиях зашит маркер 'HIDE' — скрываем элемент от обычного пользователя
|
|
244
|
-
if (forbiddenRoles.includes(HIDE_ROLE_MARKER))
|
|
245
|
-
return true;
|
|
246
|
-
// В остальных случаях проверяем стандартное пересечение ролей
|
|
247
|
-
return hasArrayIntersection(userRoles, forbiddenRoles);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Проверяет, есть ли у пользователя хотя бы одна из разрешенных ролей.
|
|
251
|
-
* ADMIN всегда возвращает true.
|
|
252
|
-
*/
|
|
253
|
-
hasAnyRole(allowedRoles) {
|
|
254
|
-
const userRoles = this.authService.roles() ?? [];
|
|
255
|
-
if (userRoles.includes(ADMIN_ROLE))
|
|
256
|
-
return true;
|
|
257
|
-
return hasArrayIntersection(userRoles, allowedRoles);
|
|
258
|
-
}
|
|
259
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
260
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, providedIn: 'root' });
|
|
261
|
-
}
|
|
262
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, decorators: [{
|
|
263
|
-
type: Injectable,
|
|
264
|
-
args: [{
|
|
265
|
-
providedIn: 'root',
|
|
266
|
-
}]
|
|
267
|
-
}] });
|
|
268
|
-
|
|
269
|
-
// Сервис для вывода сообщений(ошибки, успеха)
|
|
270
|
-
class NotificationService {
|
|
271
|
-
// eslint-disable-next-line no-magic-numbers
|
|
272
|
-
duration = 5000;
|
|
273
|
-
_snackBar = inject(MatSnackBar);
|
|
274
|
-
openSnackBar(message, action, duration = this.duration) {
|
|
275
|
-
this._snackBar.open(message, action, {
|
|
276
|
-
duration,
|
|
277
|
-
panelClass: ['red-snackbar'],
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
success(message, duration = this.duration) {
|
|
281
|
-
this.openSnackBar(message, 'Закрыть', duration);
|
|
282
|
-
}
|
|
283
|
-
info(message, duration = this.duration) {
|
|
284
|
-
this.openSnackBar(message, 'Закрыть', duration);
|
|
285
|
-
}
|
|
286
|
-
helper(message, duration = this.duration) {
|
|
287
|
-
this.openSnackBar(message, 'Закрыть', duration);
|
|
288
|
-
}
|
|
289
|
-
warning(message, duration = this.duration) {
|
|
290
|
-
this.openSnackBar(message, 'Закрыть', duration);
|
|
291
|
-
}
|
|
292
|
-
error(message, duration = this.duration) {
|
|
293
|
-
this.openSnackBar(message, 'Закрыть', duration);
|
|
294
|
-
}
|
|
295
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
296
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: NotificationService, providedIn: 'root' });
|
|
199
|
+
if (!arrayA || !arrayB) return false;
|
|
200
|
+
return arrayA.some((item) => arrayB.includes(item));
|
|
297
201
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
202
|
+
var RoleService = class RoleService {
|
|
203
|
+
authService = inject(AuthService);
|
|
204
|
+
hasForbiddenRole(forbiddenRoles) {
|
|
205
|
+
if (!forbiddenRoles || forbiddenRoles.length === 0) return false;
|
|
206
|
+
const userRoles = this.authService.roles() ?? [];
|
|
207
|
+
if (userRoles.includes("ADMIN")) return false;
|
|
208
|
+
if (forbiddenRoles.includes("HIDE")) return true;
|
|
209
|
+
return hasArrayIntersection(userRoles, forbiddenRoles);
|
|
210
|
+
}
|
|
211
|
+
hasAnyRole(allowedRoles) {
|
|
212
|
+
const userRoles = this.authService.roles() ?? [];
|
|
213
|
+
if (userRoles.includes("ADMIN")) return true;
|
|
214
|
+
return hasArrayIntersection(userRoles, allowedRoles);
|
|
215
|
+
}
|
|
216
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
217
|
+
minVersion: "12.0.0",
|
|
218
|
+
version: "22.2.2",
|
|
219
|
+
ngImport: i0,
|
|
220
|
+
type: RoleService,
|
|
221
|
+
deps: [],
|
|
222
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
223
|
+
});
|
|
224
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
225
|
+
minVersion: "12.0.0",
|
|
226
|
+
version: "22.2.2",
|
|
227
|
+
ngImport: i0,
|
|
228
|
+
type: RoleService,
|
|
229
|
+
providedIn: "root"
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
233
|
+
minVersion: "12.0.0",
|
|
234
|
+
version: "22.2.2",
|
|
235
|
+
ngImport: i0,
|
|
236
|
+
type: RoleService,
|
|
237
|
+
decorators: [{
|
|
238
|
+
type: Injectable,
|
|
239
|
+
args: [{ providedIn: "root" }]
|
|
240
|
+
}]
|
|
241
|
+
});
|
|
242
|
+
var NotificationService = class NotificationService {
|
|
243
|
+
duration = 5e3;
|
|
244
|
+
_snackBar = inject(MatSnackBar);
|
|
245
|
+
openSnackBar(message, action, duration = this.duration) {
|
|
246
|
+
this._snackBar.open(message, action, {
|
|
247
|
+
duration,
|
|
248
|
+
panelClass: ["red-snackbar"]
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
success(message, duration = this.duration) {
|
|
252
|
+
this.openSnackBar(message, "Закрыть", duration);
|
|
253
|
+
}
|
|
254
|
+
info(message, duration = this.duration) {
|
|
255
|
+
this.openSnackBar(message, "Закрыть", duration);
|
|
256
|
+
}
|
|
257
|
+
helper(message, duration = this.duration) {
|
|
258
|
+
this.openSnackBar(message, "Закрыть", duration);
|
|
259
|
+
}
|
|
260
|
+
warning(message, duration = this.duration) {
|
|
261
|
+
this.openSnackBar(message, "Закрыть", duration);
|
|
262
|
+
}
|
|
263
|
+
error(message, duration = this.duration) {
|
|
264
|
+
this.openSnackBar(message, "Закрыть", duration);
|
|
265
|
+
}
|
|
266
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
267
|
+
minVersion: "12.0.0",
|
|
268
|
+
version: "22.2.2",
|
|
269
|
+
ngImport: i0,
|
|
270
|
+
type: NotificationService,
|
|
271
|
+
deps: [],
|
|
272
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
273
|
+
});
|
|
274
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
275
|
+
minVersion: "12.0.0",
|
|
276
|
+
version: "22.2.2",
|
|
277
|
+
ngImport: i0,
|
|
278
|
+
type: NotificationService,
|
|
279
|
+
providedIn: "root"
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
283
|
+
minVersion: "12.0.0",
|
|
284
|
+
version: "22.2.2",
|
|
285
|
+
ngImport: i0,
|
|
286
|
+
type: NotificationService,
|
|
287
|
+
decorators: [{
|
|
288
|
+
type: Injectable,
|
|
289
|
+
args: [{ providedIn: "root" }]
|
|
290
|
+
}]
|
|
291
|
+
});
|
|
309
292
|
export { ADMIN_ROLE, API_NAME, APP_ENVIRONMENT, AuthEventService, AuthService, BYPASS_AUTH, DEFAULT_TIMEOUT, HIDE_ROLE_MARKER, NotificationService, REQUEST_TIMEOUT, RoleService, UIKIT_CONFIG, UIKIT_NOTIFICATION_TOKEN, User, UserService, hasArrayIntersection };
|
|
310
|
-
|
|
293
|
+
|
|
294
|
+
//# sourceMappingURL=kuzntsv-uikit.mjs.map
|