@tuki-io/tuki-widgets 0.0.65 → 0.0.67
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/.editorconfig +16 -16
- package/.vscode/extensions.json +4 -4
- package/.vscode/launch.json +20 -20
- package/.vscode/tasks.json +42 -42
- package/README.md +25 -25
- package/package.json +1 -1
- package/projects/tuki/widgets/README.md +24 -24
- package/projects/tuki/widgets/di2mt/public-api.ts +3 -3
- package/projects/tuki/widgets/di2mt/widgets/site-upgrade/site-upgrade.module.ts +1 -1
- package/projects/tuki/widgets/karma.conf.js +44 -44
- package/projects/tuki/widgets/ng-package.json +10 -7
- package/projects/tuki/widgets/package.json +1 -1
- package/projects/tuki/widgets/src/lib/widgets.component.spec.ts +23 -23
- package/projects/tuki/widgets/src/lib/widgets.component.ts +20 -20
- package/projects/tuki/widgets/src/lib/widgets.module.ts +16 -16
- package/projects/tuki/widgets/src/lib/widgets.service.spec.ts +16 -16
- package/projects/tuki/widgets/src/lib/widgets.service.ts +9 -9
- package/projects/tuki/widgets/src/public-api.ts +7 -7
- package/projects/tuki/widgets/src/test.ts +27 -27
- package/projects/tuki/widgets/styles.scss +572 -572
- package/projects/tuki/widgets/tsconfig.lib.json +36 -36
- package/projects/tuki/widgets/tsconfig.lib.prod.json +10 -10
- package/projects/tuki/widgets/tsconfig.spec.json +17 -17
- package/projects/tuki/widgets/user-device-manage/ng-package.json +7 -7
- package/projects/tuki/widgets/user-device-manage/public-api.ts +8 -8
- package/projects/tuki/widgets/user-device-manage/src/app.constants.ts +96 -96
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/arrow-left.svg +5 -5
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/arrow-right.svg +5 -5
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/close_icon_x.svg +3 -3
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/delete_icon.svg +5 -5
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/dragger-vertical-icon.svg +3 -3
- package/projects/tuki/widgets/user-device-manage/src/assets/icons/vartical_divider_icon.svg +3 -3
- package/projects/tuki/widgets/user-device-manage/src/classes/device.ts +292 -292
- package/projects/tuki/widgets/user-device-manage/src/classes/line-association-interface.ts +50 -50
- package/projects/tuki/widgets/user-device-manage/src/classes/line-association.ts +177 -177
- package/projects/tuki/widgets/user-device-manage/src/classes/line-call-info-display.ts +21 -21
- package/projects/tuki/widgets/user-device-manage/src/classes/line-directory.ts +41 -41
- package/projects/tuki/widgets/user-device-manage/src/classes/line.ts +144 -144
- package/projects/tuki/widgets/user-device-manage/src/classes/notification.ts +40 -40
- package/projects/tuki/widgets/user-device-manage/src/classes/recording-options.ts +6 -6
- package/projects/tuki/widgets/user-device-manage/src/classes/simplified-user.ts +169 -169
- package/projects/tuki/widgets/user-device-manage/src/classes/site-defaults.ts +167 -167
- package/projects/tuki/widgets/user-device-manage/src/classes/translation-pattern.ts +50 -50
- package/projects/tuki/widgets/user-device-manage/src/classes/types.ts +19 -19
- package/projects/tuki/widgets/user-device-manage/src/classes/user-interface.ts +225 -225
- package/projects/tuki/widgets/user-device-manage/src/classes/user.ts +8 -8
- package/projects/tuki/widgets/user-device-manage/src/common-functions.ts +16 -16
- package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.html +14 -14
- package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.scss +80 -80
- package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.ts +35 -35
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.html +21 -21
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.scss +97 -97
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.ts +28 -28
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.html +5 -5
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.scss +19 -19
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.ts +13 -13
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.html +6 -6
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.scss +4 -4
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.ts +63 -63
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.html +241 -241
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.scss +500 -500
- package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.ts +194 -194
- package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.html +27 -27
- package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.scss +131 -131
- package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.ts +25 -25
- package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.html +209 -209
- package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.scss +502 -502
- package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.ts +354 -354
- package/projects/tuki/widgets/user-device-manage/src/environments/environment.prod.ts +9 -9
- package/projects/tuki/widgets/user-device-manage/src/environments/environment.ts +10 -10
- package/projects/tuki/widgets/user-device-manage/src/interseptors/auth.interceptor.ts +35 -35
- package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.html +50 -50
- package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.scss +8 -8
- package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.ts +81 -81
- package/projects/tuki/widgets/user-device-manage/src/material.module.ts +87 -87
- package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.html +33 -33
- package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.scss +84 -84
- package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.ts +46 -46
- package/projects/tuki/widgets/user-device-manage/src/removeKynFromIBM.service.ts +25 -25
- package/projects/tuki/widgets/user-device-manage/src/services/api.service.ts +87 -87
- package/projects/tuki/widgets/user-device-manage/src/services/common-functions.ts +17 -17
- package/projects/tuki/widgets/user-device-manage/src/services/device.service.ts +95 -95
- package/projects/tuki/widgets/user-device-manage/src/services/dns.service.ts +111 -111
- package/projects/tuki/widgets/user-device-manage/src/services/line.service.ts +89 -89
- package/projects/tuki/widgets/user-device-manage/src/services/notification.service.ts +68 -68
- package/projects/tuki/widgets/user-device-manage/src/services/removeKynFromIBM.service.ts +25 -25
- package/projects/tuki/widgets/user-device-manage/src/services/site-settings.service.ts +82 -82
- package/projects/tuki/widgets/user-device-manage/src/services/sorting-utils.service.ts +203 -203
- package/projects/tuki/widgets/user-device-manage/src/services/user.service.ts +283 -283
- package/projects/tuki/widgets/user-device-manage/src/services/utils.service.ts +87 -87
- package/projects/tuki/widgets/user-device-manage/src/services/validation.service.ts +829 -829
- package/projects/tuki/widgets/user-device-manage/src/styles/_variables.scss +90 -90
- package/projects/tuki/widgets/user-device-manage/src/styles/form.scss +231 -231
- package/projects/tuki/widgets/user-device-manage/src/styles/icons.scss +32 -32
- package/projects/tuki/widgets/user-device-manage/src/styles/styles.scss +110 -110
- package/projects/tuki/widgets/user-device-manage/src/styles/tables.scss +30 -30
- package/projects/tuki/widgets/user-device-manage/src/user-device-manage.module.ts +73 -73
- package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.component.html +6 -6
- package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.component.scss +11 -11
- package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.ts +13 -13
- package/projects/tuki/widgets/user-manage/ng-package.json +7 -7
- package/projects/tuki/widgets/user-manage/public-api.ts +6 -6
- package/projects/tuki/widgets/user-manage/src/app.constants.ts +50 -50
- package/projects/tuki/widgets/user-manage/src/assets/icons/arrow-left.svg +5 -5
- package/projects/tuki/widgets/user-manage/src/assets/icons/arrow-right.svg +5 -5
- package/projects/tuki/widgets/user-manage/src/assets/icons/delete_icon.svg +5 -5
- package/projects/tuki/widgets/user-manage/src/assets/icons/dragger-vertical-icon.svg +3 -3
- package/projects/tuki/widgets/user-manage/src/assets/icons/vartical_divider_icon.svg +3 -3
- package/projects/tuki/widgets/user-manage/src/classes/device.ts +232 -232
- package/projects/tuki/widgets/user-manage/src/classes/line-association-interface.ts +43 -43
- package/projects/tuki/widgets/user-manage/src/classes/line-association.ts +161 -161
- package/projects/tuki/widgets/user-manage/src/classes/line-call-info-display.ts +21 -21
- package/projects/tuki/widgets/user-manage/src/classes/line-directory.ts +42 -42
- package/projects/tuki/widgets/user-manage/src/classes/line.ts +144 -144
- package/projects/tuki/widgets/user-manage/src/classes/notification.ts +39 -39
- package/projects/tuki/widgets/user-manage/src/classes/pagination.ts +18 -18
- package/projects/tuki/widgets/user-manage/src/classes/recording-options.ts +6 -6
- package/projects/tuki/widgets/user-manage/src/classes/simplified-user.ts +165 -165
- package/projects/tuki/widgets/user-manage/src/classes/table-data.ts +6 -6
- package/projects/tuki/widgets/user-manage/src/classes/translation-pattern.ts +49 -49
- package/projects/tuki/widgets/user-manage/src/classes/user-interface.ts +225 -225
- package/projects/tuki/widgets/user-manage/src/classes/user-list.ts +42 -42
- package/projects/tuki/widgets/user-manage/src/classes/user.ts +8 -8
- package/projects/tuki/widgets/user-manage/src/common-functions.ts +16 -16
- package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.html +27 -27
- package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.scss +131 -131
- package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.ts +25 -25
- package/projects/tuki/widgets/user-manage/src/environments/environment.prod.ts +9 -9
- package/projects/tuki/widgets/user-manage/src/environments/environment.ts +10 -10
- package/projects/tuki/widgets/user-manage/src/interseptors/auth.interceptor.ts +35 -35
- package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.html +50 -50
- package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.scss +8 -8
- package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.ts +81 -81
- package/projects/tuki/widgets/user-manage/src/material.module.ts +85 -85
- package/projects/tuki/widgets/user-manage/src/notifications/notification.component.html +33 -33
- package/projects/tuki/widgets/user-manage/src/notifications/notification.component.scss +84 -84
- package/projects/tuki/widgets/user-manage/src/notifications/notification.component.ts +46 -46
- package/projects/tuki/widgets/user-manage/src/removeKynFromIBM.service.ts +25 -25
- package/projects/tuki/widgets/user-manage/src/services/api.service.ts +90 -90
- package/projects/tuki/widgets/user-manage/src/services/dns.service.ts +116 -116
- package/projects/tuki/widgets/user-manage/src/services/line.service.ts +31 -31
- package/projects/tuki/widgets/user-manage/src/services/notification.service.ts +68 -68
- package/projects/tuki/widgets/user-manage/src/services/removeKynFromIBM.service.ts +25 -25
- package/projects/tuki/widgets/user-manage/src/services/site-settings.service.ts +35 -35
- package/projects/tuki/widgets/user-manage/src/services/sorting-utils.service.ts +203 -203
- package/projects/tuki/widgets/user-manage/src/services/user.service.ts +242 -242
- package/projects/tuki/widgets/user-manage/src/services/users-search.service.ts +59 -59
- package/projects/tuki/widgets/user-manage/src/services/utils.service.ts +71 -71
- package/projects/tuki/widgets/user-manage/src/styles/_variables.scss +90 -90
- package/projects/tuki/widgets/user-manage/src/styles/form.scss +231 -231
- package/projects/tuki/widgets/user-manage/src/styles/icons.scss +32 -32
- package/projects/tuki/widgets/user-manage/src/styles/styles.scss +110 -110
- package/projects/tuki/widgets/user-manage/src/styles/tables.scss +30 -30
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.html +10 -10
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.scss +429 -429
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.ts +63 -63
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.html +32 -32
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.scss +444 -444
- package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.ts +89 -89
- package/projects/tuki/widgets/user-manage/src/user-details/notification.service.ts +68 -68
- package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.html +29 -29
- package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.scss +64 -64
- package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.ts +19 -19
- package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.html +290 -290
- package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.scss +463 -463
- package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.ts +212 -212
- package/projects/tuki/widgets/user-manage/src/user-manage.module.ts +63 -63
- package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.html +6 -6
- package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.scss +11 -11
- package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.ts +13 -13
- package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.html +26 -26
- package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.scss +41 -41
- package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.ts +41 -41
- package/projects/tuki/widgets/users-list/ng-package.json +6 -6
- package/projects/tuki/widgets/users-list/public-api.ts +8 -8
- package/projects/tuki/widgets/users-list/src/app.constants.ts +54 -54
- package/projects/tuki/widgets/users-list/src/assets/icons/close_icon_modal.svg +3 -3
- package/projects/tuki/widgets/users-list/src/assets/icons/move_user_to_another_location.svg +14 -14
- package/projects/tuki/widgets/users-list/src/assets/icons/white-close-icon.svg +3 -3
- package/projects/tuki/widgets/users-list/src/classes/app-location.ts +36 -36
- package/projects/tuki/widgets/users-list/src/classes/device.ts +225 -225
- package/projects/tuki/widgets/users-list/src/classes/line.ts +144 -144
- package/projects/tuki/widgets/users-list/src/classes/move-user.ts +225 -225
- package/projects/tuki/widgets/users-list/src/classes/notification.ts +38 -38
- package/projects/tuki/widgets/users-list/src/classes/pagination.ts +18 -18
- package/projects/tuki/widgets/users-list/src/classes/simlified-user.ts +74 -74
- package/projects/tuki/widgets/users-list/src/classes/table-data.ts +6 -6
- package/projects/tuki/widgets/users-list/src/classes/user-interface.ts +225 -225
- package/projects/tuki/widgets/users-list/src/classes/user-list.ts +47 -47
- package/projects/tuki/widgets/users-list/src/classes/user.ts +8 -8
- package/projects/tuki/widgets/users-list/src/material.module.ts +94 -94
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.html +37 -37
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.scss +129 -129
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.ts +46 -46
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.html +31 -31
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.scss +20 -20
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.ts +26 -26
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.html +222 -222
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.scss +239 -239
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.ts +206 -206
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.html +12 -12
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.scss +41 -41
- package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.ts +36 -36
- package/projects/tuki/widgets/users-list/src/services/api-webex.service.ts +14 -14
- package/projects/tuki/widgets/users-list/src/services/api.service.ts +90 -90
- package/projects/tuki/widgets/users-list/src/services/dns.service.ts +128 -128
- package/projects/tuki/widgets/users-list/src/services/events-communication.service.ts +11 -11
- package/projects/tuki/widgets/users-list/src/services/move-user.service.ts +59 -59
- package/projects/tuki/widgets/users-list/src/services/notification.service.ts +68 -68
- package/projects/tuki/widgets/users-list/src/services/removeKynFromIBM.service.ts +25 -25
- package/projects/tuki/widgets/users-list/src/services/site-settings.service.ts +26 -26
- package/projects/tuki/widgets/users-list/src/services/user.service.ts +159 -159
- package/projects/tuki/widgets/users-list/src/services/users-search.service.ts +137 -137
- package/projects/tuki/widgets/users-list/src/styles/styles.scss +572 -572
- package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.html +15 -15
- package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.scss +103 -103
- package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.ts +35 -35
- package/projects/tuki/widgets/users-list/src/users-list.component.html +86 -86
- package/projects/tuki/widgets/users-list/src/users-list.component.scss +572 -572
- package/projects/tuki/widgets/users-list/src/users-list.component.ts +312 -312
- package/projects/tuki/widgets/users-list/src/users-list.module.ts +63 -63
- package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.html +6 -6
- package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.scss +11 -11
- package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.ts +13 -13
- package/projects/tuki/widgets/users-list/src/utils/common-functions.ts +32 -32
- package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.html +33 -33
- package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.scss +84 -84
- package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.ts +46 -46
- package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.html +26 -26
- package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.scss +41 -41
- package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.ts +41 -41
- package/projects/tuki/widgets/users-list/src/utils/utils.service.ts +71 -71
- package/tsconfig.json +46 -46
|
@@ -1,283 +1,283 @@
|
|
|
1
|
-
import {Injectable, OnInit} from '@angular/core';
|
|
2
|
-
import { Observable, of, forkJoin, Subject } from 'rxjs';
|
|
3
|
-
import { SimplifiedUser } from './../classes/simplified-user';
|
|
4
|
-
import { API } from '../app.constants';
|
|
5
|
-
import { APIService } from './api.service';
|
|
6
|
-
import { map } from 'rxjs/operators';
|
|
7
|
-
import { UtilsService } from './utils.service';
|
|
8
|
-
import { LineAssociation } from './../classes/line-association';
|
|
9
|
-
import { LineAssociationInterface } from './../classes/line-association-interface';
|
|
10
|
-
import { LineService } from './line.service';
|
|
11
|
-
import { SortingUtilsService } from './sorting-utils.service';
|
|
12
|
-
import { ValidationService } from './validation.service';
|
|
13
|
-
import { Device } from './../classes/device';
|
|
14
|
-
|
|
15
|
-
@Injectable()
|
|
16
|
-
export class UserService implements OnInit{
|
|
17
|
-
siteId: number = -1;
|
|
18
|
-
userId: string = '';
|
|
19
|
-
userIdExistPending = false;
|
|
20
|
-
hasExistedUserId = false;
|
|
21
|
-
user!: SimplifiedUser;
|
|
22
|
-
originUser!: SimplifiedUser;
|
|
23
|
-
onUserLineSaved$ = new Subject<any>();
|
|
24
|
-
onFetchUserToken$ = new Subject<any>();
|
|
25
|
-
|
|
26
|
-
get lineAssociation(): LineAssociation | LineAssociationInterface {
|
|
27
|
-
return this.user?.devices[0].lineAssociations[0];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get originLineAssociation(): LineAssociation | LineAssociationInterface {
|
|
31
|
-
return this.originUser?.devices[0].lineAssociations[0];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
private apiService: APIService,
|
|
36
|
-
private lineService: LineService
|
|
37
|
-
) {
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
ngOnInit(): void {
|
|
42
|
-
console.log(this.siteId)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
resetLineAssociation(deviceIndex: number, lineIndex: number, validationService: ValidationService): void {
|
|
46
|
-
const originLine = this.originUser?.devices[deviceIndex]?.lineAssociations[lineIndex];
|
|
47
|
-
if (this.user?.devices[deviceIndex]?.lineAssociations[lineIndex] && originLine) {
|
|
48
|
-
this.user.devices[deviceIndex].lineAssociations[lineIndex] = new LineAssociation(JSON.parse(JSON.stringify(originLine.getFullData())), validationService)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
resetDevice(currentDevice: Device, validationService: ValidationService): void {
|
|
53
|
-
const originDevice = this.originUser.devices.find(device => device.name === currentDevice.name);
|
|
54
|
-
const deviceInd = this.user.devices.findIndex(device => device.name === currentDevice.name);
|
|
55
|
-
if (originDevice && deviceInd > -1) {
|
|
56
|
-
const lineAssociations = this.user.devices[deviceInd].lineAssociations;
|
|
57
|
-
this.user.devices[deviceInd] = new Device(JSON.parse(JSON.stringify(originDevice.getNoLinesFullData())), validationService);
|
|
58
|
-
this.user.devices[deviceInd].lineAssociations = lineAssociations;
|
|
59
|
-
console.log('device after reset = ', this.user.devices[deviceInd]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public fetchUserToken(siteId: number, userId: string, validationService: ValidationService, isSetNewTokenOnly?: boolean): any {
|
|
64
|
-
/*if (this.siteId === siteId && this.userId === userId && this.user) {
|
|
65
|
-
return of(this.user);
|
|
66
|
-
}*/
|
|
67
|
-
this.siteId = siteId;
|
|
68
|
-
this.userId = userId;
|
|
69
|
-
return this.apiService.fetch(API.USER_TOKEN.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(userId))))
|
|
70
|
-
.pipe(map((result: any) => {
|
|
71
|
-
const user = result && Object.values(result)[0];
|
|
72
|
-
const userToken = result && Object.keys(result)[0];
|
|
73
|
-
if (user) {
|
|
74
|
-
if (!isSetNewTokenOnly) {
|
|
75
|
-
this.setSimplifiedUser(user, validationService, userToken);
|
|
76
|
-
} else {
|
|
77
|
-
this.user.token = user.token;
|
|
78
|
-
this.originUser.token = user.token;
|
|
79
|
-
}
|
|
80
|
-
this.onFetchUserToken$.next(true);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}))
|
|
84
|
-
// .pipe(this.handleError(false, true));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public updateUserFields(body: any): any {
|
|
88
|
-
if (!this.userId || !this.siteId || !this.user?.token) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
return this.apiService.post(API.UPDATE_USER_FIELDS.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), body)
|
|
92
|
-
// .pipe(this.handleError(false, true));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public fetchUserById(id: string) {
|
|
96
|
-
this.userIdExistPending = true;
|
|
97
|
-
return this.apiService.fetch(API.USER_BY_ID.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))))
|
|
98
|
-
.pipe(map(result => {
|
|
99
|
-
this.userIdExistPending = false;
|
|
100
|
-
return result;
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public fetchLeanUserConversationById(id: string) {
|
|
105
|
-
return this.apiService.fetch(API.LEAN_USER_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public fetchLeanUserDevicesConversationById(id: string) {
|
|
109
|
-
return this.apiService.fetch(API.LEAN_USER_DEVICES_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
110
|
-
}
|
|
111
|
-
public fetchLeanUserLinesConversationById(id: string, leanUserDevicesToken: string) {
|
|
112
|
-
return this.apiService.fetch(API.LEAN_USER_LINES_CONVERSATION_START.replace(':siteId', String(this.siteId))
|
|
113
|
-
.replace(':userId', encodeURIComponent(encodeURIComponent(id))).replace(':leanUserDevicesToken', leanUserDevicesToken));
|
|
114
|
-
}
|
|
115
|
-
public fetchLeanUserSNRConversationById(id: string) {
|
|
116
|
-
return this.apiService.fetch(API.LEAN_USER_SNR_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public persistCacheChanges() {
|
|
120
|
-
/*const params = {
|
|
121
|
-
excludeDeviceExtraOptions: true
|
|
122
|
-
};*/
|
|
123
|
-
return this.processUserChangesToCache()
|
|
124
|
-
.pipe(map((result: any) => {
|
|
125
|
-
return this.apiService.post(API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), {}, {})
|
|
126
|
-
.subscribe(() => {
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
// .pipe(map((user) => {
|
|
130
|
-
// // this.setUser(user, false, this.user.token);
|
|
131
|
-
// this.user.hasModifiedCache = false;
|
|
132
|
-
// }))
|
|
133
|
-
// .pipe(this.handleError(true, true));
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public processUserChangesToCache(): any {
|
|
138
|
-
const calls = [];
|
|
139
|
-
const body = UtilsService.diff(this.originUser.getUserDetailsSavableData(), this.user.getUserDetailsSavableData(), 'user');
|
|
140
|
-
if (body?.length) {
|
|
141
|
-
calls.push(this.updateUserFields(body));
|
|
142
|
-
}
|
|
143
|
-
if (!calls?.length) {
|
|
144
|
-
return of(this.user);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return forkJoin(calls)
|
|
148
|
-
.pipe(map((responses: any) => {
|
|
149
|
-
// ApiUserResponse
|
|
150
|
-
this.handleSaveUserResponse(responses);
|
|
151
|
-
}))
|
|
152
|
-
// .pipe(this.handleError(false, true));
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public saveNewLine(validationService: ValidationService): any {
|
|
157
|
-
this.deleteLine(this.user.siteId, this.lineAssociation.linePkid, encodeURIComponent(this.user.token))
|
|
158
|
-
.subscribe(() => {
|
|
159
|
-
const URL = API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token);
|
|
160
|
-
this.apiService.post(URL, {}, )
|
|
161
|
-
.subscribe(() => {
|
|
162
|
-
this.fetchUserToken(this.siteId, this.user.userid, validationService, true)
|
|
163
|
-
.subscribe(() => {
|
|
164
|
-
this.runNewLineCreation();
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public persistUserCache(): any {
|
|
171
|
-
const URL = API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token);
|
|
172
|
-
return this.apiService.post(URL, {}, );
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public runNewLineCreation(): void {
|
|
176
|
-
// CREATE NEW LINE
|
|
177
|
-
const newLineBody = SortingUtilsService.diff(
|
|
178
|
-
this.lineService.generateLineAssociationFromLine(null),
|
|
179
|
-
this.lineService.generateLineAssociationFromLine(this.lineAssociation),
|
|
180
|
-
'device.lineAssociations', null
|
|
181
|
-
);
|
|
182
|
-
this.associateLineToUserDevice(
|
|
183
|
-
this.user.siteId,
|
|
184
|
-
this.user.devices[0].name,
|
|
185
|
-
newLineBody,
|
|
186
|
-
null,
|
|
187
|
-
this.lineAssociation.callingSearchSpace
|
|
188
|
-
).subscribe((response: any) => {
|
|
189
|
-
if (response?.currentUpdatedUser) {
|
|
190
|
-
const linePkId = response.currentUpdatedUser.devices[0]?.lineAssociations[0]?.linePkid || response.currentUpdatedUser.devices[0]?.lineAssociations[0]?.lineLocalId;
|
|
191
|
-
forkJoin([
|
|
192
|
-
this.updateLineFields(this.siteId, linePkId, this.user.token, this.lineAssociation.alertingName),
|
|
193
|
-
this.updateDeviceFields(this.siteId, this.user.devices[0]?.name, this.user.token)
|
|
194
|
-
]).subscribe((response: any) => {
|
|
195
|
-
this.originUser.devices[0].lineAssociations[0].directoryNumber.directoryNumber = this.lineAssociation.directoryNumber.directoryNumber;
|
|
196
|
-
this.onUserLineSaved$.next(true);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
// -----
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public deleteLine(siteId: number, pkid: string, token: string) {
|
|
204
|
-
return this.apiService.delete(API.DELETE_LINE.replace(':siteId', String(siteId)).replace(':pkid', pkid).replace(':token', encodeURIComponent(token)), {})
|
|
205
|
-
// .pipe(this.handleError(true, false));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
public disassociateLine(siteId: number, linePkid: string, token: string, deviceName: string) {
|
|
209
|
-
return this.apiService.delete(
|
|
210
|
-
API.DISASSOCIATE_LINE.replace(':siteId', String(siteId))
|
|
211
|
-
.replace(':linePkid', linePkid)
|
|
212
|
-
.replace(':deviceName', deviceName)
|
|
213
|
-
.replace(':token', encodeURIComponent(token)), {})
|
|
214
|
-
// .pipe(this.handleError(true, false));
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public updateLineFields(siteId: number, pkid: string, token: string, alertingName: any) {
|
|
218
|
-
const body = ['line.description=', `line.alertingName=${alertingName}`];
|
|
219
|
-
return this.apiService.post(API.UPDATE_LINE_FIELDS.replace(':siteId', String(siteId)).replace(':pkid', encodeURIComponent(pkid)).replace(':token', encodeURIComponent(token)), body)
|
|
220
|
-
// .pipe(this.handleError(true, false));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public updateDeviceFields(siteId: number, deviceName: string, token: string) {
|
|
224
|
-
const body = ['device.associatedDNs.0=null'];
|
|
225
|
-
return this.apiService.post(API.UPDATE_DEVICE_FIELDS.replace(':siteId', String(siteId)).replace(':deviceName', deviceName).replace(':token', encodeURIComponent(token)), body)
|
|
226
|
-
// .pipe(this.handleError(true, false));
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
public checkDestinationNumber(siteId: string, directoryNumber: string, routePartitionName: string) {
|
|
230
|
-
const params = {
|
|
231
|
-
dntype: 'EXTENSION'
|
|
232
|
-
};
|
|
233
|
-
const body = {
|
|
234
|
-
directoryNumber: directoryNumber,
|
|
235
|
-
routePartitionName: routePartitionName
|
|
236
|
-
};
|
|
237
|
-
return this.apiService.post(API.CHECK_DESTINATION_NUMBER.replace(':siteId', siteId), body, params);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public associateLineToUserDevice(siteId: number, deviceName: string, body: any, pkid: any, css: any) {
|
|
241
|
-
let params = {};
|
|
242
|
-
if (pkid) {
|
|
243
|
-
params = {linePkid: pkid};
|
|
244
|
-
}
|
|
245
|
-
if (css) {
|
|
246
|
-
// @ts-ignore
|
|
247
|
-
params['css'] = css;
|
|
248
|
-
}
|
|
249
|
-
return this.apiService.post(API.ASSOCIATE_LINE.replace(':siteId', String(siteId)).replace(':deviceName', deviceName)
|
|
250
|
-
.replace(':token', encodeURIComponent(this.user.token)), body, params)
|
|
251
|
-
// .pipe(this.handleError(true, true));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
public hasUnsavedChanges() {
|
|
255
|
-
if (this.user && this.originUser) {
|
|
256
|
-
return !this.user.equal(this.originUser);
|
|
257
|
-
}
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
public setSimplifiedUser(user: any, validationService: ValidationService, userToken?: string): void {
|
|
262
|
-
this.user = new SimplifiedUser(user, validationService);
|
|
263
|
-
const copiedUser = JSON.parse(JSON.stringify(user));
|
|
264
|
-
this.originUser = new SimplifiedUser(copiedUser, validationService);
|
|
265
|
-
if (!this.user.token && userToken) {
|
|
266
|
-
this.user.token = userToken;
|
|
267
|
-
this.originUser.token = userToken;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private handleSaveUserResponse(responses: any) {
|
|
272
|
-
if (!responses?.length) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
for (let len = responses.length, i = len - 1; i >= 0; i--) {
|
|
276
|
-
if (responses[i] && responses[i].currentUpdatedUser) {
|
|
277
|
-
// this.setUser(responses[i].currentUpdatedUser, false, this.user.token);
|
|
278
|
-
this.user.hasModifiedCache = true;
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
1
|
+
import {Injectable, OnInit} from '@angular/core';
|
|
2
|
+
import { Observable, of, forkJoin, Subject } from 'rxjs';
|
|
3
|
+
import { SimplifiedUser } from './../classes/simplified-user';
|
|
4
|
+
import { API } from '../app.constants';
|
|
5
|
+
import { APIService } from './api.service';
|
|
6
|
+
import { map } from 'rxjs/operators';
|
|
7
|
+
import { UtilsService } from './utils.service';
|
|
8
|
+
import { LineAssociation } from './../classes/line-association';
|
|
9
|
+
import { LineAssociationInterface } from './../classes/line-association-interface';
|
|
10
|
+
import { LineService } from './line.service';
|
|
11
|
+
import { SortingUtilsService } from './sorting-utils.service';
|
|
12
|
+
import { ValidationService } from './validation.service';
|
|
13
|
+
import { Device } from './../classes/device';
|
|
14
|
+
|
|
15
|
+
@Injectable()
|
|
16
|
+
export class UserService implements OnInit{
|
|
17
|
+
siteId: number = -1;
|
|
18
|
+
userId: string = '';
|
|
19
|
+
userIdExistPending = false;
|
|
20
|
+
hasExistedUserId = false;
|
|
21
|
+
user!: SimplifiedUser;
|
|
22
|
+
originUser!: SimplifiedUser;
|
|
23
|
+
onUserLineSaved$ = new Subject<any>();
|
|
24
|
+
onFetchUserToken$ = new Subject<any>();
|
|
25
|
+
|
|
26
|
+
get lineAssociation(): LineAssociation | LineAssociationInterface {
|
|
27
|
+
return this.user?.devices[0].lineAssociations[0];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get originLineAssociation(): LineAssociation | LineAssociationInterface {
|
|
31
|
+
return this.originUser?.devices[0].lineAssociations[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
private apiService: APIService,
|
|
36
|
+
private lineService: LineService
|
|
37
|
+
) {
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ngOnInit(): void {
|
|
42
|
+
console.log(this.siteId)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
resetLineAssociation(deviceIndex: number, lineIndex: number, validationService: ValidationService): void {
|
|
46
|
+
const originLine = this.originUser?.devices[deviceIndex]?.lineAssociations[lineIndex];
|
|
47
|
+
if (this.user?.devices[deviceIndex]?.lineAssociations[lineIndex] && originLine) {
|
|
48
|
+
this.user.devices[deviceIndex].lineAssociations[lineIndex] = new LineAssociation(JSON.parse(JSON.stringify(originLine.getFullData())), validationService)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
resetDevice(currentDevice: Device, validationService: ValidationService): void {
|
|
53
|
+
const originDevice = this.originUser.devices.find(device => device.name === currentDevice.name);
|
|
54
|
+
const deviceInd = this.user.devices.findIndex(device => device.name === currentDevice.name);
|
|
55
|
+
if (originDevice && deviceInd > -1) {
|
|
56
|
+
const lineAssociations = this.user.devices[deviceInd].lineAssociations;
|
|
57
|
+
this.user.devices[deviceInd] = new Device(JSON.parse(JSON.stringify(originDevice.getNoLinesFullData())), validationService);
|
|
58
|
+
this.user.devices[deviceInd].lineAssociations = lineAssociations;
|
|
59
|
+
console.log('device after reset = ', this.user.devices[deviceInd]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public fetchUserToken(siteId: number, userId: string, validationService: ValidationService, isSetNewTokenOnly?: boolean): any {
|
|
64
|
+
/*if (this.siteId === siteId && this.userId === userId && this.user) {
|
|
65
|
+
return of(this.user);
|
|
66
|
+
}*/
|
|
67
|
+
this.siteId = siteId;
|
|
68
|
+
this.userId = userId;
|
|
69
|
+
return this.apiService.fetch(API.USER_TOKEN.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(userId))))
|
|
70
|
+
.pipe(map((result: any) => {
|
|
71
|
+
const user = result && Object.values(result)[0];
|
|
72
|
+
const userToken = result && Object.keys(result)[0];
|
|
73
|
+
if (user) {
|
|
74
|
+
if (!isSetNewTokenOnly) {
|
|
75
|
+
this.setSimplifiedUser(user, validationService, userToken);
|
|
76
|
+
} else {
|
|
77
|
+
this.user.token = user.token;
|
|
78
|
+
this.originUser.token = user.token;
|
|
79
|
+
}
|
|
80
|
+
this.onFetchUserToken$.next(true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}))
|
|
84
|
+
// .pipe(this.handleError(false, true));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public updateUserFields(body: any): any {
|
|
88
|
+
if (!this.userId || !this.siteId || !this.user?.token) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
return this.apiService.post(API.UPDATE_USER_FIELDS.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), body)
|
|
92
|
+
// .pipe(this.handleError(false, true));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public fetchUserById(id: string) {
|
|
96
|
+
this.userIdExistPending = true;
|
|
97
|
+
return this.apiService.fetch(API.USER_BY_ID.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))))
|
|
98
|
+
.pipe(map(result => {
|
|
99
|
+
this.userIdExistPending = false;
|
|
100
|
+
return result;
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public fetchLeanUserConversationById(id: string) {
|
|
105
|
+
return this.apiService.fetch(API.LEAN_USER_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public fetchLeanUserDevicesConversationById(id: string) {
|
|
109
|
+
return this.apiService.fetch(API.LEAN_USER_DEVICES_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
110
|
+
}
|
|
111
|
+
public fetchLeanUserLinesConversationById(id: string, leanUserDevicesToken: string) {
|
|
112
|
+
return this.apiService.fetch(API.LEAN_USER_LINES_CONVERSATION_START.replace(':siteId', String(this.siteId))
|
|
113
|
+
.replace(':userId', encodeURIComponent(encodeURIComponent(id))).replace(':leanUserDevicesToken', leanUserDevicesToken));
|
|
114
|
+
}
|
|
115
|
+
public fetchLeanUserSNRConversationById(id: string) {
|
|
116
|
+
return this.apiService.fetch(API.LEAN_USER_SNR_CONVERSATION_START.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public persistCacheChanges() {
|
|
120
|
+
/*const params = {
|
|
121
|
+
excludeDeviceExtraOptions: true
|
|
122
|
+
};*/
|
|
123
|
+
return this.processUserChangesToCache()
|
|
124
|
+
.pipe(map((result: any) => {
|
|
125
|
+
return this.apiService.post(API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), {}, {})
|
|
126
|
+
.subscribe(() => {
|
|
127
|
+
|
|
128
|
+
})
|
|
129
|
+
// .pipe(map((user) => {
|
|
130
|
+
// // this.setUser(user, false, this.user.token);
|
|
131
|
+
// this.user.hasModifiedCache = false;
|
|
132
|
+
// }))
|
|
133
|
+
// .pipe(this.handleError(true, true));
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public processUserChangesToCache(): any {
|
|
138
|
+
const calls = [];
|
|
139
|
+
const body = UtilsService.diff(this.originUser.getUserDetailsSavableData(), this.user.getUserDetailsSavableData(), 'user');
|
|
140
|
+
if (body?.length) {
|
|
141
|
+
calls.push(this.updateUserFields(body));
|
|
142
|
+
}
|
|
143
|
+
if (!calls?.length) {
|
|
144
|
+
return of(this.user);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return forkJoin(calls)
|
|
148
|
+
.pipe(map((responses: any) => {
|
|
149
|
+
// ApiUserResponse
|
|
150
|
+
this.handleSaveUserResponse(responses);
|
|
151
|
+
}))
|
|
152
|
+
// .pipe(this.handleError(false, true));
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public saveNewLine(validationService: ValidationService): any {
|
|
157
|
+
this.deleteLine(this.user.siteId, this.lineAssociation.linePkid, encodeURIComponent(this.user.token))
|
|
158
|
+
.subscribe(() => {
|
|
159
|
+
const URL = API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token);
|
|
160
|
+
this.apiService.post(URL, {}, )
|
|
161
|
+
.subscribe(() => {
|
|
162
|
+
this.fetchUserToken(this.siteId, this.user.userid, validationService, true)
|
|
163
|
+
.subscribe(() => {
|
|
164
|
+
this.runNewLineCreation();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public persistUserCache(): any {
|
|
171
|
+
const URL = API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token);
|
|
172
|
+
return this.apiService.post(URL, {}, );
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public runNewLineCreation(): void {
|
|
176
|
+
// CREATE NEW LINE
|
|
177
|
+
const newLineBody = SortingUtilsService.diff(
|
|
178
|
+
this.lineService.generateLineAssociationFromLine(null),
|
|
179
|
+
this.lineService.generateLineAssociationFromLine(this.lineAssociation),
|
|
180
|
+
'device.lineAssociations', null
|
|
181
|
+
);
|
|
182
|
+
this.associateLineToUserDevice(
|
|
183
|
+
this.user.siteId,
|
|
184
|
+
this.user.devices[0].name,
|
|
185
|
+
newLineBody,
|
|
186
|
+
null,
|
|
187
|
+
this.lineAssociation.callingSearchSpace
|
|
188
|
+
).subscribe((response: any) => {
|
|
189
|
+
if (response?.currentUpdatedUser) {
|
|
190
|
+
const linePkId = response.currentUpdatedUser.devices[0]?.lineAssociations[0]?.linePkid || response.currentUpdatedUser.devices[0]?.lineAssociations[0]?.lineLocalId;
|
|
191
|
+
forkJoin([
|
|
192
|
+
this.updateLineFields(this.siteId, linePkId, this.user.token, this.lineAssociation.alertingName),
|
|
193
|
+
this.updateDeviceFields(this.siteId, this.user.devices[0]?.name, this.user.token)
|
|
194
|
+
]).subscribe((response: any) => {
|
|
195
|
+
this.originUser.devices[0].lineAssociations[0].directoryNumber.directoryNumber = this.lineAssociation.directoryNumber.directoryNumber;
|
|
196
|
+
this.onUserLineSaved$.next(true);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
// -----
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public deleteLine(siteId: number, pkid: string, token: string) {
|
|
204
|
+
return this.apiService.delete(API.DELETE_LINE.replace(':siteId', String(siteId)).replace(':pkid', pkid).replace(':token', encodeURIComponent(token)), {})
|
|
205
|
+
// .pipe(this.handleError(true, false));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public disassociateLine(siteId: number, linePkid: string, token: string, deviceName: string) {
|
|
209
|
+
return this.apiService.delete(
|
|
210
|
+
API.DISASSOCIATE_LINE.replace(':siteId', String(siteId))
|
|
211
|
+
.replace(':linePkid', linePkid)
|
|
212
|
+
.replace(':deviceName', deviceName)
|
|
213
|
+
.replace(':token', encodeURIComponent(token)), {})
|
|
214
|
+
// .pipe(this.handleError(true, false));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public updateLineFields(siteId: number, pkid: string, token: string, alertingName: any) {
|
|
218
|
+
const body = ['line.description=', `line.alertingName=${alertingName}`];
|
|
219
|
+
return this.apiService.post(API.UPDATE_LINE_FIELDS.replace(':siteId', String(siteId)).replace(':pkid', encodeURIComponent(pkid)).replace(':token', encodeURIComponent(token)), body)
|
|
220
|
+
// .pipe(this.handleError(true, false));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
public updateDeviceFields(siteId: number, deviceName: string, token: string) {
|
|
224
|
+
const body = ['device.associatedDNs.0=null'];
|
|
225
|
+
return this.apiService.post(API.UPDATE_DEVICE_FIELDS.replace(':siteId', String(siteId)).replace(':deviceName', deviceName).replace(':token', encodeURIComponent(token)), body)
|
|
226
|
+
// .pipe(this.handleError(true, false));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public checkDestinationNumber(siteId: string, directoryNumber: string, routePartitionName: string) {
|
|
230
|
+
const params = {
|
|
231
|
+
dntype: 'EXTENSION'
|
|
232
|
+
};
|
|
233
|
+
const body = {
|
|
234
|
+
directoryNumber: directoryNumber,
|
|
235
|
+
routePartitionName: routePartitionName
|
|
236
|
+
};
|
|
237
|
+
return this.apiService.post(API.CHECK_DESTINATION_NUMBER.replace(':siteId', siteId), body, params);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public associateLineToUserDevice(siteId: number, deviceName: string, body: any, pkid: any, css: any) {
|
|
241
|
+
let params = {};
|
|
242
|
+
if (pkid) {
|
|
243
|
+
params = {linePkid: pkid};
|
|
244
|
+
}
|
|
245
|
+
if (css) {
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
params['css'] = css;
|
|
248
|
+
}
|
|
249
|
+
return this.apiService.post(API.ASSOCIATE_LINE.replace(':siteId', String(siteId)).replace(':deviceName', deviceName)
|
|
250
|
+
.replace(':token', encodeURIComponent(this.user.token)), body, params)
|
|
251
|
+
// .pipe(this.handleError(true, true));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public hasUnsavedChanges() {
|
|
255
|
+
if (this.user && this.originUser) {
|
|
256
|
+
return !this.user.equal(this.originUser);
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
public setSimplifiedUser(user: any, validationService: ValidationService, userToken?: string): void {
|
|
262
|
+
this.user = new SimplifiedUser(user, validationService);
|
|
263
|
+
const copiedUser = JSON.parse(JSON.stringify(user));
|
|
264
|
+
this.originUser = new SimplifiedUser(copiedUser, validationService);
|
|
265
|
+
if (!this.user.token && userToken) {
|
|
266
|
+
this.user.token = userToken;
|
|
267
|
+
this.originUser.token = userToken;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private handleSaveUserResponse(responses: any) {
|
|
272
|
+
if (!responses?.length) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
for (let len = responses.length, i = len - 1; i >= 0; i--) {
|
|
276
|
+
if (responses[i] && responses[i].currentUpdatedUser) {
|
|
277
|
+
// this.setUser(responses[i].currentUpdatedUser, false, this.user.token);
|
|
278
|
+
this.user.hasModifiedCache = true;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|