bx-rest 0.0.21 → 0.0.22

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.
@@ -1,3 +1,1669 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, NgModule, inject, Component, ViewEncapsulation, Inject } from '@angular/core';
3
+ import { map, catchError, tap, mergeMap as mergeMap$1, first } from 'rxjs/operators';
4
+ import { Subscription, filter, take, of, throwError, forkJoin, mergeMap } from 'rxjs';
5
+ import clone from 'just-clone';
6
+ import * as i1$1 from '@angular/material/snack-bar';
7
+ import { MatSnackBarRef, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
8
+ import * as i2 from '@angular/material/icon';
9
+ import { MatIconModule } from '@angular/material/icon';
10
+ import * as i1 from '@angular/material/button';
11
+ import { MatButtonModule } from '@angular/material/button';
12
+ import * as i1$2 from '@ngrx/store';
13
+ import { createAction, props, createReducer, on } from '@ngrx/store';
14
+ import { __awaiter } from 'tslib';
15
+ import { DateTime } from 'luxon';
16
+ import * as i2$1 from '@angular/router';
17
+ import flatten from 'just-flatten-it';
18
+ import * as i1$3 from '@angular/common/http';
19
+ import { HttpParams } from '@angular/common/http';
20
+
21
+ const $get = 'get';
22
+ const $add = 'add';
23
+ const $set = 'set';
24
+ const $event = 'event';
25
+ const $update = 'update';
26
+ const $user = 'user';
27
+ const $task = 'task';
28
+ const $calendar = 'calendar';
29
+ const $meeting = 'meeting';
30
+ const $list = 'list';
31
+ const $search = 'search';
32
+ const $accessibility = 'accessibility';
33
+ const $delete = 'delete';
34
+ const $nearest = 'nearest';
35
+ const $params = 'params';
36
+ const $status = 'status';
37
+ const $resource = 'resource';
38
+ const $booking = 'booking';
39
+ const $section = 'section';
40
+ const $settings = 'settings';
41
+ const $tasks = 'tasks';
42
+ const $elapseditem = 'elapseditem';
43
+ const $getlist = 'getlist';
44
+ const $approve = 'approve';
45
+ const $complete = 'complete';
46
+ const $counters = 'counters';
47
+ const $deger = 'deger';
48
+ const $delegate = 'delegate';
49
+ const $disapprove = 'disapprove';
50
+ const $favorite = 'favorite';
51
+ const $files = 'files';
52
+ const $file = 'file';
53
+ const $attach = 'attach';
54
+ const $field = 'field';
55
+ const $getFields = 'get' + $field + 's';
56
+ const $getaccess = 'getaccess';
57
+ const $history = 'history';
58
+ const $pause = 'pause';
59
+ const $renew = 'renew';
60
+ const $start = 'start';
61
+ const $result = 'result';
62
+ const $planner = 'planner';
63
+ const $disk = 'disk';
64
+ const $rename = 'rename';
65
+ const $markdeleted = 'markdeleted';
66
+ const $restore = 'restore';
67
+ const $folder = 'folder';
68
+ const $getchildren = 'getchildren';
69
+ const $copyto = 'copyto';
70
+ const $moveto = 'moveto';
71
+ const $uploadfile = 'uploadfile';
72
+ const $storage = 'storage';
73
+ const $getTypes = 'getTypes';
74
+ const $stages = 'stages';
75
+ const $getmanifest = 'getmanifest';
76
+ const $isactionallowed = 'isactionallowed';
77
+ const $commentitem = 'commentitem';
78
+ const $department = 'department';
79
+ const $sonet_group = 'sonet_group';
80
+ const $create = 'create';
81
+ const $feature = 'feature';
82
+ const $access = 'access';
83
+ const $request = 'request';
84
+ const $socialnetwork = 'socialnetwork';
85
+ const $api = 'api';
86
+ const $workgroup = 'workgroup';
87
+ const $log = 'log';
88
+ const $blogpost = 'blogpost';
89
+ const $lists = 'lists';
90
+ const $iblock = 'iblock';
91
+ const $type = 'type';
92
+ const $id = 'id';
93
+ const $element = 'element';
94
+ const $url = 'url';
95
+
96
+ class BXRestListsElement {
97
+ constructor(http, mapResult) {
98
+ this.http = http;
99
+ this.mapResult = mapResult;
100
+ this.url = {
101
+ add: [$lists, $element, $add],
102
+ delete: [$lists, $element, $delete],
103
+ get: [$lists, $element, $get],
104
+ update: [$lists, $element, $update],
105
+ getFileUrl: [$lists, $element, $get, $file, $url] // Метод возвращает путь к файлу
106
+ };
107
+ }
108
+ get(pram) {
109
+ return this.http.post(this.url.get, pram)
110
+ .pipe(map(v => (v && v.result)
111
+ ? Object.assign(v, { result: v.result.map(i => this.mapResult.get(i)) })
112
+ : undefined));
113
+ }
114
+ }
115
+
116
+ class BXRestLists {
117
+ constructor(element) {
118
+ this.element = element;
119
+ this.url = {
120
+ add: [$lists, $add],
121
+ delete: [$lists, $delete],
122
+ get: [$lists, $get],
123
+ update: [$lists, $update],
124
+ getIblockTypeId: [$lists, $get, $iblock, $type, $id], // Метод возвращает id типа инфоблока
125
+ };
126
+ }
127
+ }
128
+ BXRestLists.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestLists, deps: [{ token: BXRestListsElement }], target: i0.ɵɵFactoryTarget.Injectable });
129
+ BXRestLists.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestLists, providedIn: 'root' });
130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestLists, decorators: [{
131
+ type: Injectable,
132
+ args: [{
133
+ providedIn: 'root'
134
+ }]
135
+ }], ctorParameters: function () { return [{ type: BXRestListsElement }]; } });
136
+
137
+ class BxRestModule {
138
+ }
139
+ BxRestModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
140
+ BxRestModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, imports: [MatIconModule,
141
+ MatButtonModule], exports: [MatButtonModule,
142
+ MatIconModule] });
143
+ BxRestModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, imports: [MatIconModule,
144
+ MatButtonModule, MatButtonModule,
145
+ MatIconModule] });
146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, decorators: [{
147
+ type: NgModule,
148
+ args: [{
149
+ declarations: [],
150
+ imports: [
151
+ MatIconModule,
152
+ MatButtonModule
153
+ ],
154
+ exports: [
155
+ MatButtonModule,
156
+ MatIconModule
157
+ ]
158
+ }]
159
+ }] });
160
+
161
+ class ToastMessageComponent {
162
+ constructor(data) {
163
+ this.data = data;
164
+ this.snackBarRef = inject(MatSnackBarRef);
165
+ }
166
+ getClass() {
167
+ switch (this.data.type) {
168
+ case 'error':
169
+ case 'warning':
170
+ case 'success':
171
+ return this.data.type + '-message';
172
+ }
173
+ return '';
174
+ }
175
+ }
176
+ ToastMessageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ToastMessageComponent, deps: [{ token: MAT_SNACK_BAR_DATA }], target: i0.ɵɵFactoryTarget.Component });
177
+ ToastMessageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ToastMessageComponent, isStandalone: true, selector: "app-view", ngImport: i0, template: "<div class=\"w-100 d-flex\">\n <span matSnackBarLabel [class]=\"getClass()\">\n {{ data.message }}\n</span>\n <span matSnackBarActions [class]=\"getClass()\">\n <button mat-button matSnackBarAction (click)=\"snackBarRef.dismissWithAction()\">\n <mat-icon>\n close\n </mat-icon>\n </button>\n</span>\n</div>\n\n", styles: [":host{display:flex;background-color:red}:host .mdc-snackbar__surface{padding:0;margin:0}:host .error-message{color:red}:host.error-box{background-color:#eec1c1}:host.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.error-box .mdc-snackbar__surface{background-color:#eec1c1}mat-snack-bar-container.mdc-snackbar.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.warning-box .mdc-snackbar__surface{background-color:#f0f2b9}mat-snack-bar-container.mdc-snackbar.warning-box .warning-message{color:#15140f}mat-snack-bar-container.mdc-snackbar.success-box .mdc-snackbar__surface{background-color:#daf7d1}mat-snack-bar-container.mdc-snackbar.success-box .success-message{color:#423f31}\n"], dependencies: [{ kind: "ngmodule", type: BxRestModule }, { kind: "component", type: i1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], encapsulation: i0.ViewEncapsulation.None });
178
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ToastMessageComponent, decorators: [{
179
+ type: Component,
180
+ args: [{ selector: 'app-view', encapsulation: ViewEncapsulation.None, standalone: true, imports: [BxRestModule], template: "<div class=\"w-100 d-flex\">\n <span matSnackBarLabel [class]=\"getClass()\">\n {{ data.message }}\n</span>\n <span matSnackBarActions [class]=\"getClass()\">\n <button mat-button matSnackBarAction (click)=\"snackBarRef.dismissWithAction()\">\n <mat-icon>\n close\n </mat-icon>\n </button>\n</span>\n</div>\n\n", styles: [":host{display:flex;background-color:red}:host .mdc-snackbar__surface{padding:0;margin:0}:host .error-message{color:red}:host.error-box{background-color:#eec1c1}:host.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.error-box .mdc-snackbar__surface{background-color:#eec1c1}mat-snack-bar-container.mdc-snackbar.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.warning-box .mdc-snackbar__surface{background-color:#f0f2b9}mat-snack-bar-container.mdc-snackbar.warning-box .warning-message{color:#15140f}mat-snack-bar-container.mdc-snackbar.success-box .mdc-snackbar__surface{background-color:#daf7d1}mat-snack-bar-container.mdc-snackbar.success-box .success-message{color:#423f31}\n"] }]
181
+ }], ctorParameters: function () {
182
+ return [{ type: undefined, decorators: [{
183
+ type: Inject,
184
+ args: [MAT_SNACK_BAR_DATA]
185
+ }] }];
186
+ } });
187
+
188
+ /**
189
+ * Сервис для вывода сообщений пользователю
190
+ * TODO: логирование
191
+ */
192
+ class SnackBarService {
193
+ constructor(snackBar) {
194
+ this.snackBar = snackBar;
195
+ }
196
+ error(message, sec = 12) {
197
+ this.standardMessage(message, sec, 'error');
198
+ }
199
+ warning(message, sec = 7) {
200
+ this.standardMessage(message, sec, 'warning');
201
+ }
202
+ success(message, sec = 7) {
203
+ this.standardMessage(message, sec, 'success');
204
+ }
205
+ standardMessage(message, sec = 5, name = 'error') {
206
+ this.snackBar.open(message);
207
+ this.snackBar.openFromComponent(ToastMessageComponent, {
208
+ duration: sec * 1000,
209
+ data: {
210
+ message: message,
211
+ type: name
212
+ },
213
+ panelClass: name + '-box'
214
+ });
215
+ }
216
+ }
217
+ SnackBarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, deps: [{ token: i1$1.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
218
+ SnackBarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, providedIn: 'root' });
219
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, decorators: [{
220
+ type: Injectable,
221
+ args: [{
222
+ providedIn: 'root'
223
+ }]
224
+ }], ctorParameters: function () { return [{ type: i1$1.MatSnackBar }]; } });
225
+
226
+ // Generate an internal UID to make the regexp pattern harder to guess.
227
+ const UID_LENGTH = 16;
228
+ const UID = generateUID();
229
+ const PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|A|U|I|B|L)-' + UID + '-(\\d+)__@"', 'g');
230
+ const IS_NATIVE_CODE_REGEXP = /\{\s*\[native code]\s*}/g;
231
+ const IS_PURE_FUNCTION = /function.*?\(/;
232
+ const IS_ARROW_FUNCTION = /.*?=>.*?/;
233
+ const UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g;
234
+ const RESERVED_SYMBOLS = ['*', 'async'];
235
+ // Mapping of unsafe HTML and invalid JavaScript line terminator chars to their
236
+ // Unicode char counterparts which are safe to use in JavaScript strings.
237
+ const ESCAPED_CHARS = {
238
+ '<': '\\u003C',
239
+ '>': '\\u003E',
240
+ '/': '\\u002F',
241
+ '\u2028': '\\u2028',
242
+ '\u2029': '\\u2029'
243
+ };
244
+ function escapeUnsafeChars(unsafeChar) {
245
+ return (ESCAPED_CHARS.hasOwnProperty(unsafeChar)) ? ESCAPED_CHARS[unsafeChar] : '';
246
+ }
247
+ function generateUID() {
248
+ let bytes = window.crypto.getRandomValues(new Uint32Array(UID_LENGTH));
249
+ let result = '';
250
+ for (let i = 0; i < UID_LENGTH; ++i) {
251
+ result += bytes[i].toString(16);
252
+ }
253
+ return result;
254
+ }
255
+ function deleteFunctions(obj) {
256
+ let functionKeys = [];
257
+ for (let key in obj) {
258
+ if (typeof obj[key] === "function") {
259
+ functionKeys.push(key);
260
+ }
261
+ }
262
+ for (let i = 0; i < functionKeys.length; i++) {
263
+ delete obj[functionKeys[i]];
264
+ }
265
+ }
266
+ function serialize(obj, options = {}) {
267
+ // Backwards-compatibility for `space` as the second argument.
268
+ if (typeof options === 'number' || typeof options === 'string') {
269
+ options = { space: options };
270
+ }
271
+ let functions = [];
272
+ let regexps = [];
273
+ let dates = [];
274
+ let maps = [];
275
+ let sets = [];
276
+ let arrays = [];
277
+ let undefs = [];
278
+ let infinities = [];
279
+ let bigInts = [];
280
+ let urls = [];
281
+ // Returns placeholders for functions and regexps (identified by index)
282
+ // which are later replaced by their string representation.
283
+ function replacer(key, value) {
284
+ // For nested function
285
+ if (options.ignoreFunction) {
286
+ deleteFunctions(value);
287
+ }
288
+ if (!value && value !== undefined) {
289
+ return value;
290
+ }
291
+ // let origValue: any = this[key];
292
+ let origValue = value;
293
+ let type = typeof origValue;
294
+ switch (type) {
295
+ case 'object':
296
+ if (origValue instanceof RegExp) {
297
+ return '@__R-' + UID + '-' + (regexps.push(origValue) - 1) + '__@';
298
+ }
299
+ else if (origValue instanceof Date) {
300
+ return '@__D-' + UID + '-' + (dates.push(origValue) - 1) + '__@';
301
+ }
302
+ else if (origValue instanceof Map) {
303
+ return '@__M-' + UID + '-' + (maps.push(origValue) - 1) + '__@';
304
+ }
305
+ else if (origValue instanceof Set) {
306
+ return '@__S-' + UID + '-' + (sets.push(origValue) - 1) + '__@';
307
+ }
308
+ if (origValue instanceof Array) {
309
+ let isSparse = origValue.filter(function () {
310
+ return true;
311
+ }).length !== origValue.length;
312
+ if (isSparse) {
313
+ return '@__A-' + UID + '-' + (arrays.push(origValue) - 1) + '__@';
314
+ }
315
+ }
316
+ if (origValue instanceof URL) {
317
+ return '@__L-' + UID + '-' + (urls.push(origValue) - 1) + '__@';
318
+ }
319
+ break;
320
+ case 'function':
321
+ return '@__F-' + UID + '-' + (functions.push(origValue) - 1) + '__@';
322
+ case 'undefined':
323
+ return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
324
+ case 'number':
325
+ return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
326
+ case 'bigint':
327
+ return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
328
+ }
329
+ return value;
330
+ }
331
+ function serializeFunc(fn) {
332
+ let serializedFn = fn.toString();
333
+ if (IS_NATIVE_CODE_REGEXP.test(serializedFn)) {
334
+ throw new TypeError('Serializing native function: ' + fn.name);
335
+ }
336
+ // pure functions, example: {key: function() {}}
337
+ if (IS_PURE_FUNCTION.test(serializedFn)) {
338
+ return serializedFn;
339
+ }
340
+ // arrow functions, example: arg1 => arg1+5
341
+ if (IS_ARROW_FUNCTION.test(serializedFn)) {
342
+ return serializedFn;
343
+ }
344
+ let argsStartsAt = serializedFn.indexOf('(');
345
+ let def = serializedFn.slice(0, argsStartsAt)
346
+ .trim()
347
+ .split(' ')
348
+ .filter(function (val) {
349
+ return val.length > 0;
350
+ });
351
+ let nonReservedSymbols = def.filter(function (val) {
352
+ return RESERVED_SYMBOLS.indexOf(val) === -1;
353
+ });
354
+ // enhanced literal objects, example: {key() {}}
355
+ if (nonReservedSymbols.length > 0) {
356
+ return (def.indexOf('async') > -1 ? 'async ' : '') + 'function'
357
+ + (def.join('').indexOf('*') > -1 ? '*' : '')
358
+ + serializedFn.slice(argsStartsAt);
359
+ }
360
+ // arrow functions
361
+ return serializedFn;
362
+ }
363
+ // Check if the parameter is function
364
+ if (options.ignoreFunction && typeof obj === "function") {
365
+ obj = undefined;
366
+ }
367
+ // Protects against `JSON.stringify()` returning `undefined`, by serializing
368
+ // to the literal string: "undefined".
369
+ if (obj === undefined) {
370
+ return String(obj);
371
+ }
372
+ let str = '';
373
+ // Creates a JSON string representation of the value.
374
+ // NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args.
375
+ if (options.isJSON && !options.space) {
376
+ str = JSON.stringify(obj);
377
+ }
378
+ else {
379
+ str = JSON.stringify(obj, options.isJSON ? undefined : replacer, options.space);
380
+ }
381
+ // Replace unsafe HTML and invalid JavaScript line terminator chars with
382
+ // their safe Unicode char counterpart. This _must_ happen before the
383
+ // regexps and functions are serialized and added back to the string.
384
+ if (options.unsafe !== true) {
385
+ str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
386
+ }
387
+ if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && arrays.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0 && urls.length === 0) {
388
+ return str;
389
+ }
390
+ // Replaces all occurrences of function, regexp, date, map and set placeholders in the
391
+ // JSON string with their string representations. If the original value can
392
+ // not be found, then `undefined` is used.
393
+ return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
394
+ // The placeholder may not be preceded by a backslash. This is to prevent
395
+ // replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
396
+ // invalid JS.
397
+ if (backSlash) {
398
+ return match;
399
+ }
400
+ switch (type) {
401
+ case 'D':
402
+ return "new Date(\"" + dates[valueIndex].toISOString() + "\")";
403
+ case 'R':
404
+ return "new RegExp(" + serialize(regexps[valueIndex].source) + ", \"" + regexps[valueIndex].flags + "\")";
405
+ case 'M':
406
+ return "new Map(" + serialize(Array.from(maps[valueIndex].entries()), options) + ")";
407
+ case 'S':
408
+ return "new Set(" + serialize(Array.from(sets[valueIndex].values()), options) + ")";
409
+ case 'A':
410
+ return "Array.prototype.slice.call(" + serialize(Object.assign({ length: arrays[valueIndex].length }, arrays[valueIndex]), options) + ")";
411
+ case 'U':
412
+ return 'undefined';
413
+ case 'I':
414
+ return infinities[valueIndex];
415
+ case 'B':
416
+ return "BigInt(\"" + bigInts[valueIndex] + "\")";
417
+ case 'L':
418
+ return "new URL(\"" + urls[valueIndex].toString() + "\")";
419
+ }
420
+ let fn = functions[valueIndex];
421
+ return serializeFunc(fn);
422
+ });
423
+ }
424
+
425
+ class JSONServices {
426
+ static deserialize(data) {
427
+ return eval('(' + data + ')');
428
+ }
429
+ static serialize(data) {
430
+ return serialize(data);
431
+ }
432
+ }
433
+ JSONServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
434
+ JSONServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, providedIn: 'root' });
435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, decorators: [{
436
+ type: Injectable,
437
+ args: [{
438
+ providedIn: 'root'
439
+ }]
440
+ }] });
441
+
442
+ class CookiesServices {
443
+ static get(name) {
444
+ const results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
445
+ if (results)
446
+ return results[2];
447
+ else
448
+ return '';
449
+ }
450
+ static set(name, value, age = 0) {
451
+ let string = name + '=' + value + ';';
452
+ if (age) {
453
+ string += ' max-age=' + age;
454
+ }
455
+ string += '; SameSite=None; Secure';
456
+ document.cookie = string;
457
+ }
458
+ static setObj(name, value, age = 0) {
459
+ let string = name + '=' + JSONServices.serialize(value) + ';';
460
+ if (age) {
461
+ string += ' max-age=' + age;
462
+ }
463
+ string += '; SameSite=None; Secure';
464
+ document.cookie = string;
465
+ }
466
+ static getObj(name) {
467
+ const results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
468
+ if (results) {
469
+ return JSONServices.deserialize(results[2]);
470
+ }
471
+ return false;
472
+ }
473
+ }
474
+ CookiesServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
475
+ CookiesServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, providedIn: 'root' });
476
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, decorators: [{
477
+ type: Injectable,
478
+ args: [{
479
+ providedIn: 'root'
480
+ }]
481
+ }] });
482
+
483
+ const save$1 = createAction('[Auth Component] Save', props());
484
+ const saveAccessToken = createAction('[Auth Component] SaveAccessToken', props());
485
+ const initialState$1 = {
486
+ access_token: '',
487
+ client_endpoint: '',
488
+ domain: '',
489
+ expires: 0,
490
+ expires_in: 0,
491
+ member_id: '',
492
+ refresh_token: '',
493
+ scope: '',
494
+ server_endpoint: '',
495
+ status: '',
496
+ user_id: 0
497
+ };
498
+ const _authReducer = createReducer(initialState$1, on(saveAccessToken, (s, data) => {
499
+ let copy = clone(s);
500
+ return Object.assign(copy, data);
501
+ }));
502
+ function authReducer(state = initialState$1, action) {
503
+ return _authReducer(state, action);
504
+ }
505
+
506
+ const time = {
507
+ oneDayMilliseconds: 1000 * 60 * 60 * 24
508
+ };
509
+
510
+ class BaseServices {
511
+ toStr(val) {
512
+ return (val) ? String(val) : '';
513
+ }
514
+ toNum(val) {
515
+ return (val && Number(val)) ? Number(val) : 0;
516
+ }
517
+ toDate(val, format, opt) {
518
+ if (val instanceof Date) {
519
+ return val;
520
+ }
521
+ else if (typeof val == 'string') {
522
+ if (format) {
523
+ if (opt) {
524
+ return DateTime.fromFormat(val, format, opt).toJSDate();
525
+ }
526
+ return DateTime.fromFormat(val, format).toJSDate();
527
+ }
528
+ else {
529
+ return new Date(val);
530
+ }
531
+ }
532
+ else if (typeof val == 'number') {
533
+ return new Date(val);
534
+ }
535
+ console.error('Wrong date format', val, format);
536
+ throw 'Wrong date format';
537
+ }
538
+ getBXStrTime(date) {
539
+ return this.toISOStringWithTimezone(date);
540
+ }
541
+ toISOStringWithTimezone(date) {
542
+ const tzOffset = -date.getTimezoneOffset();
543
+ const diff = tzOffset >= 0 ? '+' : '-';
544
+ const pad = (n) => `${Math.floor(Math.abs(n))}`.padStart(2, '0');
545
+ return date.getFullYear() +
546
+ '-' + pad(date.getMonth() + 1) +
547
+ '-' + pad(date.getDate()) +
548
+ 'T' + pad(date.getHours()) +
549
+ ':' + pad(date.getMinutes()) +
550
+ ':' + pad(date.getSeconds()) +
551
+ diff + pad(tzOffset / 60) +
552
+ ':' + pad(tzOffset % 60);
553
+ }
554
+ ;
555
+ toBool(val) {
556
+ switch (typeof val) {
557
+ case 'string':
558
+ val = val.toLowerCase();
559
+ if (val === 'n' || val === 'y') { // битриксовые понятия о bool
560
+ return val === 'y';
561
+ }
562
+ else if (val === 'true' || val === 'false') { // битриксовые понятия о bool
563
+ return val === 'true';
564
+ }
565
+ else {
566
+ return false;
567
+ }
568
+ default:
569
+ return Boolean(val);
570
+ }
571
+ }
572
+ toBXYorN(val) {
573
+ return (val) ? 'Y' : 'N';
574
+ }
575
+ typeof(val) {
576
+ return typeof val;
577
+ }
578
+ typeDefClass(val) {
579
+ if (val) {
580
+ if (val instanceof Date) {
581
+ return 'date';
582
+ }
583
+ return undefined;
584
+ }
585
+ else {
586
+ return null;
587
+ }
588
+ }
589
+ toJSON(val) {
590
+ return JSON.stringify(val);
591
+ }
592
+ fromJSON(val) {
593
+ return JSON.parse(val);
594
+ }
595
+ prepareBaseAddress(url, add = '') {
596
+ if (url.search('https://') !== 0 && url.search('http://')) {
597
+ url = 'https://' + url;
598
+ }
599
+ if (url.lastIndexOf('/') !== (url.length - 1)) {
600
+ url = url + '/';
601
+ }
602
+ url = url + add;
603
+ return url;
604
+ }
605
+ getHomeAddress() {
606
+ // return this.prepareBaseAddress(environment.urls.home)
607
+ return this.prepareBaseAddress('b24.trace-studio.com');
608
+ }
609
+ dateDiff(a, b) {
610
+ return new Date(a.valueOf() - b.valueOf());
611
+ }
612
+ dateDiffInDays(a, b) {
613
+ return Math.floor(this.dateDiff(a, b).valueOf() / time.oneDayMilliseconds);
614
+ }
615
+ getBase64File(file) {
616
+ return new Promise((resolve, reject) => {
617
+ const reader = new FileReader();
618
+ reader.readAsDataURL(file);
619
+ reader.onload = () => resolve(reader.result);
620
+ reader.onerror = error => reject(error);
621
+ });
622
+ }
623
+ getBase64FileLikeStr(file) {
624
+ return __awaiter(this, void 0, void 0, function* () {
625
+ let result = yield this.getBase64File(file);
626
+ if (typeof result === 'string') {
627
+ let split = result.split(',');
628
+ return {
629
+ header: split[0],
630
+ val: split[1]
631
+ };
632
+ }
633
+ return undefined;
634
+ });
635
+ }
636
+ sumArray(numbers) {
637
+ return numbers.reduce((a, b) => {
638
+ return a + b;
639
+ });
640
+ }
641
+ isItTheSameDate(date1, date2) {
642
+ return date1.getDate() === date2.getDate()
643
+ && date1.getMonth() === date2.getMonth()
644
+ && date1.getFullYear() === date2.getFullYear();
645
+ }
646
+ toUnix(date) {
647
+ return Math.floor(date.valueOf() / 1000);
648
+ }
649
+ arrSum(x) {
650
+ let s = 0;
651
+ for (let i = 0; i < x.length; i++) {
652
+ s += x[i];
653
+ }
654
+ return s;
655
+ }
656
+ getBaseUrlHttps(url, component = false) {
657
+ if (component) {
658
+ return encodeURI(this.cropUrl(url) + '/');
659
+ }
660
+ else {
661
+ return encodeURI('https://' + this.cropUrl(url) + '/');
662
+ }
663
+ }
664
+ cropUrl(url) {
665
+ url = (url) ? url.replace('https://', '') : '';
666
+ url = (url) ? url.replace('http://', '') : '';
667
+ url = (url) ? url.replace('https:', '') : '';
668
+ url = (url) ? url.replace('http:', '') : '';
669
+ return url;
670
+ }
671
+ }
672
+ BaseServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
673
+ BaseServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseServices, providedIn: 'root' });
674
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseServices, decorators: [{
675
+ type: Injectable,
676
+ args: [{
677
+ providedIn: 'root'
678
+ }]
679
+ }] });
680
+
681
+ class LocalStorageServices {
682
+ static get(name) {
683
+ return localStorage.getItem(name);
684
+ }
685
+ static getObj(name) {
686
+ return JSONServices.deserialize(localStorage.getItem(name));
687
+ }
688
+ static set(name, value) {
689
+ localStorage.setItem(name, value);
690
+ }
691
+ static setObj(name, value) {
692
+ let get = this.get(name);
693
+ if (get && typeof get === 'object') {
694
+ localStorage.setItem(name, JSONServices.serialize(Object.assign(get, value)));
695
+ }
696
+ else {
697
+ localStorage.setItem(name, JSONServices.serialize(value));
698
+ }
699
+ }
700
+ static del(name) {
701
+ localStorage.removeItem(name);
702
+ }
703
+ }
704
+ LocalStorageServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
705
+ LocalStorageServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, providedIn: 'root' });
706
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, decorators: [{
707
+ type: Injectable,
708
+ args: [{
709
+ providedIn: 'root'
710
+ }]
711
+ }] });
712
+
713
+ class RestServices {
714
+ constructor() {
715
+ this.BX24 = false;
716
+ // @ts-ignore
717
+ this.BX24 = (window.BX24) ? window.BX24 : false;
718
+ }
719
+ init(callBack) {
720
+ return (this.BX24) ? this.BX24.init(callBack) : false;
721
+ }
722
+ }
723
+ RestServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
724
+ RestServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, providedIn: 'root' });
725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, decorators: [{
726
+ type: Injectable,
727
+ args: [{
728
+ providedIn: 'root'
729
+ }]
730
+ }], ctorParameters: function () { return []; } });
731
+
732
+ class SessionKeyServices extends BaseServices {
733
+ constructor(store, route, BxApiLib) {
734
+ super();
735
+ this.store = store;
736
+ this.route = route;
737
+ this.BxApiLib = BxApiLib;
738
+ this.authHave = false;
739
+ this.subscribe = {
740
+ authData: new Subscription()
741
+ };
742
+ this.authData$ = this.store.select('auth');
743
+ this.authData$.subscribe(authData => {
744
+ if ((authData && !authData.access_token.length) || !authData) {
745
+ // получаем токен по собственным каналом (в битриксе приложение trace:apps.trace)
746
+ window.addEventListener('message', (event) => {
747
+ if (event.origin !== window.origin) { // проверяем что это не наше сообщение (с текущего приложения)
748
+ if (event.data && event.data.param) {
749
+ if (typeof event.data.param === 'string') {
750
+ event.data.param = JSON.parse(event.data.param);
751
+ }
752
+ let save = {};
753
+ if (event.data.param.access_token) {
754
+ let param = event.data.param;
755
+ save.access_token = event.data.param.access_token;
756
+ save = {
757
+ access_token: (param.access_token) ? param.access_token : undefined,
758
+ client_endpoint: (param.client_endpoint) ? param.client_endpoint : undefined,
759
+ domain: (param.domain) ? param.domain : undefined,
760
+ expires: (param.expires) ? param.expires : undefined,
761
+ expires_in: (param.expires_in) ? param.expires_in : undefined,
762
+ member_id: (param.member_id) ? param.member_id : undefined,
763
+ refresh_token: (param.refresh_token) ? param.refresh_token : undefined,
764
+ scope: (param.scope) ? param.scope : undefined,
765
+ server_endpoint: (param.server_endpoint) ? param.server_endpoint : undefined,
766
+ status: (param.status) ? param.status : undefined,
767
+ user_id: (param.user_id) ? param.user_id : undefined,
768
+ type: (param.type) ? param.type : undefined,
769
+ };
770
+ }
771
+ if (Object.keys(save).length && save.access_token) {
772
+ this.store.dispatch(saveAccessToken(save));
773
+ this.subscribeAll();
774
+ }
775
+ }
776
+ }
777
+ });
778
+ this.subscribe.authData = this.route.queryParamMap
779
+ .pipe(filter(param => param.has('AUTH_ID')
780
+ || param.has('access_token')
781
+ || param.has('REFRESH_ID')
782
+ || param.has('DOMAIN')))
783
+ .subscribe((param) => {
784
+ let save = {};
785
+ if (param.has('AUTH_ID') && !authData.access_token.length) {
786
+ const get = param.get('AUTH_ID');
787
+ if (get) {
788
+ CookiesServices.set('auth', get); // потом убрать
789
+ save.access_token = get;
790
+ }
791
+ }
792
+ if (param.has('access_token') && !authData.access_token.length) {
793
+ const get = param.get('access_token');
794
+ if (get) {
795
+ CookiesServices.set('auth', get); // потом убрать
796
+ save.access_token = get;
797
+ }
798
+ }
799
+ if (param.has('REFRESH_ID') && !authData.refresh_token.length) {
800
+ const get = param.get('REFRESH_ID');
801
+ if (get) {
802
+ save.refresh_token = get;
803
+ }
804
+ }
805
+ if (param.has('DOMAIN') && !authData.domain.length) {
806
+ const get = param.get('DOMAIN');
807
+ if (get) {
808
+ save.domain = get;
809
+ }
810
+ }
811
+ if (Object.keys(save).length && save.access_token) {
812
+ this.store.dispatch(saveAccessToken(save));
813
+ this.subscribeAll();
814
+ }
815
+ else {
816
+ // если битрикс не шлёт нужные мне параметры на прямую
817
+ // просим их мне отдать так как описано это в документации
818
+ let f = () => {
819
+ if (this.BxApiLib.BX24) {
820
+ const initDate = this.BxApiLib.BX24.getAuth();
821
+ this.store.dispatch(saveAccessToken(initDate));
822
+ }
823
+ };
824
+ this.BxApiLib.init(f);
825
+ }
826
+ });
827
+ }
828
+ else if (this.getAuth().length) {
829
+ this.authHave = true;
830
+ }
831
+ this.authData = authData;
832
+ });
833
+ }
834
+ subscribeAll() {
835
+ this.subscribe.authData.unsubscribe();
836
+ }
837
+ getAuth() {
838
+ if (window.BX && window.BX.bitrix_sessid()) {
839
+ return window.BX.bitrix_sessid();
840
+ }
841
+ else if (this.getSessid().length) {
842
+ let str = this.getSessid();
843
+ return (str) ? str : '';
844
+ }
845
+ else {
846
+ return CookiesServices.get('auth');
847
+ }
848
+ }
849
+ getKeyAuth() {
850
+ if (window.BX && window.BX.bitrix_sessid()
851
+ || this.getSessid().length) {
852
+ return 'sessid';
853
+ }
854
+ else {
855
+ return 'auth';
856
+ }
857
+ }
858
+ getSessid() {
859
+ const check = new URLSearchParams(document.location.search).get('sessid');
860
+ if (check) {
861
+ LocalStorageServices.set('sessid', check);
862
+ return check;
863
+ }
864
+ else if (LocalStorageServices.get('sessid')) {
865
+ return LocalStorageServices.get('sessid');
866
+ }
867
+ return '';
868
+ }
869
+ setAuthParams(params) {
870
+ const keyAuth = this.getKeyAuth();
871
+ if (params[keyAuth]) {
872
+ return true;
873
+ }
874
+ else if (keyAuth) {
875
+ params[keyAuth] = this.getAuth();
876
+ return true;
877
+ }
878
+ return false;
879
+ }
880
+ getAuthParams() {
881
+ // if (env.production && !env.component) {
882
+ return this.authData$.pipe(take(1), map(v => (v) ? v.access_token : undefined));
883
+ // } else {
884
+ // return of(this.getAuth())
885
+ // }
886
+ }
887
+ getBaseUrl() {
888
+ return this.authData$.pipe(map(v => (v && v.domain) ? this.prepareBaseAddress(v.domain, 'b24.trace-studio.com') : undefined));
889
+ }
890
+ }
891
+ SessionKeyServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, deps: [{ token: i1$2.Store }, { token: i2$1.ActivatedRoute }, { token: RestServices }], target: i0.ɵɵFactoryTarget.Injectable });
892
+ SessionKeyServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, providedIn: 'root' });
893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, decorators: [{
894
+ type: Injectable,
895
+ args: [{
896
+ providedIn: 'root'
897
+ }]
898
+ }], ctorParameters: function () { return [{ type: i1$2.Store }, { type: i2$1.ActivatedRoute }, { type: RestServices }]; } });
899
+
900
+ class HttpData extends BaseServices {
901
+ constructor() {
902
+ super(...arguments);
903
+ this.defSettings = {
904
+ timeZone: {
905
+ calc: true,
906
+ levelOut: false
907
+ }
908
+ };
909
+ }
910
+ getHttpParamsGet(// не так уж и сложно сделать сложенный HttpParams, да гугл?
911
+ obj, sendHttpParams = new HttpParams(), thisArray = false, nesting = [],
912
+ // settings = this.defSettings
913
+ _ = this.defSettings) {
914
+ for (const key in obj) {
915
+ let setKey = '';
916
+ if (nesting.length) {
917
+ let first = nesting[0];
918
+ setKey = (nesting.length > 1)
919
+ ? first + '[' + nesting.slice(1).join('][') + '][' + key + ']'
920
+ : first + '[' + key + ']';
921
+ }
922
+ else {
923
+ setKey = key;
924
+ }
925
+ switch (typeof obj[key]) {
926
+ case 'string':
927
+ sendHttpParams = sendHttpParams.set(setKey, obj[key]);
928
+ break;
929
+ case 'symbol':
930
+ case 'number':
931
+ case 'bigint':
932
+ case 'boolean':
933
+ sendHttpParams = sendHttpParams.set(setKey, String(obj[key]));
934
+ break;
935
+ case 'object':
936
+ nesting.push(key);
937
+ sendHttpParams = this.getHttpParamsGet(obj[key], sendHttpParams, false, nesting);
938
+ nesting.pop();
939
+ break;
940
+ case 'function':
941
+ case 'undefined':
942
+ default:
943
+ console.error('Ты отправил что-то не то', obj[key], typeof obj[key], typeof obj);
944
+ }
945
+ }
946
+ return sendHttpParams;
947
+ }
948
+ getHttpParamsPost(obj, sendHttpParams = new FormData(), thisArray = false, nesting = [], settings = this.defSettings) {
949
+ if (obj instanceof Blob) {
950
+ let first = nesting[0];
951
+ let setKey = (nesting.length > 1)
952
+ ? first + '[' + nesting.slice(1).join('][') + ']'
953
+ : first;
954
+ sendHttpParams.set(setKey, obj);
955
+ return sendHttpParams;
956
+ }
957
+ else if (obj instanceof Date) {
958
+ let first = nesting[0];
959
+ let tzoffset = (settings.timeZone.calc) ? obj.getTimezoneOffset() * 60000 : 0; // вычисляем влияние часового пояса
960
+ let levelOut = (settings.timeZone.levelOut) ? obj.getTimezoneOffset() * 60000 : 0; // вычисляем влияние часового пояса
961
+ let setKey = (nesting.length > 1)
962
+ ? first + '[' + nesting.slice(1).join('][') + ']'
963
+ : first;
964
+ sendHttpParams.set(setKey, (new Date(obj.valueOf() + tzoffset - levelOut)).toISOString());
965
+ return sendHttpParams;
966
+ }
967
+ else {
968
+ for (const key in obj) {
969
+ let setKey = '';
970
+ if (nesting.length) {
971
+ let first = nesting[0];
972
+ setKey = (nesting.length > 1)
973
+ ? first + '[' + nesting.slice(1).join('][') + '][' + key + ']'
974
+ : first + '[' + key + ']';
975
+ }
976
+ else {
977
+ setKey = key;
978
+ }
979
+ switch (typeof obj[key]) {
980
+ case 'string':
981
+ sendHttpParams.set(setKey, obj[key]);
982
+ break;
983
+ case 'symbol':
984
+ case 'number':
985
+ case 'bigint':
986
+ case 'boolean':
987
+ sendHttpParams.set(setKey, String(obj[key]));
988
+ break;
989
+ case 'object':
990
+ nesting.push(key);
991
+ sendHttpParams = this.getHttpParamsPost(obj[key], sendHttpParams, false, nesting, settings);
992
+ nesting.pop();
993
+ break;
994
+ case 'function':
995
+ case 'undefined':
996
+ default:
997
+ console.error('Ты отправил что-то не то', obj[key], typeof obj[key], typeof obj);
998
+ }
999
+ }
1000
+ }
1001
+ return sendHttpParams;
1002
+ }
1003
+ mapResult(v) {
1004
+ if (v && (v.result || typeof v.result === 'boolean')) {
1005
+ return v.result;
1006
+ }
1007
+ return undefined;
1008
+ }
1009
+ sliceArrayIntoChunks(arr, chunkSize) {
1010
+ const res = [];
1011
+ for (let i = 0; i < arr.length; i += chunkSize) {
1012
+ const chunk = arr.slice(i, i + chunkSize);
1013
+ res.push(chunk);
1014
+ }
1015
+ return res;
1016
+ }
1017
+ removingMultipleSlashes(str) {
1018
+ return str.replace(/\/{2,}/g, '/');
1019
+ }
1020
+ }
1021
+
1022
+ class BaseHttp extends HttpData {
1023
+ constructor(http, snackBar) {
1024
+ super();
1025
+ this.http = http;
1026
+ this.snackBar = snackBar;
1027
+ }
1028
+ handleError(result, textError = 'получения данных') {
1029
+ return (error) => {
1030
+ console.error(`failed: ${error.message}`);
1031
+ this.snackBar.error('Ошибка: ' + textError);
1032
+ return of(result);
1033
+ };
1034
+ }
1035
+ }
1036
+ BaseHttp.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, deps: [{ token: i1$3.HttpClient }, { token: SnackBarService }], target: i0.ɵɵFactoryTarget.Injectable });
1037
+ BaseHttp.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, providedIn: 'root' });
1038
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, decorators: [{
1039
+ type: Injectable,
1040
+ args: [{
1041
+ providedIn: 'root'
1042
+ }]
1043
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: SnackBarService }]; } });
1044
+
1045
+ class BaseHttpServices extends BaseHttp {
1046
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
1047
+ return this.http.get(url, {
1048
+ params: this.getHttpParamsGet(params, new HttpParams(), false, [], settings)
1049
+ }).pipe(catchError(err => {
1050
+ if (!textError.length && err.error.error_description) {
1051
+ textError = err.error.error_description;
1052
+ }
1053
+ this.snackBar.error('Ошибка: ' + textError);
1054
+ return throwError(() => err);
1055
+ }));
1056
+ }
1057
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
1058
+ return this.http.post(url, this.getHttpParamsPost(params, new FormData(), false, [], settings)).pipe(catchError(err => {
1059
+ if (!textError.length && err.error.error_description) {
1060
+ textError = err.error.error_description;
1061
+ }
1062
+ this.snackBar.error('Ошибка: ' + textError);
1063
+ console.error(err);
1064
+ return throwError(() => err);
1065
+ }));
1066
+ }
1067
+ }
1068
+
1069
+ class HttpServices extends BaseHttpServices {
1070
+ constructor(http, snackBar, session) {
1071
+ super(http, snackBar);
1072
+ this.session = session;
1073
+ }
1074
+ timeNowOnServer() {
1075
+ return this.httpGet('server.time').pipe(map(v => {
1076
+ if (v && v.result) {
1077
+ return new Date(v.result);
1078
+ }
1079
+ return undefined;
1080
+ }));
1081
+ }
1082
+ /**
1083
+ * Это пиздец а не метод
1084
+ * @param param
1085
+ */
1086
+ branch(param) {
1087
+ let prepareParam = Object.entries(this.prepareBatch(param));
1088
+ const size = 50; // больше не отдаст
1089
+ let subarray = []; //массив в который будет выведен результат.
1090
+ for (let i = 0; i < Math.ceil(prepareParam.length / size); i++) {
1091
+ subarray[i] = prepareParam.slice((i * size), (i * size) + size);
1092
+ }
1093
+ return forkJoin(subarray.map(i => {
1094
+ return this.httpPost('batch.json', {
1095
+ halt: 0,
1096
+ cmd: Object.assign({}, ...i.map(x => {
1097
+ return { [x[0]]: x[1] };
1098
+ }))
1099
+ });
1100
+ }));
1101
+ }
1102
+ prepareBatch(param) {
1103
+ let res = Object.keys(param).reduce((obj, key) => {
1104
+ obj[key] = '';
1105
+ return obj;
1106
+ }, {});
1107
+ for (let key in param) {
1108
+ if (typeof key === 'string' || typeof key === 'number' && param[key].param) {
1109
+ res[key] = param[key].name + '?' + this.getHttpParamsGet(param[key].param).toString();
1110
+ }
1111
+ }
1112
+ return res;
1113
+ }
1114
+ mapBranchResult(res) {
1115
+ return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined));
1116
+ }
1117
+ mapBranchResultWithoutKey(res) {
1118
+ return flatten(Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)));
1119
+ }
1120
+ post(name, params = {}, textError = '', settings = this.defSettings) {
1121
+ return this.httpPost(this.getNameMethod(name), params, textError, settings);
1122
+ }
1123
+ get(name, params = {}, textError = '', settings = this.defSettings) {
1124
+ return this.httpGet(this.getNameMethod(name), params, textError, settings);
1125
+ }
1126
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
1127
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1128
+ if (auth) {
1129
+ const paramsClone = clone(params);
1130
+ paramsClone[this.session.getKeyAuth()] = auth;
1131
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1132
+ if (v) {
1133
+ return this.http.post(this.prepareBaseAddress(v) + url, this.getHttpParamsPost(paramsClone, new FormData(), false, [], settings))
1134
+ .pipe(take(1), catchError(err => {
1135
+ if (!textError.length && err.error.error_description) {
1136
+ textError = err.error.error_description;
1137
+ }
1138
+ this.snackBar.error('Ошибка: ' + textError);
1139
+ return throwError(() => err);
1140
+ }));
1141
+ }
1142
+ return throwError(() => 'get base url error');
1143
+ }));
1144
+ }
1145
+ else {
1146
+ this.snackBar.error('Error: Auth not get');
1147
+ return throwError(() => 'auth not get');
1148
+ }
1149
+ }));
1150
+ }
1151
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
1152
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1153
+ if (auth) {
1154
+ if (params === null) {
1155
+ params = {};
1156
+ }
1157
+ const paramsClone = clone(params);
1158
+ paramsClone[this.session.getKeyAuth()] = auth;
1159
+ let options = {
1160
+ params: this.getHttpParamsGet(paramsClone)
1161
+ };
1162
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1163
+ if (v) {
1164
+ return this.http.get(this.prepareBaseAddress(v) + url, options).pipe(take(1), catchError(err => {
1165
+ if (!textError.length && err.error.error_description) {
1166
+ textError = err.error.error_description;
1167
+ }
1168
+ this.snackBar.error('Ошибка: ' + textError);
1169
+ return throwError(() => err);
1170
+ }));
1171
+ }
1172
+ return throwError(() => 'get base url error');
1173
+ }));
1174
+ }
1175
+ else {
1176
+ this.snackBar.error('Error: Auth not get');
1177
+ return throwError(() => 'auth not get');
1178
+ }
1179
+ }));
1180
+ }
1181
+ getNameMethod(arr) {
1182
+ return arr.join('.');
1183
+ }
1184
+ }
1185
+ HttpServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, deps: [{ token: i1$3.HttpClient }, { token: SnackBarService }, { token: SessionKeyServices }], target: i0.ɵɵFactoryTarget.Injectable });
1186
+ HttpServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, providedIn: 'root' });
1187
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, decorators: [{
1188
+ type: Injectable,
1189
+ args: [{
1190
+ providedIn: 'root'
1191
+ }]
1192
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: SnackBarService }, { type: SessionKeyServices }]; } });
1193
+
1194
+ class HttpBXServices extends HttpServices {
1195
+ timeNowOnServer() {
1196
+ return this.httpGet('server.time').pipe(map(v => {
1197
+ if (v && v.result) {
1198
+ return new Date(v.result);
1199
+ }
1200
+ return undefined;
1201
+ }));
1202
+ }
1203
+ /**
1204
+ * Это пиздец а не метод
1205
+ * @param param
1206
+ */
1207
+ branch(param) {
1208
+ let prepareParam = Object.entries(this.prepareBatch(param));
1209
+ const size = 50; // больше не отдаст
1210
+ let subarray = []; //массив в который будет выведен результат.
1211
+ for (let i = 0; i < Math.ceil(prepareParam.length / size); i++) {
1212
+ subarray[i] = prepareParam.slice((i * size), (i * size) + size);
1213
+ }
1214
+ return forkJoin(subarray.map(i => {
1215
+ return this.httpPost('batch.json', {
1216
+ halt: 0,
1217
+ cmd: Object.assign({}, ...i.map(x => {
1218
+ return { [x[0]]: x[1] };
1219
+ }))
1220
+ });
1221
+ }));
1222
+ }
1223
+ prepareBatch(param) {
1224
+ let res = Object.keys(param).reduce((obj, key) => {
1225
+ obj[key] = '';
1226
+ return obj;
1227
+ }, {});
1228
+ for (let key in param) {
1229
+ if (typeof key === 'string' || typeof key === 'number' && param[key].param) {
1230
+ res[key] = param[key].name + '?' + this.getHttpParamsGet(param[key].param).toString();
1231
+ }
1232
+ }
1233
+ return res;
1234
+ }
1235
+ mapBranchResult(res) {
1236
+ return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined));
1237
+ }
1238
+ mapBranchResultWithoutKey(res) {
1239
+ return flatten(Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)));
1240
+ }
1241
+ post(name, params = {}, textError = '', settings = this.defSettings) {
1242
+ return this.httpPost(this.getNameMethod(name), params, textError, settings);
1243
+ }
1244
+ get(name, params = {}, textError = '', settings = this.defSettings) {
1245
+ return this.httpGet(this.getNameMethod(name), params, textError, settings);
1246
+ }
1247
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
1248
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1249
+ if (auth) {
1250
+ const paramsClone = clone(params);
1251
+ paramsClone[this.session.getKeyAuth()] = auth;
1252
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1253
+ if (v) {
1254
+ return this.http.post(this.prepareBaseAddress(v) + url, this.getHttpParamsPost(paramsClone, new FormData(), false, [], settings))
1255
+ .pipe(take(1), catchError(err => {
1256
+ if (!textError.length && err.error.error_description) {
1257
+ textError = err.error.error_description;
1258
+ }
1259
+ this.snackBar.error('Ошибка: ' + textError);
1260
+ return throwError(() => err);
1261
+ }));
1262
+ }
1263
+ return throwError(() => 'get base url error');
1264
+ }));
1265
+ }
1266
+ else {
1267
+ this.snackBar.error('Error: Auth not get');
1268
+ return throwError(() => 'auth not get');
1269
+ }
1270
+ }));
1271
+ }
1272
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
1273
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1274
+ if (auth) {
1275
+ if (params === null) {
1276
+ params = {};
1277
+ }
1278
+ const paramsClone = clone(params);
1279
+ paramsClone[this.session.getKeyAuth()] = auth;
1280
+ let options = {
1281
+ params: this.getHttpParamsGet(paramsClone)
1282
+ };
1283
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1284
+ if (v) {
1285
+ return this.http.get(this.prepareBaseAddress(v) + url, options).pipe(take(1), catchError(err => {
1286
+ if (!textError.length && err.error.error_description) {
1287
+ textError = err.error.error_description;
1288
+ }
1289
+ this.snackBar.error('Ошибка: ' + textError);
1290
+ return throwError(() => err);
1291
+ }));
1292
+ }
1293
+ return throwError(() => 'get base url error');
1294
+ }));
1295
+ }
1296
+ else {
1297
+ this.snackBar.error('Error: Auth not get');
1298
+ return throwError(() => 'auth not get');
1299
+ }
1300
+ }));
1301
+ }
1302
+ getNameMethod(arr) {
1303
+ return arr.join('.');
1304
+ }
1305
+ }
1306
+ HttpBXServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1307
+ HttpBXServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, providedIn: 'root' });
1308
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, decorators: [{
1309
+ type: Injectable,
1310
+ args: [{
1311
+ providedIn: 'root'
1312
+ }]
1313
+ }] });
1314
+
1315
+ const save = createAction('[Users Component] Save', props());
1316
+ const saveArr = createAction('[Users Component] Save Arr', props());
1317
+ const update = createAction('[Users Component] Update', props());
1318
+ const loadAll = createAction('[Users Component] loadAll', props());
1319
+ const saveSelf = createAction('[Users Component] saveSelf', props());
1320
+ const saveIDLoadedDepartment = createAction('[Users Component] saveIDLoadedDepartment', props());
1321
+ const initialState = {
1322
+ load: {
1323
+ all: false,
1324
+ department: []
1325
+ },
1326
+ self: undefined,
1327
+ data: []
1328
+ };
1329
+ const _usersReducer = createReducer(initialState, on(saveIDLoadedDepartment, (s, data) => {
1330
+ let copy = clone(s);
1331
+ copy.load.department = [...copy.load.department, ...data.id];
1332
+ return copy;
1333
+ }), on(save, (s, data) => {
1334
+ const find = s.data.find(v => v.ID === data.ID);
1335
+ if (!find) {
1336
+ const copy = clone(s);
1337
+ copy.data.push(data);
1338
+ return copy;
1339
+ }
1340
+ return s;
1341
+ }), on(saveArr, (s, data) => {
1342
+ const copy = clone(s);
1343
+ if (copy.data && copy.data.length) {
1344
+ for (const user of data.arr) {
1345
+ const find = copy.data.find(v => v.ID === user.ID);
1346
+ if (!find) {
1347
+ copy.data.push(user);
1348
+ }
1349
+ }
1350
+ }
1351
+ else {
1352
+ copy.data = [...data.arr];
1353
+ }
1354
+ return copy;
1355
+ }), on(update, (s, data) => {
1356
+ const copy = clone(s);
1357
+ let find = copy.data.findIndex(v => v.ID === data.ID);
1358
+ if (find !== -1) {
1359
+ const copy = clone(s);
1360
+ copy.data.splice(find, 1, data);
1361
+ // copy.data.push(data)
1362
+ return copy;
1363
+ }
1364
+ return s;
1365
+ }), on(loadAll, (s, data) => {
1366
+ if (data.load !== s.load.all) {
1367
+ const copy = clone(s);
1368
+ copy.load.all = data.load;
1369
+ return copy;
1370
+ }
1371
+ return s;
1372
+ }), on(saveSelf, (s, data) => {
1373
+ return Object.assign(Object.assign({}, s), { self: data.self });
1374
+ }));
1375
+ function usersReducer(state = initialState, action) {
1376
+ return _usersReducer(state, action);
1377
+ }
1378
+
1379
+ class BaseMapServices extends BaseServices {
1380
+ }
1381
+ BaseMapServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1382
+ BaseMapServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, providedIn: 'root' });
1383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, decorators: [{
1384
+ type: Injectable,
1385
+ args: [{
1386
+ providedIn: 'root'
1387
+ }]
1388
+ }] });
1389
+
1390
+ class BitrixApiUserMapServices extends BaseMapServices {
1391
+ HttpToBX(user) {
1392
+ let res = Object.assign(clone(user), {
1393
+ ID: this.toNum(user.ID),
1394
+ IS_ONLINE: this.toBool(user.IS_ONLINE),
1395
+ DATE_REGISTER: this.toDate(user.DATE_REGISTER),
1396
+ PERSONAL_BIRTHDAY: this.toDate(user.PERSONAL_BIRTHDAY),
1397
+ });
1398
+ if (user.LAST_LOGIN) {
1399
+ res.LAST_LOGIN = this.toDate(user.LAST_LOGIN);
1400
+ }
1401
+ return res;
1402
+ }
1403
+ BXtoHttp(user) {
1404
+ return Object.assign(clone(user), {
1405
+ ID: this.toStr(user.ID),
1406
+ IS_ONLINE: this.toBXYorN(user.IS_ONLINE),
1407
+ DATE_REGISTER: this.getBXStrTime(user.DATE_REGISTER),
1408
+ PERSONAL_BIRTHDAY: this.toStr(user.PERSONAL_BIRTHDAY),
1409
+ LAST_LOGIN: this.toStr(user.LAST_LOGIN)
1410
+ });
1411
+ }
1412
+ getFIO(user) {
1413
+ let res = '';
1414
+ if (!user.LAST_NAME) {
1415
+ const SECOND_NAME = (user.SECOND_NAME) ? user.SECOND_NAME : '';
1416
+ const NAME = (user.NAME) ? user.NAME : '';
1417
+ res = NAME + ' ' + SECOND_NAME;
1418
+ }
1419
+ else if (!user.NAME) {
1420
+ res = user.LAST_NAME;
1421
+ }
1422
+ else if (!user.SECOND_NAME) {
1423
+ res = user.LAST_NAME + ' ' + user.NAME;
1424
+ }
1425
+ else {
1426
+ res = user.LAST_NAME + ' ' + user.NAME + ' ' + user.SECOND_NAME;
1427
+ }
1428
+ return res.trim();
1429
+ }
1430
+ getFI(user) {
1431
+ let res = '';
1432
+ if (!user.LAST_NAME) {
1433
+ const NAME = (user.NAME) ? user.NAME : '';
1434
+ res = NAME;
1435
+ }
1436
+ else if (!user.NAME) {
1437
+ res = user.LAST_NAME;
1438
+ }
1439
+ else {
1440
+ res = user.LAST_NAME + ' ' + user.NAME;
1441
+ }
1442
+ return res.trim();
1443
+ }
1444
+ getFIOShort(user) {
1445
+ let res = '';
1446
+ if (!user.LAST_NAME) {
1447
+ const SECOND_NAME = (user.SECOND_NAME) ? user.SECOND_NAME : '';
1448
+ const NAME = (user.NAME) ? user.NAME : '';
1449
+ res = NAME + ' ' + SECOND_NAME;
1450
+ }
1451
+ else if (!user.NAME) {
1452
+ res = user.LAST_NAME;
1453
+ }
1454
+ else if (!user.SECOND_NAME) {
1455
+ res = user.LAST_NAME + ' ' + user.NAME.charAt(0).toUpperCase() + '.';
1456
+ }
1457
+ else {
1458
+ res =
1459
+ user.LAST_NAME + ' ' +
1460
+ user.NAME.charAt(0).toUpperCase() + '.' +
1461
+ user.SECOND_NAME.charAt(0).toUpperCase() + '.';
1462
+ }
1463
+ return res.trim();
1464
+ }
1465
+ }
1466
+ BitrixApiUserMapServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1467
+ BitrixApiUserMapServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, providedIn: 'root' });
1468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, decorators: [{
1469
+ type: Injectable,
1470
+ args: [{
1471
+ providedIn: 'root'
1472
+ }]
1473
+ }] });
1474
+
1475
+ class BXRestUser {
1476
+ constructor(http, snackBar,
1477
+ // private img: ImgServices,
1478
+ //private dateTrace: DateTrace,
1479
+ store, userMap) {
1480
+ this.http = http;
1481
+ this.snackBar = snackBar;
1482
+ this.store = store;
1483
+ this.userMap = userMap;
1484
+ this.url = {
1485
+ admin: [$user, 'admin'],
1486
+ get: [$user, $get],
1487
+ current: [$user, 'current'],
1488
+ update: [$user, $update],
1489
+ search: [$user, $search],
1490
+ access: [$user, 'access'],
1491
+ // AU - все авторизованные пользователи
1492
+ // D1 - подразделение с id=1
1493
+ // G1 - группа с id=1
1494
+ fields: [$user, 'fields'],
1495
+ userfield: {
1496
+ list: [$user, 'userfield', $list]
1497
+ }
1498
+ };
1499
+ this.def = {
1500
+ params: { ACTIVE: 1, start: 0 }
1501
+ };
1502
+ this.user$ = this.store.select('users');
1503
+ }
1504
+ admin() {
1505
+ return this.http.get(this.url.admin);
1506
+ }
1507
+ get(params = {}) {
1508
+ let copyParams = clone(params);
1509
+ this.setDefParam(copyParams);
1510
+ return this.http.post(this.url.get, copyParams, 'Не удалось получить пользователей')
1511
+ .pipe(tap(v => {
1512
+ if (v && v.result) {
1513
+ this.saveArrUser(v.result);
1514
+ }
1515
+ }));
1516
+ }
1517
+ current(update = false) {
1518
+ if (update) {
1519
+ return this.getSelfHttp();
1520
+ }
1521
+ else {
1522
+ return this.user$.pipe(mergeMap$1(v => {
1523
+ if (v && v.self) {
1524
+ return of(v.self);
1525
+ }
1526
+ else {
1527
+ return this.getSelfHttp();
1528
+ }
1529
+ }), first());
1530
+ }
1531
+ }
1532
+ getSelfHttp() {
1533
+ return this.http.get(this.url.current, {}, 'Не удалось получить пользователя')
1534
+ .pipe(map(v => {
1535
+ if (v && v.result) {
1536
+ return this.userMap.HttpToBX(v.result);
1537
+ }
1538
+ return undefined;
1539
+ }), tap(v => {
1540
+ if (v) {
1541
+ this.store.dispatch(saveSelf({ self: v }));
1542
+ }
1543
+ }));
1544
+ }
1545
+ access(access, textError = 'Не удалось получить права') {
1546
+ return this.http.get(this.url.access, { ACCESS: access }, textError);
1547
+ }
1548
+ // getAll(params: iBXGetParam = {}): Observable<iBXRestUser [] | undefined> {
1549
+ // if (!Object.keys(params).length) {
1550
+ // params = clone(this.def.params)
1551
+ // }
1552
+ //
1553
+ // const saveAllUser = compare(params, this.def.params)
1554
+ // return this.user$.pipe(
1555
+ // take(1),
1556
+ // mergeMap(v => {
1557
+ // if (v.load.all) {
1558
+ // if (compare(this.def.params, params)) {
1559
+ // return of(clone(v.data))
1560
+ // }
1561
+ // }
1562
+ //
1563
+ // return this.getEndArray(params).pipe(
1564
+ // take(1),
1565
+ // map(v => {
1566
+ // if (v && v.result) {
1567
+ // let cl = clone(v.result)
1568
+ // return this.saveArrUser(cl)
1569
+ // }
1570
+ // return undefined
1571
+ // }),
1572
+ // )
1573
+ // }),
1574
+ // tap(v => {
1575
+ // if (v && v.length && saveAllUser) {
1576
+ // this.store.dispatch(loadAll({load: true}))
1577
+ // }
1578
+ // params.start = this.def.params.start
1579
+ // })
1580
+ // )
1581
+ // }
1582
+ saveArrUser(users) {
1583
+ let result = [];
1584
+ for (const user of users) {
1585
+ result.push(this.userMap.HttpToBX(user));
1586
+ }
1587
+ this.store.dispatch(saveArr({ arr: result }));
1588
+ return result;
1589
+ }
1590
+ search(params) {
1591
+ if (typeof params === 'string') {
1592
+ params = { FIND: params };
1593
+ }
1594
+ if (typeof params.ACTIVE !== 'boolean') {
1595
+ params.ACTIVE = true;
1596
+ }
1597
+ return this.http.get(this.url.search, params, 'Сервер не отвечает на запрос поиска');
1598
+ }
1599
+ fields() {
1600
+ return this.http.get(this.url.fields);
1601
+ }
1602
+ update(user, fieldUpdate) {
1603
+ if (fieldUpdate && fieldUpdate.length) {
1604
+ let sendData = {
1605
+ ID: user.ID,
1606
+ };
1607
+ const userBX = this.userMap.BXtoHttp(user);
1608
+ for (const field of fieldUpdate) {
1609
+ if (userBX[field]) {
1610
+ sendData[field] = userBX[field];
1611
+ }
1612
+ else {
1613
+ this.snackBar.error('Одно из указанных полей отправлено не верно');
1614
+ }
1615
+ }
1616
+ return this.http.post(this.url.update, sendData, 'Не удалось обновить пользователя с ID' + user.ID);
1617
+ }
1618
+ else {
1619
+ this.snackBar.error('Не указано ни одно поле для редактирования пользователя');
1620
+ return of({});
1621
+ }
1622
+ }
1623
+ // getEndArray(params: UserFilter = {}): Observable<iHttpAnswerBX<iBXRestUserHttp[]> | undefined> {
1624
+ // return this.get(params).pipe(
1625
+ // mergeMap(items => {
1626
+ // if (items && items.result && typeof items.result === 'object') {
1627
+ // if (items.next) {
1628
+ // params.start = items.next
1629
+ // return this.getEndArray(params).pipe(map(vEnd => {
1630
+ // if (vEnd && items.result && vEnd.result) {
1631
+ // return {result: [...items.result, ...vEnd.result]}
1632
+ // }
1633
+ // return (items) ? items : undefined
1634
+ // }))
1635
+ // }
1636
+ // return of(items)
1637
+ // } else {
1638
+ // return of(undefined)
1639
+ // }
1640
+ // }),
1641
+ // )
1642
+ // }
1643
+ setDefParam(params) {
1644
+ if (!params.hasOwnProperty('ACTIVE')) {
1645
+ params.ACTIVE = this.def.params.ACTIVE;
1646
+ }
1647
+ if (params.ACTIVE && params.ACTIVE === 2) {
1648
+ delete params.ACTIVE;
1649
+ }
1650
+ if (!params.hasOwnProperty('start')) {
1651
+ params.start = this.def.params.start;
1652
+ }
1653
+ if (params.UF_DEPARTMENT && !params.UF_DEPARTMENT.length) {
1654
+ delete params.UF_DEPARTMENT;
1655
+ }
1656
+ }
1657
+ }
1658
+ BXRestUser.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, deps: [{ token: HttpBXServices }, { token: SnackBarService }, { token: i1$2.Store }, { token: BitrixApiUserMapServices }], target: i0.ɵɵFactoryTarget.Injectable });
1659
+ BXRestUser.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, providedIn: 'root' });
1660
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, decorators: [{
1661
+ type: Injectable,
1662
+ args: [{
1663
+ providedIn: 'root'
1664
+ }]
1665
+ }], ctorParameters: function () { return [{ type: HttpBXServices }, { type: SnackBarService }, { type: i1$2.Store }, { type: BitrixApiUserMapServices }]; } });
1666
+
1
1667
  // import { Observable } from 'rxjs'
2
1668
  // import BXRestListsElementMap from './map/lists/element'
3
1669
  // import { map } from 'rxjs/operators'
@@ -8,31 +1674,14 @@ class BXRest {
8
1674
  this.lists = lists;
9
1675
  }
10
1676
  }
11
- // @Injectable({
12
- // providedIn: 'root'
13
- // })
14
- // export class BXRest extends new Proxy(BXRestBase, {
15
- // get(target, prop, receiver) {
16
- // const res = Reflect.get(target, prop, receiver)
17
- // console.log('res', res)
18
- // if (res in Observable) {
19
- // let mapRes = new BXRestListsElementMap()
20
- // console.log('res', res)
21
- // return Reflect.get(target, prop, receiver).pipe(
22
- // // @ts-ignore
23
- // map(v => (v && v.result)
24
- // // @ts-ignore
25
- // ? Object.assign(v, {result: v.result.map(i => mapRes.get(i))})
26
- // : undefined
27
- // ),
28
- // // @ts-ignore
29
- // map(v => mapResult(v))
30
- // )
31
- // }
32
- // return res
33
- // }
34
- // }) {
35
- // }
1677
+ BXRest.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRest, deps: [{ token: BXRestUser }, { token: BXRestLists }], target: i0.ɵɵFactoryTarget.Injectable });
1678
+ BXRest.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRest, providedIn: 'root' });
1679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRest, decorators: [{
1680
+ type: Injectable,
1681
+ args: [{
1682
+ providedIn: 'root'
1683
+ }]
1684
+ }], ctorParameters: function () { return [{ type: BXRestUser }, { type: BXRestLists }]; } });
36
1685
 
37
1686
  /*
38
1687
  * Public API Surface of bx-rest