@bnsights/bbsf-utilities 1.0.2 → 1.0.6
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/bnsights-bbsf-utilities-1.0.6.tgz +0 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +245 -181
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -1
- package/esm2015/lib/shared/authentication/auth.service.js +6 -17
- package/esm2015/lib/shared/models/ErrorModel.js +1 -1
- package/esm2015/lib/shared/services/controlvalidation.service.js +50 -33
- package/esm2015/lib/shared/services/requesthandler.service.js +58 -17
- package/esm2015/lib/shared/services/utility.service.js +3 -3
- package/fesm2015/bnsights-bbsf-utilities.js +219 -164
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/authentication/auth.service.d.ts +1 -1
- package/lib/shared/models/ErrorModel.d.ts +1 -1
- package/lib/shared/services/controlvalidation.service.d.ts +2 -2
- package/lib/shared/services/requesthandler.service.d.ts +11 -7
- package/lib/shared/services/utility.service.d.ts +2 -2
- package/package.json +1 -1
|
@@ -14,7 +14,8 @@ import * as i1$1 from '@angular/common/http';
|
|
|
14
14
|
import { HttpHeaders, HttpClient, HttpParams } from '@angular/common/http';
|
|
15
15
|
import { UserManager, WebStorageStateStore } from 'oidc-client';
|
|
16
16
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
17
|
-
import {
|
|
17
|
+
import { Observable } from 'rxjs/internal/Observable';
|
|
18
|
+
import { takeUntil, tap, map } from 'rxjs/operators';
|
|
18
19
|
|
|
19
20
|
// This file can be replaced during build by using the `fileReplacements` array.
|
|
20
21
|
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
|
|
@@ -162,31 +163,20 @@ class AuthService {
|
|
|
162
163
|
getCurrentUser() {
|
|
163
164
|
return this.manager.getUser();
|
|
164
165
|
}
|
|
165
|
-
isAuthenticated(
|
|
166
|
+
isAuthenticated() {
|
|
166
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
168
|
let user = yield this.manager.getUser().then(user => {
|
|
168
169
|
return user;
|
|
169
170
|
});
|
|
170
|
-
|
|
171
|
-
if (allowedPermission.length == 0) {
|
|
172
|
-
return this.user != null && !this.user.expired;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
let isUserInRole = this.isUserInRole(allowedPermission);
|
|
176
|
-
return this.user != null && !this.user.expired && isUserInRole;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else
|
|
180
|
-
return this.user != null && !this.user.expired;
|
|
171
|
+
return this.user != null && !this.user.expired;
|
|
181
172
|
});
|
|
182
173
|
}
|
|
183
174
|
isUserInRole(allowedPermission) {
|
|
184
|
-
;
|
|
185
|
-
|
|
186
|
-
return allowedPermission.every(i => permissionSetSID.includes(i));
|
|
175
|
+
let selectedPermissionSetID = this.user.profile["selectedPermissionSetID"];
|
|
176
|
+
return allowedPermission.includes(selectedPermissionSetID);
|
|
187
177
|
}
|
|
188
178
|
authorizationHeaderValue() {
|
|
189
|
-
return `${AuthService.user.token_type} ${AuthService.user.access_token}
|
|
179
|
+
return AuthService.user ? `${AuthService.user.token_type} ${AuthService.user.access_token}` : "";
|
|
190
180
|
}
|
|
191
181
|
name() {
|
|
192
182
|
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
@@ -247,10 +237,10 @@ class UtilityService {
|
|
|
247
237
|
return currentLanguage;
|
|
248
238
|
}
|
|
249
239
|
isCurrentLanguageEnglish() {
|
|
250
|
-
this.getCurrentLanguage() == "en";
|
|
240
|
+
return this.getCurrentLanguage() == "en";
|
|
251
241
|
}
|
|
252
242
|
isCurrentLanguageArabic() {
|
|
253
|
-
this.getCurrentLanguage() == "ar";
|
|
243
|
+
return this.getCurrentLanguage() == "ar";
|
|
254
244
|
}
|
|
255
245
|
notifySuccessMessage(Message, title, time) {
|
|
256
246
|
let MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
@@ -319,13 +309,174 @@ class RequestOptionsModel {
|
|
|
319
309
|
}
|
|
320
310
|
}
|
|
321
311
|
|
|
312
|
+
class RequestHandlerService {
|
|
313
|
+
constructor(http, authService, environmentService, utilityService, bbsfTranslateService) {
|
|
314
|
+
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
315
|
+
this.http = http;
|
|
316
|
+
this.authService = authService;
|
|
317
|
+
this.environmentService = environmentService;
|
|
318
|
+
this.utilityService = utilityService;
|
|
319
|
+
this.bbsfTranslateService = bbsfTranslateService;
|
|
320
|
+
this.requestOptions = new RequestOptionsModel();
|
|
321
|
+
this.currentLanguage = "";
|
|
322
|
+
this.onDestroy$ = new Subject();
|
|
323
|
+
this.bbsfTranslateService.onLangChange.subscribe((event) => {
|
|
324
|
+
if (this.currentLanguage != event.lang) {
|
|
325
|
+
this.currentLanguage = event.lang;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
getLuckyNumber() {
|
|
330
|
+
return Observable.create((subject) => {
|
|
331
|
+
setInterval(() => {
|
|
332
|
+
const number = Math.floor(Math.random() * 10);
|
|
333
|
+
console.log(number);
|
|
334
|
+
subject.next(number);
|
|
335
|
+
}, 1000);
|
|
336
|
+
}).pipe(takeUntil(this.onDestroy$));
|
|
337
|
+
}
|
|
338
|
+
get(Url, params, requestOptions) {
|
|
339
|
+
if (requestOptions)
|
|
340
|
+
this.requestOptions = requestOptions;
|
|
341
|
+
let headers = new HttpHeaders({
|
|
342
|
+
'Content-Type': 'application/json',
|
|
343
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
344
|
+
});
|
|
345
|
+
this.currentLanguage = localStorage.getItem('language');
|
|
346
|
+
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
347
|
+
headers = headers.set('ignore-cookies', 'true');
|
|
348
|
+
if (!this.requestOptions.disableBlockUI)
|
|
349
|
+
this.utilityService.startBlockUI();
|
|
350
|
+
let object;
|
|
351
|
+
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
352
|
+
if (!this.requestOptions.disableBlockUI)
|
|
353
|
+
this.utilityService.stopBlockUI();
|
|
354
|
+
}), map((data) => {
|
|
355
|
+
let result = data;
|
|
356
|
+
return result;
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
post(Url, model, params, requestOptions) {
|
|
360
|
+
if (requestOptions)
|
|
361
|
+
this.requestOptions = requestOptions;
|
|
362
|
+
let headers = new HttpHeaders({
|
|
363
|
+
'Content-Type': 'application/json',
|
|
364
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
365
|
+
});
|
|
366
|
+
this.currentLanguage = localStorage.getItem('language');
|
|
367
|
+
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
368
|
+
headers = headers.set('ignore-cookies', 'true');
|
|
369
|
+
if (!this.requestOptions.disableBlockUI)
|
|
370
|
+
this.utilityService.startBlockUI();
|
|
371
|
+
return this.http.post(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
372
|
+
if (!this.requestOptions.disableBlockUI)
|
|
373
|
+
this.utilityService.stopBlockUI();
|
|
374
|
+
}));
|
|
375
|
+
}
|
|
376
|
+
delete(Url, deletedId, params, requestOptions) {
|
|
377
|
+
if (requestOptions)
|
|
378
|
+
this.requestOptions = requestOptions;
|
|
379
|
+
let headers = new HttpHeaders({
|
|
380
|
+
'Content-Type': 'application/json',
|
|
381
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
382
|
+
});
|
|
383
|
+
this.currentLanguage = localStorage.getItem('language');
|
|
384
|
+
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
385
|
+
headers = headers.set('ignore-cookies', 'true');
|
|
386
|
+
if (!this.requestOptions.disableBlockUI)
|
|
387
|
+
this.utilityService.startBlockUI();
|
|
388
|
+
return this.http.delete(this.environmentService.getApiUrl() + Url + `/${deletedId}`, { headers: headers, params: params }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
389
|
+
if (!this.requestOptions.disableBlockUI)
|
|
390
|
+
this.utilityService.stopBlockUI();
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
put(Url, model, params, requestOptions) {
|
|
394
|
+
if (requestOptions)
|
|
395
|
+
this.requestOptions = requestOptions;
|
|
396
|
+
let headers = new HttpHeaders({
|
|
397
|
+
'Content-Type': 'application/json',
|
|
398
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
399
|
+
});
|
|
400
|
+
this.currentLanguage = localStorage.getItem('language');
|
|
401
|
+
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
402
|
+
headers = headers.set('ignore-cookies', 'true');
|
|
403
|
+
if (!this.requestOptions.disableBlockUI)
|
|
404
|
+
this.utilityService.startBlockUI();
|
|
405
|
+
return this.http.put(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
406
|
+
if (!this.requestOptions.disableBlockUI)
|
|
407
|
+
this.utilityService.stopBlockUI();
|
|
408
|
+
}));
|
|
409
|
+
}
|
|
410
|
+
destroyHandler() {
|
|
411
|
+
this.onDestroy$.next();
|
|
412
|
+
}
|
|
413
|
+
ngOnDestroy() {
|
|
414
|
+
console.log("clearInterval");
|
|
415
|
+
this.destroyHandler();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
RequestHandlerService.decorators = [
|
|
419
|
+
{ type: Injectable }
|
|
420
|
+
];
|
|
421
|
+
RequestHandlerService.ctorParameters = () => [
|
|
422
|
+
{ type: HttpClient },
|
|
423
|
+
{ type: AuthService },
|
|
424
|
+
{ type: EnvironmentService },
|
|
425
|
+
{ type: UtilityService },
|
|
426
|
+
{ type: BBSFTranslateService }
|
|
427
|
+
];
|
|
428
|
+
|
|
429
|
+
class StylesBundleService {
|
|
430
|
+
constructor(document, translateService) {
|
|
431
|
+
this.document = document;
|
|
432
|
+
this.translateService = translateService;
|
|
433
|
+
}
|
|
434
|
+
loadThemes(lang, bundleEnglishName, bundleArabicName) {
|
|
435
|
+
if (lang == "ar") {
|
|
436
|
+
this.loadStyleBundle(bundleArabicName.toString());
|
|
437
|
+
document.querySelector('html').setAttribute("lang", "ar");
|
|
438
|
+
document.querySelector('html').setAttribute("dir", "rtl");
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
this.loadStyleBundle(bundleEnglishName.toString());
|
|
442
|
+
document.querySelector('html').setAttribute("lang", "en");
|
|
443
|
+
document.querySelector('html').setAttribute("dir", "ltr");
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
loadStyleBundle(styleName) {
|
|
447
|
+
const head = this.document.getElementsByTagName('head')[0];
|
|
448
|
+
let themeLink = this.document.getElementById('client-theme');
|
|
449
|
+
if (themeLink && themeLink.href.includes(styleName)) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
453
|
+
themeLink.remove();
|
|
454
|
+
}
|
|
455
|
+
const style = this.document.createElement('link');
|
|
456
|
+
style.id = 'client-theme';
|
|
457
|
+
style.rel = 'stylesheet';
|
|
458
|
+
style.href = `${styleName}`;
|
|
459
|
+
head.appendChild(style);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
StylesBundleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0.ɵɵinject(i1$2.DOCUMENT), i0.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
|
|
463
|
+
StylesBundleService.decorators = [
|
|
464
|
+
{ type: Injectable, args: [{
|
|
465
|
+
providedIn: 'root'
|
|
466
|
+
},] }
|
|
467
|
+
];
|
|
468
|
+
StylesBundleService.ctorParameters = () => [
|
|
469
|
+
{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
470
|
+
{ type: BBSFTranslateService }
|
|
471
|
+
];
|
|
472
|
+
|
|
322
473
|
class ControlValidationService {
|
|
323
474
|
constructor(utilityService) {
|
|
324
475
|
this.utilityService = utilityService;
|
|
325
476
|
this.requestOptions = new RequestOptionsModel();
|
|
326
477
|
this.isCreatedBefor = false;
|
|
327
478
|
}
|
|
328
|
-
showGlobalError(errorMessage) {
|
|
479
|
+
showGlobalError(errorMessage, formId, deleteOld) {
|
|
329
480
|
let globalErorrElement = document.getElementsByClassName('alert alert-danger alert-InvalidValidation');
|
|
330
481
|
if (globalErorrElement.length > 0) {
|
|
331
482
|
this.removeElementsByClass('alert alert-danger alert-InvalidValidation');
|
|
@@ -334,28 +485,40 @@ class ControlValidationService {
|
|
|
334
485
|
this.removeElementsByClass('alert alert-danger alert-InvalidValidation');
|
|
335
486
|
}
|
|
336
487
|
// tslint:disable-next-line: prefer-const
|
|
337
|
-
|
|
488
|
+
if (!formId)
|
|
489
|
+
formId = "currentForm";
|
|
490
|
+
var object = document.getElementById(formId);
|
|
338
491
|
const tagName = 'div';
|
|
339
492
|
// tslint:disable-next-line: prefer-const
|
|
340
493
|
var elementToAppend = document.createElement(tagName); // Your tag name here
|
|
341
494
|
let message = "";
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
//
|
|
495
|
+
if (!errorMessage || (typeof errorMessage == "string")) {
|
|
496
|
+
if (localStorage.getItem('language') == "ar")
|
|
497
|
+
message = errorMessage ? errorMessage : "لديك بعص الأخطاء . من فضلك قم بالمراجعه ";
|
|
498
|
+
else
|
|
499
|
+
message = errorMessage ? errorMessage : "You have some validation errors. Please check below";
|
|
500
|
+
elementToAppend.innerHTML = "<ul><li>" + message + "</li></ul>";
|
|
501
|
+
elementToAppend.className += 'alert alert-danger alert-InvalidValidation';
|
|
502
|
+
elementToAppend.id += 'errorId';
|
|
503
|
+
// tslint:disable-next-line: prefer-for-of
|
|
504
|
+
const elementToAppen = elementToAppend.cloneNode(true);
|
|
505
|
+
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
506
|
+
object.insertBefore(elementToAppen, object.firstChild);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
elementToAppend.innerHTML = "<ul>";
|
|
510
|
+
for (const iterator of errorMessage) {
|
|
511
|
+
elementToAppend.innerHTML = "<li>" + iterator + "</li>";
|
|
512
|
+
}
|
|
513
|
+
elementToAppend.innerHTML = "</ul>";
|
|
514
|
+
elementToAppend.className += 'alert alert-danger alert-InvalidValidation';
|
|
515
|
+
elementToAppend.id += 'errorId';
|
|
516
|
+
// tslint:disable-next-line: prefer-for-of
|
|
353
517
|
const elementToAppen = elementToAppend.cloneNode(true);
|
|
354
|
-
let targetElement =
|
|
355
|
-
|
|
356
|
-
this.isCreatedBefor = true;
|
|
357
|
-
break;
|
|
518
|
+
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
519
|
+
object.insertBefore(elementToAppen, object.firstChild);
|
|
358
520
|
}
|
|
521
|
+
this.isCreatedBefor = true;
|
|
359
522
|
}
|
|
360
523
|
RemoveGlobalError() {
|
|
361
524
|
const removedList = document.getElementsByClassName('alert alert-danger alert-InvalidValidation');
|
|
@@ -397,54 +560,59 @@ class ControlValidationService {
|
|
|
397
560
|
elements[0].parentNode.removeChild(elements[0]);
|
|
398
561
|
}
|
|
399
562
|
}
|
|
400
|
-
renderServerErrors(form, err, requestOptions) {
|
|
563
|
+
renderServerErrors(form, err, requestOptions, formId) {
|
|
401
564
|
if (err.error == null) {
|
|
402
565
|
return;
|
|
403
566
|
}
|
|
567
|
+
let errorsArray = [];
|
|
404
568
|
this.requestOptions = requestOptions;
|
|
405
569
|
err.error.validation_errors.forEach((element) => {
|
|
406
570
|
let fieldName = element.field;
|
|
407
|
-
let controlName = element.
|
|
571
|
+
let controlName = element.controlName;
|
|
408
572
|
let message = element.message;
|
|
409
573
|
if (form == null) {
|
|
410
574
|
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${fieldName}: ${message}`);
|
|
411
575
|
}
|
|
412
|
-
else if (!this.hasControlName(form, controlName)) {
|
|
413
|
-
|
|
576
|
+
else if (controlName && !this.hasControlName(form, controlName)) {
|
|
577
|
+
errorsArray.push(`${fieldName}: ${message}`);
|
|
578
|
+
// this.showGlobalError(`${fieldName}: ${message}`,formId )
|
|
414
579
|
}
|
|
415
580
|
else {
|
|
416
581
|
this.setFieldError(form, controlName, fieldName, message);
|
|
417
582
|
}
|
|
418
583
|
});
|
|
584
|
+
if (errorsArray.length > 0)
|
|
585
|
+
this.showGlobalError(errorsArray, formId);
|
|
419
586
|
}
|
|
420
587
|
hasControlName(form, controlName) {
|
|
421
588
|
let control = form.get(controlName);
|
|
422
589
|
return control != null;
|
|
423
590
|
}
|
|
424
591
|
setFieldError(form, controlName, fieldName, message) {
|
|
425
|
-
let control =
|
|
426
|
-
|
|
592
|
+
let control = null;
|
|
593
|
+
if (controlName)
|
|
594
|
+
control = form.get(controlName);
|
|
595
|
+
else
|
|
596
|
+
control = form.get(fieldName.split('.')[0]);
|
|
597
|
+
let errors = { "errorMassage": message };
|
|
427
598
|
let fieldNameArray = fieldName.split('.');
|
|
428
599
|
if (fieldNameArray.length >= 1) {
|
|
429
|
-
switch (fieldNameArray[length - 1].toLocaleLowerCase()) {
|
|
600
|
+
switch (fieldNameArray[fieldNameArray.length - 1].toLocaleLowerCase()) {
|
|
430
601
|
case "english":
|
|
431
|
-
let englishControl = control.get("
|
|
602
|
+
let englishControl = control.get("English");
|
|
432
603
|
englishControl.setErrors(errors);
|
|
433
|
-
englishControl.markAsTouched();
|
|
434
|
-
englishControl.updateValueAndValidity();
|
|
435
604
|
break;
|
|
436
605
|
case "arabic":
|
|
437
|
-
let arabicControl = control.get("
|
|
606
|
+
let arabicControl = control.get("Arabic");
|
|
438
607
|
arabicControl.setErrors(errors);
|
|
439
|
-
arabicControl.markAsTouched();
|
|
440
|
-
arabicControl.updateValueAndValidity();
|
|
441
608
|
break;
|
|
442
609
|
default:
|
|
443
610
|
control.setErrors(errors);
|
|
444
|
-
control.markAsTouched();
|
|
445
|
-
control.updateValueAndValidity();
|
|
446
611
|
}
|
|
447
612
|
}
|
|
613
|
+
else if (fieldNameArray.length == 1) {
|
|
614
|
+
control.setErrors(errors);
|
|
615
|
+
}
|
|
448
616
|
else {
|
|
449
617
|
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${fieldName}: ${message}`);
|
|
450
618
|
}
|
|
@@ -463,119 +631,6 @@ __decorate([
|
|
|
463
631
|
BlockUI()
|
|
464
632
|
], ControlValidationService.prototype, "blockUI", void 0);
|
|
465
633
|
|
|
466
|
-
class RequestHandlerService {
|
|
467
|
-
constructor(http, authService, environmentService, utilityService, controlValidationService, bbsfTranslateService) {
|
|
468
|
-
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
469
|
-
this.http = http;
|
|
470
|
-
this.authService = authService;
|
|
471
|
-
this.environmentService = environmentService;
|
|
472
|
-
this.utilityService = utilityService;
|
|
473
|
-
this.controlValidationService = controlValidationService;
|
|
474
|
-
this.bbsfTranslateService = bbsfTranslateService;
|
|
475
|
-
this.requestOptions = new RequestOptionsModel();
|
|
476
|
-
this.currentLanguage = "";
|
|
477
|
-
this.onDestroy$ = new Subject();
|
|
478
|
-
this.bbsfTranslateService.onLangChange.subscribe((event) => {
|
|
479
|
-
if (this.currentLanguage != event.lang) {
|
|
480
|
-
this.currentLanguage = event.lang;
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
get(Url, params, requestOptions) {
|
|
485
|
-
if (requestOptions)
|
|
486
|
-
this.requestOptions = requestOptions;
|
|
487
|
-
let headers = new HttpHeaders({
|
|
488
|
-
'Content-Type': 'application/json',
|
|
489
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
490
|
-
});
|
|
491
|
-
this.currentLanguage = localStorage.getItem('language');
|
|
492
|
-
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
493
|
-
if (!this.requestOptions.disableBlockUI)
|
|
494
|
-
this.utilityService.startBlockUI();
|
|
495
|
-
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
496
|
-
if (!this.requestOptions.disableBlockUI)
|
|
497
|
-
this.utilityService.stopBlockUI();
|
|
498
|
-
}));
|
|
499
|
-
}
|
|
500
|
-
post(Url, model, params, requestOptions) {
|
|
501
|
-
if (requestOptions)
|
|
502
|
-
this.requestOptions = requestOptions;
|
|
503
|
-
let headers = new HttpHeaders({
|
|
504
|
-
'Content-Type': 'application/json',
|
|
505
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
506
|
-
});
|
|
507
|
-
this.currentLanguage = localStorage.getItem('language');
|
|
508
|
-
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
509
|
-
if (!this.requestOptions.disableBlockUI)
|
|
510
|
-
this.utilityService.startBlockUI();
|
|
511
|
-
return this.http.post(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
512
|
-
if (!this.requestOptions.disableBlockUI)
|
|
513
|
-
this.utilityService.stopBlockUI();
|
|
514
|
-
}));
|
|
515
|
-
}
|
|
516
|
-
destroyHandler() {
|
|
517
|
-
this.onDestroy$.next();
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
RequestHandlerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RequestHandlerService_Factory() { return new RequestHandlerService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(AuthService), i0.ɵɵinject(EnvironmentService), i0.ɵɵinject(UtilityService), i0.ɵɵinject(ControlValidationService), i0.ɵɵinject(BBSFTranslateService)); }, token: RequestHandlerService, providedIn: "root" });
|
|
521
|
-
RequestHandlerService.decorators = [
|
|
522
|
-
{ type: Injectable, args: [{
|
|
523
|
-
providedIn: 'root'
|
|
524
|
-
},] }
|
|
525
|
-
];
|
|
526
|
-
RequestHandlerService.ctorParameters = () => [
|
|
527
|
-
{ type: HttpClient },
|
|
528
|
-
{ type: AuthService },
|
|
529
|
-
{ type: EnvironmentService },
|
|
530
|
-
{ type: UtilityService },
|
|
531
|
-
{ type: ControlValidationService },
|
|
532
|
-
{ type: BBSFTranslateService }
|
|
533
|
-
];
|
|
534
|
-
|
|
535
|
-
class StylesBundleService {
|
|
536
|
-
constructor(document, translateService) {
|
|
537
|
-
this.document = document;
|
|
538
|
-
this.translateService = translateService;
|
|
539
|
-
}
|
|
540
|
-
loadThemes(lang, bundleEnglishName, bundleArabicName) {
|
|
541
|
-
if (lang == "ar") {
|
|
542
|
-
this.loadStyleBundle(bundleArabicName.toString());
|
|
543
|
-
document.querySelector('html').setAttribute("lang", "ar");
|
|
544
|
-
document.querySelector('html').setAttribute("dir", "rtl");
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
this.loadStyleBundle(bundleEnglishName.toString());
|
|
548
|
-
document.querySelector('html').setAttribute("lang", "en");
|
|
549
|
-
document.querySelector('html').setAttribute("dir", "ltr");
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
loadStyleBundle(styleName) {
|
|
553
|
-
const head = this.document.getElementsByTagName('head')[0];
|
|
554
|
-
let themeLink = this.document.getElementById('client-theme');
|
|
555
|
-
if (themeLink && themeLink.href.includes(styleName)) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
559
|
-
themeLink.remove();
|
|
560
|
-
}
|
|
561
|
-
const style = this.document.createElement('link');
|
|
562
|
-
style.id = 'client-theme';
|
|
563
|
-
style.rel = 'stylesheet';
|
|
564
|
-
style.href = `${styleName}`;
|
|
565
|
-
head.appendChild(style);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
StylesBundleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0.ɵɵinject(i1$2.DOCUMENT), i0.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
|
|
569
|
-
StylesBundleService.decorators = [
|
|
570
|
-
{ type: Injectable, args: [{
|
|
571
|
-
providedIn: 'root'
|
|
572
|
-
},] }
|
|
573
|
-
];
|
|
574
|
-
StylesBundleService.ctorParameters = () => [
|
|
575
|
-
{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
576
|
-
{ type: BBSFTranslateService }
|
|
577
|
-
];
|
|
578
|
-
|
|
579
634
|
class MasterLayoutService {
|
|
580
635
|
constructor(router, http, authService, stylesBundleService, translate) {
|
|
581
636
|
this.router = router;
|