@tuki-io/tuki-widgets 0.0.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.
Files changed (117) hide show
  1. package/.editorconfig +16 -0
  2. package/.vscode/extensions.json +4 -0
  3. package/.vscode/launch.json +20 -0
  4. package/.vscode/tasks.json +42 -0
  5. package/README.md +27 -0
  6. package/angular.json +41 -0
  7. package/package.json +42 -0
  8. package/projects/tuki/widgets/README.md +24 -0
  9. package/projects/tuki/widgets/karma.conf.js +44 -0
  10. package/projects/tuki/widgets/ng-package.json +7 -0
  11. package/projects/tuki/widgets/package.json +13 -0
  12. package/projects/tuki/widgets/src/lib/widgets.component.spec.ts +23 -0
  13. package/projects/tuki/widgets/src/lib/widgets.component.ts +20 -0
  14. package/projects/tuki/widgets/src/lib/widgets.module.ts +16 -0
  15. package/projects/tuki/widgets/src/lib/widgets.service.spec.ts +16 -0
  16. package/projects/tuki/widgets/src/lib/widgets.service.ts +9 -0
  17. package/projects/tuki/widgets/src/public-api.ts +7 -0
  18. package/projects/tuki/widgets/src/test.ts +27 -0
  19. package/projects/tuki/widgets/styles/_variables.scss +90 -0
  20. package/projects/tuki/widgets/styles/form.scss +231 -0
  21. package/projects/tuki/widgets/styles/icons.scss +32 -0
  22. package/projects/tuki/widgets/styles/styles.scss +110 -0
  23. package/projects/tuki/widgets/styles/tables.scss +30 -0
  24. package/projects/tuki/widgets/tsconfig.lib.json +36 -0
  25. package/projects/tuki/widgets/tsconfig.lib.prod.json +10 -0
  26. package/projects/tuki/widgets/tsconfig.spec.json +17 -0
  27. package/projects/tuki/widgets/user-manage/ng-package.json +7 -0
  28. package/projects/tuki/widgets/user-manage/public-api.ts +6 -0
  29. package/projects/tuki/widgets/user-manage/src/app.constants.ts +38 -0
  30. package/projects/tuki/widgets/user-manage/src/classes/device.ts +225 -0
  31. package/projects/tuki/widgets/user-manage/src/classes/line.ts +117 -0
  32. package/projects/tuki/widgets/user-manage/src/classes/notification.ts +39 -0
  33. package/projects/tuki/widgets/user-manage/src/classes/pagination.ts +18 -0
  34. package/projects/tuki/widgets/user-manage/src/classes/simplified-user.ts +128 -0
  35. package/projects/tuki/widgets/user-manage/src/classes/table-data.ts +6 -0
  36. package/projects/tuki/widgets/user-manage/src/classes/user-interface.ts +225 -0
  37. package/projects/tuki/widgets/user-manage/src/classes/user-list.ts +40 -0
  38. package/projects/tuki/widgets/user-manage/src/classes/user.ts +8 -0
  39. package/projects/tuki/widgets/user-manage/src/common-functions.ts +16 -0
  40. package/projects/tuki/widgets/user-manage/src/environments/environment.prod.ts +9 -0
  41. package/projects/tuki/widgets/user-manage/src/environments/environment.ts +10 -0
  42. package/projects/tuki/widgets/user-manage/src/interseptors/auth.interceptor.ts +36 -0
  43. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.html +50 -0
  44. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.scss +3 -0
  45. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.ts +81 -0
  46. package/projects/tuki/widgets/user-manage/src/material.module.ts +85 -0
  47. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.html +33 -0
  48. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.scss +84 -0
  49. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.ts +46 -0
  50. package/projects/tuki/widgets/user-manage/src/removeKynFromIBM.service.ts +25 -0
  51. package/projects/tuki/widgets/user-manage/src/services/api.service.ts +89 -0
  52. package/projects/tuki/widgets/user-manage/src/services/notification.service.ts +68 -0
  53. package/projects/tuki/widgets/user-manage/src/services/removeKynFromIBM.service.ts +25 -0
  54. package/projects/tuki/widgets/user-manage/src/services/site-settings.service.ts +35 -0
  55. package/projects/tuki/widgets/user-manage/src/services/user.service.ts +120 -0
  56. package/projects/tuki/widgets/user-manage/src/services/users-search.service.ts +58 -0
  57. package/projects/tuki/widgets/user-manage/src/services/utils.service.ts +71 -0
  58. package/projects/tuki/widgets/user-manage/src/styles/_variables.scss +90 -0
  59. package/projects/tuki/widgets/user-manage/src/styles/form.scss +231 -0
  60. package/projects/tuki/widgets/user-manage/src/styles/icons.scss +32 -0
  61. package/projects/tuki/widgets/user-manage/src/styles/styles.scss +110 -0
  62. package/projects/tuki/widgets/user-manage/src/styles/tables.scss +30 -0
  63. package/projects/tuki/widgets/user-manage/src/user-details/notification.service.ts +68 -0
  64. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.html +32 -0
  65. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.scss +53 -0
  66. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.ts +19 -0
  67. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.html +291 -0
  68. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.scss +461 -0
  69. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.ts +163 -0
  70. package/projects/tuki/widgets/user-manage/src/user-manage.module.ts +53 -0
  71. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.html +6 -0
  72. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.scss +11 -0
  73. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.ts +13 -0
  74. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.html +26 -0
  75. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.scss +41 -0
  76. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.ts +41 -0
  77. package/projects/tuki/widgets/users-list/ng-package.json +6 -0
  78. package/projects/tuki/widgets/users-list/public-api.ts +8 -0
  79. package/projects/tuki/widgets/users-list/src/app.constants.ts +35 -0
  80. package/projects/tuki/widgets/users-list/src/classes/device.ts +225 -0
  81. package/projects/tuki/widgets/users-list/src/classes/line.ts +117 -0
  82. package/projects/tuki/widgets/users-list/src/classes/notification.ts +38 -0
  83. package/projects/tuki/widgets/users-list/src/classes/pagination.ts +18 -0
  84. package/projects/tuki/widgets/users-list/src/classes/simlified-user.ts +74 -0
  85. package/projects/tuki/widgets/users-list/src/classes/table-data.ts +6 -0
  86. package/projects/tuki/widgets/users-list/src/classes/user-interface.ts +225 -0
  87. package/projects/tuki/widgets/users-list/src/classes/user-list.ts +40 -0
  88. package/projects/tuki/widgets/users-list/src/classes/user.ts +8 -0
  89. package/projects/tuki/widgets/users-list/src/material.module.ts +84 -0
  90. package/projects/tuki/widgets/users-list/src/services/api.service.ts +87 -0
  91. package/projects/tuki/widgets/users-list/src/services/events-communication.service.ts +11 -0
  92. package/projects/tuki/widgets/users-list/src/services/notification.service.ts +68 -0
  93. package/projects/tuki/widgets/users-list/src/services/removeKynFromIBM.service.ts +25 -0
  94. package/projects/tuki/widgets/users-list/src/services/user.service.ts +117 -0
  95. package/projects/tuki/widgets/users-list/src/services/users-search.service.ts +58 -0
  96. package/projects/tuki/widgets/users-list/src/users-list.component.css +4 -0
  97. package/projects/tuki/widgets/users-list/src/users-list.component.css.map +1 -0
  98. package/projects/tuki/widgets/users-list/src/users-list.component.html +39 -0
  99. package/projects/tuki/widgets/users-list/src/users-list.component.scss +9 -0
  100. package/projects/tuki/widgets/users-list/src/users-list.component.ts +85 -0
  101. package/projects/tuki/widgets/users-list/src/users-list.module.ts +36 -0
  102. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.css +11 -0
  103. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.css.map +1 -0
  104. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.html +6 -0
  105. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.scss +11 -0
  106. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.ts +13 -0
  107. package/projects/tuki/widgets/users-list/src/utils/common-functions.ts +16 -0
  108. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.html +33 -0
  109. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.scss +84 -0
  110. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.ts +46 -0
  111. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.css +45 -0
  112. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.css.map +1 -0
  113. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.html +26 -0
  114. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.scss +41 -0
  115. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.ts +41 -0
  116. package/projects/tuki/widgets/users-list/src/utils/utils.service.ts +71 -0
  117. package/tsconfig.json +46 -0
@@ -0,0 +1,225 @@
1
+ /*
2
+
3
+ export interface UserInterface {
4
+ userid: string;
5
+ firstName: string;
6
+ lastName: string;
7
+ middleName: string;
8
+ email: string;
9
+ department: string;
10
+ telephoneNumber: string;
11
+ homeNumber: string;
12
+ mobileNumber: string;
13
+ pagerNumber: string;
14
+ displayName: string;
15
+ features: string[];
16
+ ldapIntegrated: boolean;
17
+ sparkLicenses: any[];
18
+ extensionMobility: ExtensionMobilityInterface;
19
+ singleNumberReach?: SingleNumberReachInterface;
20
+ primaryLineReference: LineDirectoryInterface;
21
+ voicemail: VoicemailInterface;
22
+ devices: DeviceInterface[];
23
+ deviceProfiles: DeviceInterface[];
24
+ lines: LineInterface[];
25
+ subscribeCss: string;
26
+ presenceGroup: string;
27
+ allowDeviceControlFromCti: boolean;
28
+ enableCrossClusterEm: boolean;
29
+ ucServiceProfile: string;
30
+ manager: string;
31
+ title: string;
32
+ associatedPc: string;
33
+ userProfile: string;
34
+ enableUserToHostConferenceNow: boolean;
35
+ attendeesAccessCode: string;
36
+ enableMobileVoiceAccess: boolean;
37
+ mlppUserIdNumber: string;
38
+ mlppPrecedencePattern: string;
39
+ userLocale: string;
40
+ siteId: number;
41
+ siteName: string;
42
+ location: string;
43
+ lineAppearances: Array<LineAppearance>;
44
+ meetMes: Array<MeetMeConferencing>;
45
+ homeCluster: boolean;
46
+ vmOnlyUser?: boolean;
47
+ directoryUri:string;
48
+ }
49
+
50
+ export interface SingleNumberReachInterface {
51
+ remoteDestinationProfileName: string;
52
+ remoteDestinations?: RemoteDestinationInterface[];
53
+ devicePool?: string;
54
+ css?: string;
55
+ rerouteCss?: string;
56
+ }
57
+
58
+ export interface VoicemailInterface {
59
+ callHandlerObjectId?: string;
60
+ extension: string;
61
+ vmUserTemplate?: string;
62
+ vmPassword?: VoicemailSettingsInterface;
63
+ vmMailbox?: MailboxInterface;
64
+ vmUnifiedMessagingAccount?: UnifiedMessagingAccount[];
65
+ notificationDevices?: VoicemailNotifications[];
66
+ alternateExtensions?: AlternateExtensions[];
67
+ language?: LanguageMailbox;
68
+ messageActions?: MessageActions;
69
+ webAppPassword?: WebAppPassword;
70
+ vmPasswordSettings?: VmPasswordSettings;
71
+ pkid?: string;
72
+ }
73
+
74
+ export interface ExtensionMobilityInterface {
75
+ deviceType: string;
76
+ deviceProfileName: string;
77
+ buttonTemplate: string;
78
+ services: string[];
79
+ protocol: string;
80
+ userLocale: string;
81
+ lineAssociations: LineAssociationInterface[];
82
+ speedDials: SpeedDialInterface[];
83
+ }
84
+
85
+ export interface SpeedDialInterface {
86
+ index: number;
87
+ position: number;
88
+ destination: string;
89
+ label: string;
90
+ editMode?: boolean;
91
+ }
92
+
93
+ export interface DeviceInterface {
94
+ name: string;
95
+ newName: string;
96
+ pkid: string;
97
+ entityChangeType: EntityChangeType;
98
+ deviceType: string;
99
+ protocol: string;
100
+ description: string;
101
+ buttonTemplate: string;
102
+ softkeyTemplate: string;
103
+ devicePoolName: string;
104
+ location: string;
105
+ userLocale: string;
106
+ enabledExtensionMobility: boolean;
107
+ callingSearchSpaceName: string;
108
+ services: string[];
109
+ networkLocale: string;
110
+ securityProfile: string;
111
+ lineAssociations: LineAssociationInterface[];
112
+ speedDials: SpeedDialInterface[];
113
+ sipProfile: string;
114
+ subscribeCallingSearchSpaceName: string;
115
+ commonPhoneConfigName: string;
116
+ ctiRemoteDevice: boolean;
117
+ firstExpansionModule: string;
118
+ secondExpansionModule: string;
119
+ thirdExpansionModule: string;
120
+ builtInBridge: string;
121
+ extraOptions?: DeviceExtraOptionsInterface;
122
+ formDisabledControls?: string[];
123
+ sharedUsers: string[];
124
+ busyLampFields: BusyLampFieldsInterface[];
125
+ meetMeEnabled: boolean;
126
+ deviceKind;
127
+ isCtiRoutePoint?: boolean;
128
+ cucmId: string;
129
+ plarDevice?: boolean;
130
+ firmwareVersion;
131
+ certificateOperation: string;
132
+ authenticationMode: string;
133
+ authenticationString?: string;
134
+ rsaKeySize?: string;
135
+ operationCompletesBy: string;
136
+ certificateStatus: string;
137
+ day?: string;
138
+ month?: string;
139
+ year?: string;
140
+ hour?: string;
141
+ securityProfileUuid?: string;
142
+ excludeDeviceExtraOptions?: boolean;
143
+ }
144
+
145
+ export interface DeviceViewConfiguration {
146
+ viewMode: any;
147
+ editMode: boolean;
148
+ }
149
+
150
+ export enum DeviceViewType {
151
+ details = 0,
152
+ lines = 1,
153
+ speedDials = 2,
154
+ blf = 2,
155
+ }
156
+
157
+ export interface LineAssociationInterface {
158
+ index: number;
159
+ position?: number;
160
+ e164Mask: string;
161
+ textLabel: string;
162
+ displayLabel: string;
163
+ displayLabelAscii: string;
164
+ directoryNumber: LineDirectoryInterface;
165
+ didPattern: TranslationPatternInterface;
166
+ mappedDids: Array<string>;
167
+ linePkid: string;
168
+ maxNumberOfCalls: number;
169
+ busyTrigger: number;
170
+ recordingOption: RecordingOptions;
171
+ recordingProfile: string;
172
+ recordingMediaSource: string;
173
+ visualMWI: string;
174
+ audibleMWI: string;
175
+ ringSetting_idle: string;
176
+ ringSetting_active: string;
177
+ pickupAAS_idle: string;
178
+ pickupAAS_active: string;
179
+ monitorCSS: string;
180
+ logMissedCall: string;
181
+ callInfoDisplay: LineCallInfoDisplayInterface;
182
+ lineLocalId: string;
183
+ sharedUsers: string[];
184
+ sharedDevices: string[];
185
+ ownerUserId: Array<string>;
186
+ associated: boolean;
187
+ populateWithDid: boolean;
188
+ }
189
+
190
+ export interface LineCallInfoDisplayInterface {
191
+ callerName: string;
192
+ callerNumber: string;
193
+ redirectedNumber: string;
194
+ dialedNumber: string;
195
+ }
196
+
197
+ export interface LineDirectoryInterface {
198
+ directoryNumber: string;
199
+ routePartitionName: string;
200
+ pkid: string;
201
+ dnType: string;
202
+ subType?: string;
203
+ templateDirectoryNumber?: string;
204
+ }
205
+
206
+ export interface TranslationPatternInterface {
207
+ pattern: string;
208
+ calledPartyTransformationMask: string;
209
+ description?: string;
210
+ site?: SiteShortDataInterface;
211
+ hasMultipleSites?: boolean;
212
+ multipleSitesId?: string;
213
+ }
214
+
215
+ export interface SiteShortDataInterface {
216
+ id: number;
217
+ name: string;
218
+ }
219
+
220
+ export enum RecordingOptions {
221
+ disabled = 'Call Recording Disabled',
222
+ auto_enabled = 'Automatic Call Recording Enabled',
223
+ selective_enabled = 'Selective Call Recording Enabled'
224
+ }
225
+ */
@@ -0,0 +1,40 @@
1
+ import { DeviceInterface } from './device';
2
+ import { LineInterface } from './line';
3
+
4
+ export class ListUser implements ListUserInterface {
5
+ // @ts-ignore
6
+ userid: string;
7
+ firstName?: string;
8
+ lastName?: string;
9
+ email?: string;
10
+ telephoneNumber?: string;
11
+ devices: DeviceInterface[] = [];
12
+ deviceProfiles: DeviceInterface[] = [];
13
+ lines?: LineInterface[];
14
+ siteId?: number;
15
+ siteName?: string;
16
+ webexUUID?: string;
17
+ cucmId?: number;
18
+
19
+ constructor(user?: ListUser) {
20
+ if (user) {
21
+ Object.assign(this, user);
22
+ }
23
+ }
24
+ }
25
+
26
+ export interface ListUserInterface {
27
+ userid: string;
28
+ firstName?: string;
29
+ lastName?: string;
30
+ email?: string;
31
+ telephoneNumber?: string;
32
+ viewMode?: any;
33
+ devices: DeviceInterface[];
34
+ deviceProfiles: DeviceInterface[];
35
+ lines?: LineInterface[];
36
+ siteId?: number;
37
+ siteName?: string;
38
+ webexUUID?: string;
39
+ cucmId?: number;
40
+ }
@@ -0,0 +1,8 @@
1
+ export enum UserView {
2
+ USER = 0,
3
+ DEVICE = 1,
4
+ LINE = 2,
5
+ SNR = 3,
6
+ FEATURES = 4,
7
+ USER_COLLECTION = 5
8
+ }
@@ -0,0 +1,84 @@
1
+ import { NgModule } from '@angular/core';
2
+
3
+ import { MatExpansionModule } from '@angular/material/expansion';
4
+ import { MatDatepickerModule } from '@angular/material/datepicker';
5
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
6
+ import { MatChipsModule } from '@angular/material/chips';
7
+ import { MatListModule } from '@angular/material/list';
8
+ import { MatSidenavModule } from '@angular/material/sidenav';
9
+ import { MatTreeModule } from '@angular/material/tree';
10
+ import { DragDropModule } from '@angular/cdk/drag-drop';
11
+ import { MatButtonModule } from '@angular/material/button';
12
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
13
+ import { MatInputModule } from '@angular/material/input';
14
+ import { MatNativeDateModule } from '@angular/material/core';
15
+ import { MatTooltipModule } from '@angular/material/tooltip';
16
+ import {MatFormFieldModule} from '@angular/material/form-field';
17
+ import {MatStepperModule} from '@angular/material/stepper';
18
+ import {MatTabsModule} from '@angular/material/tabs';
19
+ import {MatCardModule} from '@angular/material/card';
20
+ import {MatSelectModule} from '@angular/material/select';
21
+ import {MatCheckboxModule} from '@angular/material/checkbox';
22
+ import {MatSlideToggleModule} from '@angular/material/slide-toggle';
23
+ import { MatTableModule } from '@angular/material/table';
24
+ import { MatPaginatorModule } from '@angular/material/paginator';
25
+
26
+
27
+ @NgModule({
28
+ imports: [
29
+ DragDropModule,
30
+ MatButtonModule,
31
+ MatListModule,
32
+ MatProgressSpinnerModule,
33
+ MatExpansionModule,
34
+ MatInputModule,
35
+ MatInputModule,
36
+ MatListModule,
37
+ MatTreeModule,
38
+ MatTreeModule,
39
+ MatNativeDateModule,
40
+ MatDatepickerModule,
41
+ MatTooltipModule,
42
+ MatAutocompleteModule,
43
+ MatChipsModule,
44
+ MatSidenavModule,
45
+ MatFormFieldModule,
46
+ MatStepperModule,
47
+ MatTabsModule,
48
+ MatCardModule,
49
+ MatSelectModule,
50
+ MatCheckboxModule,
51
+ MatSlideToggleModule,
52
+ MatTableModule,
53
+ MatPaginatorModule
54
+ ],
55
+ exports: [
56
+ DragDropModule,
57
+ MatButtonModule,
58
+ MatListModule,
59
+ MatProgressSpinnerModule,
60
+ MatExpansionModule,
61
+ MatInputModule,
62
+ MatInputModule,
63
+ MatListModule,
64
+ MatTreeModule,
65
+ MatTreeModule,
66
+ MatNativeDateModule,
67
+ MatDatepickerModule,
68
+ MatTooltipModule,
69
+ MatAutocompleteModule,
70
+ MatChipsModule,
71
+ MatSidenavModule,
72
+ MatFormFieldModule,
73
+ MatStepperModule,
74
+ MatTabsModule,
75
+ MatCardModule,
76
+ MatCheckboxModule,
77
+ MatSelectModule,
78
+ MatSlideToggleModule,
79
+ MatProgressSpinnerModule,
80
+ MatTableModule,
81
+ MatPaginatorModule
82
+ ],
83
+ })
84
+ export class MaterialModule { }
@@ -0,0 +1,87 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
3
+ import { TableDataInterface } from '../classes/table-data';
4
+ import { Observable } from 'rxjs';
5
+
6
+ const apiUrl = 'http://192.168.0.191:8080';
7
+
8
+ @Injectable()
9
+ export class APIService {
10
+ public token: any;
11
+ constructor(
12
+ private httpClient: HttpClient
13
+ ) {
14
+ }
15
+
16
+ fetch(url: string, params = {}, cache?: boolean) {
17
+ const headers = this.getHeaders(cache);
18
+ return this.httpClient.get(apiUrl + url, {params: this.prepareEncodedParams(params), headers});
19
+ }
20
+
21
+ post(url: string, body: any, params = {}): any {
22
+ body = body || null;
23
+ const headers = this.getHeaders();
24
+ return this.httpClient.post(apiUrl + url, body, {params: this.prepareEncodedParams(params), headers});
25
+ }
26
+
27
+ // use when response extended data is necessary:
28
+ postExtended(url: string, body = null, params = {}, headers = {}) {
29
+ headers = headers || this.getHeaders();
30
+ return this.httpClient.post(apiUrl + url, body, {
31
+ headers,
32
+ observe: 'response',
33
+ params: this.prepareEncodedParams(params)
34
+ });
35
+ }
36
+
37
+ put(url: string, body = null, params = {}) {
38
+ const headers = this.getHeaders();
39
+ return this.httpClient.put(apiUrl + url, body, {headers, params: this.prepareEncodedParams(params)});
40
+ }
41
+
42
+ delete(url: string, params = {}) {
43
+ const headers = this.getHeaders();
44
+ return this.httpClient.delete(apiUrl + url, {headers, params: this.prepareEncodedParams(params)});
45
+ }
46
+
47
+ fetchPagination(url: string, pageSize: number, pageNumber: number, additionalParams = {}, cache?: boolean): Observable<TableDataInterface> {
48
+ const copyAdditionalParams = JSON.parse(JSON.stringify(additionalParams));
49
+ const params = Object.assign(copyAdditionalParams, {size: pageSize.toString(), page: pageNumber.toString()});
50
+ return this.fetch(url, params, cache) as Observable<TableDataInterface>;
51
+ }
52
+
53
+ private prepareEncodedParams(params: any) {
54
+ const result: any = {};
55
+
56
+ if (!params) {
57
+ return {};
58
+ }
59
+ for (const key of Object.keys(params)) {
60
+ if (params[key]) {
61
+ const stringParam = params[key].toString();
62
+ result[key] = stringParam.includes('+') ? encodeURIComponent(stringParam) : stringParam;
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+
68
+ private getHeaders(cache?: boolean): HttpHeaders {
69
+ let headers = new HttpHeaders();
70
+ if (cache) {
71
+ headers = headers.append('_Cache', 'true ');
72
+ }
73
+ const token = this.token || this.getParameterByName('token');
74
+ headers = headers.append('Authorization', 'Bearer '+ token);
75
+ return headers;
76
+ }
77
+
78
+ private getParameterByName(name: any, url = window.location.href) {
79
+ name = name.replace(/[\[\]]/g, '\\$&');
80
+ var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
81
+ results = regex.exec(url);
82
+ if (!results) return null;
83
+ if (!results[2]) return '';
84
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
85
+ }
86
+
87
+ }
@@ -0,0 +1,11 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Subject } from 'rxjs';
3
+
4
+ @Injectable()
5
+ export class EventsCommunicationService {
6
+ public onSuccessfulLoginEvent = new Subject();
7
+
8
+ constructor() {
9
+ }
10
+
11
+ }
@@ -0,0 +1,68 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Notification } from '../classes/notification';
3
+ import { Subject } from 'rxjs';
4
+ const SUCCESS_TIME = 5000;
5
+ const INACTIVE_SESSION_MESSAGE = 'Your session was lost due to inactivity. Please login again';
6
+ const INACTIVE_SESSION = 'SESSION_INACTIVE';
7
+
8
+ @Injectable()
9
+ export class NotificationService {
10
+
11
+ public listChange = new Subject();
12
+
13
+ private max = 0;
14
+ private list: Notification[] = [];
15
+
16
+ constructor(
17
+ ) {
18
+ }
19
+
20
+ error(message: string, ttl?: number): void {
21
+ this.notify('error', message, ttl);
22
+ }
23
+
24
+ success(message: string, ttl?: number): void {
25
+ this.notify('success', message, (!ttl) ? SUCCESS_TIME : ttl);
26
+ }
27
+
28
+ warning(message: string, ttl?: number): void {
29
+ this.notify('warning', message, ttl);
30
+ }
31
+
32
+ info(message: string, ttl?: number): void {
33
+ this.notify('info', message, ttl);
34
+ }
35
+ private notify(type: string, message: string, ttl?: number): void {
36
+ const found = this.list.find((n: Notification) => n.message === message);
37
+ if (found) {
38
+ this.remove(found);
39
+ }
40
+ const notification = new Notification({
41
+ id: ++this.max,
42
+ type, message, ttl
43
+ });
44
+ if (notification.ttl > 0) {
45
+ notification.timerId = setTimeout(() => this.remove(notification, true), notification.ttl);
46
+ }
47
+ this.list.push(notification);
48
+ this.listChange.next(this.list);
49
+ }
50
+
51
+ remove(notification: Notification, auto?: boolean): void {
52
+ if (!auto && notification.timerId) {
53
+ // clear timeout in case of manual remove
54
+ clearInterval(notification.timerId);
55
+ }
56
+ this.list = this.list.filter(n => n.id !== notification.id);
57
+ this.listChange.next(this.list);
58
+ }
59
+
60
+ private removeInactiveSessionError(): void {
61
+ if (!this.list || !this.list.length) {
62
+ return;
63
+ }
64
+ this.list = this.list.filter(n => n.message !== INACTIVE_SESSION_MESSAGE && n.message !== INACTIVE_SESSION);
65
+ this.listChange.next(this.list);
66
+ }
67
+
68
+ }
@@ -0,0 +1,25 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { CUCMS_TO_IGNORE, CUCS_TO_IGNORE } from '../app.constants';
3
+
4
+ @Injectable()
5
+ export class RemoveKynFromIBMService {
6
+ constructor() {
7
+ }
8
+
9
+
10
+ removeCUCMS(date: any, customerId: number) {
11
+ if (customerId === 8) {
12
+ return date.filter((val: any) => !CUCMS_TO_IGNORE.includes(Math.round(val.cucmId)));
13
+ }
14
+ return date;
15
+ }
16
+
17
+ removeCUCS(date: any, customerId: number) {
18
+ if (customerId === 8) {
19
+ return date.filter((val: any) => !CUCS_TO_IGNORE.includes(Math.round(val.cucId)));
20
+ }
21
+ return date;
22
+ }
23
+
24
+
25
+ }
@@ -0,0 +1,117 @@
1
+ import {Injectable, OnInit} from '@angular/core';
2
+ import { Observable, of, forkJoin } from 'rxjs';
3
+ import { SimplifiedUser } from '../classes/simlified-user';
4
+ import { API } from '../app.constants';
5
+ import { APIService } from './api.service';
6
+ import { map } from 'rxjs/operators';
7
+ import { UtilsService } from '../utils/utils.service';
8
+
9
+ @Injectable()
10
+ export class UserService implements OnInit{
11
+ siteId: number = -1;
12
+ userId: string = '';
13
+ userIdExistPending = false;
14
+ hasExistedUserId = false;
15
+ user!: SimplifiedUser;
16
+ originUser!: SimplifiedUser;
17
+
18
+ constructor(
19
+ private apiService: APIService
20
+ ) {
21
+
22
+ }
23
+
24
+ ngOnInit(): void {
25
+ console.log(this.siteId)
26
+ }
27
+
28
+ public fetchUserToken(siteId: number, userId: string): any {
29
+ if (this.siteId === siteId && this.userId === userId && this.user) {
30
+ return of(this.user);
31
+ }
32
+ this.siteId = siteId;
33
+ this.userId = userId;
34
+ return this.apiService.fetch(API.USER_TOKEN.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(userId))))
35
+ .pipe(map((result: any) => {
36
+ this.setSimplifiedUser(Object.values(result)[0]);
37
+ }))
38
+ // .pipe(this.handleError(false, true));
39
+ }
40
+
41
+ public updateUserFields(body: any): any {
42
+ if (!this.userId || !this.siteId || !this.user?.token) {
43
+ return;
44
+ }
45
+ return this.apiService.post(API.UPDATE_USER_FIELDS.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), body)
46
+ // .pipe(this.handleError(false, true));
47
+ }
48
+
49
+ public fetchUserById(id: string) {
50
+ this.userIdExistPending = true;
51
+ return this.apiService.fetch(API.USER_BY_ID.replace(':siteId', String(this.siteId)).replace(':userId', encodeURIComponent(encodeURIComponent(id))))
52
+ .pipe(map(result => {
53
+ this.userIdExistPending = false;
54
+ return result;
55
+ }));
56
+ }
57
+
58
+ public persistCacheChanges() {
59
+ const params = {
60
+ excludeDeviceExtraOptions: true
61
+ };
62
+ return this.processUserChangesToCache()
63
+ .pipe(map((result: any) => {
64
+ return this.apiService.post(API.PERSIST_USER_CACHE.replace(':siteId', String(this.siteId)).replace(':token', this.user.token), {}, params)
65
+ .subscribe(() => {
66
+
67
+ })
68
+ // .pipe(map((user) => {
69
+ // // this.setUser(user, false, this.user.token);
70
+ // this.user.hasModifiedCache = false;
71
+ // }))
72
+ // .pipe(this.handleError(true, true));
73
+ }));
74
+ }
75
+
76
+ public processUserChangesToCache(): any {
77
+ const calls = [];
78
+ const body = UtilsService.diff(this.originUser.getSavableData(), this.user.getSavableData(), 'user');
79
+ if (body) {
80
+ calls.push(this.updateUserFields(body));
81
+ }
82
+ if (!calls?.length) {
83
+ return of(this.user);
84
+ }
85
+
86
+ return forkJoin(calls)
87
+ .pipe(map((responses: any) => {
88
+ // ApiUserResponse
89
+ this.handleSaveUserResponse(responses);
90
+ }))
91
+ // .pipe(this.handleError(false, true));
92
+
93
+ }
94
+
95
+ public hasUnsavedChanges() {
96
+ return !this.user.equal(this.originUser);
97
+ }
98
+
99
+ public setSimplifiedUser(user: any): void {
100
+ this.user = new SimplifiedUser(user);
101
+ const copiedUser = JSON.parse(JSON.stringify(user));
102
+ this.originUser = new SimplifiedUser(copiedUser);
103
+ }
104
+
105
+ private handleSaveUserResponse(responses: any) {
106
+ if (!responses?.length) {
107
+ return;
108
+ }
109
+ for (let len = responses.length, i = len - 1; i >= 0; i--) {
110
+ if (responses[i] && responses[i].currentUpdatedUser) {
111
+ // this.setUser(responses[i].currentUpdatedUser, false, this.user.token);
112
+ this.user.hasModifiedCache = true;
113
+ return;
114
+ }
115
+ }
116
+ }
117
+ }