@bnsights/bbsf-utilities 1.0.34 → 1.0.36

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.
Files changed (172) hide show
  1. package/README.md +8 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +10 -0
  4. package/package.json +20 -28
  5. package/src/lib/bbsf-utilities.module.ts +52 -0
  6. package/src/lib/shared/authentication/auth.service.ts +242 -0
  7. package/src/lib/shared/config/environment.ts +16 -0
  8. package/src/lib/shared/config/word/constants.js +133 -0
  9. package/src/lib/shared/config/word/docx-document.js +482 -0
  10. package/src/lib/shared/config/word/helpers/index.js +3 -0
  11. package/src/lib/shared/config/word/helpers/render-document-file.js +334 -0
  12. package/src/lib/shared/config/word/helpers/xml-builder.js +2165 -0
  13. package/src/lib/shared/config/word/html-to-docx.js +259 -0
  14. package/src/lib/shared/config/word/index.js +63 -0
  15. package/src/lib/shared/config/word/namespaces.js +40 -0
  16. package/src/lib/shared/config/word/schemas/content-types.js +26 -0
  17. package/src/lib/shared/config/word/schemas/core.js +44 -0
  18. package/src/lib/shared/config/word/schemas/document-rels.js +17 -0
  19. package/src/lib/shared/config/word/schemas/document.template.js +119 -0
  20. package/src/lib/shared/config/word/schemas/font-table.js +41 -0
  21. package/src/lib/shared/config/word/schemas/generic-rels.js +11 -0
  22. package/src/lib/shared/config/word/schemas/index.js +12 -0
  23. package/src/lib/shared/config/word/schemas/numbering.js +18 -0
  24. package/src/lib/shared/config/word/schemas/rels.js +12 -0
  25. package/src/lib/shared/config/word/schemas/settings.js +14 -0
  26. package/src/lib/shared/config/word/schemas/styles.js +152 -0
  27. package/src/lib/shared/config/word/schemas/theme.js +199 -0
  28. package/src/lib/shared/config/word/schemas/web-settings.js +10 -0
  29. package/src/lib/shared/config/word/utils/color-conversion.js +60 -0
  30. package/src/lib/shared/config/word/utils/list.js +55 -0
  31. package/src/lib/shared/config/word/utils/unit-conversion.js +53 -0
  32. package/src/lib/shared/config/word/utils/url.js +8 -0
  33. package/src/lib/shared/config/word/utils/vnode.js +3 -0
  34. package/src/lib/shared/config/word/word-work/assets/contentTypesXml.ts +1 -0
  35. package/src/lib/shared/config/word/word-work/assets/documentXmlRels.ts +1 -0
  36. package/src/lib/shared/config/word/word-work/assets/index.ts +3 -0
  37. package/src/lib/shared/config/word/word-work/assets/relsXml.ts +1 -0
  38. package/src/lib/shared/config/word/word-work/index.ts +8 -0
  39. package/src/lib/shared/config/word/word-work/internal.ts +69 -0
  40. package/src/lib/shared/config/word/word-work/templates/documentTemplate.ts +58 -0
  41. package/src/lib/shared/config/word/word-work/templates/index.ts +3 -0
  42. package/src/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.ts +21 -0
  43. package/src/lib/shared/config/word/word-work/templates/mhtPartTemplate.ts +14 -0
  44. package/src/lib/shared/config/word/word-work/utils.ts +27 -0
  45. package/src/lib/shared/models/AreaModel.ts +5 -0
  46. package/{lib/shared/models/ErrorModel.d.ts → src/lib/shared/models/ErrorModel.ts} +5 -2
  47. package/src/lib/shared/models/RequestOptionsModel.ts +13 -0
  48. package/src/lib/shared/models/WordDocumentModel.ts +19 -0
  49. package/src/lib/shared/services/AppearanceConfiguration.service.ts +30 -0
  50. package/src/lib/shared/services/configuration.service.ts +18 -0
  51. package/src/lib/shared/services/controlvalidation.service.ts +194 -0
  52. package/src/lib/shared/services/environment.service.ts +56 -0
  53. package/src/lib/shared/services/masterlayout.service.ts +89 -0
  54. package/src/lib/shared/services/requesthandler.service.ts +241 -0
  55. package/src/lib/shared/services/stylesbundle.service.ts +52 -0
  56. package/src/lib/shared/services/translate.service.ts +8 -0
  57. package/src/lib/shared/services/translationresolver.service.ts +16 -0
  58. package/src/lib/shared/services/utility.service.ts +94 -0
  59. package/src/lib/shared/services/word-document.service.ts +36 -0
  60. package/src/public-api.ts +27 -0
  61. package/src/test.ts +26 -0
  62. package/tsconfig.lib.json +39 -0
  63. package/tsconfig.lib.prod.json +11 -0
  64. package/tsconfig.spec.json +17 -0
  65. package/tslint.json +17 -0
  66. package/bnsights-bbsf-utilities-1.0.34.tgz +0 -0
  67. package/bnsights-bbsf-utilities.d.ts +0 -4
  68. package/bnsights-bbsf-utilities.metadata.json +0 -1
  69. package/bundles/bnsights-bbsf-utilities.umd.js +0 -4865
  70. package/bundles/bnsights-bbsf-utilities.umd.js.map +0 -1
  71. package/esm2015/bnsights-bbsf-utilities.js +0 -5
  72. package/esm2015/lib/bbsf-utilities.module.js +0 -52
  73. package/esm2015/lib/shared/authentication/auth.service.js +0 -236
  74. package/esm2015/lib/shared/config/environment.js +0 -12
  75. package/esm2015/lib/shared/config/word/constants.js +0 -105
  76. package/esm2015/lib/shared/config/word/docx-document.js +0 -351
  77. package/esm2015/lib/shared/config/word/helpers/index.js +0 -4
  78. package/esm2015/lib/shared/config/word/helpers/render-document-file.js +0 -278
  79. package/esm2015/lib/shared/config/word/helpers/xml-builder.js +0 -1765
  80. package/esm2015/lib/shared/config/word/html-to-docx.js +0 -195
  81. package/esm2015/lib/shared/config/word/index.js +0 -55
  82. package/esm2015/lib/shared/config/word/namespaces.js +0 -37
  83. package/esm2015/lib/shared/config/word/schemas/content-types.js +0 -26
  84. package/esm2015/lib/shared/config/word/schemas/core.js +0 -29
  85. package/esm2015/lib/shared/config/word/schemas/document-rels.js +0 -16
  86. package/esm2015/lib/shared/config/word/schemas/document.template.js +0 -109
  87. package/esm2015/lib/shared/config/word/schemas/font-table.js +0 -40
  88. package/esm2015/lib/shared/config/word/schemas/generic-rels.js +0 -11
  89. package/esm2015/lib/shared/config/word/schemas/index.js +0 -13
  90. package/esm2015/lib/shared/config/word/schemas/numbering.js +0 -19
  91. package/esm2015/lib/shared/config/word/schemas/rels.js +0 -11
  92. package/esm2015/lib/shared/config/word/schemas/settings.js +0 -13
  93. package/esm2015/lib/shared/config/word/schemas/styles.js +0 -149
  94. package/esm2015/lib/shared/config/word/schemas/theme.js +0 -200
  95. package/esm2015/lib/shared/config/word/schemas/web-settings.js +0 -9
  96. package/esm2015/lib/shared/config/word/utils/color-conversion.js +0 -60
  97. package/esm2015/lib/shared/config/word/utils/list.js +0 -51
  98. package/esm2015/lib/shared/config/word/utils/unit-conversion.js +0 -30
  99. package/esm2015/lib/shared/config/word/utils/url.js +0 -9
  100. package/esm2015/lib/shared/config/word/utils/vnode.js +0 -3
  101. package/esm2015/lib/shared/config/word/word-work/templates/documentTemplate.js +0 -54
  102. package/esm2015/lib/shared/config/word/word-work/templates/index.js +0 -4
  103. package/esm2015/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.js +0 -22
  104. package/esm2015/lib/shared/config/word/word-work/templates/mhtPartTemplate.js +0 -10
  105. package/esm2015/lib/shared/config/word/word-work/utils.js +0 -26
  106. package/esm2015/lib/shared/models/AreaModel.js +0 -3
  107. package/esm2015/lib/shared/models/ErrorModel.js +0 -3
  108. package/esm2015/lib/shared/models/RequestOptionsModel.js +0 -11
  109. package/esm2015/lib/shared/models/WordDocumentModel.js +0 -8
  110. package/esm2015/lib/shared/services/AppearanceConfiguration.service.js +0 -37
  111. package/esm2015/lib/shared/services/configuration.service.js +0 -26
  112. package/esm2015/lib/shared/services/controlvalidation.service.js +0 -168
  113. package/esm2015/lib/shared/services/environment.service.js +0 -48
  114. package/esm2015/lib/shared/services/masterlayout.service.js +0 -96
  115. package/esm2015/lib/shared/services/requesthandler.service.js +0 -206
  116. package/esm2015/lib/shared/services/stylesbundle.service.js +0 -56
  117. package/esm2015/lib/shared/services/translate.service.js +0 -13
  118. package/esm2015/lib/shared/services/translationresolver.service.js +0 -20
  119. package/esm2015/lib/shared/services/utility.service.js +0 -96
  120. package/esm2015/lib/shared/services/word-document.service.js +0 -39
  121. package/esm2015/public-api.js +0 -20
  122. package/fesm2015/bnsights-bbsf-utilities.js +0 -4634
  123. package/fesm2015/bnsights-bbsf-utilities.js.map +0 -1
  124. package/lib/bbsf-utilities.module.d.ts +0 -6
  125. package/lib/shared/authentication/auth.service.d.ts +0 -41
  126. package/lib/shared/config/environment.d.ts +0 -1
  127. package/lib/shared/config/word/constants.d.ts +0 -124
  128. package/lib/shared/config/word/docx-document.d.ts +0 -73
  129. package/lib/shared/config/word/helpers/index.d.ts +0 -1
  130. package/lib/shared/config/word/helpers/render-document-file.d.ts +0 -4
  131. package/lib/shared/config/word/helpers/xml-builder.d.ts +0 -14
  132. package/lib/shared/config/word/html-to-docx.d.ts +0 -1
  133. package/lib/shared/config/word/index.d.ts +0 -1
  134. package/lib/shared/config/word/namespaces.d.ts +0 -36
  135. package/lib/shared/config/word/schemas/content-types.d.ts +0 -1
  136. package/lib/shared/config/word/schemas/core.d.ts +0 -1
  137. package/lib/shared/config/word/schemas/document-rels.d.ts +0 -1
  138. package/lib/shared/config/word/schemas/document.template.d.ts +0 -4
  139. package/lib/shared/config/word/schemas/font-table.d.ts +0 -1
  140. package/lib/shared/config/word/schemas/generic-rels.d.ts +0 -1
  141. package/lib/shared/config/word/schemas/index.d.ts +0 -12
  142. package/lib/shared/config/word/schemas/numbering.d.ts +0 -1
  143. package/lib/shared/config/word/schemas/rels.d.ts +0 -1
  144. package/lib/shared/config/word/schemas/settings.d.ts +0 -1
  145. package/lib/shared/config/word/schemas/styles.d.ts +0 -1
  146. package/lib/shared/config/word/schemas/theme.d.ts +0 -1
  147. package/lib/shared/config/word/schemas/web-settings.d.ts +0 -1
  148. package/lib/shared/config/word/utils/color-conversion.d.ts +0 -7
  149. package/lib/shared/config/word/utils/list.d.ts +0 -6
  150. package/lib/shared/config/word/utils/unit-conversion.d.ts +0 -29
  151. package/lib/shared/config/word/utils/url.d.ts +0 -1
  152. package/lib/shared/config/word/utils/vnode.d.ts +0 -1
  153. package/lib/shared/config/word/word-work/templates/documentTemplate.d.ts +0 -12
  154. package/lib/shared/config/word/word-work/templates/index.d.ts +0 -3
  155. package/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.d.ts +0 -1
  156. package/lib/shared/config/word/word-work/templates/mhtPartTemplate.d.ts +0 -1
  157. package/lib/shared/config/word/word-work/utils.d.ts +0 -1
  158. package/lib/shared/models/AreaModel.d.ts +0 -4
  159. package/lib/shared/models/RequestOptionsModel.d.ts +0 -11
  160. package/lib/shared/models/WordDocumentModel.d.ts +0 -16
  161. package/lib/shared/services/AppearanceConfiguration.service.d.ts +0 -11
  162. package/lib/shared/services/configuration.service.d.ts +0 -7
  163. package/lib/shared/services/controlvalidation.service.d.ts +0 -19
  164. package/lib/shared/services/environment.service.d.ts +0 -13
  165. package/lib/shared/services/masterlayout.service.d.ts +0 -24
  166. package/lib/shared/services/requesthandler.service.d.ts +0 -32
  167. package/lib/shared/services/stylesbundle.service.d.ts +0 -9
  168. package/lib/shared/services/translate.service.d.ts +0 -3
  169. package/lib/shared/services/translationresolver.service.d.ts +0 -8
  170. package/lib/shared/services/utility.service.d.ts +0 -21
  171. package/lib/shared/services/word-document.service.d.ts +0 -5
  172. package/public-api.d.ts +0 -16
package/README.md CHANGED
@@ -5,6 +5,14 @@ BBSF Utilities package is part of BBSF 3 packages. It has all the common service
5
5
  For more info please visit [BBSF Controls documenation](https://bbsfadmin.bnsights.com/controls) or [BBSF documentation](https://bnsightsprojects.visualstudio.com/BBSF%203/_wiki/wikis/BBSF-3.wiki/65/BBSF-Documentation)
6
6
 
7
7
  # Change Log
8
+ ## 1.0.36 / 19-7-2023
9
+ ===================
10
+ * Update Control Validation Service
11
+
12
+ ## 1.0.35 / 27-3-2022
13
+ ===================
14
+ * Add Word Document Service
15
+ * Update Angular Version
8
16
 
9
17
  ## 1.0.34 / 26-3-2022 (!!!Warning!! Testing Release)
10
18
  ===================
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/@bnsights/bbsf-utilities'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/bbsf-utilities",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": [
8
+ "."
9
+ ]
10
+ }
package/package.json CHANGED
@@ -1,28 +1,20 @@
1
- {
2
- "name": "@bnsights/bbsf-utilities",
3
- "version": "1.0.34",
4
- "peerDependencies": {
5
- "@angular/common": "^11.2.14",
6
- "@angular/core": "^11.2.14"
7
- },
8
- "dependencies": {
9
- "@angular/http": "^7.2.16",
10
- "@ngx-translate/core": "^13.0.0",
11
- "@ngx-translate/http-loader": "^6.0.0",
12
- "class-transformer": "^0.5.1",
13
- "ng-block-ui": "^3.0.2",
14
- "ngx-toastr": "^13.2.0",
15
- "oidc-client": "^1.11.5",
16
- "reflect-metadata": "^0.1.13",
17
- "tslib": "^2.0.0",
18
- "ng-pick-datetime": "^7.0.0"
19
- },
20
- "main": "bundles/bnsights-bbsf-utilities.umd.js",
21
- "module": "fesm2015/bnsights-bbsf-utilities.js",
22
- "es2015": "fesm2015/bnsights-bbsf-utilities.js",
23
- "esm2015": "esm2015/bnsights-bbsf-utilities.js",
24
- "fesm2015": "fesm2015/bnsights-bbsf-utilities.js",
25
- "typings": "bnsights-bbsf-utilities.d.ts",
26
- "metadata": "bnsights-bbsf-utilities.metadata.json",
27
- "sideEffects": false
28
- }
1
+ {
2
+ "name": "@bnsights/bbsf-utilities",
3
+ "version": "1.0.36",
4
+ "peerDependencies": {
5
+ "@angular/common": "~12.2.12",
6
+ "@angular/core": "~12.2.12"
7
+ },
8
+ "dependencies": {
9
+ "@angular/http": "^7.2.16",
10
+ "@ngx-translate/core": "^13.0.0",
11
+ "@ngx-translate/http-loader": "^6.0.0",
12
+ "class-transformer": "^0.5.1",
13
+ "ng-block-ui": "^3.0.2",
14
+ "ngx-toastr": "^13.2.0",
15
+ "oidc-client": "^1.11.5",
16
+ "reflect-metadata": "^0.1.13",
17
+ "tslib": "^2.0.0",
18
+ "ng-pick-datetime": "^7.0.0"
19
+ }
20
+ }
@@ -0,0 +1,52 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { Injector, NgModule } from '@angular/core';
4
+ import { RouterModule } from '@angular/router';
5
+ import { TranslateService } from '@ngx-translate/core';
6
+ import { BlockUIModule } from 'ng-block-ui';
7
+ import { ToastrModule } from 'ngx-toastr';
8
+ import { HttpModule } from '@angular/http';
9
+ import { UtilityService } from './shared/services/utility.service';
10
+ import { EnvironmentService } from './shared/services/environment.service';
11
+ import { AuthService } from './shared/authentication/auth.service';
12
+ import { RequestHandlerService } from './shared/services/requesthandler.service';
13
+ import { StylesBundleService } from './shared/services/stylesbundle.service';
14
+ import { BBSFTranslateService } from './shared/services/translate.service';
15
+ import { ControlValidationService } from './shared/services/controlvalidation.service';
16
+ import { MasterLayoutService } from './shared/services/masterlayout.service';
17
+ import { ConfigurationService } from './shared/services/configuration.service';
18
+
19
+ export let AppInjector: Injector;
20
+
21
+ @NgModule({
22
+ declarations: [
23
+ ],
24
+ imports: [
25
+ CommonModule,
26
+ BlockUIModule.forRoot(),
27
+ HttpModule,
28
+ RouterModule,
29
+ ToastrModule.forRoot(),
30
+
31
+ ],
32
+ exports: [
33
+ ],
34
+ providers: [
35
+ UtilityService,
36
+ EnvironmentService,
37
+ AuthService,
38
+ RequestHandlerService,
39
+ StylesBundleService,
40
+ TranslateService,
41
+ BBSFTranslateService,
42
+ ControlValidationService,
43
+ MasterLayoutService,
44
+ ConfigurationService
45
+ ]
46
+ })
47
+ export class BBSFUtilitiesModule {
48
+ constructor(private injector: Injector) {
49
+ AppInjector = this.injector;
50
+
51
+ }
52
+ }
@@ -0,0 +1,242 @@
1
+ import { Injectable, Injector } from '@angular/core';
2
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
3
+ import { UserManager, User, WebStorageStateStore } from 'oidc-client';
4
+ import { BehaviorSubject, Subject } from 'rxjs';
5
+ import { EnvironmentService } from '../services/environment.service';
6
+ import { BBSFTranslateService } from '../services/translate.service';
7
+ import { Router } from '@angular/router';
8
+ import { MasterLayoutService } from '../services/masterlayout.service';
9
+
10
+ @Injectable({
11
+ providedIn: 'root',
12
+ })
13
+ export class AuthService {
14
+ // Observable navItem source
15
+ private _authNavStatusSource = new BehaviorSubject<boolean>(false);
16
+ // Observable navItem stream
17
+ authNavStatus$ = this._authNavStatusSource.asObservable();
18
+ // Observable navItem source
19
+ private _userSource: Subject<User> = new Subject<User>();
20
+ UserStatus$ = this._userSource.asObservable();
21
+ private manager = this.getUserManager();
22
+ public redirectUrl: string = '';
23
+ static user: User | null = null;
24
+ user: User | null;
25
+ static UserClaims: any = null;
26
+
27
+ constructor(private injector: Injector, private http: HttpClient, private environmentService: EnvironmentService, private translateService: BBSFTranslateService, private router: Router) {
28
+
29
+ this.manager.getUser().then(async (user) => {
30
+ this.manager.storeUser(user);
31
+ AuthService.user = user;
32
+ this.user = user;
33
+ this._authNavStatusSource.next(await this.isAuthenticated());
34
+ });
35
+
36
+ this.manager.events.addAccessTokenExpired((_) => {
37
+ this._authNavStatusSource.next(false);
38
+ });
39
+ }
40
+
41
+ getUserManager() {
42
+ let user = null;
43
+ let isExternal =
44
+ this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
45
+ 'true';
46
+ if (isExternal) {
47
+ user = new UserManager({
48
+ authority: this.environmentService.getIdentityServerUrl(),
49
+ client_id: this.environmentService.getIsIdentityServerClientId(),
50
+ client_secret:
51
+ this.environmentService.getIsIdentityServerClientSecret(),
52
+ redirect_uri:
53
+ this.environmentService.getBaseUrl() +
54
+ '/Admin/authentication/auth-callback',
55
+ post_logout_redirect_uri: this.environmentService.getBaseUrl(),
56
+ response_type: 'code',
57
+ scope: 'openid profile email',
58
+ filterProtocolClaims: true,
59
+ loadUserInfo: true,
60
+ automaticSilentRenew: true,
61
+ silent_redirect_uri:
62
+ this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
63
+ userStore: new WebStorageStateStore({ store: window.localStorage }),
64
+ });
65
+ } else {
66
+ user = new UserManager({
67
+ authority: this.environmentService.getIdentityServerUrl(),
68
+ client_id: 'angular_spa',
69
+ redirect_uri:
70
+ this.environmentService.getBaseUrl() +
71
+ '/Admin/authentication/auth-callback',
72
+ post_logout_redirect_uri: this.environmentService.getBaseUrl(),
73
+ response_type: 'id_token token',
74
+ scope: 'openid profile email IdentityServerApi',
75
+ filterProtocolClaims: true,
76
+ loadUserInfo: true,
77
+ automaticSilentRenew: true,
78
+ silent_redirect_uri:
79
+ this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
80
+ userStore: new WebStorageStateStore({ store: window.localStorage }),
81
+ });
82
+ }
83
+ return user;
84
+ }
85
+
86
+ login() {
87
+ return this.manager.signinRedirect();
88
+ }
89
+
90
+ getUser() {
91
+ this.manager.getUser().then(async (user) => {
92
+ AuthService.user = user;
93
+ this.user = user;
94
+ this._authNavStatusSource.next(await this.isAuthenticated());
95
+ });
96
+ }
97
+ storUser(User: any) {
98
+ this.manager.storeUser(User);
99
+ }
100
+
101
+ revokeAccessToken() {
102
+ this.manager.revokeAccessToken();
103
+ }
104
+
105
+ signinSilent() {
106
+ let x = this.manager.signinSilentCallback();
107
+ x.then((s) => {
108
+ //console.log(s)
109
+ });
110
+ }
111
+
112
+ async completeAuthentication() {
113
+ this.user = await this.manager.signinRedirectCallback();
114
+ AuthService.user = this.user;
115
+ this._userSource.next(AuthService.user);
116
+ this._authNavStatusSource.next(await this.isAuthenticated());
117
+ let isExternal =
118
+ this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
119
+ 'true';
120
+ if (isExternal) {
121
+ const masterLayoutService = this.injector.get(MasterLayoutService);
122
+
123
+ let userClaims = await masterLayoutService.getUserClaims().toPromise()
124
+ .then((e) => {
125
+ AuthService.UserClaims = e;
126
+ }, (error) => {
127
+ console.log(error)
128
+ });
129
+
130
+ AuthService.user.profile = Object.assign(
131
+ AuthService.user.profile,
132
+ AuthService.UserClaims
133
+ );
134
+ }
135
+
136
+ this.storUser(AuthService.user);
137
+ if (
138
+ !localStorage.getItem('language') ||
139
+ localStorage.getItem('language') == this.user.profile.locale
140
+ )
141
+ localStorage.setItem('language', this.user.profile.locale);
142
+
143
+ if (this.translateService.currentLang != localStorage.getItem('language')) {
144
+ this.translateService.resetLang(this.translateService.currentLang);
145
+ await this.translateService
146
+ .reloadLang(localStorage.getItem('language'))
147
+ .subscribe((res) => {
148
+ console.log(res);
149
+ });
150
+ }
151
+ this._userSource.next(AuthService.user);
152
+ this._authNavStatusSource.next(await this.isAuthenticated());
153
+ this.user = AuthService.user;
154
+ }
155
+
156
+ async refreshToken(token) {
157
+ const httpOptions = {
158
+ headers: new HttpHeaders({
159
+ 'Content-Type': 'application/json',
160
+ Authorization: token,
161
+ }),
162
+ };
163
+
164
+ this.manager.revokeAccessToken();
165
+ return await this.http
166
+ .post<any>(
167
+ `${this.environmentService.getIdentityServerUrl()}/users/refresh-token`,
168
+ httpOptions,
169
+ { withCredentials: true }
170
+ )
171
+ .subscribe((user) => {
172
+ this._userSource.next(user);
173
+ AuthService.user = user;
174
+ this.user = user;
175
+ });
176
+ }
177
+
178
+ getCurrentUser() {
179
+ return this.manager.getUser();
180
+ }
181
+
182
+ async isAuthenticated(): Promise<boolean> {
183
+ let user = await this.manager.getUser().then((user) => {
184
+ return user;
185
+ });
186
+ return this.user != null && !this.user.expired;
187
+ }
188
+ isUserInRole(allowedPermission: number[]) {
189
+ let selectedPermissionSetID: number = Number.parseInt(
190
+ this.user.profile['selectedpermissionsetid']
191
+ );
192
+ return allowedPermission.includes(selectedPermissionSetID);
193
+ }
194
+
195
+ authorizationHeaderValue(): string {
196
+ return AuthService.user
197
+ ? `${AuthService.user.token_type} ${AuthService.user.access_token}`
198
+ : '';
199
+ }
200
+
201
+ name(): string {
202
+ return AuthService.user != null ? AuthService.user.profile.given_name : '';
203
+ }
204
+ setUrl(url) {
205
+ localStorage.setItem('redirectUrl', url);
206
+ }
207
+ getUrl() {
208
+ return localStorage.getItem('redirectUrl');
209
+ }
210
+ async signinSilentCallback() {
211
+ let user = await this.manager.signinSilentCallback();
212
+ //await this.manager.storeUser(user);
213
+ AuthService.user = user;
214
+ console.log('Token from signinSilentCallback :' + AuthService.user);
215
+ this.user = user;
216
+ }
217
+ async signout() {
218
+ if (await !this.isAuthenticated())
219
+ this.router.navigate(['/Admin/account/login']), localStorage.clear();
220
+ let isExternal =
221
+ this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
222
+ 'true';
223
+ if (isExternal) {
224
+ await this.clearUserSessionClaims()
225
+ .toPromise()
226
+ .then((res) => {
227
+ let result = res;
228
+ });
229
+ }
230
+ await this.manager.signoutRedirect();
231
+ }
232
+
233
+ clearUserSessionClaims() {
234
+ const httpOptions = {
235
+ headers: new HttpHeaders({
236
+ 'Content-Type': 'application/json',
237
+ }),
238
+ };
239
+ let ApiUrl = '/api/Home/';
240
+ return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
241
+ }
242
+ }
@@ -0,0 +1,16 @@
1
+ // This file can be replaced during build by using the `fileReplacements` array.
2
+ // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3
+ // The list of file replacements can be found in `angular.json`.
4
+
5
+ export const environment = Object.assign({
6
+ },
7
+ (window as any).Environment);
8
+
9
+
10
+ /*
11
+ * In development mode, to ignore zone related error stack frames such as
12
+ * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
13
+ * import the following file, but please comment it out in production mode
14
+ * because it will have performance impact when throw error
15
+ */
16
+ // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
@@ -0,0 +1,133 @@
1
+ import { cloneDeep } from 'lodash';
2
+
3
+ const applicationName = 'html-to-docx';
4
+ const defaultOrientation = 'portrait';
5
+ const landscapeWidth = 15840;
6
+ const landscapeHeight = 12240;
7
+ const landscapeMargins = {
8
+ top: 1800,
9
+ right: 1440,
10
+ bottom: 1800,
11
+ left: 1440,
12
+ header: 720,
13
+ footer: 720,
14
+ gutter: 0,
15
+ };
16
+ const portraitMargins = {
17
+ top: 1440,
18
+ right: 1800,
19
+ bottom: 1440,
20
+ left: 1800,
21
+ header: 720,
22
+ footer: 720,
23
+ gutter: 0,
24
+ };
25
+ const defaultFont = 'Times New Roman';
26
+ const defaultFontSize = 22;
27
+ const defaultDocumentOptions = {
28
+ orientation: defaultOrientation,
29
+ margins: cloneDeep(portraitMargins),
30
+ title: '',
31
+ subject: '',
32
+ creator: applicationName,
33
+ keywords: [applicationName],
34
+ description: '',
35
+ lastModifiedBy: applicationName,
36
+ revision: 1,
37
+ createdAt: new Date(),
38
+ modifiedAt: new Date(),
39
+ headerType: 'default',
40
+ header: false,
41
+ footerType: 'default',
42
+ footer: false,
43
+ font: defaultFont,
44
+ fontSize: defaultFontSize,
45
+ complexScriptFontSize: defaultFontSize,
46
+ table: {
47
+ row: {
48
+ cantSplit: false,
49
+ },
50
+ },
51
+ pageSize: {
52
+ width: landscapeHeight,
53
+ height: landscapeWidth,
54
+ },
55
+ pageNumber: false,
56
+ skipFirstHeaderFooter: false,
57
+ lineNumber: false,
58
+ lineNumberOptions: {
59
+ countBy: 1,
60
+ start: 0,
61
+ restart: 'continuous',
62
+ },
63
+ numbering: {
64
+ defaultOrderedListStyleType: 'decimal',
65
+ },
66
+ };
67
+ const defaultHTMLString = '<p></p>';
68
+ const relsFolderName = '_rels';
69
+ const headerFileName = 'header1';
70
+ const footerFileName = 'footer1';
71
+ const themeFileName = 'theme1';
72
+ const documentFileName = 'document';
73
+ const headerType = 'header';
74
+ const footerType = 'footer';
75
+ const themeType = 'theme';
76
+ const hyperlinkType = 'hyperlink';
77
+ const imageType = 'image';
78
+ const internalRelationship = 'Internal';
79
+ const wordFolder = 'word';
80
+ const themeFolder = 'theme';
81
+ const paragraphBordersObject = {
82
+ top: {
83
+ size: 0,
84
+ spacing: 3,
85
+ color: 'FFFFFF',
86
+ },
87
+ left: {
88
+ size: 0,
89
+ spacing: 3,
90
+ color: 'FFFFFF',
91
+ },
92
+ bottom: {
93
+ size: 0,
94
+ spacing: 3,
95
+ color: 'FFFFFF',
96
+ },
97
+ right: {
98
+ size: 0,
99
+ spacing: 3,
100
+ color: 'FFFFFF',
101
+ },
102
+ };
103
+ const colorlessColors = ['transparent', 'auto'];
104
+ const verticalAlignValues = ['top', 'middle', 'bottom'];
105
+
106
+ export {
107
+ defaultDocumentOptions,
108
+ defaultHTMLString,
109
+ relsFolderName,
110
+ headerFileName,
111
+ footerFileName,
112
+ themeFileName,
113
+ documentFileName,
114
+ headerType,
115
+ footerType,
116
+ themeType,
117
+ internalRelationship,
118
+ wordFolder,
119
+ themeFolder,
120
+ landscapeMargins,
121
+ portraitMargins,
122
+ defaultOrientation,
123
+ landscapeWidth,
124
+ landscapeHeight,
125
+ applicationName,
126
+ defaultFont,
127
+ defaultFontSize,
128
+ hyperlinkType,
129
+ imageType,
130
+ paragraphBordersObject,
131
+ colorlessColors,
132
+ verticalAlignValues,
133
+ };