@sam-senior/sam-utils 2.0.3 → 3.0.0
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/README.md +1 -1
- package/esm2022/lib/has-integrated-role.model.mjs +2 -0
- package/esm2022/lib/sam-utils.service.mjs +216 -0
- package/esm2022/lib/tenant-information.mjs +2 -0
- package/esm2022/lib/user-roles.model.mjs +4 -0
- package/esm2022/lib/user.model.mjs +2 -0
- package/esm2022/public-api.mjs +5 -0
- package/esm2022/sam-senior-sam-utils.mjs +5 -0
- package/fesm2022/sam-senior-sam-utils.mjs +227 -0
- package/fesm2022/sam-senior-sam-utils.mjs.map +1 -0
- package/{sam-senior-sam-utils.d.ts → index.d.ts} +5 -4
- package/lib/has-integrated-role.model.d.ts +3 -3
- package/lib/sam-utils.service.d.ts +29 -26
- package/lib/tenant-information.d.ts +3 -3
- package/lib/user-roles.model.d.ts +3 -3
- package/lib/user.model.d.ts +16 -16
- package/package.json +21 -14
- package/public-api.d.ts +1 -1
- package/bundles/sam-senior-sam-utils.umd.js +0 -549
- package/bundles/sam-senior-sam-utils.umd.js.map +0 -1
- package/bundles/sam-senior-sam-utils.umd.min.js +0 -2
- package/bundles/sam-senior-sam-utils.umd.min.js.map +0 -1
- package/esm2015/lib/has-integrated-role.model.js +0 -13
- package/esm2015/lib/sam-utils.service.js +0 -351
- package/esm2015/lib/tenant-information.js +0 -13
- package/esm2015/lib/user-roles.model.js +0 -11
- package/esm2015/lib/user.model.js +0 -39
- package/esm2015/public-api.js +0 -9
- package/esm2015/sam-senior-sam-utils.js +0 -9
- package/esm5/lib/has-integrated-role.model.js +0 -13
- package/esm5/lib/sam-utils.service.js +0 -435
- package/esm5/lib/tenant-information.js +0 -13
- package/esm5/lib/user-roles.model.js +0 -15
- package/esm5/lib/user.model.js +0 -39
- package/esm5/public-api.js +0 -9
- package/esm5/sam-senior-sam-utils.js +0 -9
- package/fesm2015/sam-senior-sam-utils.js +0 -351
- package/fesm2015/sam-senior-sam-utils.js.map +0 -1
- package/fesm5/sam-senior-sam-utils.js +0 -434
- package/fesm5/sam-senior-sam-utils.js.map +0 -1
- package/sam-senior-sam-utils.metadata.json +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare class UserRoles {
|
|
2
|
-
roles: string[];
|
|
3
|
-
}
|
|
1
|
+
export declare class UserRoles {
|
|
2
|
+
roles: string[];
|
|
3
|
+
}
|
package/lib/user.model.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface User {
|
|
2
|
-
admin: boolean;
|
|
3
|
-
allowedToChangePassword: boolean;
|
|
4
|
-
authenticationType: string;
|
|
5
|
-
blocked: boolean;
|
|
6
|
-
changePassword: boolean;
|
|
7
|
-
description: string;
|
|
8
|
-
email: string;
|
|
9
|
-
fullName: string;
|
|
10
|
-
id: string;
|
|
11
|
-
locale: string;
|
|
12
|
-
tenantDomain: string;
|
|
13
|
-
tenantLocale: string;
|
|
14
|
-
tenantName: string;
|
|
15
|
-
username: string;
|
|
16
|
-
}
|
|
1
|
+
export interface User {
|
|
2
|
+
admin: boolean;
|
|
3
|
+
allowedToChangePassword: boolean;
|
|
4
|
+
authenticationType: string;
|
|
5
|
+
blocked: boolean;
|
|
6
|
+
changePassword: boolean;
|
|
7
|
+
description: string;
|
|
8
|
+
email: string;
|
|
9
|
+
fullName: string;
|
|
10
|
+
id: string;
|
|
11
|
+
locale: string;
|
|
12
|
+
tenantDomain: string;
|
|
13
|
+
tenantLocale: string;
|
|
14
|
+
tenantName: string;
|
|
15
|
+
username: string;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sam-senior/sam-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "
|
|
6
|
-
"@angular/core": "
|
|
5
|
+
"@angular/common": "^18.0.0",
|
|
6
|
+
"@angular/core": "^18.0.0"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
"module": "fesm2022/sam-senior-sam-utils.mjs",
|
|
9
|
+
"typings": "index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./package.json": {
|
|
12
|
+
"default": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"esm2022": "./esm2022/sam-senior-sam-utils.mjs",
|
|
17
|
+
"esm": "./esm2022/sam-senior-sam-utils.mjs",
|
|
18
|
+
"default": "./fesm2022/sam-senior-sam-utils.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"tslib": "^2.3.0"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/public-api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './lib/sam-utils.service';
|
|
1
|
+
export * from './lib/sam-utils.service';
|
|
@@ -1,549 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common/http')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@sam-senior/sam-utils', ['exports', '@angular/core', 'rxjs', '@angular/common/http'], factory) :
|
|
4
|
-
(factory((global['sam-senior'] = global['sam-senior'] || {}, global['sam-senior']['sam-utils'] = {}),global.ng.core,global.rxjs,global.ng.common.http));
|
|
5
|
-
}(this, (function (exports,i0,rxjs,i1) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
var __assign = function () {
|
|
22
|
-
__assign = Object.assign || function __assign(t) {
|
|
23
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24
|
-
s = arguments[i];
|
|
25
|
-
for (var p in s)
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
27
|
-
t[p] = s[p];
|
|
28
|
-
}
|
|
29
|
-
return t;
|
|
30
|
-
};
|
|
31
|
-
return __assign.apply(this, arguments);
|
|
32
|
-
};
|
|
33
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
34
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
-
function fulfilled(value) { try {
|
|
37
|
-
step(generator.next(value));
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
reject(e);
|
|
41
|
-
} }
|
|
42
|
-
function rejected(value) { try {
|
|
43
|
-
step(generator["throw"](value));
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
} }
|
|
48
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
49
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function __generator(thisArg, body) {
|
|
53
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
54
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
55
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
56
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
|
-
function step(op) {
|
|
58
|
-
if (f)
|
|
59
|
-
throw new TypeError("Generator is already executing.");
|
|
60
|
-
while (_)
|
|
61
|
-
try {
|
|
62
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
63
|
-
return t;
|
|
64
|
-
if (y = 0, t)
|
|
65
|
-
op = [op[0] & 2, t.value];
|
|
66
|
-
switch (op[0]) {
|
|
67
|
-
case 0:
|
|
68
|
-
case 1:
|
|
69
|
-
t = op;
|
|
70
|
-
break;
|
|
71
|
-
case 4:
|
|
72
|
-
_.label++;
|
|
73
|
-
return { value: op[1], done: false };
|
|
74
|
-
case 5:
|
|
75
|
-
_.label++;
|
|
76
|
-
y = op[1];
|
|
77
|
-
op = [0];
|
|
78
|
-
continue;
|
|
79
|
-
case 7:
|
|
80
|
-
op = _.ops.pop();
|
|
81
|
-
_.trys.pop();
|
|
82
|
-
continue;
|
|
83
|
-
default:
|
|
84
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
85
|
-
_ = 0;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
89
|
-
_.label = op[1];
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
93
|
-
_.label = t[1];
|
|
94
|
-
t = op;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
if (t && _.label < t[2]) {
|
|
98
|
-
_.label = t[2];
|
|
99
|
-
_.ops.push(op);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
if (t[2])
|
|
103
|
-
_.ops.pop();
|
|
104
|
-
_.trys.pop();
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
op = body.call(thisArg, _);
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
op = [6, e];
|
|
111
|
-
y = 0;
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
f = t = 0;
|
|
115
|
-
}
|
|
116
|
-
if (op[0] & 5)
|
|
117
|
-
throw op[1];
|
|
118
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @fileoverview added by tsickle
|
|
124
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
125
|
-
*/
|
|
126
|
-
var SamUtilsService = /** @class */ (function () {
|
|
127
|
-
function SamUtilsService(httpClient) {
|
|
128
|
-
this.httpClient = httpClient;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @param {?} urlParts
|
|
132
|
-
* @return {?}
|
|
133
|
-
*/
|
|
134
|
-
SamUtilsService.prototype.getUrlWithoutIds = /**
|
|
135
|
-
* @param {?} urlParts
|
|
136
|
-
* @return {?}
|
|
137
|
-
*/
|
|
138
|
-
function (urlParts) {
|
|
139
|
-
return urlParts.map(( /**
|
|
140
|
-
* @param {?} urlPart
|
|
141
|
-
* @return {?}
|
|
142
|
-
*/function (urlPart) {
|
|
143
|
-
/** @type {?} */
|
|
144
|
-
var url = urlPart;
|
|
145
|
-
try {
|
|
146
|
-
/** @type {?} */
|
|
147
|
-
var id = ( /** @type {?} */(parseFloat(urlPart)));
|
|
148
|
-
if (id > 0 || id === 'new') {
|
|
149
|
-
url = '{id}';
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (_) {
|
|
153
|
-
url = urlPart;
|
|
154
|
-
}
|
|
155
|
-
return url;
|
|
156
|
-
})).join('/');
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* @param {?} product
|
|
160
|
-
* @return {?}
|
|
161
|
-
*/
|
|
162
|
-
SamUtilsService.prototype.setUserProperties = /**
|
|
163
|
-
* @param {?} product
|
|
164
|
-
* @return {?}
|
|
165
|
-
*/
|
|
166
|
-
function (product) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
-
var user;
|
|
169
|
-
return __generator(this, function (_a) {
|
|
170
|
-
switch (_a.label) {
|
|
171
|
-
case 0: return [4 /*yield*/, this.getActiveUser().toPromise()];
|
|
172
|
-
case 1:
|
|
173
|
-
user = _a.sent();
|
|
174
|
-
gtag('set', 'user_properties', {
|
|
175
|
-
product_g7: product,
|
|
176
|
-
tenant: user.tenantName,
|
|
177
|
-
username: user.username
|
|
178
|
-
});
|
|
179
|
-
return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* @param {?} page
|
|
186
|
-
* @param {?} product
|
|
187
|
-
* @return {?}
|
|
188
|
-
*/
|
|
189
|
-
SamUtilsService.prototype.pageLoading = /**
|
|
190
|
-
* @param {?} page
|
|
191
|
-
* @param {?} product
|
|
192
|
-
* @return {?}
|
|
193
|
-
*/
|
|
194
|
-
function (page, product) {
|
|
195
|
-
if (!SamUtilsService.HAS_LOADED && window.performance) {
|
|
196
|
-
SamUtilsService.HAS_LOADED = true;
|
|
197
|
-
/** @type {?} */
|
|
198
|
-
var timeSincePageLoad = Math.round(performance.now());
|
|
199
|
-
this.sendToAnalytics('tempo_carregamento_tela', {
|
|
200
|
-
time_value: (timeSincePageLoad / 1000),
|
|
201
|
-
page: page
|
|
202
|
-
}, product).then();
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* @return {?}
|
|
207
|
-
*/
|
|
208
|
-
SamUtilsService.prototype.getBaseURL = /**
|
|
209
|
-
* @return {?}
|
|
210
|
-
*/
|
|
211
|
-
function () {
|
|
212
|
-
try {
|
|
213
|
-
/** @type {?} */
|
|
214
|
-
var cookie = document.cookie.split(';').filter(( /**
|
|
215
|
-
* @param {?} cookieStr
|
|
216
|
-
* @return {?}
|
|
217
|
-
*/function (cookieStr) {
|
|
218
|
-
return cookieStr.includes('com.senior.base.url');
|
|
219
|
-
}));
|
|
220
|
-
return decodeURIComponent(cookie[0].split('=')[1]).slice(0, -1);
|
|
221
|
-
}
|
|
222
|
-
catch (err) {
|
|
223
|
-
throw Error('Platform G7 not configured in this app');
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* @param {?} eventName
|
|
228
|
-
* @param {?} params
|
|
229
|
-
* @param {?=} product
|
|
230
|
-
* @return {?}
|
|
231
|
-
*/
|
|
232
|
-
SamUtilsService.prototype.sendToAnalytics = /**
|
|
233
|
-
* @param {?} eventName
|
|
234
|
-
* @param {?} params
|
|
235
|
-
* @param {?=} product
|
|
236
|
-
* @return {?}
|
|
237
|
-
*/
|
|
238
|
-
function (eventName, params, product) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var user;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
switch (_a.label) {
|
|
243
|
-
case 0: return [4 /*yield*/, this.getActiveUser().toPromise()];
|
|
244
|
-
case 1:
|
|
245
|
-
user = _a.sent();
|
|
246
|
-
gtag('event', eventName, __assign(__assign({}, params), { environment: this.getBaseURL(), user: user.username, tentant: user.tenantName, product: product ? product : params.product, debug_mode: true }));
|
|
247
|
-
return [2 /*return*/];
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* @template T
|
|
254
|
-
* @param {?} value
|
|
255
|
-
* @return {?}
|
|
256
|
-
*/
|
|
257
|
-
SamUtilsService.prototype.createObservableWithValue = /**
|
|
258
|
-
* @template T
|
|
259
|
-
* @param {?} value
|
|
260
|
-
* @return {?}
|
|
261
|
-
*/
|
|
262
|
-
function (value) {
|
|
263
|
-
return new rxjs.Observable(( /**
|
|
264
|
-
* @param {?} observer
|
|
265
|
-
* @return {?}
|
|
266
|
-
*/function (observer) {
|
|
267
|
-
observer.next(value);
|
|
268
|
-
observer.complete();
|
|
269
|
-
}));
|
|
270
|
-
};
|
|
271
|
-
/* tslint:disable */
|
|
272
|
-
/* tslint:disable */
|
|
273
|
-
/**
|
|
274
|
-
* @return {?}
|
|
275
|
-
*/
|
|
276
|
-
SamUtilsService.prototype.getBrowser = /* tslint:disable */
|
|
277
|
-
/**
|
|
278
|
-
* @return {?}
|
|
279
|
-
*/
|
|
280
|
-
function () {
|
|
281
|
-
if ((!!window['opr'] && !!window['opr'].addons) || !!window['opera'] || navigator.userAgent.indexOf(' OPR/') >= 0) { // Opera 8.0+
|
|
282
|
-
return 'Opera';
|
|
283
|
-
}
|
|
284
|
-
else if (typeof InstallTrigger !== 'undefined') { // Firefox 1.0+
|
|
285
|
-
return 'Firefox';
|
|
286
|
-
}
|
|
287
|
-
else if (/constructor/i.test(( /** @type {?} */(window['HTMLElement']))) || (( /**
|
|
288
|
-
* @param {?} p
|
|
289
|
-
* @return {?}
|
|
290
|
-
*/function (p) { return p.toString() === "[object SafariRemoteNotification]"; }))(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification))) { // Safari 3.0+ "[object HTMLElementConstructor]"
|
|
291
|
-
return 'Safari';
|
|
292
|
-
}
|
|
293
|
-
else if ( /*@cc_on!@*/!!document['documentMode']) { // Internet Explorer 6-11
|
|
294
|
-
return 'Internet Explorer';
|
|
295
|
-
}
|
|
296
|
-
else if (!( /*@cc_on!@*/!!document['documentMode']) && !!window['StyleMedia']) { //Edge 20+
|
|
297
|
-
return 'Edge';
|
|
298
|
-
}
|
|
299
|
-
else if (!!window['chrome']) { // Chrome 1+
|
|
300
|
-
return 'Chrome';
|
|
301
|
-
}
|
|
302
|
-
return 'unknown';
|
|
303
|
-
};
|
|
304
|
-
/* tslint:enable */
|
|
305
|
-
/* tslint:enable */
|
|
306
|
-
/**
|
|
307
|
-
* @return {?}
|
|
308
|
-
*/
|
|
309
|
-
SamUtilsService.prototype.getG7BridgeURL = /* tslint:enable */
|
|
310
|
-
/**
|
|
311
|
-
* @return {?}
|
|
312
|
-
*/
|
|
313
|
-
function () {
|
|
314
|
-
try {
|
|
315
|
-
/** @type {?} */
|
|
316
|
-
var dt = document.cookie.split(';').filter(( /**
|
|
317
|
-
* @param {?} cookieStr
|
|
318
|
-
* @return {?}
|
|
319
|
-
*/function (cookieStr) {
|
|
320
|
-
return cookieStr.includes('com.senior.services.url');
|
|
321
|
-
}));
|
|
322
|
-
return decodeURIComponent(dt[0].split('=')[1]).slice(0, -1);
|
|
323
|
-
}
|
|
324
|
-
catch (err) {
|
|
325
|
-
throw Error('Platform G7 not configured in this app');
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* @return {?}
|
|
330
|
-
*/
|
|
331
|
-
SamUtilsService.prototype.getActiveUser = /**
|
|
332
|
-
* @return {?}
|
|
333
|
-
*/
|
|
334
|
-
function () {
|
|
335
|
-
return this.httpClient.get(this.getG7BridgeURL() + "/rest/platform/user/queries/getUser", {
|
|
336
|
-
headers: this.getHeaders()
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
/**
|
|
340
|
-
* @param {?} user
|
|
341
|
-
* @return {?}
|
|
342
|
-
*/
|
|
343
|
-
SamUtilsService.prototype.getRolesByActiveUser = /**
|
|
344
|
-
* @param {?} user
|
|
345
|
-
* @return {?}
|
|
346
|
-
*/
|
|
347
|
-
function (user) {
|
|
348
|
-
return this.httpClient.get(this.getG7BridgeURL() + "/rest/platform/authorization/queries/getUserRoles?user=" + user, {
|
|
349
|
-
headers: this.getHeaders()
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
|
-
/**
|
|
353
|
-
* @param {?} schemaName
|
|
354
|
-
* @return {?}
|
|
355
|
-
*/
|
|
356
|
-
SamUtilsService.prototype.getTenatInformation = /**
|
|
357
|
-
* @param {?} schemaName
|
|
358
|
-
* @return {?}
|
|
359
|
-
*/
|
|
360
|
-
function (schemaName) {
|
|
361
|
-
return this.httpClient.get(this.getG7BridgeURL() + "/rest/sam/administration/queries/getErpCode", {
|
|
362
|
-
params: {
|
|
363
|
-
schemaName: schemaName
|
|
364
|
-
},
|
|
365
|
-
headers: this.getHeaders()
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
/**
|
|
369
|
-
* @return {?}
|
|
370
|
-
*/
|
|
371
|
-
SamUtilsService.prototype.hasIntegratedRole = /**
|
|
372
|
-
* @return {?}
|
|
373
|
-
*/
|
|
374
|
-
function () {
|
|
375
|
-
return this.httpClient.get(this.getG7BridgeURL() + "/rest/sam/application/queries/hasIntegratedRole", {
|
|
376
|
-
headers: this.getHeaders()
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* @private
|
|
381
|
-
* @return {?}
|
|
382
|
-
*/
|
|
383
|
-
SamUtilsService.prototype.getHeaders = /**
|
|
384
|
-
* @private
|
|
385
|
-
* @return {?}
|
|
386
|
-
*/
|
|
387
|
-
function () {
|
|
388
|
-
/** @type {?} */
|
|
389
|
-
var token = this.getG7Token();
|
|
390
|
-
return new i1.HttpHeaders().set('Authorization', token.token_type + " " + token.access_token);
|
|
391
|
-
};
|
|
392
|
-
/**
|
|
393
|
-
* @return {?}
|
|
394
|
-
*/
|
|
395
|
-
SamUtilsService.prototype.getG7Token = /**
|
|
396
|
-
* @return {?}
|
|
397
|
-
*/
|
|
398
|
-
function () {
|
|
399
|
-
try {
|
|
400
|
-
/** @type {?} */
|
|
401
|
-
var seniorToken = document.cookie.split(';').filter(( /**
|
|
402
|
-
* @param {?} cookieStr
|
|
403
|
-
* @return {?}
|
|
404
|
-
*/function (cookieStr) {
|
|
405
|
-
return cookieStr.includes('com.senior.token');
|
|
406
|
-
}));
|
|
407
|
-
return JSON.parse(decodeURIComponent(seniorToken[0].split('=')[1]));
|
|
408
|
-
}
|
|
409
|
-
catch (err) {
|
|
410
|
-
throw Error('Platform G7 not configured in this app');
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
/**
|
|
414
|
-
* @param {?} tracksaleKey
|
|
415
|
-
* @param {?} tracksaleCampaign
|
|
416
|
-
* @param {?} pageUrl
|
|
417
|
-
* @return {?}
|
|
418
|
-
*/
|
|
419
|
-
SamUtilsService.prototype.trackSale = /**
|
|
420
|
-
* @param {?} tracksaleKey
|
|
421
|
-
* @param {?} tracksaleCampaign
|
|
422
|
-
* @param {?} pageUrl
|
|
423
|
-
* @return {?}
|
|
424
|
-
*/
|
|
425
|
-
function (tracksaleKey, tracksaleCampaign, pageUrl) {
|
|
426
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
427
|
-
var userInformation, roles, role, hasIntegratedRole, tenantInformation, browser, fullname, email;
|
|
428
|
-
return __generator(this, function (_a) {
|
|
429
|
-
switch (_a.label) {
|
|
430
|
-
case 0:
|
|
431
|
-
if (!(( /** @type {?} */(window))).show_tacksale) {
|
|
432
|
-
return [2 /*return*/];
|
|
433
|
-
}
|
|
434
|
-
return [4 /*yield*/, this.getActiveUser().toPromise()];
|
|
435
|
-
case 1:
|
|
436
|
-
userInformation = _a.sent();
|
|
437
|
-
roles = '';
|
|
438
|
-
if (!(( /** @type {?} */(window))).can_capture_role)
|
|
439
|
-
return [3 /*break*/, 3];
|
|
440
|
-
return [4 /*yield*/, this.getRolesByActiveUser(userInformation.username).toPromise()];
|
|
441
|
-
case 2:
|
|
442
|
-
role = _a.sent();
|
|
443
|
-
roles = role.roles.join(', ');
|
|
444
|
-
_a.label = 3;
|
|
445
|
-
case 3: return [4 /*yield*/, this.hasIntegratedRole().toPromise()];
|
|
446
|
-
case 4:
|
|
447
|
-
hasIntegratedRole = _a.sent();
|
|
448
|
-
return [4 /*yield*/, this.getTenatInformation(userInformation.tenantName).toPromise()];
|
|
449
|
-
case 5:
|
|
450
|
-
tenantInformation = _a.sent();
|
|
451
|
-
browser = this.getBrowser();
|
|
452
|
-
fullname = userInformation.fullName.replace('+', ' ');
|
|
453
|
-
email = userInformation.email;
|
|
454
|
-
(( /**
|
|
455
|
-
* @param {?} f
|
|
456
|
-
* @param {?} b
|
|
457
|
-
* @param {?} g
|
|
458
|
-
* @return {?}
|
|
459
|
-
*/function (f, b, g) {
|
|
460
|
-
/** @type {?} */
|
|
461
|
-
var a = {
|
|
462
|
-
key: tracksaleKey,
|
|
463
|
-
campaign: tracksaleCampaign,
|
|
464
|
-
name: fullname,
|
|
465
|
-
email: email,
|
|
466
|
-
tags: {
|
|
467
|
-
'tenant': userInformation.tenantName,
|
|
468
|
-
'papel': roles,
|
|
469
|
-
'device': browser,
|
|
470
|
-
'uf': '',
|
|
471
|
-
'SAM': !hasIntegratedRole.hasIntegratedRole,
|
|
472
|
-
'GAS': hasIntegratedRole.hasIntegratedRole,
|
|
473
|
-
'GestaoIncidentes': '',
|
|
474
|
-
'Cameras': '',
|
|
475
|
-
'PortariaVirtual': '',
|
|
476
|
-
'Autoatendimento': '',
|
|
477
|
-
'pagina': pageUrl,
|
|
478
|
-
'ID ERP': tenantInformation.erpCode
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
// Seguindo o exemplo da arquitera.
|
|
482
|
-
// Fonte não será alterado nesta task;
|
|
483
|
-
/** @type {?} */
|
|
484
|
-
var e;
|
|
485
|
-
/** @type {?} */
|
|
486
|
-
var c = f.getElementsByTagName(b)[0];
|
|
487
|
-
if (f.getElementById(g)) {
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
e = f.createElement(b);
|
|
491
|
-
e.id = g;
|
|
492
|
-
e.src = 'https://cdn.tracksale.co/tracksale-js/tracksale.js';
|
|
493
|
-
e.type = 'text/javascript';
|
|
494
|
-
e.async = true;
|
|
495
|
-
e.onload = e.onreadystatechange = ( /**
|
|
496
|
-
* @return {?}
|
|
497
|
-
*/function () {
|
|
498
|
-
/** @type {?} */
|
|
499
|
-
var h = this.readyState;
|
|
500
|
-
if (h && h !== 'complete' && h !== 'loaded') {
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
try {
|
|
504
|
-
/** @type {?} */
|
|
505
|
-
var d = new Tracksale();
|
|
506
|
-
d.init(a);
|
|
507
|
-
}
|
|
508
|
-
catch (i) { }
|
|
509
|
-
});
|
|
510
|
-
c.parentNode.insertBefore(e, c);
|
|
511
|
-
})(document, 'script', 'tracksale-js'));
|
|
512
|
-
return [2 /*return*/];
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
};
|
|
517
|
-
SamUtilsService.HAS_LOADED = false;
|
|
518
|
-
SamUtilsService.decorators = [
|
|
519
|
-
{ type: i0.Injectable, args: [{
|
|
520
|
-
providedIn: 'root'
|
|
521
|
-
},] }
|
|
522
|
-
];
|
|
523
|
-
/** @nocollapse */
|
|
524
|
-
SamUtilsService.ctorParameters = function () {
|
|
525
|
-
return [
|
|
526
|
-
{ type: i1.HttpClient }
|
|
527
|
-
];
|
|
528
|
-
};
|
|
529
|
-
/** @nocollapse */ SamUtilsService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SamUtilsService_Factory() { return new SamUtilsService(i0.ɵɵinject(i1.HttpClient)); }, token: SamUtilsService, providedIn: "root" });
|
|
530
|
-
return SamUtilsService;
|
|
531
|
-
}());
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* @fileoverview added by tsickle
|
|
535
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* @fileoverview added by tsickle
|
|
540
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
541
|
-
*/
|
|
542
|
-
|
|
543
|
-
exports.SamUtilsService = SamUtilsService;
|
|
544
|
-
|
|
545
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
546
|
-
|
|
547
|
-
})));
|
|
548
|
-
|
|
549
|
-
//# sourceMappingURL=sam-senior-sam-utils.umd.js.map
|