verben-ticketing-ui 0.6.0
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 +25 -0
- package/esm2022/public-api.mjs +9 -0
- package/esm2022/src/lib/components/add-ticket/add-ticket.component.mjs +306 -0
- package/esm2022/src/lib/components/add-ticket/add-ticket.module.mjs +98 -0
- package/esm2022/src/lib/components/add-ticket/index.mjs +2 -0
- package/esm2022/src/lib/components/add-ticket/public-api.mjs +3 -0
- package/esm2022/src/lib/components/add-ticket/verben-ticketing-ui-src-lib-components-add-ticket.mjs +5 -0
- package/esm2022/src/lib/components/file-render/file-render.component.mjs +34 -0
- package/esm2022/src/lib/components/file-render/file-render.module.mjs +94 -0
- package/esm2022/src/lib/components/file-render/index.mjs +2 -0
- package/esm2022/src/lib/components/file-render/public-api.mjs +3 -0
- package/esm2022/src/lib/components/file-render/verben-ticketing-ui-src-lib-components-file-render.mjs +5 -0
- package/esm2022/src/lib/components/ticketing/base-table-style.mjs +56 -0
- package/esm2022/src/lib/components/ticketing/index.mjs +2 -0
- package/esm2022/src/lib/components/ticketing/public-api.mjs +4 -0
- package/esm2022/src/lib/components/ticketing/ticketing.component.mjs +813 -0
- package/esm2022/src/lib/components/ticketing/ticketing.module.mjs +96 -0
- package/esm2022/src/lib/components/ticketing/ticketing.service.mjs +220 -0
- package/esm2022/src/lib/components/ticketing/verben-ticketing-ui-src-lib-components-ticketing.mjs +5 -0
- package/esm2022/src/lib/components/ticketing-detail/chat-control/chat-control.component.mjs +240 -0
- package/esm2022/src/lib/components/ticketing-detail/chat-control/chat-control.module.mjs +98 -0
- package/esm2022/src/lib/components/ticketing-detail/index.mjs +2 -0
- package/esm2022/src/lib/components/ticketing-detail/public-api.mjs +3 -0
- package/esm2022/src/lib/components/ticketing-detail/ticketing-detail.component.mjs +592 -0
- package/esm2022/src/lib/components/ticketing-detail/ticketing-detail.module.mjs +109 -0
- package/esm2022/src/lib/components/ticketing-detail/verben-ticketing-ui-src-lib-components-ticketing-detail.mjs +5 -0
- package/esm2022/src/lib/constants/index.mjs +2 -0
- package/esm2022/src/lib/constants/keynames.mjs +2 -0
- package/esm2022/src/lib/constants/pagesize.mjs +3 -0
- package/esm2022/src/lib/constants/public-api.mjs +3 -0
- package/esm2022/src/lib/constants/verben-ticketing-ui-src-lib-constants.mjs +5 -0
- package/esm2022/src/lib/models/Application.mjs +2 -0
- package/esm2022/src/lib/models/ApplicationRoleAction.mjs +2 -0
- package/esm2022/src/lib/models/ApplicationRoleContext.mjs +2 -0
- package/esm2022/src/lib/models/BaseModel.mjs +2 -0
- package/esm2022/src/lib/models/CacheDataRequest.mjs +2 -0
- package/esm2022/src/lib/models/Company.mjs +2 -0
- package/esm2022/src/lib/models/ErrorResponse.mjs +11 -0
- package/esm2022/src/lib/models/File.mjs +2 -0
- package/esm2022/src/lib/models/FilterTypes.mjs +9 -0
- package/esm2022/src/lib/models/HttpRequestType.mjs +8 -0
- package/esm2022/src/lib/models/KeyValueParam.mjs +2 -0
- package/esm2022/src/lib/models/ModelRelationship.mjs +2 -0
- package/esm2022/src/lib/models/OAuthParam.mjs +2 -0
- package/esm2022/src/lib/models/OAuthType.mjs +9 -0
- package/esm2022/src/lib/models/PagedResult.mjs +2 -0
- package/esm2022/src/lib/models/PasswordRequestParam.mjs +2 -0
- package/esm2022/src/lib/models/PermissionConfig.mjs +2 -0
- package/esm2022/src/lib/models/ResponseKeyValue.mjs +2 -0
- package/esm2022/src/lib/models/Role.mjs +2 -0
- package/esm2022/src/lib/models/RoleAction.mjs +2 -0
- package/esm2022/src/lib/models/RoleContext.mjs +2 -0
- package/esm2022/src/lib/models/Schedule.mjs +2 -0
- package/esm2022/src/lib/models/ScheduleType.mjs +6 -0
- package/esm2022/src/lib/models/SearchDynamicWrapper.mjs +2 -0
- package/esm2022/src/lib/models/SearchOperator.mjs +6 -0
- package/esm2022/src/lib/models/SearchPropertySign.mjs +11 -0
- package/esm2022/src/lib/models/SearchPropertyValue.mjs +2 -0
- package/esm2022/src/lib/models/SearchPropertyValueType.mjs +11 -0
- package/esm2022/src/lib/models/SortDirection.mjs +7 -0
- package/esm2022/src/lib/models/TaskUser.mjs +2 -0
- package/esm2022/src/lib/models/Tenant.mjs +2 -0
- package/esm2022/src/lib/models/TenantConfig.mjs +2 -0
- package/esm2022/src/lib/models/TenantPriority.mjs +2 -0
- package/esm2022/src/lib/models/Ticket.mjs +2 -0
- package/esm2022/src/lib/models/TicketMessage.mjs +2 -0
- package/esm2022/src/lib/models/TicketStatus.mjs +8 -0
- package/esm2022/src/lib/models/UserRequest.mjs +2 -0
- package/esm2022/src/lib/models/auth-mechanism.mjs +8 -0
- package/esm2022/src/lib/models/base.mjs +2 -0
- package/esm2022/src/lib/models/conditions.mjs +13 -0
- package/esm2022/src/lib/models/index.mjs +2 -0
- package/esm2022/src/lib/models/log-in.mjs +2 -0
- package/esm2022/src/lib/models/mainUser.mjs +2 -0
- package/esm2022/src/lib/models/oauth-resp.mjs +2 -0
- package/esm2022/src/lib/models/oauth-response.mjs +2 -0
- package/esm2022/src/lib/models/object-state.mjs +8 -0
- package/esm2022/src/lib/models/otpValue.mjs +2 -0
- package/esm2022/src/lib/models/paged.mjs +2 -0
- package/esm2022/src/lib/models/public-api.mjs +57 -0
- package/esm2022/src/lib/models/query-params.mjs +2 -0
- package/esm2022/src/lib/models/request-status.mjs +5 -0
- package/esm2022/src/lib/models/resend-otp-data.mjs +2 -0
- package/esm2022/src/lib/models/sign-up.mjs +2 -0
- package/esm2022/src/lib/models/single-sign-on.mjs +2 -0
- package/esm2022/src/lib/models/status.mjs +6 -0
- package/esm2022/src/lib/models/user-access-request-status.mjs +7 -0
- package/esm2022/src/lib/models/user-access-request.mjs +2 -0
- package/esm2022/src/lib/models/user-management.mjs +2 -0
- package/esm2022/src/lib/models/user.mjs +2 -0
- package/esm2022/src/lib/models/verben-ticketing-ui-src-lib-models.mjs +5 -0
- package/esm2022/src/lib/pipes/async-label.pipe.mjs +26 -0
- package/esm2022/src/lib/pipes/company-date.pipe.mjs +30 -0
- package/esm2022/src/lib/pipes/ellipse-word.pipe.mjs +23 -0
- package/esm2022/src/lib/pipes/index.mjs +2 -0
- package/esm2022/src/lib/pipes/public-api.mjs +4 -0
- package/esm2022/src/lib/pipes/verben-ticketing-ui-src-lib-pipes.mjs +5 -0
- package/esm2022/src/lib/services/company-settings.service.mjs +23 -0
- package/esm2022/src/lib/services/environment.service.mjs +26 -0
- package/esm2022/src/lib/services/http-web-request.service.mjs +100 -0
- package/esm2022/src/lib/services/import.service.mjs +247 -0
- package/esm2022/src/lib/services/index.mjs +2 -0
- package/esm2022/src/lib/services/label.service.mjs +261 -0
- package/esm2022/src/lib/services/public-api.mjs +8 -0
- package/esm2022/src/lib/services/shared.service.mjs +58 -0
- package/esm2022/src/lib/services/util.service.mjs +72 -0
- package/esm2022/src/lib/services/verben-ticketing-ui-src-lib-services.mjs +5 -0
- package/esm2022/src/utils/components/base-data-view.component.mjs +111 -0
- package/esm2022/src/utils/index.mjs +2 -0
- package/esm2022/src/utils/models/DataViewConfig.mjs +2 -0
- package/esm2022/src/utils/public-api.mjs +3 -0
- package/esm2022/src/utils/verben-ticketing-ui-src-utils.mjs +5 -0
- package/esm2022/verben-ticketing-ui.mjs +5 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-add-ticket.mjs +403 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-add-ticket.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-file-render.mjs +130 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-file-render.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-ticketing-detail.mjs +1018 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-ticketing-detail.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-ticketing.mjs +1166 -0
- package/fesm2022/verben-ticketing-ui-src-lib-components-ticketing.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-constants.mjs +11 -0
- package/fesm2022/verben-ticketing-ui-src-lib-constants.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-models.mjs +138 -0
- package/fesm2022/verben-ticketing-ui-src-lib-models.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-pipes.mjs +81 -0
- package/fesm2022/verben-ticketing-ui-src-lib-pipes.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-lib-services.mjs +770 -0
- package/fesm2022/verben-ticketing-ui-src-lib-services.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui-src-utils.mjs +118 -0
- package/fesm2022/verben-ticketing-ui-src-utils.mjs.map +1 -0
- package/fesm2022/verben-ticketing-ui.mjs +14 -0
- package/fesm2022/verben-ticketing-ui.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/package.json +82 -0
- package/public-api.d.ts +4 -0
- package/src/lib/components/add-ticket/add-ticket.component.d.ts +44 -0
- package/src/lib/components/add-ticket/add-ticket.module.d.ts +15 -0
- package/src/lib/components/add-ticket/index.d.ts +1 -0
- package/src/lib/components/add-ticket/public-api.d.ts +2 -0
- package/src/lib/components/file-render/file-render.component.d.ts +14 -0
- package/src/lib/components/file-render/file-render.module.d.ts +14 -0
- package/src/lib/components/file-render/index.d.ts +1 -0
- package/src/lib/components/file-render/public-api.d.ts +2 -0
- package/src/lib/components/ticketing/base-table-style.d.ts +1 -0
- package/src/lib/components/ticketing/index.d.ts +1 -0
- package/src/lib/components/ticketing/public-api.d.ts +3 -0
- package/src/lib/components/ticketing/ticketing.component.d.ts +100 -0
- package/src/lib/components/ticketing/ticketing.module.d.ts +12 -0
- package/src/lib/components/ticketing/ticketing.service.d.ts +27 -0
- package/src/lib/components/ticketing-detail/chat-control/chat-control.component.d.ts +47 -0
- package/src/lib/components/ticketing-detail/chat-control/chat-control.module.d.ts +15 -0
- package/src/lib/components/ticketing-detail/index.d.ts +1 -0
- package/src/lib/components/ticketing-detail/public-api.d.ts +2 -0
- package/src/lib/components/ticketing-detail/ticketing-detail.component.d.ts +77 -0
- package/src/lib/components/ticketing-detail/ticketing-detail.module.d.ts +17 -0
- package/src/lib/constants/index.d.ts +1 -0
- package/src/lib/constants/keynames.d.ts +1 -0
- package/src/lib/constants/pagesize.d.ts +2 -0
- package/src/lib/constants/public-api.d.ts +2 -0
- package/src/lib/models/Application.d.ts +5 -0
- package/src/lib/models/ApplicationRoleAction.d.ts +9 -0
- package/src/lib/models/ApplicationRoleContext.d.ts +9 -0
- package/src/lib/models/BaseModel.d.ts +14 -0
- package/src/lib/models/CacheDataRequest.d.ts +7 -0
- package/src/lib/models/Company.d.ts +22 -0
- package/src/lib/models/ErrorResponse.d.ts +6 -0
- package/src/lib/models/File.d.ts +7 -0
- package/src/lib/models/FilterTypes.d.ts +6 -0
- package/src/lib/models/HttpRequestType.d.ts +6 -0
- package/src/lib/models/KeyValueParam.d.ts +5 -0
- package/src/lib/models/ModelRelationship.d.ts +7 -0
- package/src/lib/models/OAuthParam.d.ts +9 -0
- package/src/lib/models/OAuthType.d.ts +7 -0
- package/src/lib/models/PagedResult.d.ts +9 -0
- package/src/lib/models/PasswordRequestParam.d.ts +5 -0
- package/src/lib/models/PermissionConfig.d.ts +7 -0
- package/src/lib/models/ResponseKeyValue.d.ts +5 -0
- package/src/lib/models/Role.d.ts +9 -0
- package/src/lib/models/RoleAction.d.ts +10 -0
- package/src/lib/models/RoleContext.d.ts +10 -0
- package/src/lib/models/Schedule.d.ts +22 -0
- package/src/lib/models/ScheduleType.d.ts +4 -0
- package/src/lib/models/SearchDynamicWrapper.d.ts +7 -0
- package/src/lib/models/SearchOperator.d.ts +4 -0
- package/src/lib/models/SearchPropertySign.d.ts +9 -0
- package/src/lib/models/SearchPropertyValue.d.ts +14 -0
- package/src/lib/models/SearchPropertyValueType.d.ts +9 -0
- package/src/lib/models/SortDirection.d.ts +5 -0
- package/src/lib/models/TaskUser.d.ts +10 -0
- package/src/lib/models/Tenant.d.ts +22 -0
- package/src/lib/models/TenantConfig.d.ts +20 -0
- package/src/lib/models/TenantPriority.d.ts +10 -0
- package/src/lib/models/Ticket.d.ts +21 -0
- package/src/lib/models/TicketMessage.d.ts +11 -0
- package/src/lib/models/TicketStatus.d.ts +6 -0
- package/src/lib/models/UserRequest.d.ts +32 -0
- package/src/lib/models/auth-mechanism.d.ts +14 -0
- package/src/lib/models/base.d.ts +12 -0
- package/src/lib/models/conditions.d.ts +11 -0
- package/src/lib/models/index.d.ts +1 -0
- package/src/lib/models/log-in.d.ts +8 -0
- package/src/lib/models/mainUser.d.ts +19 -0
- package/src/lib/models/oauth-resp.d.ts +6 -0
- package/src/lib/models/oauth-response.d.ts +6 -0
- package/src/lib/models/object-state.d.ts +6 -0
- package/src/lib/models/otpValue.d.ts +9 -0
- package/src/lib/models/paged.d.ts +9 -0
- package/src/lib/models/public-api.d.ts +56 -0
- package/src/lib/models/query-params.d.ts +7 -0
- package/src/lib/models/request-status.d.ts +3 -0
- package/src/lib/models/resend-otp-data.d.ts +8 -0
- package/src/lib/models/sign-up.d.ts +9 -0
- package/src/lib/models/single-sign-on.d.ts +7 -0
- package/src/lib/models/status.d.ts +4 -0
- package/src/lib/models/user-access-request-status.d.ts +5 -0
- package/src/lib/models/user-access-request.d.ts +9 -0
- package/src/lib/models/user-management.d.ts +8 -0
- package/src/lib/models/user.d.ts +24 -0
- package/src/lib/pipes/async-label.pipe.d.ts +11 -0
- package/src/lib/pipes/company-date.pipe.d.ts +10 -0
- package/src/lib/pipes/ellipse-word.pipe.d.ts +8 -0
- package/src/lib/pipes/index.d.ts +1 -0
- package/src/lib/pipes/public-api.d.ts +3 -0
- package/src/lib/services/company-settings.service.d.ts +11 -0
- package/src/lib/services/environment.service.d.ts +22 -0
- package/src/lib/services/http-web-request.service.d.ts +24 -0
- package/src/lib/services/import.service.d.ts +14 -0
- package/src/lib/services/index.d.ts +1 -0
- package/src/lib/services/label.service.d.ts +24 -0
- package/src/lib/services/public-api.d.ts +7 -0
- package/src/lib/services/shared.service.d.ts +16 -0
- package/src/lib/services/util.service.d.ts +15 -0
- package/src/utils/components/base-data-view.component.d.ts +34 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/models/DataViewConfig.d.ts +11 -0
- package/src/utils/public-api.d.ts +2 -0
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, Optional } from '@angular/core';
|
|
3
|
+
import { ErrorResponse, ObjectState, SearchOperator, SearchPropertySign } from 'verben-ticketing-ui/src/lib/models';
|
|
4
|
+
import * as i1 from '@angular/common/http';
|
|
5
|
+
import * as i3 from 'verben-ng-ui';
|
|
6
|
+
import { UTIL_SERVICE } from 'verben-ng-ui';
|
|
7
|
+
import * as i1$1 from '@angular/router';
|
|
8
|
+
import { DEFAULT_PAGE_SIZE } from 'verben-ticketing-ui/src/lib/constants';
|
|
9
|
+
|
|
10
|
+
// In your library's services/environment.service.ts
|
|
11
|
+
// import { ENVIRONMENT } from '../models/ENVIRONMENT_TOKEN';
|
|
12
|
+
const ENVIRONMENT = new InjectionToken('environment');
|
|
13
|
+
class EnvironmentService {
|
|
14
|
+
env;
|
|
15
|
+
constructor(env) {
|
|
16
|
+
this.env = env;
|
|
17
|
+
}
|
|
18
|
+
get environment() {
|
|
19
|
+
return this.env;
|
|
20
|
+
}
|
|
21
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EnvironmentService, deps: [{ token: ENVIRONMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
22
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EnvironmentService, providedIn: 'root' });
|
|
23
|
+
}
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EnvironmentService, decorators: [{
|
|
25
|
+
type: Injectable,
|
|
26
|
+
args: [{
|
|
27
|
+
providedIn: 'root',
|
|
28
|
+
}]
|
|
29
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
30
|
+
type: Inject,
|
|
31
|
+
args: [ENVIRONMENT]
|
|
32
|
+
}] }] });
|
|
33
|
+
|
|
34
|
+
class HttpWebRequestService {
|
|
35
|
+
http;
|
|
36
|
+
envSvc;
|
|
37
|
+
notificationService;
|
|
38
|
+
isProd;
|
|
39
|
+
constructor(http, envSvc, notificationService) {
|
|
40
|
+
this.http = http;
|
|
41
|
+
this.envSvc = envSvc;
|
|
42
|
+
this.notificationService = notificationService;
|
|
43
|
+
this.isProd = this.envSvc.environment.production;
|
|
44
|
+
}
|
|
45
|
+
buildHeaders() {
|
|
46
|
+
const customToken = this.envSvc.environment.Token;
|
|
47
|
+
console.log({ CustomerToken: customToken });
|
|
48
|
+
return customToken
|
|
49
|
+
? {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
'X-Custom-Auth': customToken,
|
|
52
|
+
Authorization: customToken,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJNYWlsQWRkcmVzcyI6InZlcmJlbmFAZ21haWwuY29tIiwiQXBwbGljYXRpb24iOiIiLCJOYW1lIjoiVmVyYmVuYSBMb2dpYyBMaW1pdGVkIiwiUm9sZXMiOiIiLCJUZW5hbnRJZCI6IlBETFRDNiIsIlNlcnZpY2VOYW1lIjoiV2hpdGUzNjAiLCJuYmYiOjE3MzYxNjM1OTYsImV4cCI6MTczNjM3OTU5NiwiaWF0IjoxNzM2MTYzNTk2fQ.q5ErmDIP0NwKKRlVeb9_EfmrEfd8gsFzkNNszkTeTg4',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
buildUrl(url, baseUrl) {
|
|
60
|
+
return `${baseUrl}/${url}`;
|
|
61
|
+
}
|
|
62
|
+
handleError(err) {
|
|
63
|
+
const msg = err?.ErrorMsg ||
|
|
64
|
+
err?.errors?.values?.toString() ||
|
|
65
|
+
`Error occurred`;
|
|
66
|
+
this.notificationService.error(msg, { timeout: 10000 });
|
|
67
|
+
return new ErrorResponse(msg);
|
|
68
|
+
}
|
|
69
|
+
request(method, url, body, baseUrl = this.envSvc.environment.AuthenticationAPI) {
|
|
70
|
+
const options = {
|
|
71
|
+
headers: this.buildHeaders(),
|
|
72
|
+
};
|
|
73
|
+
const requestUrl = this.buildUrl(url, baseUrl);
|
|
74
|
+
switch (method) {
|
|
75
|
+
case 'GET':
|
|
76
|
+
return new Promise((resolve) => this.http.get(requestUrl, options).subscribe({
|
|
77
|
+
next: resolve,
|
|
78
|
+
error: (err) => resolve(this.handleError(err)),
|
|
79
|
+
}));
|
|
80
|
+
case 'POST':
|
|
81
|
+
return new Promise((resolve) => this.http.post(requestUrl, body, options).subscribe({
|
|
82
|
+
next: resolve,
|
|
83
|
+
error: (err) => resolve(this.handleError(err)),
|
|
84
|
+
}));
|
|
85
|
+
case 'POST_NO_ERROR':
|
|
86
|
+
return new Promise((resolve) => this.http.post(requestUrl, body, options).subscribe({
|
|
87
|
+
next: resolve,
|
|
88
|
+
}));
|
|
89
|
+
case 'PUT':
|
|
90
|
+
return this.http.put(requestUrl, body, options);
|
|
91
|
+
case 'DELETE':
|
|
92
|
+
return this.http.delete(requestUrl, options);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
get(url, baseUrl) {
|
|
96
|
+
return this.request('GET', url, undefined, baseUrl);
|
|
97
|
+
}
|
|
98
|
+
post(url, body, baseUrl) {
|
|
99
|
+
return this.request('POST', url, JSON.stringify(body), baseUrl);
|
|
100
|
+
}
|
|
101
|
+
postNoError(url, body, baseUrl) {
|
|
102
|
+
return this.request('POST_NO_ERROR', url, JSON.stringify(body), baseUrl);
|
|
103
|
+
}
|
|
104
|
+
postFile(url, formData, baseUrl) {
|
|
105
|
+
return new Promise((resolve) => this.http
|
|
106
|
+
.post(this.buildUrl(url, baseUrl || this.envSvc.environment.AuthenticationAPI), formData)
|
|
107
|
+
.subscribe({
|
|
108
|
+
next: resolve,
|
|
109
|
+
error: (err) => resolve(this.handleError(err)),
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
put(url, body, baseUrl) {
|
|
113
|
+
return this.request('PUT', url, body, baseUrl);
|
|
114
|
+
}
|
|
115
|
+
delete(url, baseUrl) {
|
|
116
|
+
return this.request('DELETE', url, undefined, baseUrl);
|
|
117
|
+
}
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HttpWebRequestService, deps: [{ token: i1.HttpClient }, { token: EnvironmentService }, { token: i3.NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
119
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HttpWebRequestService, providedIn: 'root' });
|
|
120
|
+
}
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HttpWebRequestService, decorators: [{
|
|
122
|
+
type: Injectable,
|
|
123
|
+
args: [{
|
|
124
|
+
providedIn: 'root',
|
|
125
|
+
}]
|
|
126
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: EnvironmentService }, { type: i3.NotificationService }] });
|
|
127
|
+
|
|
128
|
+
class UtilService {
|
|
129
|
+
parentUtilService;
|
|
130
|
+
route;
|
|
131
|
+
constructor(parentUtilService, route) {
|
|
132
|
+
this.parentUtilService = parentUtilService;
|
|
133
|
+
this.route = route;
|
|
134
|
+
}
|
|
135
|
+
sendBI(state) {
|
|
136
|
+
if (this.parentUtilService && this.parentUtilService.sendBI) {
|
|
137
|
+
this.parentUtilService.sendBI(state);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
console.warn('Util Service is not provided');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
showInfo(message) {
|
|
144
|
+
if (this.parentUtilService && this.parentUtilService.showInfo) {
|
|
145
|
+
this.parentUtilService.showInfo(message);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.warn('Util Service is not provided');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
showSuccess(message) {
|
|
152
|
+
if (this.parentUtilService && this.parentUtilService.showSuccess) {
|
|
153
|
+
this.parentUtilService.showSuccess(message);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
console.warn('Util Service is not provided');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
goToPage(page, extra) {
|
|
160
|
+
if (extra && typeof extra === 'object') {
|
|
161
|
+
this.route.navigate([`/${page}`], { queryParams: extra });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (extra) {
|
|
165
|
+
this.route.navigate([`/${page}`, extra]);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.route.navigate([`/${page}`]);
|
|
169
|
+
}
|
|
170
|
+
openFullRouteInNewWindow(url) {
|
|
171
|
+
window.open(url, '_blank');
|
|
172
|
+
}
|
|
173
|
+
showError(message) {
|
|
174
|
+
if (this.parentUtilService && this.parentUtilService.showError) {
|
|
175
|
+
this.parentUtilService.showError(message);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
console.warn('Util Service is not provided');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UtilService, deps: [{ token: UTIL_SERVICE, optional: true }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
182
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UtilService, providedIn: 'root' });
|
|
183
|
+
}
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UtilService, decorators: [{
|
|
185
|
+
type: Injectable,
|
|
186
|
+
args: [{
|
|
187
|
+
providedIn: 'root',
|
|
188
|
+
}]
|
|
189
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
190
|
+
type: Optional
|
|
191
|
+
}, {
|
|
192
|
+
type: Inject,
|
|
193
|
+
args: [UTIL_SERVICE]
|
|
194
|
+
}] }, { type: i1$1.Router }] });
|
|
195
|
+
|
|
196
|
+
class ImportService {
|
|
197
|
+
utilService;
|
|
198
|
+
server;
|
|
199
|
+
constructor(utilService, server //private cdr: ChangeDetectorRef
|
|
200
|
+
) {
|
|
201
|
+
this.utilService = utilService;
|
|
202
|
+
this.server = server;
|
|
203
|
+
}
|
|
204
|
+
// onComplete(
|
|
205
|
+
// event: any[],
|
|
206
|
+
// defaults: T,
|
|
207
|
+
// endpoint: string | null,
|
|
208
|
+
// baseUrl: string,
|
|
209
|
+
// dataRef: T[],
|
|
210
|
+
// cardDataRef: CardData[],
|
|
211
|
+
// pagedState: PagedResult<T> | null = null,
|
|
212
|
+
// stringProps: (keyof T)[] = []
|
|
213
|
+
// ) {
|
|
214
|
+
// const normalized = event.map((raw) => {
|
|
215
|
+
// const def = defaults;
|
|
216
|
+
// let merged: T = {
|
|
217
|
+
// ...def,
|
|
218
|
+
// ...raw,
|
|
219
|
+
// Code: raw.Code ? String(raw.Code) : '',
|
|
220
|
+
// };
|
|
221
|
+
// stringProps.forEach((key) => {
|
|
222
|
+
// const value = raw[key];
|
|
223
|
+
// merged[key] = value != null ? String(value) : ('' as any);
|
|
224
|
+
// });
|
|
225
|
+
// const dateProps: (keyof T)[] = ['CreatedAt', 'UpdatedAt'];
|
|
226
|
+
// dateProps.forEach((key) => {
|
|
227
|
+
// const val = merged[key];
|
|
228
|
+
// let dateObj: Date;
|
|
229
|
+
// if (val instanceof Date) {
|
|
230
|
+
// dateObj = val;
|
|
231
|
+
// } else if (typeof val === 'number') {
|
|
232
|
+
// dateObj = this.excelSerialToDate(val);
|
|
233
|
+
// } else if (typeof val === 'string') {
|
|
234
|
+
// dateObj = new Date(val);
|
|
235
|
+
// } else {
|
|
236
|
+
// dateObj = new Date();
|
|
237
|
+
// }
|
|
238
|
+
// if (isNaN(dateObj.getTime())) {
|
|
239
|
+
// dateObj = new Date();
|
|
240
|
+
// }
|
|
241
|
+
// merged[key] = dateObj.toISOString() as any;
|
|
242
|
+
// });
|
|
243
|
+
// return merged;
|
|
244
|
+
// });
|
|
245
|
+
// if (normalized && normalized.length > 0) {
|
|
246
|
+
// this.saveImportedDataBatch(
|
|
247
|
+
// normalized,
|
|
248
|
+
// endpoint,
|
|
249
|
+
// baseUrl,
|
|
250
|
+
// dataRef,
|
|
251
|
+
// cardDataRef,
|
|
252
|
+
// pagedState
|
|
253
|
+
// );
|
|
254
|
+
// }
|
|
255
|
+
// }
|
|
256
|
+
// async saveImportedDataBatch(
|
|
257
|
+
// items: T[],
|
|
258
|
+
// endpoint: string | null,
|
|
259
|
+
// baseUrl: string,
|
|
260
|
+
// dataRef: T[],
|
|
261
|
+
// cardDataRef: CardData[],
|
|
262
|
+
// pagedState: PagedResult<T> | null = null
|
|
263
|
+
// ) {
|
|
264
|
+
// if (!items?.length) return;
|
|
265
|
+
// const preparedItems = items.map((item) => ({
|
|
266
|
+
// ...item,
|
|
267
|
+
// DataState: ObjectState.New,
|
|
268
|
+
// Id: '',
|
|
269
|
+
// }));
|
|
270
|
+
// if (!endpoint) {
|
|
271
|
+
// preparedItems.forEach((srv, idx) => {
|
|
272
|
+
// const newItem = {
|
|
273
|
+
// ...srv,
|
|
274
|
+
// Id: dataRef.length.toString(),
|
|
275
|
+
// id: dataRef.length.toString(),
|
|
276
|
+
// };
|
|
277
|
+
// const cardData: CardData = {
|
|
278
|
+
// selected: false,
|
|
279
|
+
// title: newItem.Id.toString(),
|
|
280
|
+
// data: newItem,
|
|
281
|
+
// body: [],
|
|
282
|
+
// children: [],
|
|
283
|
+
// };
|
|
284
|
+
// dataRef.push(newItem);
|
|
285
|
+
// cardDataRef.push(cardData);
|
|
286
|
+
// if (pagedState) {
|
|
287
|
+
// pagedState.Skip += 1;
|
|
288
|
+
// }
|
|
289
|
+
// });
|
|
290
|
+
// return;
|
|
291
|
+
// }
|
|
292
|
+
// this.utilService.sendBI(true);
|
|
293
|
+
// const res = await this.server.post(endpoint, preparedItems, baseUrl);
|
|
294
|
+
// this.utilService.sendBI(false);
|
|
295
|
+
// if (res instanceof ErrorResponse) {
|
|
296
|
+
// return;
|
|
297
|
+
// } else {
|
|
298
|
+
// this.utilService.showSuccess('Operation Account saved successfully');
|
|
299
|
+
// const result = res as T[];
|
|
300
|
+
// result.forEach((srv, idx) => {
|
|
301
|
+
// const newItem = {
|
|
302
|
+
// ...srv,
|
|
303
|
+
// Id: srv.Code,
|
|
304
|
+
// id: srv.Code,
|
|
305
|
+
// };
|
|
306
|
+
// const cardData: CardData = {
|
|
307
|
+
// selected: false,
|
|
308
|
+
// title: newItem.Id.toString(),
|
|
309
|
+
// data: newItem,
|
|
310
|
+
// body: [],
|
|
311
|
+
// children: [],
|
|
312
|
+
// };
|
|
313
|
+
// dataRef.push(newItem);
|
|
314
|
+
// // this.cdr.detectChanges();
|
|
315
|
+
// cardDataRef.push(cardData);
|
|
316
|
+
// if (pagedState) {
|
|
317
|
+
// pagedState.Skip += 1;
|
|
318
|
+
// }
|
|
319
|
+
// });
|
|
320
|
+
// }
|
|
321
|
+
// }
|
|
322
|
+
onComplete(event, defaults, endpoint, baseUrl, entity, updateCallback, pagedState = null, stringProps = [], numberProps = [], datePropsExtras = []) {
|
|
323
|
+
const normalized = event.map((raw) => {
|
|
324
|
+
const def = defaults;
|
|
325
|
+
let merged = {
|
|
326
|
+
...def,
|
|
327
|
+
...raw,
|
|
328
|
+
Code: raw.Code ? String(raw.Code) : '',
|
|
329
|
+
};
|
|
330
|
+
stringProps.forEach((key) => {
|
|
331
|
+
const value = raw[key];
|
|
332
|
+
merged[key] = value != null ? String(value) : '';
|
|
333
|
+
});
|
|
334
|
+
numberProps.forEach((key) => {
|
|
335
|
+
const value = raw[key];
|
|
336
|
+
if (typeof value === 'string') {
|
|
337
|
+
// Only parse if it's a valid number
|
|
338
|
+
const num = value === '' || isNaN(Number(value)) ? 0 : Number(value);
|
|
339
|
+
merged[key] = num;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
merged[key] = value;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
const dateProps = ['CreatedAt', 'UpdatedAt'].concat(datePropsExtras);
|
|
346
|
+
dateProps.forEach((key) => {
|
|
347
|
+
const val = merged[key];
|
|
348
|
+
let dateObj;
|
|
349
|
+
if (val instanceof Date) {
|
|
350
|
+
dateObj = val;
|
|
351
|
+
}
|
|
352
|
+
else if (typeof val === 'number') {
|
|
353
|
+
dateObj = this.excelSerialToDate(val);
|
|
354
|
+
}
|
|
355
|
+
else if (typeof val === 'string') {
|
|
356
|
+
dateObj = new Date(val);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
dateObj = new Date();
|
|
360
|
+
}
|
|
361
|
+
if (isNaN(dateObj.getTime())) {
|
|
362
|
+
dateObj = new Date();
|
|
363
|
+
}
|
|
364
|
+
merged[key] = dateObj;
|
|
365
|
+
});
|
|
366
|
+
return merged;
|
|
367
|
+
});
|
|
368
|
+
if (normalized && normalized.length > 0) {
|
|
369
|
+
this.saveImportedDataBatch(normalized, endpoint, baseUrl, entity, updateCallback, pagedState);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async saveImportedDataBatch(items, endpoint, baseUrl, entity, updateCallback, pagedState = null) {
|
|
373
|
+
if (!items?.length)
|
|
374
|
+
return;
|
|
375
|
+
const preparedItems = items.map((item) => ({
|
|
376
|
+
...item,
|
|
377
|
+
DataState: ObjectState.New,
|
|
378
|
+
Id: '',
|
|
379
|
+
}));
|
|
380
|
+
if (!endpoint) {
|
|
381
|
+
preparedItems.forEach((srv, idx) => {
|
|
382
|
+
srv.Id = `UPLOAD ${idx}`;
|
|
383
|
+
// srv.id = `UPLOAD ${idx}`;
|
|
384
|
+
});
|
|
385
|
+
updateCallback(preparedItems);
|
|
386
|
+
if (pagedState) {
|
|
387
|
+
pagedState.Skip += preparedItems.length;
|
|
388
|
+
}
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
this.utilService.sendBI(true);
|
|
392
|
+
const res = await this.server.post(endpoint, preparedItems, baseUrl);
|
|
393
|
+
this.utilService.sendBI(false);
|
|
394
|
+
if (res instanceof ErrorResponse) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
this.utilService.showSuccess(`${entity} upload successful`);
|
|
399
|
+
const result = res;
|
|
400
|
+
result.forEach((srv, idx) => {
|
|
401
|
+
srv.Id = srv.Code;
|
|
402
|
+
// srv.id = srv.Code;
|
|
403
|
+
// const newItem = {
|
|
404
|
+
// ...srv,
|
|
405
|
+
// Id: srv.Code,
|
|
406
|
+
// id: srv.Code,
|
|
407
|
+
// };
|
|
408
|
+
// const cardData: CardData = {
|
|
409
|
+
// selected: false,
|
|
410
|
+
// title: newItem.Id.toString(),
|
|
411
|
+
// data: newItem,
|
|
412
|
+
// body: [],
|
|
413
|
+
// children: [],
|
|
414
|
+
// };
|
|
415
|
+
});
|
|
416
|
+
updateCallback(result);
|
|
417
|
+
if (pagedState) {
|
|
418
|
+
pagedState.Skip += result.length;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
excelSerialToDate(serial) {
|
|
423
|
+
1;
|
|
424
|
+
const excelEpoch = new Date(Date.UTC(1899, 11, 30));
|
|
425
|
+
const millisPerDay = 24 * 60 * 60 * 1000;
|
|
426
|
+
return new Date(excelEpoch.getTime() + serial * millisPerDay);
|
|
427
|
+
}
|
|
428
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ImportService, deps: [{ token: UtilService }, { token: HttpWebRequestService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
429
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ImportService, providedIn: 'root' });
|
|
430
|
+
}
|
|
431
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ImportService, decorators: [{
|
|
432
|
+
type: Injectable,
|
|
433
|
+
args: [{
|
|
434
|
+
providedIn: 'root',
|
|
435
|
+
}]
|
|
436
|
+
}], ctorParameters: () => [{ type: UtilService }, { type: HttpWebRequestService }] });
|
|
437
|
+
|
|
438
|
+
class LabelService {
|
|
439
|
+
utilService;
|
|
440
|
+
server;
|
|
441
|
+
cache = new Map();
|
|
442
|
+
inFlightRequests = new Map();
|
|
443
|
+
batchedRequests = new Map();
|
|
444
|
+
tempStore = new Map();
|
|
445
|
+
batchingDelay = 50; // Sliding debounce delay in ms
|
|
446
|
+
cacheInProgress = new Map();
|
|
447
|
+
constructor(utilService, server) {
|
|
448
|
+
this.utilService = utilService;
|
|
449
|
+
this.server = server;
|
|
450
|
+
}
|
|
451
|
+
async getAsyncLabel(value, entity, labelProp, env, key = 'Code') {
|
|
452
|
+
const cacheKey = `${entity}_${labelProp}_${value}_${env}_${key}`;
|
|
453
|
+
if (this.cache.has(cacheKey)) {
|
|
454
|
+
const value = this.cache.get(cacheKey);
|
|
455
|
+
return value;
|
|
456
|
+
}
|
|
457
|
+
var payload = {
|
|
458
|
+
Fields: [labelProp],
|
|
459
|
+
SearchKeyValues: [
|
|
460
|
+
{
|
|
461
|
+
PropertyName: key,
|
|
462
|
+
EntityValue: value,
|
|
463
|
+
Operator: SearchOperator.And,
|
|
464
|
+
Sign: SearchPropertySign.EQ,
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
};
|
|
468
|
+
this.utilService.sendBI(true);
|
|
469
|
+
const res = await this.server.postNoError(`SearchDynamic${entity}/0/1`, payload, env);
|
|
470
|
+
this.utilService.sendBI(false);
|
|
471
|
+
if (res instanceof ErrorResponse) {
|
|
472
|
+
return value;
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
const result = res.Result;
|
|
476
|
+
const label = result.length > 0 ? result[0] : value;
|
|
477
|
+
this.cache.set(cacheKey, label);
|
|
478
|
+
return label;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
async getAsyncLabelWithRequestTracking(value, entity, labelProp, env, key = 'Code') {
|
|
482
|
+
const cacheKey = `${entity}_${labelProp}_${value}_${env}_${key}`;
|
|
483
|
+
if (this.cache.has(cacheKey)) {
|
|
484
|
+
return this.cache.get(cacheKey);
|
|
485
|
+
}
|
|
486
|
+
if (this.inFlightRequests.has(cacheKey)) {
|
|
487
|
+
return this.inFlightRequests.get(cacheKey);
|
|
488
|
+
}
|
|
489
|
+
const requestPromise = (async () => {
|
|
490
|
+
const payload = {
|
|
491
|
+
Fields: [labelProp],
|
|
492
|
+
SearchKeyValues: [
|
|
493
|
+
{
|
|
494
|
+
PropertyName: key,
|
|
495
|
+
EntityValue: value,
|
|
496
|
+
Operator: SearchOperator.And,
|
|
497
|
+
Sign: SearchPropertySign.EQ,
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
};
|
|
501
|
+
this.utilService.sendBI(true);
|
|
502
|
+
const res = await this.server.post(`SearchDynamic${entity}/0/1`, payload, env);
|
|
503
|
+
this.utilService.sendBI(false);
|
|
504
|
+
let label;
|
|
505
|
+
if (res instanceof ErrorResponse) {
|
|
506
|
+
label = '';
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
const result = res.Result;
|
|
510
|
+
label = result.length > 0 ? result[0] : value;
|
|
511
|
+
}
|
|
512
|
+
this.cache.set(cacheKey, label);
|
|
513
|
+
this.inFlightRequests.delete(cacheKey);
|
|
514
|
+
return label;
|
|
515
|
+
})();
|
|
516
|
+
// Save the in-flight request
|
|
517
|
+
this.inFlightRequests.set(cacheKey, requestPromise);
|
|
518
|
+
return requestPromise;
|
|
519
|
+
}
|
|
520
|
+
async getAsyncLabelWithRequestTrackingNoGateway(value, entity, labelProp, env, controller, key = 'Code') {
|
|
521
|
+
const cacheKey = `${entity}_${labelProp}_${value}_${env}_${key}_${controller}`;
|
|
522
|
+
if (this.cache.has(cacheKey)) {
|
|
523
|
+
return this.cache.get(cacheKey);
|
|
524
|
+
}
|
|
525
|
+
if (this.inFlightRequests.has(cacheKey)) {
|
|
526
|
+
return this.inFlightRequests.get(cacheKey);
|
|
527
|
+
}
|
|
528
|
+
const requestPromise = (async () => {
|
|
529
|
+
const payload = {
|
|
530
|
+
Fields: [labelProp],
|
|
531
|
+
SearchKeyValues: [
|
|
532
|
+
{
|
|
533
|
+
PropertyName: key,
|
|
534
|
+
EntityValue: value,
|
|
535
|
+
Operator: SearchOperator.And,
|
|
536
|
+
Sign: SearchPropertySign.EQ,
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
};
|
|
540
|
+
this.utilService.sendBI(true);
|
|
541
|
+
const res = await this.server.post(`${controller}/SearchDynamic${entity}s/0/1`, payload, env);
|
|
542
|
+
this.utilService.sendBI(false);
|
|
543
|
+
let label;
|
|
544
|
+
if (res instanceof ErrorResponse) {
|
|
545
|
+
label = '';
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
const result = res.Result;
|
|
549
|
+
label = result.length > 0 ? result[0] : value;
|
|
550
|
+
}
|
|
551
|
+
this.cache.set(cacheKey, label);
|
|
552
|
+
this.inFlightRequests.delete(cacheKey);
|
|
553
|
+
return label;
|
|
554
|
+
})();
|
|
555
|
+
// Save the in-flight request
|
|
556
|
+
this.inFlightRequests.set(cacheKey, requestPromise);
|
|
557
|
+
return requestPromise;
|
|
558
|
+
}
|
|
559
|
+
async getAsyncLabelWithBatching(value, entity, labelProp, env, key = 'Code') {
|
|
560
|
+
const batchKey = `${entity}_${labelProp}_${env}_${key}`;
|
|
561
|
+
const cacheKey = `${batchKey}_${value}`;
|
|
562
|
+
if (this.cacheInProgress.has(batchKey)) {
|
|
563
|
+
await this.cacheInProgress.get(batchKey);
|
|
564
|
+
}
|
|
565
|
+
// Return from cache if available
|
|
566
|
+
if (this.cache.has(cacheKey)) {
|
|
567
|
+
return this.cache.get(cacheKey);
|
|
568
|
+
}
|
|
569
|
+
const store = this.tempStore.get(batchKey);
|
|
570
|
+
if (store) {
|
|
571
|
+
const item = store.find((x) => x.Key == value);
|
|
572
|
+
if (item) {
|
|
573
|
+
return item.Value;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return value;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return new Promise((resolve, reject) => {
|
|
580
|
+
let batch = this.batchedRequests.get(batchKey);
|
|
581
|
+
if (!batch) {
|
|
582
|
+
batch = {
|
|
583
|
+
codes: new Set(),
|
|
584
|
+
resolvers: new Map(),
|
|
585
|
+
rejectors: new Map(),
|
|
586
|
+
timer: null,
|
|
587
|
+
};
|
|
588
|
+
this.batchedRequests.set(batchKey, batch);
|
|
589
|
+
}
|
|
590
|
+
// Add current request to batch
|
|
591
|
+
batch.codes.add(value);
|
|
592
|
+
if (!batch.resolvers.has(value)) {
|
|
593
|
+
batch.resolvers.set(value, []);
|
|
594
|
+
batch.rejectors.set(value, []);
|
|
595
|
+
}
|
|
596
|
+
batch.resolvers.get(value).push(resolve);
|
|
597
|
+
batch.rejectors.get(value).push(reject);
|
|
598
|
+
// Reset debounce timer
|
|
599
|
+
if (batch.timer)
|
|
600
|
+
clearTimeout(batch.timer);
|
|
601
|
+
batch.timer = setTimeout(async () => await this.flushBatch(batchKey), this.batchingDelay);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
async flushBatch(batchKey) {
|
|
605
|
+
const batch = this.batchedRequests.get(batchKey);
|
|
606
|
+
if (!batch)
|
|
607
|
+
return;
|
|
608
|
+
this.batchedRequests.delete(batchKey);
|
|
609
|
+
const [entity, labelProp, env, key] = batchKey.split('_');
|
|
610
|
+
const values = Array.from(batch.codes);
|
|
611
|
+
const payload = {
|
|
612
|
+
Fields: [key, labelProp],
|
|
613
|
+
SearchKeyValues: values.map((val) => ({
|
|
614
|
+
PropertyName: key,
|
|
615
|
+
EntityValue: val,
|
|
616
|
+
Operator: SearchOperator.Or,
|
|
617
|
+
Sign: SearchPropertySign.EQ,
|
|
618
|
+
})),
|
|
619
|
+
};
|
|
620
|
+
payload.SearchKeyValues.push({
|
|
621
|
+
PropertyName: 'TenantId',
|
|
622
|
+
EntityValue: '',
|
|
623
|
+
Operator: SearchOperator.And,
|
|
624
|
+
Sign: SearchPropertySign.NEQ,
|
|
625
|
+
});
|
|
626
|
+
this.utilService.sendBI(true);
|
|
627
|
+
const res = await this.server.post(`SearchDynamic${entity}/0/0`, payload, env);
|
|
628
|
+
this.utilService.sendBI(false);
|
|
629
|
+
if (res instanceof ErrorResponse) {
|
|
630
|
+
for (const val of values) {
|
|
631
|
+
const resolvers = batch.resolvers.get(val) || [];
|
|
632
|
+
resolvers.forEach((r) => r(val));
|
|
633
|
+
}
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const resultArray = res.Result;
|
|
637
|
+
const labelMap = new Map();
|
|
638
|
+
resultArray.forEach((item) => {
|
|
639
|
+
labelMap.set(item[key], item[labelProp]);
|
|
640
|
+
});
|
|
641
|
+
for (const val of values) {
|
|
642
|
+
const label = labelMap.get(val) ?? val;
|
|
643
|
+
const cacheKey = `${batchKey}_${val}`;
|
|
644
|
+
this.cache.set(cacheKey, label);
|
|
645
|
+
const resolvers = batch.resolvers.get(val) || [];
|
|
646
|
+
resolvers.forEach((r) => r(label));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
async cacheData(items) {
|
|
650
|
+
for (let item of items) {
|
|
651
|
+
const batchKey = `${item.Entity}_${item.LabelProp}_${item.Environment}_${item.Key}`;
|
|
652
|
+
// Signal this batchKey is in progress
|
|
653
|
+
const inProgress = this._cacheSingleBatch(item, batchKey);
|
|
654
|
+
this.cacheInProgress.set(batchKey, inProgress);
|
|
655
|
+
await inProgress;
|
|
656
|
+
this.cacheInProgress.delete(batchKey);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
async _cacheSingleBatch(item, batchKey) {
|
|
660
|
+
if (item.Values.length == 0) {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const payload = {
|
|
664
|
+
Fields: [item.Key, item.LabelProp],
|
|
665
|
+
SearchKeyValues: item.Values.map((val) => ({
|
|
666
|
+
PropertyName: item.Key,
|
|
667
|
+
EntityValue: val,
|
|
668
|
+
Operator: SearchOperator.Or,
|
|
669
|
+
Sign: SearchPropertySign.EQ,
|
|
670
|
+
})),
|
|
671
|
+
};
|
|
672
|
+
this.utilService.sendBI(true);
|
|
673
|
+
const res = await this.server.post(`SearchDynamic${item.Entity}/0/0`, payload, item.Environment);
|
|
674
|
+
this.utilService.sendBI(false);
|
|
675
|
+
if (!(res instanceof ErrorResponse)) {
|
|
676
|
+
const resultArray = res.Result;
|
|
677
|
+
const keyValues = resultArray.map((x) => ({
|
|
678
|
+
Key: x[item.Key],
|
|
679
|
+
Value: x[item.LabelProp],
|
|
680
|
+
}));
|
|
681
|
+
this.tempStore.set(batchKey, keyValues);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LabelService, deps: [{ token: UtilService }, { token: HttpWebRequestService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
685
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LabelService, providedIn: 'root' });
|
|
686
|
+
}
|
|
687
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LabelService, decorators: [{
|
|
688
|
+
type: Injectable,
|
|
689
|
+
args: [{
|
|
690
|
+
providedIn: 'root',
|
|
691
|
+
}]
|
|
692
|
+
}], ctorParameters: () => [{ type: UtilService }, { type: HttpWebRequestService }] });
|
|
693
|
+
|
|
694
|
+
class SharedService {
|
|
695
|
+
utilService;
|
|
696
|
+
server;
|
|
697
|
+
envSvc;
|
|
698
|
+
pageSize = DEFAULT_PAGE_SIZE;
|
|
699
|
+
constructor(utilService, server, envSvc) {
|
|
700
|
+
this.utilService = utilService;
|
|
701
|
+
this.server = server;
|
|
702
|
+
this.envSvc = envSvc;
|
|
703
|
+
}
|
|
704
|
+
createCustomFile(base64data, index, file) {
|
|
705
|
+
const extension = file.name.split('.').pop();
|
|
706
|
+
const customFile = {
|
|
707
|
+
Extension: extension,
|
|
708
|
+
Name: file.name,
|
|
709
|
+
Data: base64data,
|
|
710
|
+
DataState: ObjectState.New,
|
|
711
|
+
};
|
|
712
|
+
return customFile;
|
|
713
|
+
}
|
|
714
|
+
async getAllPrioritiesForTenant(tenant) {
|
|
715
|
+
const payload = [
|
|
716
|
+
{
|
|
717
|
+
PropertyName: 'TenantId',
|
|
718
|
+
EntityValue: tenant,
|
|
719
|
+
Operator: SearchOperator.And,
|
|
720
|
+
Sign: SearchPropertySign.EQ,
|
|
721
|
+
},
|
|
722
|
+
];
|
|
723
|
+
this.utilService.sendBI(true);
|
|
724
|
+
const res = await this.server.post(`Ticket/SearchTenantPriority/0/0`, payload, this.envSvc.environment.TicketingAPI);
|
|
725
|
+
this.utilService.sendBI(false);
|
|
726
|
+
if (res instanceof ErrorResponse) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
var result = res;
|
|
731
|
+
return result;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SharedService, deps: [{ token: UtilService }, { token: HttpWebRequestService }, { token: EnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
735
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SharedService, providedIn: 'root' });
|
|
736
|
+
}
|
|
737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SharedService, decorators: [{
|
|
738
|
+
type: Injectable,
|
|
739
|
+
args: [{
|
|
740
|
+
providedIn: 'root',
|
|
741
|
+
}]
|
|
742
|
+
}], ctorParameters: () => [{ type: UtilService }, { type: HttpWebRequestService }, { type: EnvironmentService }] });
|
|
743
|
+
|
|
744
|
+
class CompanySettingsService {
|
|
745
|
+
locale = 'en-US';
|
|
746
|
+
numberDP = 2;
|
|
747
|
+
dateFormat = 'M/d/yyyy';
|
|
748
|
+
baseCurrency = 'NGN';
|
|
749
|
+
setSettings(data) {
|
|
750
|
+
this.locale = data.LocaleCode || 'en-US';
|
|
751
|
+
this.numberDP = data.NumberDP ?? 2;
|
|
752
|
+
this.dateFormat = data.DateFormat || 'M/d/yyyy';
|
|
753
|
+
this.baseCurrency = data.BaseCurrency;
|
|
754
|
+
}
|
|
755
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: CompanySettingsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
756
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: CompanySettingsService, providedIn: 'root' });
|
|
757
|
+
}
|
|
758
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: CompanySettingsService, decorators: [{
|
|
759
|
+
type: Injectable,
|
|
760
|
+
args: [{
|
|
761
|
+
providedIn: 'root',
|
|
762
|
+
}]
|
|
763
|
+
}] });
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Generated bundle index. Do not edit.
|
|
767
|
+
*/
|
|
768
|
+
|
|
769
|
+
export { CompanySettingsService, ENVIRONMENT, EnvironmentService, HttpWebRequestService, ImportService, LabelService, SharedService, UtilService };
|
|
770
|
+
//# sourceMappingURL=verben-ticketing-ui-src-lib-services.mjs.map
|