@bnsights/bbsf-utilities 1.0.36 → 1.0.37
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 -0
- package/bnsights-bbsf-utilities.d.ts +4 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -0
- package/bundles/bnsights-bbsf-utilities.umd.js +4870 -0
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -0
- package/esm2015/bnsights-bbsf-utilities.js +5 -0
- package/esm2015/lib/bbsf-utilities.module.js +52 -0
- package/esm2015/lib/shared/authentication/auth.service.js +234 -0
- package/esm2015/lib/shared/config/environment.js +12 -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/AreaModel.js +3 -0
- package/esm2015/lib/shared/models/ErrorModel.js +3 -0
- package/esm2015/lib/shared/models/RequestOptionsModel.js +11 -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 +175 -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 +4639 -0
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -0
- package/lib/bbsf-utilities.module.d.ts +6 -0
- package/lib/shared/authentication/auth.service.d.ts +41 -0
- package/lib/shared/config/environment.d.ts +1 -0
- 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/AreaModel.d.ts +4 -0
- package/{src/lib/shared/models/ErrorModel.ts → lib/shared/models/ErrorModel.d.ts} +2 -5
- package/lib/shared/models/RequestOptionsModel.d.ts +11 -0
- package/lib/shared/models/WordDocumentModel.d.ts +16 -0
- package/lib/shared/services/AppearanceConfiguration.service.d.ts +11 -0
- package/lib/shared/services/configuration.service.d.ts +7 -0
- package/lib/shared/services/controlvalidation.service.d.ts +20 -0
- package/lib/shared/services/environment.service.d.ts +13 -0
- package/lib/shared/services/masterlayout.service.d.ts +24 -0
- package/lib/shared/services/requesthandler.service.d.ts +32 -0
- package/lib/shared/services/stylesbundle.service.d.ts +9 -0
- package/lib/shared/services/translate.service.d.ts +3 -0
- package/lib/shared/services/translationresolver.service.d.ts +8 -0
- package/lib/shared/services/utility.service.d.ts +21 -0
- package/lib/shared/services/word-document.service.d.ts +5 -0
- package/package.json +28 -20
- package/public-api.d.ts +16 -0
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -10
- package/src/lib/bbsf-utilities.module.ts +0 -52
- package/src/lib/shared/authentication/auth.service.ts +0 -242
- package/src/lib/shared/config/environment.ts +0 -16
- package/src/lib/shared/config/word/constants.js +0 -133
- package/src/lib/shared/config/word/docx-document.js +0 -482
- package/src/lib/shared/config/word/helpers/index.js +0 -3
- package/src/lib/shared/config/word/helpers/render-document-file.js +0 -334
- package/src/lib/shared/config/word/helpers/xml-builder.js +0 -2165
- package/src/lib/shared/config/word/html-to-docx.js +0 -259
- package/src/lib/shared/config/word/index.js +0 -63
- package/src/lib/shared/config/word/namespaces.js +0 -40
- package/src/lib/shared/config/word/schemas/content-types.js +0 -26
- package/src/lib/shared/config/word/schemas/core.js +0 -44
- package/src/lib/shared/config/word/schemas/document-rels.js +0 -17
- package/src/lib/shared/config/word/schemas/document.template.js +0 -119
- package/src/lib/shared/config/word/schemas/font-table.js +0 -41
- package/src/lib/shared/config/word/schemas/generic-rels.js +0 -11
- package/src/lib/shared/config/word/schemas/index.js +0 -12
- package/src/lib/shared/config/word/schemas/numbering.js +0 -18
- package/src/lib/shared/config/word/schemas/rels.js +0 -12
- package/src/lib/shared/config/word/schemas/settings.js +0 -14
- package/src/lib/shared/config/word/schemas/styles.js +0 -152
- package/src/lib/shared/config/word/schemas/theme.js +0 -199
- package/src/lib/shared/config/word/schemas/web-settings.js +0 -10
- package/src/lib/shared/config/word/utils/color-conversion.js +0 -60
- package/src/lib/shared/config/word/utils/list.js +0 -55
- package/src/lib/shared/config/word/utils/unit-conversion.js +0 -53
- package/src/lib/shared/config/word/utils/url.js +0 -8
- package/src/lib/shared/config/word/utils/vnode.js +0 -3
- package/src/lib/shared/config/word/word-work/assets/contentTypesXml.ts +0 -1
- package/src/lib/shared/config/word/word-work/assets/documentXmlRels.ts +0 -1
- package/src/lib/shared/config/word/word-work/assets/index.ts +0 -3
- package/src/lib/shared/config/word/word-work/assets/relsXml.ts +0 -1
- package/src/lib/shared/config/word/word-work/index.ts +0 -8
- package/src/lib/shared/config/word/word-work/internal.ts +0 -69
- package/src/lib/shared/config/word/word-work/templates/documentTemplate.ts +0 -58
- package/src/lib/shared/config/word/word-work/templates/index.ts +0 -3
- package/src/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.ts +0 -21
- package/src/lib/shared/config/word/word-work/templates/mhtPartTemplate.ts +0 -14
- package/src/lib/shared/config/word/word-work/utils.ts +0 -27
- package/src/lib/shared/models/AreaModel.ts +0 -5
- package/src/lib/shared/models/RequestOptionsModel.ts +0 -13
- package/src/lib/shared/models/WordDocumentModel.ts +0 -19
- package/src/lib/shared/services/AppearanceConfiguration.service.ts +0 -30
- package/src/lib/shared/services/configuration.service.ts +0 -18
- package/src/lib/shared/services/controlvalidation.service.ts +0 -194
- package/src/lib/shared/services/environment.service.ts +0 -56
- package/src/lib/shared/services/masterlayout.service.ts +0 -89
- package/src/lib/shared/services/requesthandler.service.ts +0 -241
- package/src/lib/shared/services/stylesbundle.service.ts +0 -52
- package/src/lib/shared/services/translate.service.ts +0 -8
- package/src/lib/shared/services/translationresolver.service.ts +0 -16
- package/src/lib/shared/services/utility.service.ts +0 -94
- package/src/lib/shared/services/word-document.service.ts +0 -36
- package/src/public-api.ts +0 -27
- package/src/test.ts +0 -26
- package/tsconfig.lib.json +0 -39
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -17
- package/tslint.json +0 -17
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { Injectable, OnDestroy, Pipe } from '@angular/core';
|
|
2
|
-
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from "@angular/common/http";
|
|
3
|
-
import { RequestOptionsModel } from '../models/RequestOptionsModel';
|
|
4
|
-
import { AuthService } from '../authentication/auth.service';
|
|
5
|
-
import { EnvironmentService } from './environment.service';
|
|
6
|
-
import { Observable, Subject, throwError } from 'rxjs';
|
|
7
|
-
import { UtilityService } from './utility.service';
|
|
8
|
-
import { map, takeUntil, tap } from 'rxjs/operators';
|
|
9
|
-
import { BBSFTranslateService } from './translate.service';
|
|
10
|
-
import { plainToClass } from 'class-transformer';
|
|
11
|
-
import { Router } from '@angular/router';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@Injectable()
|
|
15
|
-
export class RequestHandlerService implements OnDestroy {
|
|
16
|
-
private requestOptions: RequestOptionsModel = new RequestOptionsModel();
|
|
17
|
-
private currentLanguage = "";
|
|
18
|
-
public onDestroy$: Subject<void> = new Subject<void>();
|
|
19
|
-
constructor
|
|
20
|
-
(
|
|
21
|
-
private http: HttpClient,
|
|
22
|
-
private authService: AuthService,
|
|
23
|
-
private environmentService: EnvironmentService,
|
|
24
|
-
private utilityService: UtilityService,
|
|
25
|
-
private bbsfTranslateService: BBSFTranslateService,
|
|
26
|
-
private router: Router
|
|
27
|
-
) {
|
|
28
|
-
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
29
|
-
|
|
30
|
-
this.bbsfTranslateService.onLangChange.subscribe((event) => {
|
|
31
|
-
if (this.currentLanguage != event.lang) {
|
|
32
|
-
this.currentLanguage = event.lang;
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public getLuckyNumber(): Observable<number> {
|
|
38
|
-
|
|
39
|
-
return Observable.create((subject: Subject<number>) => {
|
|
40
|
-
setInterval(() => {
|
|
41
|
-
const number = Math.floor(Math.random() * 10);
|
|
42
|
-
console.log(number)
|
|
43
|
-
subject.next(number);
|
|
44
|
-
}, 1000);
|
|
45
|
-
}).pipe(
|
|
46
|
-
takeUntil(this.onDestroy$));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
get<T>(Url: string, params?: HttpParams, responseType?: new () => T, requestOptions?: RequestOptionsModel): Observable<T> {
|
|
51
|
-
if (requestOptions)
|
|
52
|
-
this.requestOptions = requestOptions;
|
|
53
|
-
|
|
54
|
-
let headers = this.getHeaders();
|
|
55
|
-
if (!this.requestOptions.disableBlockUI)
|
|
56
|
-
this.utilityService.startBlockUI();
|
|
57
|
-
let object: T;
|
|
58
|
-
return this.http.get<T>(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(
|
|
59
|
-
takeUntil(this.onDestroy$),
|
|
60
|
-
tap((result) => {
|
|
61
|
-
if (!this.requestOptions.disableBlockUI)
|
|
62
|
-
this.utilityService.stopBlockUI();
|
|
63
|
-
}, error => {
|
|
64
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
65
|
-
this.handleError(error);
|
|
66
|
-
}), map((data: T) => {
|
|
67
|
-
if (this.requestOptions.castResponsetoClass)
|
|
68
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
69
|
-
else
|
|
70
|
-
return data;
|
|
71
|
-
})
|
|
72
|
-
) as Observable<T>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
post<T>(Url: string, model?: any, responseType?: new () => T, params?: HttpParams, requestOptions?: RequestOptionsModel): Observable<T> {
|
|
76
|
-
|
|
77
|
-
if (requestOptions)
|
|
78
|
-
this.requestOptions = requestOptions;
|
|
79
|
-
|
|
80
|
-
let headers = this.getHeaders();
|
|
81
|
-
if (!this.requestOptions.disableBlockUI)
|
|
82
|
-
this.utilityService.startBlockUI();
|
|
83
|
-
return this.http.post<T>(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(
|
|
84
|
-
takeUntil(this.onDestroy$),
|
|
85
|
-
tap((result) => {
|
|
86
|
-
if (!this.requestOptions.disableBlockUI)
|
|
87
|
-
this.utilityService.stopBlockUI();
|
|
88
|
-
}, error => {
|
|
89
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
90
|
-
this.handleError(error);
|
|
91
|
-
}), map((data: T) => {
|
|
92
|
-
if (this.requestOptions.castResponsetoClass)
|
|
93
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
94
|
-
else
|
|
95
|
-
return data;
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
delete<T>(Url: string, deletedId: string, requestOptions?: RequestOptionsModel, responseType?: new () => T, params?: HttpParams): Observable<T> {
|
|
101
|
-
if (requestOptions)
|
|
102
|
-
this.requestOptions = requestOptions;
|
|
103
|
-
|
|
104
|
-
let headers = this.getHeaders();
|
|
105
|
-
if (!this.requestOptions.disableBlockUI)
|
|
106
|
-
this.utilityService.startBlockUI();
|
|
107
|
-
return this.http.delete<T>(this.environmentService.getApiUrl() + Url + `/${deletedId}`, { headers: headers, params: params }).pipe(
|
|
108
|
-
takeUntil(this.onDestroy$),
|
|
109
|
-
tap((result) => {
|
|
110
|
-
if (!this.requestOptions.disableBlockUI)
|
|
111
|
-
this.utilityService.stopBlockUI();
|
|
112
|
-
}, error => {
|
|
113
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
114
|
-
this.handleError(error);
|
|
115
|
-
}), map((data: T) => {
|
|
116
|
-
if (this.requestOptions.castResponsetoClass)
|
|
117
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
118
|
-
else
|
|
119
|
-
return data;
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
put<T>(Url: string, model?: any, params?: HttpParams, responseType?: new () => T, requestOptions?: RequestOptionsModel): Observable<T> {
|
|
125
|
-
if (requestOptions)
|
|
126
|
-
this.requestOptions = requestOptions;
|
|
127
|
-
|
|
128
|
-
let headers = this.getHeaders();
|
|
129
|
-
if (!this.requestOptions.disableBlockUI)
|
|
130
|
-
this.utilityService.startBlockUI();
|
|
131
|
-
return this.http.put<T>(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(
|
|
132
|
-
takeUntil(this.onDestroy$),
|
|
133
|
-
tap((result) => {
|
|
134
|
-
if (!this.requestOptions.disableBlockUI)
|
|
135
|
-
this.utilityService.stopBlockUI();
|
|
136
|
-
}, error => {
|
|
137
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
138
|
-
this.handleError(error);
|
|
139
|
-
}), map((data: T) => {
|
|
140
|
-
if (this.requestOptions.castResponsetoClass)
|
|
141
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
142
|
-
else
|
|
143
|
-
return data;
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
patch<T>(Url: string, model?: any, responseType?: new () => T, params?: HttpParams, requestOptions?: RequestOptionsModel): Observable<T> {
|
|
149
|
-
|
|
150
|
-
if (requestOptions)
|
|
151
|
-
this.requestOptions = requestOptions;
|
|
152
|
-
|
|
153
|
-
let headers = new HttpHeaders({
|
|
154
|
-
'Content-Type': 'application/json',
|
|
155
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
this.currentLanguage = localStorage.getItem('language');
|
|
159
|
-
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
160
|
-
headers = headers.set('ignore-cookies', 'true');
|
|
161
|
-
if (!this.requestOptions.disableBlockUI)
|
|
162
|
-
this.utilityService.startBlockUI();
|
|
163
|
-
|
|
164
|
-
return this.http.patch<T>(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(
|
|
165
|
-
takeUntil(this.onDestroy$),
|
|
166
|
-
tap((result) => {
|
|
167
|
-
if (!this.requestOptions.disableBlockUI)
|
|
168
|
-
this.utilityService.stopBlockUI();
|
|
169
|
-
}, error => {
|
|
170
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
171
|
-
this.handleError(error);
|
|
172
|
-
}), map((data: T) => {
|
|
173
|
-
if (this.requestOptions.castResponsetoClass)
|
|
174
|
-
return plainToClass(responseType, data, { excludeExtraneousValues: true })
|
|
175
|
-
else
|
|
176
|
-
return data;
|
|
177
|
-
})
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
download<T>(Url: string, params?: HttpParams, requestOptions?: RequestOptionsModel): Observable<T> {
|
|
181
|
-
if (requestOptions)
|
|
182
|
-
this.requestOptions = requestOptions;
|
|
183
|
-
|
|
184
|
-
let headers = this.getHeaders();
|
|
185
|
-
if (!this.requestOptions.disableBlockUI)
|
|
186
|
-
this.utilityService.startBlockUI();
|
|
187
|
-
return this.http.get<T>(this.environmentService.getApiUrl() + Url, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(
|
|
188
|
-
takeUntil(this.onDestroy$),
|
|
189
|
-
tap((result) => {
|
|
190
|
-
if (!this.requestOptions.disableBlockUI)
|
|
191
|
-
this.utilityService.stopBlockUI();
|
|
192
|
-
}, error => {
|
|
193
|
-
if (!this.requestOptions.disableErrorHandler)
|
|
194
|
-
this.handleError(error);
|
|
195
|
-
})
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
public destroyHandler(): void {
|
|
200
|
-
this.onDestroy$.next();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
ngOnDestroy(): void {
|
|
204
|
-
console.log("clearInterval")
|
|
205
|
-
this.destroyHandler()
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
private handleError(err: HttpErrorResponse) {
|
|
209
|
-
var isEnglish = this.utilityService.getCurrentLanguage() == "en";
|
|
210
|
-
if (err.error instanceof ErrorEvent) {
|
|
211
|
-
this.utilityService.notifyErrorMessage()
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
if (err.status == 400)
|
|
215
|
-
throwError(err);//error 400 is thrown to be catch by the Form component to handle Fluent validation errors
|
|
216
|
-
else if (err.status == 401)
|
|
217
|
-
this.router.navigate(["/Admin/account/login"])
|
|
218
|
-
else if (err.status == 403)
|
|
219
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Sorry, You're not authorized to access this action" : "عذرا ليس لديك الصلاحيه لهذا الطلب")
|
|
220
|
-
else if (err.status == 510)
|
|
221
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Can not delete this item as it is related to others" : "لا يمكن حذف هذا العنصر لأنه مرتبط بعناصر أخرى")
|
|
222
|
-
else if (err.status == 515)
|
|
223
|
-
this.utilityService.notifyErrorMessage((err.error ? err.error.Message : err.message))
|
|
224
|
-
else {
|
|
225
|
-
console.log(`error message is: ${err.error ? err.error.Message : err.message}`)
|
|
226
|
-
this.utilityService.notifyErrorMessage(this.utilityService.getResourceValue("ErrorMassage"))
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
this.utilityService.stopBlockUI();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private getHeaders() {
|
|
233
|
-
return new HttpHeaders({
|
|
234
|
-
'Content-Type': 'application/json',
|
|
235
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
236
|
-
'Client-Local-Time-Zone': Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
237
|
-
'Accept-Language': localStorage.getItem('language'),
|
|
238
|
-
'ignore-cookies': 'true'
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DOCUMENT } from '@angular/common';
|
|
2
|
-
import { Inject, Injectable } from '@angular/core';
|
|
3
|
-
import { BlockUI, NgBlockUI } from 'ng-block-ui';
|
|
4
|
-
import { BBSFTranslateService } from './translate.service';
|
|
5
|
-
|
|
6
|
-
@Injectable({
|
|
7
|
-
providedIn: 'root'
|
|
8
|
-
})
|
|
9
|
-
export class StylesBundleService {
|
|
10
|
-
|
|
11
|
-
constructor(@Inject(DOCUMENT) private document: Document, private translateService: BBSFTranslateService) { }
|
|
12
|
-
|
|
13
|
-
loadThemes(lang: string, bundleEnglishName: string, bundleArabicName: string) {
|
|
14
|
-
if (lang == "ar") {
|
|
15
|
-
this.loadStyleBundle(bundleArabicName.toString())
|
|
16
|
-
document.querySelector('html').setAttribute("b-lang", "ar"); //use b-lang instead of lang to fix firefox number inputs in Arabic locale
|
|
17
|
-
document.querySelector('html').setAttribute("dir", "rtl");
|
|
18
|
-
} else {
|
|
19
|
-
this.loadStyleBundle(bundleEnglishName.toString())
|
|
20
|
-
document.querySelector('html').setAttribute("b-lang", "en");
|
|
21
|
-
document.querySelector('html').setAttribute("dir", "ltr");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
loadThemesColor(theme: string, bundleDarkName: string, bundleLightName: string) {
|
|
27
|
-
if (theme == "Light")
|
|
28
|
-
this.loadStyleBundle(bundleLightName.toString());
|
|
29
|
-
else
|
|
30
|
-
this.loadStyleBundle(bundleDarkName.toString())
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
loadStyleBundle(styleName: string) {
|
|
34
|
-
const head = this.document.getElementsByTagName('head')[0];
|
|
35
|
-
|
|
36
|
-
let themeLink = this.document.getElementById('client-theme') as HTMLLinkElement;
|
|
37
|
-
|
|
38
|
-
if (themeLink && themeLink.href.includes(styleName)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
42
|
-
themeLink.remove();
|
|
43
|
-
}
|
|
44
|
-
const style = this.document.createElement('link');
|
|
45
|
-
style.id = 'client-theme';
|
|
46
|
-
style.rel = 'stylesheet';
|
|
47
|
-
style.href = `${styleName}`;
|
|
48
|
-
head.appendChild(style);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@angular/core";
|
|
2
|
-
import { Resolve } from "@angular/router";
|
|
3
|
-
import { Observable } from "rxjs";
|
|
4
|
-
import { BBSFTranslateService } from "./translate.service";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@Injectable({ providedIn: 'root' })
|
|
8
|
-
export class TranslationResolverService implements Resolve<any> {
|
|
9
|
-
constructor(private translateService: BBSFTranslateService) {}
|
|
10
|
-
|
|
11
|
-
resolve(): Observable<any> {
|
|
12
|
-
return this.translateService.getTranslation(
|
|
13
|
-
this.translateService.currentLang
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Injectable, Optional, Host, SkipSelf, Component } from '@angular/core';
|
|
2
|
-
import { ToastrService } from 'ngx-toastr';
|
|
3
|
-
import { BlockUI, NgBlockUI } from 'ng-block-ui';
|
|
4
|
-
import { AuthService } from '../authentication/auth.service';
|
|
5
|
-
import { BBSFTranslateService } from './translate.service';
|
|
6
|
-
import { AppInjector } from '../../bbsf-utilities.module';
|
|
7
|
-
import { EnvironmentService } from './environment.service';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@Injectable({
|
|
12
|
-
providedIn: 'root'
|
|
13
|
-
})
|
|
14
|
-
export class UtilityService {
|
|
15
|
-
|
|
16
|
-
isCreatedBefore = false;
|
|
17
|
-
@BlockUI() blockUI: NgBlockUI;
|
|
18
|
-
|
|
19
|
-
constructor(private translator: BBSFTranslateService, private authService: AuthService, private environmentService: EnvironmentService,) {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
getResourceValue(Key: string): string {
|
|
25
|
-
let ResourceValue = this.translator.instant(Key)
|
|
26
|
-
return ResourceValue;
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getCurrentLanguage() {
|
|
31
|
-
let currentLanguage = this.environmentService.getDefaultLanguage();
|
|
32
|
-
let lang = localStorage.getItem('language');
|
|
33
|
-
if (lang)
|
|
34
|
-
currentLanguage = lang;
|
|
35
|
-
else
|
|
36
|
-
localStorage.setItem('language', currentLanguage);
|
|
37
|
-
return currentLanguage;
|
|
38
|
-
}
|
|
39
|
-
isCurrentLanguageEnglish() {
|
|
40
|
-
return this.getCurrentLanguage() == "en"
|
|
41
|
-
}
|
|
42
|
-
isCurrentLanguageArabic() {
|
|
43
|
-
return this.getCurrentLanguage() == "ar"
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
notifySuccessMessage(Message?: string, title?: string, time?: number, showHeader: boolean = true) {
|
|
47
|
-
|
|
48
|
-
let MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
49
|
-
let titleTemplate: string;
|
|
50
|
-
if (Message) {
|
|
51
|
-
MessageTemplate = Message;
|
|
52
|
-
}
|
|
53
|
-
if (title) {
|
|
54
|
-
titleTemplate = title;
|
|
55
|
-
}
|
|
56
|
-
let toaster = AppInjector.get(ToastrService);
|
|
57
|
-
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
notifyErrorMessage(Message?: string, title?: string, time?: number, showHeader: boolean = true) {
|
|
61
|
-
|
|
62
|
-
let MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
63
|
-
let titleTemplate = this.getResourceValue("Error");
|
|
64
|
-
if (Message) {
|
|
65
|
-
MessageTemplate = Message;
|
|
66
|
-
}
|
|
67
|
-
if (title) {
|
|
68
|
-
titleTemplate = title;
|
|
69
|
-
}
|
|
70
|
-
const toaster = AppInjector.get(ToastrService);
|
|
71
|
-
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
notifyWarningMessage(Message?: string, title?: string, time?: number, showHeader: boolean = true) {
|
|
75
|
-
|
|
76
|
-
let MessageTemplate = this.getResourceValue("WarningMessage");
|
|
77
|
-
let titleTemplate = this.getResourceValue("Warning");
|
|
78
|
-
if (Message) {
|
|
79
|
-
MessageTemplate = Message;
|
|
80
|
-
}
|
|
81
|
-
if (title) {
|
|
82
|
-
titleTemplate = title;
|
|
83
|
-
}
|
|
84
|
-
const toaster = AppInjector.get(ToastrService);
|
|
85
|
-
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
startBlockUI() {
|
|
89
|
-
this.blockUI.start();
|
|
90
|
-
}
|
|
91
|
-
stopBlockUI() {
|
|
92
|
-
this.blockUI.stop();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { generateContainer as GenerateDOCX } from '../config//word/index';
|
|
3
|
-
import { WordDocumentModel } from '../models/WordDocumentModel';
|
|
4
|
-
@Injectable({
|
|
5
|
-
providedIn: 'root',
|
|
6
|
-
})
|
|
7
|
-
export class WordDocumentService {
|
|
8
|
-
async generateWordByteFile(model: WordDocumentModel) {
|
|
9
|
-
let documentOptions: any = {};
|
|
10
|
-
if (model.options.isLandscape) documentOptions.orientation = 'landscape';
|
|
11
|
-
documentOptions.pageSize = {
|
|
12
|
-
width: model.options.pageWidth * 15,
|
|
13
|
-
height: model.options.pageHeight * 15,
|
|
14
|
-
};
|
|
15
|
-
documentOptions.margins = {
|
|
16
|
-
top: model.options.top * 15,
|
|
17
|
-
right: model.options.right * 15,
|
|
18
|
-
bottom: model.options.bottom * 15,
|
|
19
|
-
left: model.options.left * 15,
|
|
20
|
-
header: model.options.top * 15*2,
|
|
21
|
-
footer: model.options.bottom * 15*2,
|
|
22
|
-
gutter: 0,
|
|
23
|
-
};
|
|
24
|
-
documentOptions.footer = true;
|
|
25
|
-
documentOptions.header = true;
|
|
26
|
-
documentOptions.pageNumber = model.options.showPaging;
|
|
27
|
-
documentOptions.table = { row: { cantSplit: true } };
|
|
28
|
-
var fileBuffer = await GenerateDOCX(
|
|
29
|
-
model.body,
|
|
30
|
-
model.header,
|
|
31
|
-
documentOptions,
|
|
32
|
-
model.footer
|
|
33
|
-
);
|
|
34
|
-
return fileBuffer;
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/public-api.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Public API Surface of @bnsights/bbsf-utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from './lib/bbsf-utilities.module';
|
|
6
|
-
|
|
7
|
-
export * from './lib/shared/services/utility.service';
|
|
8
|
-
export * from './lib/shared/services/environment.service';
|
|
9
|
-
export * from './lib/shared/services/requesthandler.service'
|
|
10
|
-
export * from './lib/shared/services/stylesbundle.service'
|
|
11
|
-
export * from './lib/shared/services/translate.service'
|
|
12
|
-
export * from './lib/shared/services/controlvalidation.service'
|
|
13
|
-
export * from './lib/shared/services/masterlayout.service'
|
|
14
|
-
export * from './lib/shared/services/translationresolver.service'
|
|
15
|
-
export * from './lib/shared/services/AppearanceConfiguration.service'
|
|
16
|
-
export * from './lib/shared/services/configuration.service'
|
|
17
|
-
export * from './lib/shared/services/word-document.service'
|
|
18
|
-
|
|
19
|
-
export * from './lib/shared/config/environment';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export * from './lib/shared/authentication/auth.service';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export * from './lib/shared/models/RequestOptionsModel';
|
|
26
|
-
export * from './lib/shared/models/WordDocumentModel';
|
|
27
|
-
|
package/src/test.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js/dist/zone';
|
|
4
|
-
import 'zone.js/dist/zone-testing';
|
|
5
|
-
import { getTestBed } from '@angular/core/testing';
|
|
6
|
-
import {
|
|
7
|
-
BrowserDynamicTestingModule,
|
|
8
|
-
platformBrowserDynamicTesting
|
|
9
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
-
|
|
11
|
-
declare const require: {
|
|
12
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
-
keys(): string[];
|
|
14
|
-
<T>(id: string): T;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// First, initialize the Angular testing environment.
|
|
19
|
-
getTestBed().initTestEnvironment(
|
|
20
|
-
BrowserDynamicTestingModule,
|
|
21
|
-
platformBrowserDynamicTesting()
|
|
22
|
-
);
|
|
23
|
-
// Then we find all the tests.
|
|
24
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
25
|
-
// And load the modules.
|
|
26
|
-
context.keys().map(context);
|
package/tsconfig.lib.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../out-tsc/lib",
|
|
5
|
-
"target": "es2015",
|
|
6
|
-
"module": "es2020",
|
|
7
|
-
"baseUrl": "src/lib",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"noImplicitAny": false,
|
|
11
|
-
"inlineSources": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"allowSyntheticDefaultImports": true,
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"importHelpers": true,
|
|
17
|
-
"allowJs": true,
|
|
18
|
-
"types": [
|
|
19
|
-
"node"
|
|
20
|
-
],
|
|
21
|
-
"lib": [
|
|
22
|
-
"dom",
|
|
23
|
-
"es2018"
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
"angularCompilerOptions": {
|
|
27
|
-
"skipTemplateCodegen": true,
|
|
28
|
-
"strictMetadataEmit": false,
|
|
29
|
-
"enableResourceInlining": true,
|
|
30
|
-
"fullTemplateTypeCheck": true,
|
|
31
|
-
"resolveJsonModule": true,
|
|
32
|
-
"esModuleInterop": true,
|
|
33
|
-
"allowSyntheticDefaultImports":true
|
|
34
|
-
},
|
|
35
|
-
"exclude": [
|
|
36
|
-
"src/test.ts",
|
|
37
|
-
"**/*.spec.ts"
|
|
38
|
-
]
|
|
39
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "./tsconfig.lib.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"declarationMap": false
|
|
6
|
-
},
|
|
7
|
-
"angularCompilerOptions": {
|
|
8
|
-
// "enableIvy": false
|
|
9
|
-
"compilationMode": "partial"
|
|
10
|
-
}
|
|
11
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"src/test.ts"
|
|
12
|
-
],
|
|
13
|
-
"include": [
|
|
14
|
-
"**/*.spec.ts",
|
|
15
|
-
"**/*.d.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|