@bnsights/bbsf-utilities 1.0.36 → 1.0.38
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-1.0.38.tgz +0 -0
- package/bnsights-bbsf-utilities.d.ts +4 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -0
- package/bundles/bnsights-bbsf-utilities.umd.js +4782 -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 +54 -0
- package/esm2015/lib/shared/authentication/auth.service.js +204 -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/UserModel.js +3 -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 +89 -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 +4606 -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 +47 -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/UserModel.d.ts +6 -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 +30 -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,58 +0,0 @@
|
|
|
1
|
-
export const defaultMargins = {
|
|
2
|
-
top: 1440,
|
|
3
|
-
right: 1440,
|
|
4
|
-
bottom: 1440,
|
|
5
|
-
left: 1440,
|
|
6
|
-
header: 720,
|
|
7
|
-
footer: 720,
|
|
8
|
-
gutter: 0,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type Margins = typeof defaultMargins
|
|
12
|
-
|
|
13
|
-
export type Orient = 'landscape' | 'portrait'
|
|
14
|
-
|
|
15
|
-
export const documentTemplate = (width: number, height: number, orient: string, margins: Margins) => {
|
|
16
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
17
|
-
<w:document
|
|
18
|
-
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
19
|
-
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
|
|
20
|
-
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
21
|
-
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
|
22
|
-
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
23
|
-
xmlns:ns6="http://schemas.openxmlformats.org/schemaLibrary/2006/main"
|
|
24
|
-
xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
|
|
25
|
-
xmlns:ns8="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing"
|
|
26
|
-
xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram"
|
|
27
|
-
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
|
|
28
|
-
xmlns:ns11="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
|
|
29
|
-
xmlns:dsp="http://schemas.microsoft.com/office/drawing/2008/diagram"
|
|
30
|
-
xmlns:ns13="urn:schemas-microsoft-com:office:excel"
|
|
31
|
-
xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
32
|
-
xmlns:v="urn:schemas-microsoft-com:vml"
|
|
33
|
-
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
|
34
|
-
xmlns:ns17="urn:schemas-microsoft-com:office:powerpoint"
|
|
35
|
-
xmlns:odx="http://opendope.org/xpaths"
|
|
36
|
-
xmlns:odc="http://opendope.org/conditions"
|
|
37
|
-
xmlns:odq="http://opendope.org/questions"
|
|
38
|
-
xmlns:odi="http://opendope.org/components"
|
|
39
|
-
xmlns:odgm="http://opendope.org/SmartArt/DataHierarchy"
|
|
40
|
-
xmlns:ns24="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"
|
|
41
|
-
xmlns:ns25="http://schemas.openxmlformats.org/drawingml/2006/compatibility"
|
|
42
|
-
xmlns:ns26="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas">
|
|
43
|
-
<w:body>
|
|
44
|
-
<w:altChunk r:id="htmlChunk" />
|
|
45
|
-
<w:sectPr>
|
|
46
|
-
<w:pgSz w:w="${width}" w:h="${height}" w:orient="${orient}" />
|
|
47
|
-
<w:pgMar w:top="${margins.top}"
|
|
48
|
-
w:right="${margins.right}"
|
|
49
|
-
w:bottom="${margins.bottom}"
|
|
50
|
-
w:left="${margins.left}"
|
|
51
|
-
w:header="${margins.header}"
|
|
52
|
-
w:footer="${margins.footer}"
|
|
53
|
-
w:gutter="${margins.gutter}"/>
|
|
54
|
-
</w:sectPr>
|
|
55
|
-
</w:body>
|
|
56
|
-
</w:document>
|
|
57
|
-
`
|
|
58
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const mhtDocumentTemplate = (htmlSource: string, contentParts: string) => {
|
|
2
|
-
debugger;
|
|
3
|
-
return `MIME-Version: 1.0
|
|
4
|
-
Content-Type: multipart/related;
|
|
5
|
-
type="text/html";
|
|
6
|
-
boundary="----=mhtDocumentPart"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
------=mhtDocumentPart
|
|
10
|
-
Content-Type: text/html;
|
|
11
|
-
charset="utf-8"
|
|
12
|
-
Content-Transfer-Encoding: quoted-printable
|
|
13
|
-
Content-Location: file:///C:/fake/document.html
|
|
14
|
-
|
|
15
|
-
${htmlSource}
|
|
16
|
-
|
|
17
|
-
${contentParts}
|
|
18
|
-
|
|
19
|
-
------=mhtDocumentPart--
|
|
20
|
-
`
|
|
21
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const mhtPartTemplate = (
|
|
2
|
-
contentType: string,
|
|
3
|
-
contentEncoding: string,
|
|
4
|
-
contentLocation: string,
|
|
5
|
-
encodedContent: string,
|
|
6
|
-
) => {
|
|
7
|
-
return `------=mhtDocumentPart
|
|
8
|
-
Content-Type: ${contentType}
|
|
9
|
-
Content-Transfer-Encoding: ${contentEncoding}
|
|
10
|
-
Content-Location: ${contentLocation}
|
|
11
|
-
|
|
12
|
-
${encodedContent}
|
|
13
|
-
`
|
|
14
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { mhtDocumentTemplate, mhtPartTemplate } from './templates'
|
|
2
|
-
|
|
3
|
-
export function getMHTdocument(htmlSource: string) {
|
|
4
|
-
debugger
|
|
5
|
-
const ref = _prepareImageParts(htmlSource)
|
|
6
|
-
const imageContentPartsString = ref.imageContentParts.join('\n')
|
|
7
|
-
htmlSource = ref.htmlSource.replace(/\=/g, '=3D')
|
|
8
|
-
return mhtDocumentTemplate(htmlSource, imageContentPartsString)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _prepareImageParts(htmlSource: string) {
|
|
12
|
-
debugger
|
|
13
|
-
const imageContentParts: string[] = []
|
|
14
|
-
const inlinedSrcPattern = /"data:(\w+\/\w+);(\w+),(\S+)"/g
|
|
15
|
-
const inlinedReplacer = (match: string, contentType: string, contentEncoding: string, encodedContent: string) => {
|
|
16
|
-
const index = imageContentParts.length
|
|
17
|
-
const extension = contentType.split('/')[1]
|
|
18
|
-
const contentLocation = `file:///C:/fake/image${index}.${extension}`
|
|
19
|
-
imageContentParts.push(mhtPartTemplate(contentType, contentEncoding, contentLocation, encodedContent))
|
|
20
|
-
return `\"${contentLocation}\"`
|
|
21
|
-
}
|
|
22
|
-
if (!/<img/g.test(htmlSource)) {
|
|
23
|
-
return { htmlSource, imageContentParts }
|
|
24
|
-
}
|
|
25
|
-
htmlSource = htmlSource.replace(inlinedSrcPattern, inlinedReplacer)
|
|
26
|
-
return { htmlSource, imageContentParts }
|
|
27
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FormGroup } from "@angular/forms";
|
|
2
|
-
|
|
3
|
-
export class RequestOptionsModel {
|
|
4
|
-
disableSuccessNotification: boolean=false;
|
|
5
|
-
disableBlockUI: boolean = false;
|
|
6
|
-
disableErrorHandler: boolean = false;
|
|
7
|
-
customSuccessMessage: string;
|
|
8
|
-
customErrorMessage: string;
|
|
9
|
-
responseType:any=""
|
|
10
|
-
formGroup: FormGroup = null
|
|
11
|
-
castResponsetoClass: boolean = true;
|
|
12
|
-
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export class WordDocumentModel
|
|
2
|
-
{
|
|
3
|
-
header:string;
|
|
4
|
-
footer:string;
|
|
5
|
-
body:string;
|
|
6
|
-
options:DocumentOptionsModel=new DocumentOptionsModel()
|
|
7
|
-
}
|
|
8
|
-
export class DocumentOptionsModel
|
|
9
|
-
{
|
|
10
|
-
pageHeight:number;
|
|
11
|
-
pageWidth:number;
|
|
12
|
-
top:number;
|
|
13
|
-
bottom:number;
|
|
14
|
-
left:number;
|
|
15
|
-
right:number;
|
|
16
|
-
isLandscape:boolean;
|
|
17
|
-
showPaging:boolean;
|
|
18
|
-
|
|
19
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@angular/core";
|
|
2
|
-
import { TranslateService } from "@ngx-translate/core";
|
|
3
|
-
import { ConfigurationService } from "./configuration.service";
|
|
4
|
-
|
|
5
|
-
@Injectable({
|
|
6
|
-
providedIn: 'root'
|
|
7
|
-
})
|
|
8
|
-
export class AppearanceConfigurationService {
|
|
9
|
-
constructor(private configService: ConfigurationService) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getLayoutTheme() {
|
|
13
|
-
return this.configService.getConfigurationValue('AnonymousLayout_Theme');
|
|
14
|
-
}
|
|
15
|
-
getFooterText() {
|
|
16
|
-
return this.configService.getConfigurationValue('AnonymousLayout_FooterText');
|
|
17
|
-
}
|
|
18
|
-
getPageTitle() {
|
|
19
|
-
return this.configService.getConfigurationValue('AnonymousLayout_PageTitle');
|
|
20
|
-
}
|
|
21
|
-
getFavIcon() {
|
|
22
|
-
return this.configService.getConfigurationValue('AnonymousLayout_FavIcon');
|
|
23
|
-
}
|
|
24
|
-
getCustomStyles() {
|
|
25
|
-
return this.configService.getConfigurationValue('AnonymousLayout_CustomStyles');
|
|
26
|
-
}
|
|
27
|
-
getLogo() {
|
|
28
|
-
return this.configService.getConfigurationValue('AnonymousLayout_Logo');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "@angular/common/http";
|
|
2
|
-
import { Injectable } from "@angular/core";
|
|
3
|
-
import { TranslateService } from "@ngx-translate/core";
|
|
4
|
-
|
|
5
|
-
@Injectable({
|
|
6
|
-
providedIn: 'root'
|
|
7
|
-
})
|
|
8
|
-
export class ConfigurationService {
|
|
9
|
-
static JsonData:any[]=[]
|
|
10
|
-
constructor(private httpClient: HttpClient){
|
|
11
|
-
this.httpClient.get("./assets/config/configurations.json").subscribe(data =>{
|
|
12
|
-
ConfigurationService.JsonData = data as any[];
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
getConfigurationValue(key:string) {
|
|
16
|
-
return ConfigurationService.JsonData[key];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { Injectable, Optional, Host, SkipSelf, Component } from '@angular/core';
|
|
2
|
-
import { IndividualConfig, ToastrService } from 'ngx-toastr';
|
|
3
|
-
import { BlockUI, NgBlockUI } from 'ng-block-ui';
|
|
4
|
-
import { AbstractControl, ControlContainer, ControlValueAccessor, NG_VALUE_ACCESSOR, FormControl, FormsModule, FormGroup } from '@angular/forms';
|
|
5
|
-
import { TranslateService } from '@ngx-translate/core';
|
|
6
|
-
import { HttpErrorResponse } from '@angular/common/http';
|
|
7
|
-
import { ErrorModel } from '../models/ErrorModel';
|
|
8
|
-
import { UtilityService } from './utility.service';
|
|
9
|
-
import { RequestOptionsModel } from '../models/RequestOptionsModel';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@Injectable({
|
|
14
|
-
providedIn: 'root'
|
|
15
|
-
})
|
|
16
|
-
export class ControlValidationService {
|
|
17
|
-
private requestOptions: RequestOptionsModel = new RequestOptionsModel();
|
|
18
|
-
|
|
19
|
-
constructor(private utilityService: UtilityService) {
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
isCreatedBefor = false;
|
|
23
|
-
|
|
24
|
-
@BlockUI() blockUI: NgBlockUI;
|
|
25
|
-
|
|
26
|
-
showGlobalError(errorMessage?: string | string[], formId?: string, deleteOld?: boolean) {
|
|
27
|
-
let globalErorrElement = document.getElementsByClassName('alert alert-InvalidValidation bg-light-danger text-danger')
|
|
28
|
-
if (globalErorrElement.length > 0) {
|
|
29
|
-
this.removeElementsByClass('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
30
|
-
}
|
|
31
|
-
if (this.isCreatedBefor == true) {
|
|
32
|
-
this.removeElementsByClass('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
33
|
-
}
|
|
34
|
-
// tslint:disable-next-line: prefer-const
|
|
35
|
-
if (!formId)
|
|
36
|
-
formId = "currentForm"
|
|
37
|
-
var object = document.getElementById(formId);
|
|
38
|
-
const tagName = 'div';
|
|
39
|
-
// tslint:disable-next-line: prefer-const
|
|
40
|
-
var elementToAppend = document.createElement(tagName); // Your tag name here
|
|
41
|
-
let message: string | string[] = "";
|
|
42
|
-
|
|
43
|
-
if (!errorMessage || (typeof errorMessage == "string")) {
|
|
44
|
-
if (localStorage.getItem('language') == "ar")
|
|
45
|
-
message = errorMessage ? errorMessage : "لديك بعص الأخطاء . من فضلك قم بالمراجعه ";
|
|
46
|
-
else
|
|
47
|
-
message = errorMessage ? errorMessage : "You have some validation errors. Please check below"
|
|
48
|
-
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>";
|
|
49
|
-
elementToAppend.className += 'alert alert-InvalidValidation bg-light-danger text-danger';
|
|
50
|
-
elementToAppend.id += 'errorId';
|
|
51
|
-
// tslint:disable-next-line: prefer-for-of
|
|
52
|
-
const elementToAppen = elementToAppend.cloneNode(true);
|
|
53
|
-
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
54
|
-
object.insertBefore(elementToAppen, object.firstChild);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
let ul = document.createElement("ul");
|
|
58
|
-
elementToAppend.appendChild(ul);
|
|
59
|
-
|
|
60
|
-
for (const iterator of errorMessage) {
|
|
61
|
-
let li = document.createElement("li");
|
|
62
|
-
li.innerHTML = iterator;
|
|
63
|
-
ul.appendChild(li);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
elementToAppend.className += 'alert alert-InvalidValidation bg-light-danger text-danger';
|
|
67
|
-
elementToAppend.id += 'errorId';
|
|
68
|
-
// tslint:disable-next-line: prefer-for-of
|
|
69
|
-
const elementToAppen = elementToAppend.cloneNode(true);
|
|
70
|
-
// let targetElement = object.getElementsByClassName("b-control")[0];
|
|
71
|
-
object.insertBefore(elementToAppen, object.firstChild);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.isCreatedBefor = true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
RemoveGlobalError() {
|
|
78
|
-
const removedList = document.getElementsByClassName('alert alert-InvalidValidation bg-light-danger text-danger');
|
|
79
|
-
// tslint:disable-next-line: prefer-for-of
|
|
80
|
-
for (let index = 0; index < removedList.length; index++) {
|
|
81
|
-
const element = removedList[index];
|
|
82
|
-
element.remove();
|
|
83
|
-
}
|
|
84
|
-
this.isCreatedBefor = false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
showInputErro(errors: any) {
|
|
88
|
-
// show error on top of form
|
|
89
|
-
this.showGlobalError();
|
|
90
|
-
// remove old error from server
|
|
91
|
-
this.removeElementsByClass('errortemplet');
|
|
92
|
-
// Looping in error Object
|
|
93
|
-
for (const key in errors) {
|
|
94
|
-
if (errors.hasOwnProperty(key)) {
|
|
95
|
-
for (const iterator of errors[key]) {
|
|
96
|
-
const input = document.querySelectorAll('[ng-reflect-name=' + key + ']')[0];
|
|
97
|
-
if ((input.attributes['ng-reflect-name'].value as string) === key) {
|
|
98
|
-
this.removeElementsByClass('erroclass-' + key);
|
|
99
|
-
const tagName = 'p'
|
|
100
|
-
const elementToAppend = document.createElement(tagName); // Your tag name here
|
|
101
|
-
elementToAppend.innerHTML = iterator;
|
|
102
|
-
elementToAppend.style.color = 'red'
|
|
103
|
-
elementToAppend.className += 'errortemplet erroclass-' + key;
|
|
104
|
-
const elementToappen = elementToAppend.cloneNode(true);
|
|
105
|
-
input.parentNode.insertBefore(elementToappen, input.lastChild);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
removeElementsByClass(className) {
|
|
114
|
-
const elements = document.getElementsByClassName(className);
|
|
115
|
-
while (elements.length > 0) {
|
|
116
|
-
elements[0].parentNode.removeChild(elements[0]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
renderServerErrors(form: FormGroup, err: HttpErrorResponse, requestOptions: RequestOptionsModel, formId?: string) {
|
|
121
|
-
if (err.error == null) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
let errorsArray: string[] = [];
|
|
125
|
-
|
|
126
|
-
this.requestOptions = requestOptions;
|
|
127
|
-
|
|
128
|
-
if (err.error.validation_errors) {
|
|
129
|
-
err.error.validation_errors.forEach((element: ErrorModel) => {
|
|
130
|
-
let fieldName = element.field;
|
|
131
|
-
let controlName = element.controlName;
|
|
132
|
-
let message = element.message;
|
|
133
|
-
if (form == null) {
|
|
134
|
-
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${message}`);
|
|
135
|
-
}
|
|
136
|
-
else if (controlName && !this.hasControlName(form, controlName)) {
|
|
137
|
-
errorsArray.push(`${fieldName}: ${message}`);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.setFieldError(form, controlName, fieldName, message);
|
|
141
|
-
this.showGlobalError(null, formId);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (errorsArray.length > 0)
|
|
146
|
-
this.showGlobalError(errorsArray, formId)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private hasControlName(form: FormGroup, controlName: string): boolean {
|
|
152
|
-
let control = form.get(controlName);
|
|
153
|
-
return control != null;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private setFieldError(form: FormGroup, controlName: string, fieldName: string, message: string) {
|
|
157
|
-
let control = null
|
|
158
|
-
|
|
159
|
-
if (controlName)
|
|
160
|
-
control = this.getControlFormNameByFieldName(form, controlName);
|
|
161
|
-
else
|
|
162
|
-
control = this.getControlFormNameByFieldName(form, fieldName.split('.')[0]);
|
|
163
|
-
|
|
164
|
-
let errors = { "errorMassage": message };
|
|
165
|
-
let fieldNameArray = fieldName.split('.');
|
|
166
|
-
if (fieldNameArray.length >= 1) {
|
|
167
|
-
switch (fieldNameArray[fieldNameArray.length - 1].toLocaleLowerCase()) {
|
|
168
|
-
case "english":
|
|
169
|
-
let englishControl = control.get("English")
|
|
170
|
-
englishControl.setErrors(errors);
|
|
171
|
-
break;
|
|
172
|
-
case "arabic":
|
|
173
|
-
let arabicControl = control.get("Arabic")
|
|
174
|
-
arabicControl.setErrors(errors);
|
|
175
|
-
break;
|
|
176
|
-
default:
|
|
177
|
-
control.setErrors(errors);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(`${message}`)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private getControlFormNameByFieldName(form: FormGroup, fieldName: string) {
|
|
186
|
-
const formControls = form.controls;
|
|
187
|
-
let controlName = Object.keys(formControls).find(c => c.toLocaleLowerCase() === fieldName.toLocaleLowerCase());
|
|
188
|
-
let control = form.get(controlName);
|
|
189
|
-
return control;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { environment } from '../config/environment';
|
|
3
|
-
import { AreaModel } from '../models/AreaModel';
|
|
4
|
-
|
|
5
|
-
@Injectable({
|
|
6
|
-
providedIn: 'root'
|
|
7
|
-
})
|
|
8
|
-
export class EnvironmentService {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static AreaList: AreaModel[] = []
|
|
12
|
-
|
|
13
|
-
getEnvironmentObject() {
|
|
14
|
-
return environment;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getBaseUrl() {
|
|
18
|
-
let Url = environment["BBSF_BaseURL"]
|
|
19
|
-
return Url;
|
|
20
|
-
}
|
|
21
|
-
getApiUrl() {
|
|
22
|
-
let Url = environment["BBSF_ApiUrl"]
|
|
23
|
-
return Url;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getProductionMode() {
|
|
27
|
-
let Mode = environment["BBSF_IsProduction"] as boolean
|
|
28
|
-
|
|
29
|
-
return Mode;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getDefaultLanguage() {
|
|
33
|
-
let Mode = environment["BBSF_DefaultLanguage"] as string
|
|
34
|
-
return Mode;
|
|
35
|
-
}
|
|
36
|
-
getIdentityServerUrl() {
|
|
37
|
-
let Url = environment["BBSF_IdentityServerUrl"]
|
|
38
|
-
return Url;
|
|
39
|
-
}
|
|
40
|
-
getIsIdentityServerExternal() {
|
|
41
|
-
let Mode = environment["BBSF_IsExternalIdentityServer"] as string
|
|
42
|
-
return Mode;
|
|
43
|
-
}
|
|
44
|
-
getIsIdentityServerClientId() {
|
|
45
|
-
let Mode = environment["BBSF_IdentityServer_Client_Id"] as string
|
|
46
|
-
return Mode;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getIsIdentityServerClientSecret() {
|
|
50
|
-
let Mode = environment["BBSF_IdentityServer_Client_Secret"] as string
|
|
51
|
-
return Mode;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { HttpParams } from '@angular/common/http';
|
|
2
|
-
import { Injectable } from '@angular/core';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
import { TranslateService } from '@ngx-translate/core';
|
|
5
|
-
import { AuthService } from '../authentication/auth.service';
|
|
6
|
-
import { EnvironmentService } from './environment.service';
|
|
7
|
-
import { RequestHandlerService } from './requesthandler.service';
|
|
8
|
-
import { StylesBundleService } from './stylesbundle.service';
|
|
9
|
-
|
|
10
|
-
@Injectable({
|
|
11
|
-
providedIn: 'root',
|
|
12
|
-
})
|
|
13
|
-
export class MasterLayoutService {
|
|
14
|
-
ApiUrl = '/api/Home/';
|
|
15
|
-
constructor(private router: Router, private http: RequestHandlerService, private authService: AuthService, private stylesBundleService: StylesBundleService, private translate: TranslateService, private environmentService: EnvironmentService) { }
|
|
16
|
-
|
|
17
|
-
switchLang(lang: string, bundleEnglishName: string, bundleArabicName: string) {
|
|
18
|
-
this.changeLanguage(lang).subscribe((result) => {
|
|
19
|
-
this.updateUserInfo().subscribe((Value) => {
|
|
20
|
-
let UserInfoObject = Value;
|
|
21
|
-
this.authService.getUser();
|
|
22
|
-
this.authService.user.profile = Object.assign(
|
|
23
|
-
this.authService.user.profile,
|
|
24
|
-
UserInfoObject
|
|
25
|
-
);
|
|
26
|
-
this.authService.storUser(this.authService.user);
|
|
27
|
-
this.stylesBundleService.loadThemes(
|
|
28
|
-
lang,
|
|
29
|
-
bundleEnglishName,
|
|
30
|
-
bundleArabicName
|
|
31
|
-
);
|
|
32
|
-
localStorage.setItem('language', lang);
|
|
33
|
-
this.translate.use(lang);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
reloadComponent() {
|
|
39
|
-
let currentUrl = this.router.url;
|
|
40
|
-
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
|
41
|
-
this.router.onSameUrlNavigation = 'reload';
|
|
42
|
-
this.router.navigate([currentUrl]);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private changeLanguage(key: string) {
|
|
46
|
-
let params = new HttpParams();
|
|
47
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
48
|
-
params = params.append('LanguageKey', key);
|
|
49
|
-
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getUserClaims() {
|
|
53
|
-
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
logError(error: string) {
|
|
57
|
-
let params = new HttpParams();
|
|
58
|
-
params = params.append('error', error);
|
|
59
|
-
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private updateUserInfo() {
|
|
63
|
-
let isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() == 'true';
|
|
64
|
-
if (isExternal)
|
|
65
|
-
return this.getUserClaims();
|
|
66
|
-
return this.http.get('/connect/userinfo');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
switchRole(permissionSetID: string) {
|
|
70
|
-
this.updateRole(permissionSetID).subscribe((result) => {
|
|
71
|
-
this.updateUserInfo().subscribe((Value) => {
|
|
72
|
-
let UserInfoObject = Value;
|
|
73
|
-
this.authService.getUser();
|
|
74
|
-
this.authService.user.profile = Object.assign(
|
|
75
|
-
this.authService.user.profile,
|
|
76
|
-
UserInfoObject
|
|
77
|
-
);
|
|
78
|
-
this.authService.storUser(this.authService.user);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private updateRole(permissionSetID: string) {
|
|
84
|
-
let params = new HttpParams();
|
|
85
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
86
|
-
params = params.append('RoleID', permissionSetID);
|
|
87
|
-
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
88
|
-
}
|
|
89
|
-
}
|