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