@bnsights/bbsf-utilities 1.0.32 → 1.0.33
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 +4 -4
- package/bnsights-bbsf-utilities-1.0.33.tgz +0 -0
- package/bnsights-bbsf-utilities.d.ts +0 -1
- package/bnsights-bbsf-utilities.metadata.json +1 -0
- package/bundles/bnsights-bbsf-utilities.umd.js +4865 -0
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -0
- package/esm2015/lib/bbsf-utilities.module.js +52 -0
- package/esm2015/lib/shared/authentication/auth.service.js +236 -0
- package/esm2015/lib/shared/config/word/constants.js +105 -0
- package/esm2015/lib/shared/config/word/docx-document.js +351 -0
- package/esm2015/lib/shared/config/word/helpers/index.js +4 -0
- package/esm2015/lib/shared/config/word/helpers/render-document-file.js +278 -0
- package/esm2015/lib/shared/config/word/helpers/xml-builder.js +1765 -0
- package/esm2015/lib/shared/config/word/html-to-docx.js +195 -0
- package/esm2015/lib/shared/config/word/index.js +55 -0
- package/esm2015/lib/shared/config/word/namespaces.js +37 -0
- package/esm2015/lib/shared/config/word/schemas/content-types.js +26 -0
- package/esm2015/lib/shared/config/word/schemas/core.js +29 -0
- package/esm2015/lib/shared/config/word/schemas/document-rels.js +16 -0
- package/esm2015/lib/shared/config/word/schemas/document.template.js +109 -0
- package/esm2015/lib/shared/config/word/schemas/font-table.js +40 -0
- package/esm2015/lib/shared/config/word/schemas/generic-rels.js +11 -0
- package/esm2015/lib/shared/config/word/schemas/index.js +13 -0
- package/esm2015/lib/shared/config/word/schemas/numbering.js +19 -0
- package/esm2015/lib/shared/config/word/schemas/rels.js +11 -0
- package/esm2015/lib/shared/config/word/schemas/settings.js +13 -0
- package/esm2015/lib/shared/config/word/schemas/styles.js +149 -0
- package/esm2015/lib/shared/config/word/schemas/theme.js +200 -0
- package/esm2015/lib/shared/config/word/schemas/web-settings.js +9 -0
- package/esm2015/lib/shared/config/word/utils/color-conversion.js +60 -0
- package/esm2015/lib/shared/config/word/utils/list.js +51 -0
- package/esm2015/lib/shared/config/word/utils/unit-conversion.js +30 -0
- package/esm2015/lib/shared/config/word/utils/url.js +9 -0
- package/esm2015/lib/shared/config/word/utils/vnode.js +3 -0
- package/esm2015/lib/shared/config/word/word-work/templates/documentTemplate.js +54 -0
- package/esm2015/lib/shared/config/word/word-work/templates/index.js +4 -0
- package/esm2015/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.js +22 -0
- package/esm2015/lib/shared/config/word/word-work/templates/mhtPartTemplate.js +10 -0
- package/esm2015/lib/shared/config/word/word-work/utils.js +26 -0
- package/esm2015/lib/shared/models/WordDocumentModel.js +8 -0
- package/esm2015/lib/shared/services/AppearanceConfiguration.service.js +37 -0
- package/esm2015/lib/shared/services/configuration.service.js +26 -0
- package/esm2015/lib/shared/services/controlvalidation.service.js +168 -0
- package/esm2015/lib/shared/services/environment.service.js +48 -0
- package/esm2015/lib/shared/services/masterlayout.service.js +96 -0
- package/esm2015/lib/shared/services/requesthandler.service.js +206 -0
- package/esm2015/lib/shared/services/stylesbundle.service.js +56 -0
- package/esm2015/lib/shared/services/translate.service.js +13 -0
- package/esm2015/lib/shared/services/translationresolver.service.js +20 -0
- package/esm2015/lib/shared/services/utility.service.js +96 -0
- package/esm2015/lib/shared/services/word-document.service.js +39 -0
- package/esm2015/public-api.js +20 -0
- package/fesm2015/bnsights-bbsf-utilities.js +4634 -0
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -0
- package/lib/bbsf-utilities.module.d.ts +0 -9
- package/lib/shared/authentication/auth.service.d.ts +0 -3
- package/lib/shared/config/word/constants.d.ts +124 -0
- package/lib/shared/config/word/docx-document.d.ts +73 -0
- package/lib/shared/config/word/helpers/index.d.ts +1 -0
- package/lib/shared/config/word/helpers/render-document-file.d.ts +4 -0
- package/lib/shared/config/word/helpers/xml-builder.d.ts +14 -0
- package/lib/shared/config/word/html-to-docx.d.ts +1 -0
- package/lib/shared/config/word/index.d.ts +1 -0
- package/lib/shared/config/word/namespaces.d.ts +36 -0
- package/lib/shared/config/word/schemas/content-types.d.ts +1 -0
- package/lib/shared/config/word/schemas/core.d.ts +1 -0
- package/lib/shared/config/word/schemas/document-rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/document.template.d.ts +4 -0
- package/lib/shared/config/word/schemas/font-table.d.ts +1 -0
- package/lib/shared/config/word/schemas/generic-rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/index.d.ts +12 -0
- package/lib/shared/config/word/schemas/numbering.d.ts +1 -0
- package/lib/shared/config/word/schemas/rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/settings.d.ts +1 -0
- package/lib/shared/config/word/schemas/styles.d.ts +1 -0
- package/lib/shared/config/word/schemas/theme.d.ts +1 -0
- package/lib/shared/config/word/schemas/web-settings.d.ts +1 -0
- package/lib/shared/config/word/utils/color-conversion.d.ts +7 -0
- package/lib/shared/config/word/utils/list.d.ts +6 -0
- package/lib/shared/config/word/utils/unit-conversion.d.ts +29 -0
- package/lib/shared/config/word/utils/url.d.ts +1 -0
- package/lib/shared/config/word/utils/vnode.d.ts +1 -0
- package/lib/shared/config/word/word-work/templates/documentTemplate.d.ts +12 -0
- package/lib/shared/config/word/word-work/templates/index.d.ts +3 -0
- package/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.d.ts +1 -0
- package/lib/shared/config/word/word-work/templates/mhtPartTemplate.d.ts +1 -0
- package/lib/shared/config/word/word-work/utils.d.ts +1 -0
- package/lib/shared/models/WordDocumentModel.d.ts +16 -0
- package/lib/shared/services/AppearanceConfiguration.service.d.ts +0 -3
- package/lib/shared/services/configuration.service.d.ts +0 -3
- package/lib/shared/services/controlvalidation.service.d.ts +0 -3
- package/lib/shared/services/environment.service.d.ts +0 -3
- package/lib/shared/services/masterlayout.service.d.ts +0 -3
- package/lib/shared/services/requesthandler.service.d.ts +0 -3
- package/lib/shared/services/stylesbundle.service.d.ts +0 -3
- package/lib/shared/services/translate.service.d.ts +0 -3
- package/lib/shared/services/translationresolver.service.d.ts +0 -3
- package/lib/shared/services/utility.service.d.ts +0 -3
- package/lib/shared/services/word-document.service.d.ts +5 -0
- package/package.json +7 -19
- package/public-api.d.ts +2 -0
- package/bnsights-bbsf-utilities-1.0.32.tgz +0 -0
- package/esm2020/lib/bbsf-utilities.module.mjs +0 -74
- package/esm2020/lib/shared/authentication/auth.service.mjs +0 -217
- package/esm2020/lib/shared/services/AppearanceConfiguration.service.mjs +0 -35
- package/esm2020/lib/shared/services/configuration.service.mjs +0 -24
- package/esm2020/lib/shared/services/controlvalidation.service.mjs +0 -166
- package/esm2020/lib/shared/services/environment.service.mjs +0 -50
- package/esm2020/lib/shared/services/masterlayout.service.mjs +0 -84
- package/esm2020/lib/shared/services/requesthandler.service.mjs +0 -202
- package/esm2020/lib/shared/services/stylesbundle.service.mjs +0 -55
- package/esm2020/lib/shared/services/translate.service.mjs +0 -14
- package/esm2020/lib/shared/services/translationresolver.service.mjs +0 -18
- package/esm2020/lib/shared/services/utility.service.mjs +0 -90
- package/esm2020/public-api.mjs +0 -18
- package/fesm2015/bnsights-bbsf-utilities.mjs +0 -1009
- package/fesm2015/bnsights-bbsf-utilities.mjs.map +0 -1
- package/fesm2020/bnsights-bbsf-utilities.mjs +0 -997
- package/fesm2020/bnsights-bbsf-utilities.mjs.map +0 -1
- /package/{esm2020/bnsights-bbsf-utilities.mjs → esm2015/bnsights-bbsf-utilities.js} +0 -0
- /package/{esm2020/lib/shared/config/environment.mjs → esm2015/lib/shared/config/environment.js} +0 -0
- /package/{esm2020/lib/shared/models/AreaModel.mjs → esm2015/lib/shared/models/AreaModel.js} +0 -0
- /package/{esm2020/lib/shared/models/ErrorModel.mjs → esm2015/lib/shared/models/ErrorModel.js} +0 -0
- /package/{esm2020/lib/shared/models/RequestOptionsModel.mjs → esm2015/lib/shared/models/RequestOptionsModel.js} +0 -0
|
@@ -1,997 +0,0 @@
|
|
|
1
|
-
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
|
-
import { Injectable, Inject, NgModule } from '@angular/core';
|
|
4
|
-
import * as i6 from '@angular/router';
|
|
5
|
-
import { RouterModule } from '@angular/router';
|
|
6
|
-
import * as i5 from '@ngx-translate/core';
|
|
7
|
-
import { TranslateService } from '@ngx-translate/core';
|
|
8
|
-
import * as i1$1 from 'ng-block-ui';
|
|
9
|
-
import { BlockUI, BlockUIModule } from 'ng-block-ui';
|
|
10
|
-
import * as i2 from 'ngx-toastr';
|
|
11
|
-
import { ToastrService, ToastrModule } from 'ngx-toastr';
|
|
12
|
-
import { HttpModule } from '@angular/http';
|
|
13
|
-
import { __decorate } from 'tslib';
|
|
14
|
-
import * as i1 from '@angular/common/http';
|
|
15
|
-
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
|
16
|
-
import { UserManager, WebStorageStateStore } from 'oidc-client';
|
|
17
|
-
import { Subject, Observable, throwError, BehaviorSubject } from 'rxjs';
|
|
18
|
-
import { takeUntil, tap, map } from 'rxjs/operators';
|
|
19
|
-
import { plainToClass } from 'class-transformer';
|
|
20
|
-
|
|
21
|
-
class BBSFTranslateService extends TranslateService {
|
|
22
|
-
}
|
|
23
|
-
BBSFTranslateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFTranslateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
24
|
-
BBSFTranslateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFTranslateService, providedIn: 'root' });
|
|
25
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFTranslateService, decorators: [{
|
|
26
|
-
type: Injectable,
|
|
27
|
-
args: [{
|
|
28
|
-
providedIn: 'root'
|
|
29
|
-
}]
|
|
30
|
-
}] });
|
|
31
|
-
|
|
32
|
-
class RequestOptionsModel {
|
|
33
|
-
constructor() {
|
|
34
|
-
this.disableSuccessNotification = false;
|
|
35
|
-
this.disableBlockUI = false;
|
|
36
|
-
this.disableErrorHandler = false;
|
|
37
|
-
this.responseType = "";
|
|
38
|
-
this.formGroup = null;
|
|
39
|
-
this.castResponsetoClass = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// This file can be replaced during build by using the `fileReplacements` array.
|
|
44
|
-
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
|
|
45
|
-
// The list of file replacements can be found in `angular.json`.
|
|
46
|
-
const environment = Object.assign({}, window.Environment);
|
|
47
|
-
/*
|
|
48
|
-
* In development mode, to ignore zone related error stack frames such as
|
|
49
|
-
* `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
|
|
50
|
-
* import the following file, but please comment it out in production mode
|
|
51
|
-
* because it will have performance impact when throw error
|
|
52
|
-
*/
|
|
53
|
-
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
|
54
|
-
|
|
55
|
-
class EnvironmentService {
|
|
56
|
-
getEnvironmentObject() {
|
|
57
|
-
return environment;
|
|
58
|
-
}
|
|
59
|
-
getBaseUrl() {
|
|
60
|
-
let Url = environment["BBSF_BaseURL"];
|
|
61
|
-
return Url;
|
|
62
|
-
}
|
|
63
|
-
getApiUrl() {
|
|
64
|
-
let Url = environment["BBSF_ApiUrl"];
|
|
65
|
-
return Url;
|
|
66
|
-
}
|
|
67
|
-
getProductionMode() {
|
|
68
|
-
let Mode = environment["BBSF_IsProduction"];
|
|
69
|
-
return Mode;
|
|
70
|
-
}
|
|
71
|
-
getDefaultLanguage() {
|
|
72
|
-
let Mode = environment["BBSF_DefaultLanguage"];
|
|
73
|
-
return Mode;
|
|
74
|
-
}
|
|
75
|
-
getIdentityServerUrl() {
|
|
76
|
-
let Url = environment["BBSF_IdentityServerUrl"];
|
|
77
|
-
return Url;
|
|
78
|
-
}
|
|
79
|
-
getIsIdentityServerExternal() {
|
|
80
|
-
let Mode = environment["BBSF_IsExternalIdentityServer"];
|
|
81
|
-
return Mode;
|
|
82
|
-
}
|
|
83
|
-
getIsIdentityServerClientId() {
|
|
84
|
-
let Mode = environment["BBSF_IdentityServer_Client_Id"];
|
|
85
|
-
return Mode;
|
|
86
|
-
}
|
|
87
|
-
getIsIdentityServerClientSecret() {
|
|
88
|
-
let Mode = environment["BBSF_IdentityServer_Client_Secret"];
|
|
89
|
-
return Mode;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
EnvironmentService.AreaList = [];
|
|
93
|
-
EnvironmentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EnvironmentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
94
|
-
EnvironmentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EnvironmentService, providedIn: 'root' });
|
|
95
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EnvironmentService, decorators: [{
|
|
96
|
-
type: Injectable,
|
|
97
|
-
args: [{
|
|
98
|
-
providedIn: 'root'
|
|
99
|
-
}]
|
|
100
|
-
}] });
|
|
101
|
-
|
|
102
|
-
class RequestHandlerService {
|
|
103
|
-
constructor(http, authService, environmentService, utilityService, bbsfTranslateService, router) {
|
|
104
|
-
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
105
|
-
this.http = http;
|
|
106
|
-
this.authService = authService;
|
|
107
|
-
this.environmentService = environmentService;
|
|
108
|
-
this.utilityService = utilityService;
|
|
109
|
-
this.bbsfTranslateService = bbsfTranslateService;
|
|
110
|
-
this.router = router;
|
|
111
|
-
this.requestOptions = new RequestOptionsModel();
|
|
112
|
-
this.currentLanguage = "";
|
|
113
|
-
this.onDestroy$ = new Subject();
|
|
114
|
-
this.bbsfTranslateService.onLangChange.subscribe((event) => {
|
|
115
|
-
if (this.currentLanguage != event.lang) {
|
|
116
|
-
this.currentLanguage = event.lang;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
getLuckyNumber() {
|
|
121
|
-
return Observable.create((subject) => {
|
|
122
|
-
setInterval(() => {
|
|
123
|
-
const number = Math.floor(Math.random() * 10);
|
|
124
|
-
console.log(number);
|
|
125
|
-
subject.next(number);
|
|
126
|
-
}, 1000);
|
|
127
|
-
}).pipe(takeUntil(this.onDestroy$));
|
|
128
|
-
}
|
|
129
|
-
get(Url, params, responseType, requestOptions) {
|
|
130
|
-
if (requestOptions)
|
|
131
|
-
this.requestOptions = requestOptions;
|
|
132
|
-
let headers = this.getHeaders();
|
|
133
|
-
if (!this.requestOptions.disableBlockUI)
|
|
134
|
-
this.utilityService.startBlockUI();
|
|
135
|
-
let object;
|
|
136
|
-
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
137
|
-
if (!this.requestOptions.disableBlockUI)
|
|
138
|
-
this.utilityService.stopBlockUI();
|
|
139
|
-
}, error => {
|
|
140
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
141
|
-
this.handleError(error);
|
|
142
|
-
}), map((data) => {
|
|
143
|
-
if (this.requestOptions.castResponsetoClass)
|
|
144
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
145
|
-
else
|
|
146
|
-
return data;
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
post(Url, model, responseType, params, requestOptions) {
|
|
150
|
-
if (requestOptions)
|
|
151
|
-
this.requestOptions = requestOptions;
|
|
152
|
-
let headers = this.getHeaders();
|
|
153
|
-
if (!this.requestOptions.disableBlockUI)
|
|
154
|
-
this.utilityService.startBlockUI();
|
|
155
|
-
return this.http.post(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
156
|
-
if (!this.requestOptions.disableBlockUI)
|
|
157
|
-
this.utilityService.stopBlockUI();
|
|
158
|
-
}, error => {
|
|
159
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
160
|
-
this.handleError(error);
|
|
161
|
-
}), map((data) => {
|
|
162
|
-
if (this.requestOptions.castResponsetoClass)
|
|
163
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
164
|
-
else
|
|
165
|
-
return data;
|
|
166
|
-
}));
|
|
167
|
-
}
|
|
168
|
-
delete(Url, deletedId, requestOptions, responseType, params) {
|
|
169
|
-
if (requestOptions)
|
|
170
|
-
this.requestOptions = requestOptions;
|
|
171
|
-
let headers = this.getHeaders();
|
|
172
|
-
if (!this.requestOptions.disableBlockUI)
|
|
173
|
-
this.utilityService.startBlockUI();
|
|
174
|
-
return this.http.delete(this.environmentService.getApiUrl() + Url + `/${deletedId}`, { headers: headers, params: params }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
175
|
-
if (!this.requestOptions.disableBlockUI)
|
|
176
|
-
this.utilityService.stopBlockUI();
|
|
177
|
-
}, error => {
|
|
178
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
179
|
-
this.handleError(error);
|
|
180
|
-
}), map((data) => {
|
|
181
|
-
if (this.requestOptions.castResponsetoClass)
|
|
182
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
183
|
-
else
|
|
184
|
-
return data;
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
put(Url, model, params, responseType, requestOptions) {
|
|
188
|
-
if (requestOptions)
|
|
189
|
-
this.requestOptions = requestOptions;
|
|
190
|
-
let headers = this.getHeaders();
|
|
191
|
-
if (!this.requestOptions.disableBlockUI)
|
|
192
|
-
this.utilityService.startBlockUI();
|
|
193
|
-
return this.http.put(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
194
|
-
if (!this.requestOptions.disableBlockUI)
|
|
195
|
-
this.utilityService.stopBlockUI();
|
|
196
|
-
}, error => {
|
|
197
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
198
|
-
this.handleError(error);
|
|
199
|
-
}), map((data) => {
|
|
200
|
-
if (this.requestOptions.castResponsetoClass)
|
|
201
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
202
|
-
else
|
|
203
|
-
return data;
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
patch(Url, model, responseType, params, requestOptions) {
|
|
207
|
-
if (requestOptions)
|
|
208
|
-
this.requestOptions = requestOptions;
|
|
209
|
-
let headers = new HttpHeaders({
|
|
210
|
-
'Content-Type': 'application/json',
|
|
211
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
212
|
-
});
|
|
213
|
-
this.currentLanguage = localStorage.getItem('language');
|
|
214
|
-
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
215
|
-
headers = headers.set('ignore-cookies', 'true');
|
|
216
|
-
if (!this.requestOptions.disableBlockUI)
|
|
217
|
-
this.utilityService.startBlockUI();
|
|
218
|
-
return this.http.patch(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
219
|
-
if (!this.requestOptions.disableBlockUI)
|
|
220
|
-
this.utilityService.stopBlockUI();
|
|
221
|
-
}, error => {
|
|
222
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
223
|
-
this.handleError(error);
|
|
224
|
-
}), map((data) => {
|
|
225
|
-
if (this.requestOptions.castResponsetoClass)
|
|
226
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
227
|
-
else
|
|
228
|
-
return data;
|
|
229
|
-
}));
|
|
230
|
-
}
|
|
231
|
-
download(Url, params, requestOptions) {
|
|
232
|
-
if (requestOptions)
|
|
233
|
-
this.requestOptions = requestOptions;
|
|
234
|
-
let headers = this.getHeaders();
|
|
235
|
-
if (!this.requestOptions.disableBlockUI)
|
|
236
|
-
this.utilityService.startBlockUI();
|
|
237
|
-
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(takeUntil(this.onDestroy$), tap((result) => {
|
|
238
|
-
if (!this.requestOptions.disableBlockUI)
|
|
239
|
-
this.utilityService.stopBlockUI();
|
|
240
|
-
}, error => {
|
|
241
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
242
|
-
this.handleError(error);
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
destroyHandler() {
|
|
246
|
-
this.onDestroy$.next();
|
|
247
|
-
}
|
|
248
|
-
ngOnDestroy() {
|
|
249
|
-
console.log("clearInterval");
|
|
250
|
-
this.destroyHandler();
|
|
251
|
-
}
|
|
252
|
-
handleError(err) {
|
|
253
|
-
var isEnglish = this.utilityService.getCurrentLanguage() == "en";
|
|
254
|
-
if (err.error instanceof ErrorEvent) {
|
|
255
|
-
this.utilityService.notifyErrorMessage();
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
if (err.status == 400)
|
|
259
|
-
throwError(err); //error 400 is thrown to be catch by the Form component to handle Fluent validation errors
|
|
260
|
-
else if (err.status == 401)
|
|
261
|
-
this.router.navigate(["/Admin/account/login"]);
|
|
262
|
-
else if (err.status == 403)
|
|
263
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Sorry, You're not authorized to access this action" : "عذرا ليس لديك الصلاحيه لهذا الطلب");
|
|
264
|
-
else if (err.status == 510)
|
|
265
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Can not delete this item as it is related to others" : "لا يمكن حذف هذا العنصر لأنه مرتبط بعناصر أخرى");
|
|
266
|
-
else if (err.status == 515)
|
|
267
|
-
this.utilityService.notifyErrorMessage((err.error ? err.error.Message : err.message));
|
|
268
|
-
else {
|
|
269
|
-
console.log(`error message is: ${err.error ? err.error.Message : err.message}`);
|
|
270
|
-
this.utilityService.notifyErrorMessage(this.utilityService.getResourceValue("ErrorMassage"));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
this.utilityService.stopBlockUI();
|
|
274
|
-
}
|
|
275
|
-
getHeaders() {
|
|
276
|
-
return new HttpHeaders({
|
|
277
|
-
'Content-Type': 'application/json',
|
|
278
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
279
|
-
'Client-Local-Time-Zone': Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
280
|
-
'Accept-Language': localStorage.getItem('language'),
|
|
281
|
-
'ignore-cookies': 'true'
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
RequestHandlerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: RequestHandlerService, deps: [{ token: i1.HttpClient }, { token: AuthService }, { token: EnvironmentService }, { token: UtilityService }, { token: BBSFTranslateService }, { token: i6.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
286
|
-
RequestHandlerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: RequestHandlerService });
|
|
287
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: RequestHandlerService, decorators: [{
|
|
288
|
-
type: Injectable
|
|
289
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: AuthService }, { type: EnvironmentService }, { type: UtilityService }, { type: BBSFTranslateService }, { type: i6.Router }]; } });
|
|
290
|
-
|
|
291
|
-
class StylesBundleService {
|
|
292
|
-
constructor(document, translateService) {
|
|
293
|
-
this.document = document;
|
|
294
|
-
this.translateService = translateService;
|
|
295
|
-
}
|
|
296
|
-
loadThemes(lang, bundleEnglishName, bundleArabicName) {
|
|
297
|
-
if (lang == "ar") {
|
|
298
|
-
this.loadStyleBundle(bundleArabicName.toString());
|
|
299
|
-
document.querySelector('html').setAttribute("b-lang", "ar"); //use b-lang instead of lang to fix firefox number inputs in Arabic locale
|
|
300
|
-
document.querySelector('html').setAttribute("dir", "rtl");
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
this.loadStyleBundle(bundleEnglishName.toString());
|
|
304
|
-
document.querySelector('html').setAttribute("b-lang", "en");
|
|
305
|
-
document.querySelector('html').setAttribute("dir", "ltr");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
loadThemesColor(theme, bundleDarkName, bundleLightName) {
|
|
309
|
-
if (theme == "Light")
|
|
310
|
-
this.loadStyleBundle(bundleLightName.toString());
|
|
311
|
-
else
|
|
312
|
-
this.loadStyleBundle(bundleDarkName.toString());
|
|
313
|
-
}
|
|
314
|
-
loadStyleBundle(styleName) {
|
|
315
|
-
const head = this.document.getElementsByTagName('head')[0];
|
|
316
|
-
let themeLink = this.document.getElementById('client-theme');
|
|
317
|
-
if (themeLink && themeLink.href.includes(styleName)) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
321
|
-
themeLink.remove();
|
|
322
|
-
}
|
|
323
|
-
const style = this.document.createElement('link');
|
|
324
|
-
style.id = 'client-theme';
|
|
325
|
-
style.rel = 'stylesheet';
|
|
326
|
-
style.href = `${styleName}`;
|
|
327
|
-
head.appendChild(style);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
StylesBundleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StylesBundleService, deps: [{ token: DOCUMENT }, { token: BBSFTranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
331
|
-
StylesBundleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StylesBundleService, providedIn: 'root' });
|
|
332
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StylesBundleService, decorators: [{
|
|
333
|
-
type: Injectable,
|
|
334
|
-
args: [{
|
|
335
|
-
providedIn: 'root'
|
|
336
|
-
}]
|
|
337
|
-
}], ctorParameters: function () { return [{ type: Document, decorators: [{
|
|
338
|
-
type: Inject,
|
|
339
|
-
args: [DOCUMENT]
|
|
340
|
-
}] }, { type: BBSFTranslateService }]; } });
|
|
341
|
-
|
|
342
|
-
class MasterLayoutService {
|
|
343
|
-
constructor(router, http, authService, stylesBundleService, translate, environmentService) {
|
|
344
|
-
this.router = router;
|
|
345
|
-
this.http = http;
|
|
346
|
-
this.authService = authService;
|
|
347
|
-
this.stylesBundleService = stylesBundleService;
|
|
348
|
-
this.translate = translate;
|
|
349
|
-
this.environmentService = environmentService;
|
|
350
|
-
this.ApiUrl = '/api/Home/';
|
|
351
|
-
}
|
|
352
|
-
switchLang(lang, bundleEnglishName, bundleArabicName) {
|
|
353
|
-
this.changeLanguage(lang).subscribe((result) => {
|
|
354
|
-
this.updateUserInfo().subscribe((Value) => {
|
|
355
|
-
let UserInfoObject = Value;
|
|
356
|
-
this.authService.getUser();
|
|
357
|
-
this.authService.user.profile = Object.assign(this.authService.user.profile, UserInfoObject);
|
|
358
|
-
this.authService.storUser(this.authService.user);
|
|
359
|
-
this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
360
|
-
localStorage.setItem('language', lang);
|
|
361
|
-
this.translate.use(lang);
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
reloadComponent() {
|
|
366
|
-
let currentUrl = this.router.url;
|
|
367
|
-
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
|
368
|
-
this.router.onSameUrlNavigation = 'reload';
|
|
369
|
-
this.router.navigate([currentUrl]);
|
|
370
|
-
}
|
|
371
|
-
changeLanguage(key) {
|
|
372
|
-
let params = new HttpParams();
|
|
373
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
374
|
-
params = params.append('LanguageKey', key);
|
|
375
|
-
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
376
|
-
}
|
|
377
|
-
getUserClaims() {
|
|
378
|
-
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
379
|
-
}
|
|
380
|
-
logError(error) {
|
|
381
|
-
let params = new HttpParams();
|
|
382
|
-
params = params.append('error', error);
|
|
383
|
-
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
384
|
-
}
|
|
385
|
-
updateUserInfo() {
|
|
386
|
-
let isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() == 'true';
|
|
387
|
-
if (isExternal)
|
|
388
|
-
return this.getUserClaims();
|
|
389
|
-
return this.http.get('/connect/userinfo');
|
|
390
|
-
}
|
|
391
|
-
switchRole(permissionSetID) {
|
|
392
|
-
this.updateRole(permissionSetID).subscribe((result) => {
|
|
393
|
-
this.updateUserInfo().subscribe((Value) => {
|
|
394
|
-
let UserInfoObject = Value;
|
|
395
|
-
this.authService.getUser();
|
|
396
|
-
this.authService.user.profile = Object.assign(this.authService.user.profile, UserInfoObject);
|
|
397
|
-
this.authService.storUser(this.authService.user);
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
updateRole(permissionSetID) {
|
|
402
|
-
let params = new HttpParams();
|
|
403
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
404
|
-
params = params.append('RoleID', permissionSetID);
|
|
405
|
-
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
MasterLayoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MasterLayoutService, deps: [{ token: i6.Router }, { token: RequestHandlerService }, { token: AuthService }, { token: StylesBundleService }, { token: i5.TranslateService }, { token: EnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
409
|
-
MasterLayoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MasterLayoutService, providedIn: 'root' });
|
|
410
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MasterLayoutService, decorators: [{
|
|
411
|
-
type: Injectable,
|
|
412
|
-
args: [{
|
|
413
|
-
providedIn: 'root',
|
|
414
|
-
}]
|
|
415
|
-
}], ctorParameters: function () { return [{ type: i6.Router }, { type: RequestHandlerService }, { type: AuthService }, { type: StylesBundleService }, { type: i5.TranslateService }, { type: EnvironmentService }]; } });
|
|
416
|
-
|
|
417
|
-
class AuthService {
|
|
418
|
-
constructor(injector, http, environmentService, translateService, router) {
|
|
419
|
-
this.injector = injector;
|
|
420
|
-
this.http = http;
|
|
421
|
-
this.environmentService = environmentService;
|
|
422
|
-
this.translateService = translateService;
|
|
423
|
-
this.router = router;
|
|
424
|
-
// Observable navItem source
|
|
425
|
-
this._authNavStatusSource = new BehaviorSubject(false);
|
|
426
|
-
// Observable navItem stream
|
|
427
|
-
this.authNavStatus$ = this._authNavStatusSource.asObservable();
|
|
428
|
-
// Observable navItem source
|
|
429
|
-
this._userSource = new Subject();
|
|
430
|
-
this.UserStatus$ = this._userSource.asObservable();
|
|
431
|
-
this.manager = this.getUserManager();
|
|
432
|
-
this.redirectUrl = '';
|
|
433
|
-
this.manager.getUser().then(async (user) => {
|
|
434
|
-
this.manager.storeUser(user);
|
|
435
|
-
AuthService.user = user;
|
|
436
|
-
this.user = user;
|
|
437
|
-
this._authNavStatusSource.next(await this.isAuthenticated());
|
|
438
|
-
});
|
|
439
|
-
this.manager.events.addAccessTokenExpired((_) => {
|
|
440
|
-
this._authNavStatusSource.next(false);
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
getUserManager() {
|
|
444
|
-
let user = null;
|
|
445
|
-
let isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
446
|
-
'true';
|
|
447
|
-
if (isExternal) {
|
|
448
|
-
user = new UserManager({
|
|
449
|
-
authority: this.environmentService.getIdentityServerUrl(),
|
|
450
|
-
client_id: this.environmentService.getIsIdentityServerClientId(),
|
|
451
|
-
client_secret: this.environmentService.getIsIdentityServerClientSecret(),
|
|
452
|
-
redirect_uri: this.environmentService.getBaseUrl() +
|
|
453
|
-
'/Admin/authentication/auth-callback',
|
|
454
|
-
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
455
|
-
response_type: 'code',
|
|
456
|
-
scope: 'openid profile email',
|
|
457
|
-
filterProtocolClaims: true,
|
|
458
|
-
loadUserInfo: true,
|
|
459
|
-
automaticSilentRenew: true,
|
|
460
|
-
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
461
|
-
userStore: new WebStorageStateStore({ store: window.localStorage }),
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
user = new UserManager({
|
|
466
|
-
authority: this.environmentService.getIdentityServerUrl(),
|
|
467
|
-
client_id: 'angular_spa',
|
|
468
|
-
redirect_uri: this.environmentService.getBaseUrl() +
|
|
469
|
-
'/Admin/authentication/auth-callback',
|
|
470
|
-
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
471
|
-
response_type: 'id_token token',
|
|
472
|
-
scope: 'openid profile email IdentityServerApi',
|
|
473
|
-
filterProtocolClaims: true,
|
|
474
|
-
loadUserInfo: true,
|
|
475
|
-
automaticSilentRenew: true,
|
|
476
|
-
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
477
|
-
userStore: new WebStorageStateStore({ store: window.localStorage }),
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
return user;
|
|
481
|
-
}
|
|
482
|
-
login() {
|
|
483
|
-
return this.manager.signinRedirect();
|
|
484
|
-
}
|
|
485
|
-
getUser() {
|
|
486
|
-
this.manager.getUser().then(async (user) => {
|
|
487
|
-
AuthService.user = user;
|
|
488
|
-
this.user = user;
|
|
489
|
-
this._authNavStatusSource.next(await this.isAuthenticated());
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
storUser(User) {
|
|
493
|
-
this.manager.storeUser(User);
|
|
494
|
-
}
|
|
495
|
-
revokeAccessToken() {
|
|
496
|
-
this.manager.revokeAccessToken();
|
|
497
|
-
}
|
|
498
|
-
signinSilent() {
|
|
499
|
-
let x = this.manager.signinSilentCallback();
|
|
500
|
-
x.then((s) => {
|
|
501
|
-
//console.log(s)
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
async completeAuthentication() {
|
|
505
|
-
this.user = await this.manager.signinRedirectCallback();
|
|
506
|
-
AuthService.user = this.user;
|
|
507
|
-
this._userSource.next(AuthService.user);
|
|
508
|
-
this._authNavStatusSource.next(await this.isAuthenticated());
|
|
509
|
-
let isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
510
|
-
'true';
|
|
511
|
-
if (isExternal) {
|
|
512
|
-
const masterLayoutService = this.injector.get(MasterLayoutService);
|
|
513
|
-
let userClaims = await masterLayoutService
|
|
514
|
-
.getUserClaims()
|
|
515
|
-
.toPromise()
|
|
516
|
-
.then((e) => {
|
|
517
|
-
AuthService.UserClaims = e;
|
|
518
|
-
}, (error) => {
|
|
519
|
-
console.log(error);
|
|
520
|
-
});
|
|
521
|
-
AuthService.user.profile = Object.assign(AuthService.user.profile, AuthService.UserClaims);
|
|
522
|
-
}
|
|
523
|
-
this.storUser(AuthService.user);
|
|
524
|
-
if (!localStorage.getItem('language') ||
|
|
525
|
-
localStorage.getItem('language') == this.user.profile.locale)
|
|
526
|
-
localStorage.setItem('language', this.user.profile.locale);
|
|
527
|
-
if (this.translateService.currentLang != localStorage.getItem('language')) {
|
|
528
|
-
this.translateService.resetLang(this.translateService.currentLang);
|
|
529
|
-
await this.translateService
|
|
530
|
-
.reloadLang(localStorage.getItem('language'))
|
|
531
|
-
.subscribe((res) => {
|
|
532
|
-
console.log(res);
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
this._userSource.next(AuthService.user);
|
|
536
|
-
this._authNavStatusSource.next(await this.isAuthenticated());
|
|
537
|
-
this.user = AuthService.user;
|
|
538
|
-
}
|
|
539
|
-
async refreshToken(token) {
|
|
540
|
-
const httpOptions = {
|
|
541
|
-
headers: new HttpHeaders({
|
|
542
|
-
'Content-Type': 'application/json',
|
|
543
|
-
Authorization: token,
|
|
544
|
-
}),
|
|
545
|
-
};
|
|
546
|
-
this.manager.revokeAccessToken();
|
|
547
|
-
return await this.http
|
|
548
|
-
.post(`${this.environmentService.getIdentityServerUrl()}/users/refresh-token`, httpOptions, { withCredentials: true })
|
|
549
|
-
.subscribe((user) => {
|
|
550
|
-
this._userSource.next(user);
|
|
551
|
-
AuthService.user = user;
|
|
552
|
-
this.user = user;
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
getCurrentUser() {
|
|
556
|
-
return this.manager.getUser();
|
|
557
|
-
}
|
|
558
|
-
async isAuthenticated() {
|
|
559
|
-
let user = await this.manager.getUser().then((user) => {
|
|
560
|
-
return user;
|
|
561
|
-
});
|
|
562
|
-
return this.user != null && !this.user.expired;
|
|
563
|
-
}
|
|
564
|
-
isUserInRole(allowedPermission) {
|
|
565
|
-
let selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
566
|
-
return allowedPermission.includes(selectedPermissionSetID);
|
|
567
|
-
}
|
|
568
|
-
authorizationHeaderValue() {
|
|
569
|
-
return AuthService.user
|
|
570
|
-
? `${AuthService.user.token_type} ${AuthService.user.access_token}`
|
|
571
|
-
: '';
|
|
572
|
-
}
|
|
573
|
-
name() {
|
|
574
|
-
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
575
|
-
}
|
|
576
|
-
setUrl(url) {
|
|
577
|
-
localStorage.setItem('redirectUrl', url);
|
|
578
|
-
}
|
|
579
|
-
getUrl() {
|
|
580
|
-
return localStorage.getItem('redirectUrl');
|
|
581
|
-
}
|
|
582
|
-
async signinSilentCallback() {
|
|
583
|
-
let user = await this.manager.signinSilentCallback();
|
|
584
|
-
//await this.manager.storeUser(user);
|
|
585
|
-
AuthService.user = user;
|
|
586
|
-
console.log('Token from signinSilentCallback :' + AuthService.user);
|
|
587
|
-
this.user = user;
|
|
588
|
-
}
|
|
589
|
-
async signout() {
|
|
590
|
-
if (await !this.isAuthenticated())
|
|
591
|
-
this.router.navigate(['/Admin/account/login']), localStorage.clear();
|
|
592
|
-
let isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
593
|
-
'true';
|
|
594
|
-
if (isExternal) {
|
|
595
|
-
await this.clearUserSessionClaims()
|
|
596
|
-
.toPromise()
|
|
597
|
-
.then((res) => {
|
|
598
|
-
let result = res;
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
await this.manager.signoutRedirect();
|
|
602
|
-
}
|
|
603
|
-
clearUserSessionClaims() {
|
|
604
|
-
const httpOptions = {
|
|
605
|
-
headers: new HttpHeaders({
|
|
606
|
-
'Content-Type': 'application/json',
|
|
607
|
-
}),
|
|
608
|
-
};
|
|
609
|
-
let ApiUrl = '/api/Home/';
|
|
610
|
-
return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
AuthService.user = null;
|
|
614
|
-
AuthService.UserClaims = null;
|
|
615
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AuthService, deps: [{ token: i0.Injector }, { token: i1.HttpClient }, { token: EnvironmentService }, { token: BBSFTranslateService }, { token: i6.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
616
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
617
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AuthService, decorators: [{
|
|
618
|
-
type: Injectable,
|
|
619
|
-
args: [{
|
|
620
|
-
providedIn: 'root',
|
|
621
|
-
}]
|
|
622
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i1.HttpClient }, { type: EnvironmentService }, { type: BBSFTranslateService }, { type: i6.Router }]; } });
|
|
623
|
-
|
|
624
|
-
class UtilityService {
|
|
625
|
-
constructor(translator, authService, environmentService) {
|
|
626
|
-
this.translator = translator;
|
|
627
|
-
this.authService = authService;
|
|
628
|
-
this.environmentService = environmentService;
|
|
629
|
-
this.isCreatedBefore = false;
|
|
630
|
-
}
|
|
631
|
-
getResourceValue(Key) {
|
|
632
|
-
let ResourceValue = this.translator.instant(Key);
|
|
633
|
-
return ResourceValue;
|
|
634
|
-
}
|
|
635
|
-
getCurrentLanguage() {
|
|
636
|
-
let currentLanguage = this.environmentService.getDefaultLanguage();
|
|
637
|
-
let lang = localStorage.getItem('language');
|
|
638
|
-
if (lang)
|
|
639
|
-
currentLanguage = lang;
|
|
640
|
-
else
|
|
641
|
-
localStorage.setItem('language', currentLanguage);
|
|
642
|
-
return currentLanguage;
|
|
643
|
-
}
|
|
644
|
-
isCurrentLanguageEnglish() {
|
|
645
|
-
return this.getCurrentLanguage() == "en";
|
|
646
|
-
}
|
|
647
|
-
isCurrentLanguageArabic() {
|
|
648
|
-
return this.getCurrentLanguage() == "ar";
|
|
649
|
-
}
|
|
650
|
-
notifySuccessMessage(Message, title, time, showHeader = true) {
|
|
651
|
-
let MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
652
|
-
let titleTemplate;
|
|
653
|
-
if (Message) {
|
|
654
|
-
MessageTemplate = Message;
|
|
655
|
-
}
|
|
656
|
-
if (title) {
|
|
657
|
-
titleTemplate = title;
|
|
658
|
-
}
|
|
659
|
-
let toaster = AppInjector.get(ToastrService);
|
|
660
|
-
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
661
|
-
}
|
|
662
|
-
notifyErrorMessage(Message, title, time, showHeader = true) {
|
|
663
|
-
let MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
664
|
-
let titleTemplate = this.getResourceValue("Error");
|
|
665
|
-
if (Message) {
|
|
666
|
-
MessageTemplate = Message;
|
|
667
|
-
}
|
|
668
|
-
if (title) {
|
|
669
|
-
titleTemplate = title;
|
|
670
|
-
}
|
|
671
|
-
const toaster = AppInjector.get(ToastrService);
|
|
672
|
-
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
673
|
-
}
|
|
674
|
-
notifyWarningMessage(Message, title, time, showHeader = true) {
|
|
675
|
-
let MessageTemplate = this.getResourceValue("WarningMessage");
|
|
676
|
-
let titleTemplate = this.getResourceValue("Warning");
|
|
677
|
-
if (Message) {
|
|
678
|
-
MessageTemplate = Message;
|
|
679
|
-
}
|
|
680
|
-
if (title) {
|
|
681
|
-
titleTemplate = title;
|
|
682
|
-
}
|
|
683
|
-
const toaster = AppInjector.get(ToastrService);
|
|
684
|
-
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
685
|
-
}
|
|
686
|
-
startBlockUI() {
|
|
687
|
-
this.blockUI.start();
|
|
688
|
-
}
|
|
689
|
-
stopBlockUI() {
|
|
690
|
-
this.blockUI.stop();
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
UtilityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UtilityService, deps: [{ token: BBSFTranslateService }, { token: AuthService }, { token: EnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
694
|
-
UtilityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UtilityService, providedIn: 'root' });
|
|
695
|
-
__decorate([
|
|
696
|
-
BlockUI()
|
|
697
|
-
], UtilityService.prototype, "blockUI", void 0);
|
|
698
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UtilityService, decorators: [{
|
|
699
|
-
type: Injectable,
|
|
700
|
-
args: [{
|
|
701
|
-
providedIn: 'root'
|
|
702
|
-
}]
|
|
703
|
-
}], ctorParameters: function () { return [{ type: BBSFTranslateService }, { type: AuthService }, { type: EnvironmentService }]; }, propDecorators: { blockUI: [] } });
|
|
704
|
-
|
|
705
|
-
class ControlValidationService {
|
|
706
|
-
constructor(utilityService) {
|
|
707
|
-
this.utilityService = utilityService;
|
|
708
|
-
this.requestOptions = new RequestOptionsModel();
|
|
709
|
-
this.isCreatedBefor = false;
|
|
710
|
-
}
|
|
711
|
-
showGlobalError(errorMessage, formId, deleteOld) {
|
|
712
|
-
let globalErorrElement = document.getElementsByClassName('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
713
|
-
if (globalErorrElement.length > 0) {
|
|
714
|
-
this.removeElementsByClass('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
715
|
-
}
|
|
716
|
-
if (this.isCreatedBefor == true) {
|
|
717
|
-
this.removeElementsByClass('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
718
|
-
}
|
|
719
|
-
// tslint:disable-next-line: prefer-const
|
|
720
|
-
if (!formId)
|
|
721
|
-
formId = "currentForm";
|
|
722
|
-
var object = document.getElementById(formId);
|
|
723
|
-
const tagName = 'div';
|
|
724
|
-
// tslint:disable-next-line: prefer-const
|
|
725
|
-
var elementToAppend = document.createElement(tagName); // Your tag name here
|
|
726
|
-
let message = "";
|
|
727
|
-
if (!errorMessage || (typeof errorMessage == "string")) {
|
|
728
|
-
if (localStorage.getItem('language') == "ar")
|
|
729
|
-
message = errorMessage ? errorMessage : "لديك بعص الأخطاء . من فضلك قم بالمراجعه ";
|
|
730
|
-
else
|
|
731
|
-
message = errorMessage ? errorMessage : "You have some validation errors. Please check below";
|
|
732
|
-
elementToAppend.innerHTML = "<ul class='list-unstyled m-0 py-3 d-flex align-items-center fs-6'><li><i class='fa fa-times-circle text-danger me-3 fs-2'></i>" + message + "</li></ul>";
|
|
733
|
-
elementToAppend.className += 'alert alert-InvalidValidation bg-light-danger text-danger';
|
|
734
|
-
elementToAppend.id += 'errorId';
|
|
735
|
-
// tslint:disable-next-line: prefer-for-of
|
|
736
|
-
const elementToAppen = elementToAppend.cloneNode(true);
|
|
737
|
-
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
738
|
-
object.insertBefore(elementToAppen, object.firstChild);
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
elementToAppend.innerHTML = "<ul>";
|
|
742
|
-
for (const iterator of errorMessage) {
|
|
743
|
-
elementToAppend.innerHTML = "<li>" + iterator + "</li>";
|
|
744
|
-
}
|
|
745
|
-
elementToAppend.innerHTML = "</ul>";
|
|
746
|
-
elementToAppend.className += 'alert alert-InvalidValidation bg-light-danger text-danger';
|
|
747
|
-
elementToAppend.id += 'errorId';
|
|
748
|
-
// tslint:disable-next-line: prefer-for-of
|
|
749
|
-
const elementToAppen = elementToAppend.cloneNode(true);
|
|
750
|
-
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
751
|
-
object.insertBefore(elementToAppen, object.firstChild);
|
|
752
|
-
}
|
|
753
|
-
this.isCreatedBefor = true;
|
|
754
|
-
}
|
|
755
|
-
RemoveGlobalError() {
|
|
756
|
-
const removedList = document.getElementsByClassName('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
757
|
-
// tslint:disable-next-line: prefer-for-of
|
|
758
|
-
for (let index = 0; index < removedList.length; index++) {
|
|
759
|
-
const element = removedList[index];
|
|
760
|
-
element.remove();
|
|
761
|
-
}
|
|
762
|
-
this.isCreatedBefor = false;
|
|
763
|
-
}
|
|
764
|
-
showInputErro(errors) {
|
|
765
|
-
// show error on top of form
|
|
766
|
-
this.showGlobalError();
|
|
767
|
-
// remove old error from server
|
|
768
|
-
this.removeElementsByClass('errortemplet');
|
|
769
|
-
// Looping in error Object
|
|
770
|
-
for (const key in errors) {
|
|
771
|
-
if (errors.hasOwnProperty(key)) {
|
|
772
|
-
for (const iterator of errors[key]) {
|
|
773
|
-
const input = document.querySelectorAll('[ng-reflect-name=' + key + ']')[0];
|
|
774
|
-
if (input.attributes['ng-reflect-name'].value === key) {
|
|
775
|
-
this.removeElementsByClass('erroclass-' + key);
|
|
776
|
-
const tagName = 'p';
|
|
777
|
-
const elementToAppend = document.createElement(tagName); // Your tag name here
|
|
778
|
-
elementToAppend.innerHTML = iterator;
|
|
779
|
-
elementToAppend.style.color = 'red';
|
|
780
|
-
elementToAppend.className += 'errortemplet erroclass-' + key;
|
|
781
|
-
const elementToappen = elementToAppend.cloneNode(true);
|
|
782
|
-
input.parentNode.insertBefore(elementToappen, input.lastChild);
|
|
783
|
-
break;
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
removeElementsByClass(className) {
|
|
790
|
-
const elements = document.getElementsByClassName(className);
|
|
791
|
-
while (elements.length > 0) {
|
|
792
|
-
elements[0].parentNode.removeChild(elements[0]);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
renderServerErrors(form, err, requestOptions, formId) {
|
|
796
|
-
if (err.error == null) {
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
let errorsArray = [];
|
|
800
|
-
this.requestOptions = requestOptions;
|
|
801
|
-
err.error.validation_errors.forEach((element) => {
|
|
802
|
-
let fieldName = element.field;
|
|
803
|
-
let controlName = element.controlName;
|
|
804
|
-
let message = element.message;
|
|
805
|
-
if (form == null) {
|
|
806
|
-
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${message}`);
|
|
807
|
-
}
|
|
808
|
-
else if (controlName && !this.hasControlName(form, controlName)) {
|
|
809
|
-
errorsArray.push(`${fieldName}: ${message}`);
|
|
810
|
-
// this.showGlobalError(`${fieldName}: ${message}`,formId )
|
|
811
|
-
}
|
|
812
|
-
else {
|
|
813
|
-
this.setFieldError(form, controlName, fieldName, message);
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
if (errorsArray.length > 0)
|
|
817
|
-
this.showGlobalError(errorsArray, formId);
|
|
818
|
-
}
|
|
819
|
-
hasControlName(form, controlName) {
|
|
820
|
-
let control = form.get(controlName);
|
|
821
|
-
return control != null;
|
|
822
|
-
}
|
|
823
|
-
setFieldError(form, controlName, fieldName, message) {
|
|
824
|
-
let control = null;
|
|
825
|
-
if (controlName)
|
|
826
|
-
control = form.get(controlName);
|
|
827
|
-
else
|
|
828
|
-
control = form.get(fieldName.split('.')[0]);
|
|
829
|
-
let errors = { "errorMassage": message };
|
|
830
|
-
let fieldNameArray = fieldName.split('.');
|
|
831
|
-
if (fieldNameArray.length >= 1) {
|
|
832
|
-
switch (fieldNameArray[fieldNameArray.length - 1].toLocaleLowerCase()) {
|
|
833
|
-
case "english":
|
|
834
|
-
let englishControl = control.get("English");
|
|
835
|
-
englishControl.setErrors(errors);
|
|
836
|
-
break;
|
|
837
|
-
case "arabic":
|
|
838
|
-
let arabicControl = control.get("Arabic");
|
|
839
|
-
arabicControl.setErrors(errors);
|
|
840
|
-
break;
|
|
841
|
-
default:
|
|
842
|
-
control.setErrors(errors);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
else if (fieldNameArray.length == 1) {
|
|
846
|
-
control.setErrors(errors);
|
|
847
|
-
}
|
|
848
|
-
else {
|
|
849
|
-
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${message}`);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
ControlValidationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ControlValidationService, deps: [{ token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
854
|
-
ControlValidationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ControlValidationService, providedIn: 'root' });
|
|
855
|
-
__decorate([
|
|
856
|
-
BlockUI()
|
|
857
|
-
], ControlValidationService.prototype, "blockUI", void 0);
|
|
858
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ControlValidationService, decorators: [{
|
|
859
|
-
type: Injectable,
|
|
860
|
-
args: [{
|
|
861
|
-
providedIn: 'root'
|
|
862
|
-
}]
|
|
863
|
-
}], ctorParameters: function () { return [{ type: UtilityService }]; }, propDecorators: { blockUI: [] } });
|
|
864
|
-
|
|
865
|
-
class ConfigurationService {
|
|
866
|
-
constructor(httpClient) {
|
|
867
|
-
this.httpClient = httpClient;
|
|
868
|
-
this.httpClient.get("./assets/config/configurations.json").subscribe(data => {
|
|
869
|
-
ConfigurationService.JsonData = data;
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
getConfigurationValue(key) {
|
|
873
|
-
return ConfigurationService.JsonData[key];
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
ConfigurationService.JsonData = [];
|
|
877
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
878
|
-
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ConfigurationService, providedIn: 'root' });
|
|
879
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ConfigurationService, decorators: [{
|
|
880
|
-
type: Injectable,
|
|
881
|
-
args: [{
|
|
882
|
-
providedIn: 'root'
|
|
883
|
-
}]
|
|
884
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
885
|
-
|
|
886
|
-
let AppInjector;
|
|
887
|
-
class BBSFUtilitiesModule {
|
|
888
|
-
constructor(injector) {
|
|
889
|
-
this.injector = injector;
|
|
890
|
-
AppInjector = this.injector;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
BBSFUtilitiesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFUtilitiesModule, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
894
|
-
BBSFUtilitiesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFUtilitiesModule, imports: [CommonModule, i1$1.BlockUIModule, HttpModule,
|
|
895
|
-
RouterModule, i2.ToastrModule] });
|
|
896
|
-
BBSFUtilitiesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFUtilitiesModule, providers: [
|
|
897
|
-
UtilityService,
|
|
898
|
-
EnvironmentService,
|
|
899
|
-
AuthService,
|
|
900
|
-
RequestHandlerService,
|
|
901
|
-
StylesBundleService,
|
|
902
|
-
TranslateService,
|
|
903
|
-
BBSFTranslateService,
|
|
904
|
-
ControlValidationService,
|
|
905
|
-
MasterLayoutService,
|
|
906
|
-
ConfigurationService
|
|
907
|
-
], imports: [[
|
|
908
|
-
CommonModule,
|
|
909
|
-
BlockUIModule.forRoot(),
|
|
910
|
-
HttpModule,
|
|
911
|
-
RouterModule,
|
|
912
|
-
ToastrModule.forRoot(),
|
|
913
|
-
]] });
|
|
914
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: BBSFUtilitiesModule, decorators: [{
|
|
915
|
-
type: NgModule,
|
|
916
|
-
args: [{
|
|
917
|
-
declarations: [],
|
|
918
|
-
imports: [
|
|
919
|
-
CommonModule,
|
|
920
|
-
BlockUIModule.forRoot(),
|
|
921
|
-
HttpModule,
|
|
922
|
-
RouterModule,
|
|
923
|
-
ToastrModule.forRoot(),
|
|
924
|
-
],
|
|
925
|
-
exports: [],
|
|
926
|
-
providers: [
|
|
927
|
-
UtilityService,
|
|
928
|
-
EnvironmentService,
|
|
929
|
-
AuthService,
|
|
930
|
-
RequestHandlerService,
|
|
931
|
-
StylesBundleService,
|
|
932
|
-
TranslateService,
|
|
933
|
-
BBSFTranslateService,
|
|
934
|
-
ControlValidationService,
|
|
935
|
-
MasterLayoutService,
|
|
936
|
-
ConfigurationService
|
|
937
|
-
]
|
|
938
|
-
}]
|
|
939
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
940
|
-
|
|
941
|
-
class TranslationResolverService {
|
|
942
|
-
constructor(translateService) {
|
|
943
|
-
this.translateService = translateService;
|
|
944
|
-
}
|
|
945
|
-
resolve() {
|
|
946
|
-
return this.translateService.getTranslation(this.translateService.currentLang);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
TranslationResolverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: TranslationResolverService, deps: [{ token: BBSFTranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
950
|
-
TranslationResolverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: TranslationResolverService, providedIn: 'root' });
|
|
951
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: TranslationResolverService, decorators: [{
|
|
952
|
-
type: Injectable,
|
|
953
|
-
args: [{ providedIn: 'root' }]
|
|
954
|
-
}], ctorParameters: function () { return [{ type: BBSFTranslateService }]; } });
|
|
955
|
-
|
|
956
|
-
class AppearanceConfigurationService {
|
|
957
|
-
constructor(configService) {
|
|
958
|
-
this.configService = configService;
|
|
959
|
-
}
|
|
960
|
-
getLayoutTheme() {
|
|
961
|
-
return this.configService.getConfigurationValue('AnonymousLayout_Theme');
|
|
962
|
-
}
|
|
963
|
-
getFooterText() {
|
|
964
|
-
return this.configService.getConfigurationValue('AnonymousLayout_FooterText');
|
|
965
|
-
}
|
|
966
|
-
getPageTitle() {
|
|
967
|
-
return this.configService.getConfigurationValue('AnonymousLayout_PageTitle');
|
|
968
|
-
}
|
|
969
|
-
getFavIcon() {
|
|
970
|
-
return this.configService.getConfigurationValue('AnonymousLayout_FavIcon');
|
|
971
|
-
}
|
|
972
|
-
getCustomStyles() {
|
|
973
|
-
return this.configService.getConfigurationValue('AnonymousLayout_CustomStyles');
|
|
974
|
-
}
|
|
975
|
-
getLogo() {
|
|
976
|
-
return this.configService.getConfigurationValue('AnonymousLayout_Logo');
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
AppearanceConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AppearanceConfigurationService, deps: [{ token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
980
|
-
AppearanceConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AppearanceConfigurationService, providedIn: 'root' });
|
|
981
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: AppearanceConfigurationService, decorators: [{
|
|
982
|
-
type: Injectable,
|
|
983
|
-
args: [{
|
|
984
|
-
providedIn: 'root'
|
|
985
|
-
}]
|
|
986
|
-
}], ctorParameters: function () { return [{ type: ConfigurationService }]; } });
|
|
987
|
-
|
|
988
|
-
/*
|
|
989
|
-
* Public API Surface of @bnsights/bbsf-utilities
|
|
990
|
-
*/
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Generated bundle index. Do not edit.
|
|
994
|
-
*/
|
|
995
|
-
|
|
996
|
-
export { AppInjector, AppearanceConfigurationService, AuthService, BBSFTranslateService, BBSFUtilitiesModule, ConfigurationService, ControlValidationService, EnvironmentService, MasterLayoutService, RequestHandlerService, RequestOptionsModel, StylesBundleService, TranslationResolverService, UtilityService, environment };
|
|
997
|
-
//# sourceMappingURL=bnsights-bbsf-utilities.mjs.map
|