cmat 0.0.110 → 0.0.112
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/fesm2022/cmat-components-adapter.mjs +531 -536
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +150 -42
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +1120 -629
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +861 -441
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +580 -335
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +197 -105
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +1762 -825
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-date-range.mjs +701 -456
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +137 -30
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +410 -258
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +201 -41
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +198 -35
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +102 -26
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +167 -47
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +203 -112
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +489 -215
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +117 -27
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +276 -230
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +615 -420
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
- package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +120 -40
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +3080 -1404
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +540 -466
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +528 -125
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +141 -32
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +866 -534
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +873 -434
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +1012 -731
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +98 -35
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +463 -287
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +377 -203
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +926 -496
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +1280 -842
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +998 -690
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +143 -57
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +457 -303
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +136 -44
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +464 -168
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +346 -262
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +372 -112
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +904 -410
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
- package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +43 -25
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +162 -76
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +457 -356
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +207 -195
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +50 -30
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +41 -25
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +50 -38
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +44 -31
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +60 -49
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-reports.mjs +2751 -0
- package/fesm2022/cmat-reports.mjs.map +1 -0
- package/fesm2022/cmat-services-alert.mjs +249 -277
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +110 -81
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +184 -73
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +136 -125
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +165 -183
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +116 -95
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +75 -66
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +69 -64
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +48 -45
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-print.mjs +985 -669
- package/fesm2022/cmat-services-print.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +53 -38
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +57 -47
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +79 -68
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +424 -517
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat-validators.mjs +23 -33
- package/fesm2022/cmat-validators.mjs.map +1 -1
- package/fesm2022/cmat-version.mjs +12 -16
- package/fesm2022/cmat-version.mjs.map +1 -1
- package/fesm2022/cmat.mjs +39806 -22071
- package/fesm2022/cmat.mjs.map +1 -1
- package/package.json +5 -1
- package/types/cmat-components-adapter.d.ts +145 -156
- package/types/cmat-components-breadcrumb.d.ts +108 -86
- package/types/cmat-components-card.d.ts +34 -18
- package/types/cmat-components-carousel.d.ts +251 -134
- package/types/cmat-components-cascade.d.ts +158 -117
- package/types/cmat-components-chip-input.d.ts +105 -71
- package/types/cmat-components-code-editor.d.ts +59 -34
- package/types/cmat-components-color-picker.d.ts +378 -236
- package/types/cmat-components-custom-formly.d.ts +776 -814
- package/types/cmat-components-data-picker.d.ts +502 -360
- package/types/cmat-components-date-range.d.ts +106 -77
- package/types/cmat-components-date-time-display.d.ts +36 -13
- package/types/cmat-components-drawer.d.ts +91 -61
- package/types/cmat-components-empty-state.d.ts +47 -17
- package/types/cmat-components-file-preview.d.ts +42 -14
- package/types/cmat-components-filter-toolbar.d.ts +57 -25
- package/types/cmat-components-form-actions.d.ts +18 -10
- package/types/cmat-components-fullscreen.d.ts +21 -13
- package/types/cmat-components-highlight.d.ts +33 -26
- package/types/cmat-components-image-viewer.d.ts +119 -58
- package/types/cmat-components-inline-loading.d.ts +24 -11
- package/types/cmat-components-json-editor.d.ts +39 -28
- package/types/cmat-components-knob-input.d.ts +172 -101
- package/types/cmat-components-loading-overlay.d.ts +8 -11
- package/types/cmat-components-masonry.d.ts +27 -14
- package/types/cmat-components-material-color-picker.d.ts +56 -42
- package/types/cmat-components-material-datetimepicker.d.ts +817 -454
- package/types/cmat-components-navigation.d.ts +295 -221
- package/types/cmat-components-opt-input.d.ts +111 -90
- package/types/cmat-components-org-chart.d.ts +53 -35
- package/types/cmat-components-page-header.d.ts +37 -14
- package/types/cmat-components-pagination.d.ts +144 -107
- package/types/cmat-components-password-strength.d.ts +197 -86
- package/types/cmat-components-popover.d.ts +264 -166
- package/types/cmat-components-progress-bar.d.ts +17 -14
- package/types/cmat-components-qrcode.d.ts +111 -42
- package/types/cmat-components-rating.d.ts +105 -59
- package/types/cmat-components-rich-text-editor.d.ts +39 -16
- package/types/cmat-components-select-search.d.ts +195 -99
- package/types/cmat-components-select-table.d.ts +241 -142
- package/types/cmat-components-select-tree.d.ts +185 -118
- package/types/cmat-components-skeleton.d.ts +55 -32
- package/types/cmat-components-speed-dial.d.ts +86 -61
- package/types/cmat-components-status-tag.d.ts +42 -24
- package/types/cmat-components-table-toolbar.d.ts +30 -12
- package/types/cmat-components-timeline.d.ts +83 -51
- package/types/cmat-components-toast.d.ts +84 -85
- package/types/cmat-components-transfer-picker.d.ts +228 -181
- package/types/cmat-components-treetable.d.ts +63 -39
- package/types/cmat-components-upload.d.ts +205 -106
- package/types/cmat-components-x6-angular-shape.d.ts +29 -37
- package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
- package/types/cmat-directives-arrow-cursor.d.ts +55 -35
- package/types/cmat-directives-autofocus.d.ts +8 -11
- package/types/cmat-directives-data-exporter.d.ts +71 -40
- package/types/cmat-directives-debounce.d.ts +31 -28
- package/types/cmat-directives-digit-only.d.ts +90 -53
- package/types/cmat-directives-equal-validator.d.ts +11 -14
- package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
- package/types/cmat-lib-mock-api.d.ts +46 -55
- package/types/cmat-pipes-bytes.d.ts +7 -10
- package/types/cmat-pipes-date-format.d.ts +7 -10
- package/types/cmat-pipes-find-by-key.d.ts +8 -12
- package/types/cmat-pipes-group-by.d.ts +11 -15
- package/types/cmat-pipes-keys.d.ts +10 -13
- package/types/cmat-pipes-secure.d.ts +14 -17
- package/types/cmat-pipes-uppercase.d.ts +7 -10
- package/types/cmat-reports.d.ts +1131 -0
- package/types/cmat-services-alert.d.ts +80 -87
- package/types/cmat-services-config.d.ts +37 -43
- package/types/cmat-services-confirmation.d.ts +31 -37
- package/types/cmat-services-data.d.ts +18 -21
- package/types/cmat-services-export-as.d.ts +28 -33
- package/types/cmat-services-loading.d.ts +27 -31
- package/types/cmat-services-local-storage.d.ts +17 -21
- package/types/cmat-services-media-watcher.d.ts +14 -18
- package/types/cmat-services-platform.d.ts +8 -11
- package/types/cmat-services-print.d.ts +97 -92
- package/types/cmat-services-splash-screen.d.ts +11 -14
- package/types/cmat-services-title.d.ts +9 -12
- package/types/cmat-services-translation.d.ts +19 -22
- package/types/cmat-services-utils.d.ts +76 -80
- package/types/cmat-validators.d.ts +5 -8
- package/types/cmat-version.d.ts +8 -10
- package/types/cmat.d.ts +7551 -5194
|
@@ -1,520 +1,427 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { CMAT_VERSION } from
|
|
5
|
-
import AES from
|
|
6
|
-
import CryptoJSCore from
|
|
7
|
-
import Base64 from
|
|
8
|
-
import Hex from
|
|
9
|
-
import UTF8 from
|
|
10
|
-
import Pkcs7 from
|
|
11
|
-
import dayjs from
|
|
12
|
-
import { isUndefined } from
|
|
13
|
-
import { throwError } from
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
specialParam: 'partymanageApi'
|
|
20
|
-
})
|
|
21
|
-
});
|
|
1
|
+
import { HttpErrorResponse, HttpHeaders, HttpResponse, HttpResponseBase } from "@angular/common/http";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Injectable, InjectionToken } from "@angular/core";
|
|
4
|
+
import { CMAT_VERSION } from "cmat/version";
|
|
5
|
+
import AES from "crypto-js/aes";
|
|
6
|
+
import CryptoJSCore from "crypto-js/core";
|
|
7
|
+
import Base64 from "crypto-js/enc-base64";
|
|
8
|
+
import Hex from "crypto-js/enc-hex";
|
|
9
|
+
import UTF8 from "crypto-js/enc-utf8";
|
|
10
|
+
import Pkcs7 from "crypto-js/pad-pkcs7";
|
|
11
|
+
import dayjs from "dayjs";
|
|
12
|
+
import { isUndefined } from "lodash-es";
|
|
13
|
+
import { throwError } from "rxjs";
|
|
14
|
+
const CMAT_CRYPTO_CONFIG = new InjectionToken("CMAT_CRYPTO_CONFIG", { factory: () => ({
|
|
15
|
+
key: "14789632236987411478963223698741",
|
|
16
|
+
iv: "1478963223698741",
|
|
17
|
+
specialParam: "partymanageApi"
|
|
18
|
+
}) });
|
|
22
19
|
function initializeCmatUtilsConfig(config) {
|
|
23
|
-
|
|
20
|
+
CmatUtilsService.setCryptoConfig(config);
|
|
24
21
|
}
|
|
25
|
-
class CmatUtilsService {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
case 'image/gif':
|
|
429
|
-
fileType = 'gif';
|
|
430
|
-
break;
|
|
431
|
-
case 'application/msword':
|
|
432
|
-
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
|
433
|
-
fileType = 'word';
|
|
434
|
-
break;
|
|
435
|
-
case 'application/vnd.ms-excel':
|
|
436
|
-
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
|
437
|
-
fileType = 'excel';
|
|
438
|
-
break;
|
|
439
|
-
case 'application/pdf':
|
|
440
|
-
fileType = 'pdf';
|
|
441
|
-
break;
|
|
442
|
-
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
|
443
|
-
case 'application/vnd.ms-powerpoint':
|
|
444
|
-
fileType = 'ppt';
|
|
445
|
-
break;
|
|
446
|
-
case 'text/plain':
|
|
447
|
-
fileType = 'text';
|
|
448
|
-
break;
|
|
449
|
-
case 'video/mpeg':
|
|
450
|
-
case 'video/mp4':
|
|
451
|
-
case 'audio/mp4':
|
|
452
|
-
fileType = 'video';
|
|
453
|
-
break;
|
|
454
|
-
case 'application/zip':
|
|
455
|
-
fileType = 'zip';
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
return fileType;
|
|
459
|
-
}
|
|
460
|
-
static isDateString(value) {
|
|
461
|
-
if (!value || (typeof value !== 'string' && typeof value !== 'number')) {
|
|
462
|
-
return false;
|
|
463
|
-
}
|
|
464
|
-
const stringValue = String(value);
|
|
465
|
-
if (/^\d+$/.test(stringValue)) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
const parsedDate = Date.parse(stringValue);
|
|
469
|
-
if (isNaN(parsedDate)) {
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
return dayjs(stringValue).isValid();
|
|
473
|
-
}
|
|
474
|
-
static transformObjectsForExport(jsonObjects, columns) {
|
|
475
|
-
return jsonObjects.map((jsonObject) => {
|
|
476
|
-
const result = {};
|
|
477
|
-
columns.forEach((info) => {
|
|
478
|
-
const parts = info.code.split('.');
|
|
479
|
-
const lastPart = parts.pop();
|
|
480
|
-
let currentValue = jsonObject;
|
|
481
|
-
parts.forEach((part) => {
|
|
482
|
-
if (typeof currentValue === 'object' && currentValue !== null && Object.prototype.hasOwnProperty.call(currentValue, part)) {
|
|
483
|
-
currentValue = currentValue[part];
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
currentValue = undefined;
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
result[info.code] = currentValue && typeof currentValue === 'object' && Object.prototype.hasOwnProperty.call(currentValue, lastPart) ? currentValue[lastPart] : '';
|
|
490
|
-
});
|
|
491
|
-
return result;
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
static _base64DecodeUnicode(str) {
|
|
495
|
-
return decodeURIComponent(Array.prototype.map.call(atob(str), (c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''));
|
|
496
|
-
}
|
|
497
|
-
randomId(stringLength = 10) {
|
|
498
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
499
|
-
let id = '';
|
|
500
|
-
for (let i = 0; i < stringLength; i++) {
|
|
501
|
-
id += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
502
|
-
}
|
|
503
|
-
return id;
|
|
504
|
-
}
|
|
505
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
506
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, providedIn: 'root' }); }
|
|
507
|
-
}
|
|
508
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, decorators: [{
|
|
509
|
-
type: Injectable,
|
|
510
|
-
args: [{
|
|
511
|
-
providedIn: 'root'
|
|
512
|
-
}]
|
|
513
|
-
}] });
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Generated bundle index. Do not edit.
|
|
517
|
-
*/
|
|
518
|
-
|
|
22
|
+
var CmatUtilsService = class CmatUtilsService {
|
|
23
|
+
static {
|
|
24
|
+
this.captionAndMessageSeparator = ":";
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.noNetworkMessageCaption = "无网络";
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.noNetworkMessageDetail = "无法连接服务器";
|
|
31
|
+
}
|
|
32
|
+
static {
|
|
33
|
+
this.accessDeniedMessageCaption = "拒绝访问!";
|
|
34
|
+
}
|
|
35
|
+
static {
|
|
36
|
+
this.accessDeniedMessageDetail = "";
|
|
37
|
+
}
|
|
38
|
+
static {
|
|
39
|
+
this._key = null;
|
|
40
|
+
}
|
|
41
|
+
static {
|
|
42
|
+
this._iv = null;
|
|
43
|
+
}
|
|
44
|
+
static {
|
|
45
|
+
this._specialParam = null;
|
|
46
|
+
}
|
|
47
|
+
static get key() {
|
|
48
|
+
return this._key;
|
|
49
|
+
}
|
|
50
|
+
static get iv() {
|
|
51
|
+
return this._iv;
|
|
52
|
+
}
|
|
53
|
+
static get specialParam() {
|
|
54
|
+
return this._specialParam;
|
|
55
|
+
}
|
|
56
|
+
get exactMatchOptions() {
|
|
57
|
+
return {
|
|
58
|
+
paths: "exact",
|
|
59
|
+
fragment: "ignored",
|
|
60
|
+
matrixParams: "ignored",
|
|
61
|
+
queryParams: "exact"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
get subsetMatchOptions() {
|
|
65
|
+
return {
|
|
66
|
+
paths: "subset",
|
|
67
|
+
fragment: "ignored",
|
|
68
|
+
matrixParams: "ignored",
|
|
69
|
+
queryParams: "subset"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
static setCryptoConfig(config) {
|
|
73
|
+
this._key = UTF8.parse(config.key);
|
|
74
|
+
this._iv = UTF8.parse(config.iv);
|
|
75
|
+
this._specialParam = UTF8.parse(config.specialParam);
|
|
76
|
+
}
|
|
77
|
+
static getRequestHeaders() {
|
|
78
|
+
return new HttpHeaders().append("Content-Type", "application/json").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
|
|
79
|
+
}
|
|
80
|
+
static getRequestIdempotentHeaders() {
|
|
81
|
+
return new HttpHeaders().append("Content-Type", "application/json").append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
|
|
82
|
+
}
|
|
83
|
+
static getRequestBypassHeaders() {
|
|
84
|
+
return new HttpHeaders().append("Content-Type", "application/json").append("bypass", "true").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
|
|
85
|
+
}
|
|
86
|
+
static getRequestIdempotentBypassHeaders() {
|
|
87
|
+
return new HttpHeaders().append("Content-Type", "application/json").append("X-Request-ID", CmatUtilsService.newGuid()).append("bypass", "true").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
|
|
88
|
+
}
|
|
89
|
+
static getRequestCryptoHeaders(params) {
|
|
90
|
+
return new HttpHeaders().append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", this.getEncryptData(params).toString());
|
|
91
|
+
}
|
|
92
|
+
static getRequestCryptoBypassHeaders(params) {
|
|
93
|
+
return new HttpHeaders().append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("bypass", "true").append("App-Version", this.getEncryptData(params).toString());
|
|
94
|
+
}
|
|
95
|
+
static getRequestCryptoIdempotentHeaders(params) {
|
|
96
|
+
return new HttpHeaders().append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", this.getEncryptData(params).toString());
|
|
97
|
+
}
|
|
98
|
+
static getRequestCryptoIdempotentBypassHeaders(params) {
|
|
99
|
+
return new HttpHeaders().append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("bypass", "true").append("App-Version", this.getEncryptData(params).toString());
|
|
100
|
+
}
|
|
101
|
+
static getEncryptData(data) {
|
|
102
|
+
const src = UTF8.parse(UTF8.stringify(this.specialParam) + data);
|
|
103
|
+
return AES.encrypt(src, this.key, {
|
|
104
|
+
iv: this.iv,
|
|
105
|
+
mode: CryptoJSCore.mode.CBC,
|
|
106
|
+
padding: Pkcs7
|
|
107
|
+
}).ciphertext.toString();
|
|
108
|
+
}
|
|
109
|
+
static getDecryptData(data) {
|
|
110
|
+
const encryptedHexStr = Hex.parse(data);
|
|
111
|
+
return AES.decrypt(Base64.stringify(encryptedHexStr), this.key, {
|
|
112
|
+
iv: this.iv,
|
|
113
|
+
mode: CryptoJSCore.mode.CBC,
|
|
114
|
+
padding: Pkcs7
|
|
115
|
+
}).toString(UTF8).toString();
|
|
116
|
+
}
|
|
117
|
+
static handleError(error) {
|
|
118
|
+
if (error instanceof ErrorEvent) console.error("Client side network error occurred:", error.message);
|
|
119
|
+
else if (typeof error === "object" && error !== null && "status" in error) {
|
|
120
|
+
const httpError = error;
|
|
121
|
+
console.error(`Backend - status: ${String(httpError.status)}, message: ${String(httpError.error)}`);
|
|
122
|
+
} else console.error("Unknown error occurred:", String(error));
|
|
123
|
+
return throwError(() => error ?? "server error");
|
|
124
|
+
}
|
|
125
|
+
static getHttpResponseMessage(data) {
|
|
126
|
+
const responses = [];
|
|
127
|
+
if (data instanceof HttpResponseBase) {
|
|
128
|
+
if (this.checkNoNetwork(data)) responses.push(`${this.noNetworkMessageCaption}${this.captionAndMessageSeparator} ${this.noNetworkMessageDetail}`);
|
|
129
|
+
else {
|
|
130
|
+
const responseObject = this.getResponseBody(data);
|
|
131
|
+
if (responseObject && typeof responseObject === "object") {
|
|
132
|
+
for (const key in responseObject) if (Object.prototype.hasOwnProperty.call(responseObject, key)) {
|
|
133
|
+
const value = responseObject[key];
|
|
134
|
+
const stringValue = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
135
|
+
if (key) responses.push(`${key}${this.captionAndMessageSeparator} ${stringValue}`);
|
|
136
|
+
else if (value) responses.push(stringValue);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const responseBody = this.getResponseBody(data);
|
|
141
|
+
if (!responses.length && responseBody != null) {
|
|
142
|
+
if (typeof responseBody === "object") responses.push(JSON.stringify(responseBody));
|
|
143
|
+
else responses.push(String(responseBody));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!responses.length) responses.push(typeof data === "object" ? JSON.stringify(data) : String(data));
|
|
147
|
+
if (data instanceof HttpResponseBase && this.checkAccessDenied(data)) responses.splice(0, 0, `${this.accessDeniedMessageCaption}${this.captionAndMessageSeparator} ${this.accessDeniedMessageDetail}`);
|
|
148
|
+
return responses;
|
|
149
|
+
}
|
|
150
|
+
static findHttpResponseMessage(messageToFind, data, seachInCaptionOnly = true, includeCaptionInResult = false) {
|
|
151
|
+
const searchString = messageToFind.toLowerCase();
|
|
152
|
+
const httpMessages = this.getHttpResponseMessage(data);
|
|
153
|
+
for (const message of httpMessages) {
|
|
154
|
+
const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
|
|
155
|
+
if (fullMessage.firstPart?.toLowerCase().includes(searchString)) return includeCaptionInResult ? message : fullMessage.secondPart ?? fullMessage.firstPart;
|
|
156
|
+
}
|
|
157
|
+
if (!seachInCaptionOnly) {
|
|
158
|
+
for (const message of httpMessages) if (message.toLowerCase().includes(searchString)) {
|
|
159
|
+
if (includeCaptionInResult) return message;
|
|
160
|
+
else {
|
|
161
|
+
const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
|
|
162
|
+
return fullMessage.secondPart ?? fullMessage.firstPart;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
static getResponseBody(response) {
|
|
169
|
+
if (response instanceof HttpResponse) return response.body;
|
|
170
|
+
if (response instanceof HttpErrorResponse) return response.error ?? response.message;
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
static checkNoNetwork(response) {
|
|
174
|
+
if (response instanceof HttpResponseBase) return response.status === 0;
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
static checkAccessDenied(response) {
|
|
178
|
+
if (response instanceof HttpResponseBase) return response.status === 403;
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
static checkNotFound(response) {
|
|
182
|
+
if (response instanceof HttpResponseBase) return response.status === 404;
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
static checkIsLocalHost(url, base) {
|
|
186
|
+
if (url) {
|
|
187
|
+
const location = new URL(url, base);
|
|
188
|
+
return location.hostname === "localhost" || location.hostname === "127.0.0.1";
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
static getQueryParamsFromString(paramString) {
|
|
193
|
+
if (!paramString) return null;
|
|
194
|
+
const params = {};
|
|
195
|
+
for (const param of paramString.split("&")) {
|
|
196
|
+
const keyValue = CmatUtilsService.splitInTwo(param, "=");
|
|
197
|
+
params[keyValue.firstPart] = keyValue.secondPart;
|
|
198
|
+
}
|
|
199
|
+
return params;
|
|
200
|
+
}
|
|
201
|
+
static splitInTwo(text, separator) {
|
|
202
|
+
const separatorIndex = separator && text.includes(separator) ? text.indexOf(separator) : -1;
|
|
203
|
+
if (separatorIndex === -1) return {
|
|
204
|
+
firstPart: text,
|
|
205
|
+
secondPart: null
|
|
206
|
+
};
|
|
207
|
+
return {
|
|
208
|
+
firstPart: text.substring(0, separatorIndex).trim(),
|
|
209
|
+
secondPart: text.substring(separatorIndex + 1).trim()
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
static safeStringify(object) {
|
|
213
|
+
let result;
|
|
214
|
+
try {
|
|
215
|
+
result = JSON.stringify(object);
|
|
216
|
+
return result;
|
|
217
|
+
} catch {}
|
|
218
|
+
const simpleObject = {};
|
|
219
|
+
for (const prop in object) {
|
|
220
|
+
if (!Object.prototype.hasOwnProperty.call(object, prop)) continue;
|
|
221
|
+
const value = object[prop];
|
|
222
|
+
if (typeof value === "object") continue;
|
|
223
|
+
if (typeof value === "function") continue;
|
|
224
|
+
simpleObject[prop] = value;
|
|
225
|
+
}
|
|
226
|
+
result = "[***Sanitized Object***]: " + JSON.stringify(simpleObject);
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
static jsonTryParse(value) {
|
|
230
|
+
try {
|
|
231
|
+
return JSON.parse(value);
|
|
232
|
+
} catch {
|
|
233
|
+
if (isUndefined(value)) return;
|
|
234
|
+
return value;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
static capitalizeFirstLetter(text) {
|
|
238
|
+
if (text) return text.charAt(0).toUpperCase() + text.slice(1);
|
|
239
|
+
else return text;
|
|
240
|
+
}
|
|
241
|
+
static toTitleCase(text) {
|
|
242
|
+
return text.replace(/\w\S*/g, (subString) => subString.charAt(0).toUpperCase() + subString.substring(1).toLowerCase());
|
|
243
|
+
}
|
|
244
|
+
static toLowerCase(items) {
|
|
245
|
+
if (items instanceof Array) return items.map((item) => item.toLowerCase());
|
|
246
|
+
else if (typeof items === "string") return items.toLowerCase();
|
|
247
|
+
}
|
|
248
|
+
static uniqueId() {
|
|
249
|
+
return this.randomNumber(1e6, 9e6).toString();
|
|
250
|
+
}
|
|
251
|
+
static randomNumber(min, max) {
|
|
252
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
253
|
+
}
|
|
254
|
+
static baseUrl() {
|
|
255
|
+
let base;
|
|
256
|
+
if (window.location.origin) base = window.location.origin;
|
|
257
|
+
else base = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
|
|
258
|
+
return base.replace(/\/$/, "");
|
|
259
|
+
}
|
|
260
|
+
static newGuid() {
|
|
261
|
+
return crypto.randomUUID();
|
|
262
|
+
}
|
|
263
|
+
static testIsAbsoluteUrl(url) {
|
|
264
|
+
return (/* @__PURE__ */ new RegExp("^(?:[a-z]+:)?//", "i")).test(url);
|
|
265
|
+
}
|
|
266
|
+
static convertToAbsoluteUrl(url) {
|
|
267
|
+
return CmatUtilsService.testIsAbsoluteUrl(url) ? url : "//" + url;
|
|
268
|
+
}
|
|
269
|
+
static urlBase64Decode(str) {
|
|
270
|
+
let output = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
271
|
+
switch (output.length % 4) {
|
|
272
|
+
case 0: break;
|
|
273
|
+
case 2:
|
|
274
|
+
output += "==";
|
|
275
|
+
break;
|
|
276
|
+
case 3: output += "=";
|
|
277
|
+
}
|
|
278
|
+
return this._base64DecodeUnicode(output);
|
|
279
|
+
}
|
|
280
|
+
static decodeToken(token) {
|
|
281
|
+
const parts = token.split(".");
|
|
282
|
+
if (parts.length !== 3) throw new Error("JWT must have 3 parts");
|
|
283
|
+
const decoded = this.urlBase64Decode(parts[1]);
|
|
284
|
+
if (!decoded) throw new Error("Cannot decode the token");
|
|
285
|
+
return JSON.parse(decoded);
|
|
286
|
+
}
|
|
287
|
+
static getTokenExpirationDate(token) {
|
|
288
|
+
const decoded = this.decodeToken(token);
|
|
289
|
+
if (!Object.prototype.hasOwnProperty.call(decoded, "exp")) return null;
|
|
290
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
291
|
+
date.setUTCSeconds(Number(decoded.exp));
|
|
292
|
+
return date;
|
|
293
|
+
}
|
|
294
|
+
static isTokenExpired(token, offsetSeconds) {
|
|
295
|
+
const date = this.getTokenExpirationDate(token);
|
|
296
|
+
offsetSeconds = offsetSeconds ?? 0;
|
|
297
|
+
if (date == null) return false;
|
|
298
|
+
return !(date.valueOf() > (/* @__PURE__ */ new Date()).valueOf() + offsetSeconds * 1e3);
|
|
299
|
+
}
|
|
300
|
+
static readAsDataURL(file) {
|
|
301
|
+
return new Promise((resolve, reject) => {
|
|
302
|
+
const reader = new FileReader();
|
|
303
|
+
reader.onload = () => {
|
|
304
|
+
resolve(reader.result);
|
|
305
|
+
};
|
|
306
|
+
reader.onerror = () => {
|
|
307
|
+
reject(/* @__PURE__ */ new Error("Failed to read file as Data URL"));
|
|
308
|
+
};
|
|
309
|
+
reader.readAsDataURL(file);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
static dataURIToBlob(dataURI) {
|
|
313
|
+
const splitDataURI = dataURI.split(",");
|
|
314
|
+
const byteString = splitDataURI[0].includes("base64") ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1]);
|
|
315
|
+
const mimeString = splitDataURI[0].split(":")[1].split(";")[0];
|
|
316
|
+
const ia = new Uint8Array(byteString.length);
|
|
317
|
+
for (const [i, char] of [...byteString].entries()) ia[i] = char.charCodeAt(0);
|
|
318
|
+
return new Blob([ia], { type: mimeString });
|
|
319
|
+
}
|
|
320
|
+
static getFileType(accept) {
|
|
321
|
+
let fileType = "file";
|
|
322
|
+
switch (accept) {
|
|
323
|
+
case "image/jpeg":
|
|
324
|
+
case "image/jpg":
|
|
325
|
+
fileType = "jpg";
|
|
326
|
+
break;
|
|
327
|
+
case "image/png":
|
|
328
|
+
fileType = "png";
|
|
329
|
+
break;
|
|
330
|
+
case "text/csv":
|
|
331
|
+
fileType = "csv";
|
|
332
|
+
break;
|
|
333
|
+
case "image/gif":
|
|
334
|
+
fileType = "gif";
|
|
335
|
+
break;
|
|
336
|
+
case "application/msword":
|
|
337
|
+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
338
|
+
fileType = "word";
|
|
339
|
+
break;
|
|
340
|
+
case "application/vnd.ms-excel":
|
|
341
|
+
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
342
|
+
fileType = "excel";
|
|
343
|
+
break;
|
|
344
|
+
case "application/pdf":
|
|
345
|
+
fileType = "pdf";
|
|
346
|
+
break;
|
|
347
|
+
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
348
|
+
case "application/vnd.ms-powerpoint":
|
|
349
|
+
fileType = "ppt";
|
|
350
|
+
break;
|
|
351
|
+
case "text/plain":
|
|
352
|
+
fileType = "text";
|
|
353
|
+
break;
|
|
354
|
+
case "video/mpeg":
|
|
355
|
+
case "video/mp4":
|
|
356
|
+
case "audio/mp4":
|
|
357
|
+
fileType = "video";
|
|
358
|
+
break;
|
|
359
|
+
case "application/zip": fileType = "zip";
|
|
360
|
+
}
|
|
361
|
+
return fileType;
|
|
362
|
+
}
|
|
363
|
+
static isDateString(value) {
|
|
364
|
+
if (!value || typeof value !== "string" && typeof value !== "number") return false;
|
|
365
|
+
const stringValue = String(value);
|
|
366
|
+
if (/^\d+$/.test(stringValue)) return false;
|
|
367
|
+
if (isNaN(Date.parse(stringValue))) return false;
|
|
368
|
+
return dayjs(stringValue).isValid();
|
|
369
|
+
}
|
|
370
|
+
static transformObjectsForExport(jsonObjects, columns) {
|
|
371
|
+
return jsonObjects.map((jsonObject) => {
|
|
372
|
+
const result = {};
|
|
373
|
+
columns.forEach((info) => {
|
|
374
|
+
const parts = info.code.split(".");
|
|
375
|
+
const lastPart = parts.pop();
|
|
376
|
+
let currentValue = jsonObject;
|
|
377
|
+
parts.forEach((part) => {
|
|
378
|
+
if (typeof currentValue === "object" && currentValue !== null && Object.prototype.hasOwnProperty.call(currentValue, part)) currentValue = currentValue[part];
|
|
379
|
+
else currentValue = void 0;
|
|
380
|
+
});
|
|
381
|
+
result[info.code] = currentValue && typeof currentValue === "object" && Object.prototype.hasOwnProperty.call(currentValue, lastPart) ? currentValue[lastPart] : "";
|
|
382
|
+
});
|
|
383
|
+
return result;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
static _base64DecodeUnicode(str) {
|
|
387
|
+
return decodeURIComponent(Array.prototype.map.call(atob(str), (c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));
|
|
388
|
+
}
|
|
389
|
+
randomId(stringLength = 10) {
|
|
390
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
391
|
+
let id = "";
|
|
392
|
+
for (let i = 0; i < stringLength; i++) id += chars.charAt(Math.floor(Math.random() * 62));
|
|
393
|
+
return id;
|
|
394
|
+
}
|
|
395
|
+
static {
|
|
396
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
397
|
+
minVersion: "12.0.0",
|
|
398
|
+
version: "22.2.3",
|
|
399
|
+
ngImport: i0,
|
|
400
|
+
type: CmatUtilsService,
|
|
401
|
+
deps: [],
|
|
402
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
static {
|
|
406
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
407
|
+
minVersion: "12.0.0",
|
|
408
|
+
version: "22.2.3",
|
|
409
|
+
ngImport: i0,
|
|
410
|
+
type: CmatUtilsService,
|
|
411
|
+
providedIn: "root"
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
416
|
+
minVersion: "12.0.0",
|
|
417
|
+
version: "22.2.3",
|
|
418
|
+
ngImport: i0,
|
|
419
|
+
type: CmatUtilsService,
|
|
420
|
+
decorators: [{
|
|
421
|
+
type: Injectable,
|
|
422
|
+
args: [{ providedIn: "root" }]
|
|
423
|
+
}]
|
|
424
|
+
});
|
|
519
425
|
export { CMAT_CRYPTO_CONFIG, CmatUtilsService, initializeCmatUtilsConfig };
|
|
520
|
-
|
|
426
|
+
|
|
427
|
+
//# sourceMappingURL=cmat-services-utils.mjs.map
|