@tuki-io/tuki-widgets 0.0.205 → 0.0.207

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 (28) hide show
  1. package/esm2020/contact-center/cc-script-editor/components/node-details-sidebar/node-details-sidebar.component.mjs +3 -3
  2. package/esm2020/user-device-manage/src/device-info/device-info.component.mjs +3 -3
  3. package/esm2020/user-manage/src/classes/device.mjs +2 -1
  4. package/esm2020/user-manage/src/device-list/device-row/device-row.component.mjs +3 -3
  5. package/esm2020/users-list/src/app.constants.mjs +3 -1
  6. package/esm2020/users-list/src/services/user.service.mjs +14 -6
  7. package/esm2020/users-list/src/users-list.component.mjs +186 -12
  8. package/fesm2015/tuki-io-tuki-widgets-contact-center.mjs +2 -2
  9. package/fesm2015/tuki-io-tuki-widgets-contact-center.mjs.map +1 -1
  10. package/fesm2015/tuki-io-tuki-widgets-user-device-manage.mjs +2 -2
  11. package/fesm2015/tuki-io-tuki-widgets-user-device-manage.mjs.map +1 -1
  12. package/fesm2015/tuki-io-tuki-widgets-user-manage.mjs +10 -9
  13. package/fesm2015/tuki-io-tuki-widgets-user-manage.mjs.map +1 -1
  14. package/fesm2015/tuki-io-tuki-widgets-users-list.mjs +201 -15
  15. package/fesm2015/tuki-io-tuki-widgets-users-list.mjs.map +1 -1
  16. package/fesm2020/tuki-io-tuki-widgets-contact-center.mjs +2 -2
  17. package/fesm2020/tuki-io-tuki-widgets-contact-center.mjs.map +1 -1
  18. package/fesm2020/tuki-io-tuki-widgets-user-device-manage.mjs +2 -2
  19. package/fesm2020/tuki-io-tuki-widgets-user-device-manage.mjs.map +1 -1
  20. package/fesm2020/tuki-io-tuki-widgets-user-manage.mjs +10 -9
  21. package/fesm2020/tuki-io-tuki-widgets-user-manage.mjs.map +1 -1
  22. package/fesm2020/tuki-io-tuki-widgets-users-list.mjs +199 -15
  23. package/fesm2020/tuki-io-tuki-widgets-users-list.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/user-manage/src/classes/device.d.ts +1 -0
  26. package/users-list/src/app.constants.d.ts +2 -0
  27. package/users-list/src/services/user.service.d.ts +2 -1
  28. package/users-list/src/users-list.component.d.ts +10 -1
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, ViewEncapsulation, Inject, Injectable, EventEmitter, Input, Output, ViewChild, NgModule } from '@angular/core';
3
- import { Subject, of, forkJoin, BehaviorSubject, Observable, timer, takeUntil, switchMap, takeWhile } from 'rxjs';
3
+ import { Subject, of, forkJoin, BehaviorSubject, Observable, takeUntil, map as map$1, switchMap, EMPTY, timer, takeWhile } from 'rxjs';
4
4
  import * as i11$1 from '@angular/material/table';
5
5
  import { MatTableDataSource, MatTableModule } from '@angular/material/table';
6
6
  import * as i1 from '@angular/material/dialog';
@@ -75,8 +75,10 @@ const API = {
75
75
  GET_LOCATIONS: "/api/search/webex/customers/:customerId/locations",
76
76
  PREPARE_PERSON_MIGRATION: "/api/migration/webex/preparepersonmigration",
77
77
  MIGRATION_FORM: "/api/search/webex/customers/:customerId/migrationforms/:formId",
78
+ MIGRATION_FORM_ENTITIES_MIGRATED: "/api/search/webex/customers/:customerId/migrationformentities/migrated",
78
79
  START_MIGRATION: "/api/migration/webex/startpersonmigration",
79
80
  TRIGGER_FIRMWARE_MIGRATION: "/api/migration/:migrationType/firmwaremigration/customer/:customerId/migration/:migrationFormId",
81
+ WEBEX_REVERT: "/api/webex/provisioning/customers/:customerId/persons/:personId/revertmigration",
80
82
  REVERT: "/api/webex/provisioning/customers/:customerId/persons/:personId/revertmigration",
81
83
  SWAP_STATUSES: "/api/cache/user/customer/:customerId/swap-status"
82
84
  };
@@ -457,6 +459,11 @@ class UserService {
457
459
  .replace(':formId', String(formId));
458
460
  return this.apiWebexService.fetch(url);
459
461
  }
462
+ getMigratedMigrationFormEntities(customerId, webexUUID, feature = 'PERSON') {
463
+ const url = API.MIGRATION_FORM_ENTITIES_MIGRATED
464
+ .replace(':customerId', String(customerId));
465
+ return this.apiWebexService.fetch(url, { webexUUID, feature });
466
+ }
460
467
  getMoveUserBody(customerId, user) {
461
468
  return {
462
469
  customerId: customerId,
@@ -532,17 +539,20 @@ class UserService {
532
539
  }
533
540
  }
534
541
  triggerFirmwareUpgrade(customerId, migrationFormId, deviceMap, customerType) {
535
- const migrationType = CUSTOMER_DESTINATION_MIGTATION_TYPE[customerType].toUpperCase();
542
+ // const migrationType = CUSTOMER_DESTINATION_MIGTATION_TYPE[customerType].toUpperCase();
536
543
  const url = API.TRIGGER_FIRMWARE_MIGRATION
537
- .replace(':migrationType', migrationType)
544
+ .replace(':migrationType', 'webex'.toUpperCase())
538
545
  .replace(':customerId', String(customerId))
539
546
  .replace(':migrationFormId', String(migrationFormId));
540
- return this.apiService
547
+ return this.apiWebexService
541
548
  .post(url, deviceMap);
542
549
  // .pipe(this.handleError(true, true));
543
550
  }
544
551
  revertMigration(customerId, personId) {
545
- return this.apiService.post(API.REVERT.replace(':customerId', String(customerId)).replace(':personId', personId), {});
552
+ const url = API.WEBEX_REVERT
553
+ .replace(':customerId', String(customerId))
554
+ .replace(':personId', personId);
555
+ return this.apiWebexService.post(url, {});
546
556
  // .pipe(this.handleError(true, true));
547
557
  }
548
558
  swapStatuses(customerId, email) {
@@ -1650,11 +1660,14 @@ class UsersListComponent {
1650
1660
  }
1651
1661
  this.openUser.emit(user);
1652
1662
  }
1653
- moveUserToMT(user, index) {
1663
+ moveUserToMT(user) {
1654
1664
  if (user && user.siteId && user.userid) {
1655
1665
  this.moveUserPending = true;
1656
1666
  this.moveInProgressUserId = user.userid;
1657
- this.setStatusToUser(index, 'In Progress');
1667
+ const currentIndex = this.getUserIndexById(user.userid);
1668
+ if (currentIndex > -1) {
1669
+ this.setStatusToUser(currentIndex, 'In Progress');
1670
+ }
1658
1671
  localStorage.setItem(LOCAL_STORAGE.USER_IN_MIGRATION, user.userid);
1659
1672
  const subscription = this.userService
1660
1673
  .moveUserToMT(this.customerId, user)
@@ -1663,14 +1676,14 @@ class UsersListComponent {
1663
1676
  this.moveUserIndex = null;
1664
1677
  if (formId) {
1665
1678
  localStorage.setItem(LOCAL_STORAGE.MIGRATION_FORM_ID, String(formId));
1666
- this.pollMigrationFormStatus(formId, index, () => this.getMigratedUsers());
1679
+ this.pollMigrationFormStatusByUserId(formId, user.userid, () => this.getMigratedUsers());
1667
1680
  }
1668
1681
  else {
1669
1682
  this.getMigratedUsers();
1670
1683
  }
1671
1684
  }, () => {
1672
1685
  this.removeUserInMigrationProgress();
1673
- this.setStatusToUser(index, 'Migration Error');
1686
+ this.setStatusToUser(this.getUserIndexById(user.userid), 'Migration Error');
1674
1687
  });
1675
1688
  this.subscriptions.push(subscription);
1676
1689
  }
@@ -1823,7 +1836,7 @@ class UsersListComponent {
1823
1836
  if (result) {
1824
1837
  switch (type) {
1825
1838
  case 'QuickMove':
1826
- this.moveUserToMT(user, index);
1839
+ this.moveUserToMT(user);
1827
1840
  break;
1828
1841
  case 'MT':
1829
1842
  this.moveUser = user;
@@ -1930,6 +1943,128 @@ class UsersListComponent {
1930
1943
  const value = user?.webexUUID;
1931
1944
  return value !== null && value !== undefined && String(value).trim().length > 0;
1932
1945
  }
1946
+ buildFirmwareDeviceMap(entity, user) {
1947
+ const deviceMap = {};
1948
+ const mappedDevices = this.getActivationDevices(entity, user);
1949
+ console.log(mappedDevices);
1950
+ const devices = [];
1951
+ mappedDevices.forEach((rawDevice) => {
1952
+ const device = rawDevice;
1953
+ // @ts-ignore
1954
+ const isEligible = device.isRegistered || device.deviceToUpgrade || device.isEligible;
1955
+ devices.push({
1956
+ userId: user.userid,
1957
+ deviceName: device.name || '',
1958
+ deviceType: device.product || device.model || '',
1959
+ status: isEligible ? 'ELIGIBLE_TO_UPGRADE' : 'UNREGISTERED',
1960
+ errorDescription: '',
1961
+ cucmId: user.cucmId,
1962
+ feature: 'PERSON',
1963
+ selectable: true,
1964
+ disabledReason: false ? 'FIRMWARE_UPGRADE.DEVICE_NOT_MIGRATED' : '',
1965
+ });
1966
+ });
1967
+ if (!Object.keys(deviceMap).length) {
1968
+ console.debug('Firmware activation: no usable devices found to build deviceMap.');
1969
+ }
1970
+ devices.forEach((device) => {
1971
+ if (!deviceMap[device.cucmId]) {
1972
+ deviceMap[device.cucmId] = {};
1973
+ }
1974
+ if (!deviceMap[device.cucmId][device.feature]) {
1975
+ deviceMap[device.cucmId][device.feature] = [];
1976
+ }
1977
+ deviceMap[device.cucmId][device.feature].push(device.deviceName);
1978
+ });
1979
+ console.log("dev map ==> ", deviceMap);
1980
+ return deviceMap;
1981
+ }
1982
+ getActivationDevices(entity, user) {
1983
+ const migratedEntityDevices = Array.isArray(entity?.devices)
1984
+ ? (entity?.devices ?? [])
1985
+ : [];
1986
+ const entityDevices = Array.isArray(entity?.webexMigrationDevices)
1987
+ ? (entity?.webexMigrationDevices ?? [])
1988
+ : [];
1989
+ const allEntityDevices = [...migratedEntityDevices, ...entityDevices];
1990
+ if (allEntityDevices.length) {
1991
+ return allEntityDevices;
1992
+ }
1993
+ // Fallback for partial responses where only list-user devices are available.
1994
+ return [
1995
+ ...(Array.isArray(user?.devices) ? user.devices : []),
1996
+ ...(Array.isArray(user?.deviceProfiles) ? user.deviceProfiles : []),
1997
+ ];
1998
+ }
1999
+ unwrapMigratedDevice(rawDevice) {
2000
+ const candidate = rawDevice;
2001
+ if (candidate?.device) {
2002
+ return {
2003
+ ...candidate.device,
2004
+ ...candidate,
2005
+ };
2006
+ }
2007
+ return candidate || {};
2008
+ }
2009
+ isMigratedDeviceEligible(device) {
2010
+ const hasEligibilitySignal = device?.isRegistered !== undefined
2011
+ || device?.deviceToUpgrade !== undefined
2012
+ || device?.isEligible !== undefined;
2013
+ if (!hasEligibilitySignal) {
2014
+ return true;
2015
+ }
2016
+ return !!(device?.isRegistered || device?.deviceToUpgrade || device?.isEligible);
2017
+ }
2018
+ extractCucmId(entity, device, user) {
2019
+ const deviceCucmId = Number(device?.cucmId);
2020
+ if (Number.isFinite(deviceCucmId) && deviceCucmId > 0) {
2021
+ return deviceCucmId;
2022
+ }
2023
+ const userCucmId = Number(user?.cucmId);
2024
+ if (Number.isFinite(userCucmId)) {
2025
+ return userCucmId;
2026
+ }
2027
+ const entityCucmId = Number(entity?.cucmId);
2028
+ if (Number.isFinite(entityCucmId)) {
2029
+ return entityCucmId;
2030
+ }
2031
+ return null;
2032
+ }
2033
+ resolveMigratedDeviceKey(device) {
2034
+ return String(device?.name ||
2035
+ device?.mac ||
2036
+ device?.deviceId ||
2037
+ device?.cisUuid ||
2038
+ device?.id ||
2039
+ '').trim();
2040
+ }
2041
+ extractMigratedDeviceLines(device) {
2042
+ const values = new Set();
2043
+ const lineAssociations = Array.isArray(device?.lineAssociations) ? device.lineAssociations : [];
2044
+ lineAssociations.forEach((lineAssociation) => {
2045
+ const directoryNumber = lineAssociation?.directoryNumber?.directoryNumber;
2046
+ const templateDirectoryNumber = lineAssociation?.directoryNumber?.templateDirectoryNumber;
2047
+ const e164Mask = lineAssociation?.e164Mask;
2048
+ [directoryNumber, templateDirectoryNumber, e164Mask].forEach((value) => {
2049
+ const normalized = String(value || '').trim();
2050
+ if (normalized) {
2051
+ values.add(normalized);
2052
+ }
2053
+ });
2054
+ });
2055
+ const lines = Array.isArray(device?.lines) ? device.lines : [];
2056
+ lines.forEach((line) => {
2057
+ const directoryNumber = line?.directoryNumber?.directoryNumber;
2058
+ const templateDirectoryNumber = line?.directoryNumber?.templateDirectoryNumber;
2059
+ [directoryNumber, templateDirectoryNumber].forEach((value) => {
2060
+ const normalized = String(value || '').trim();
2061
+ if (normalized) {
2062
+ values.add(normalized);
2063
+ }
2064
+ });
2065
+ });
2066
+ return Array.from(values);
2067
+ }
1933
2068
  onFirmwareUpgradeClicked(user) {
1934
2069
  if (!this.isValidWebexUuid(user) || user.status !== 'Inactive') {
1935
2070
  return;
@@ -1946,9 +2081,21 @@ class UsersListComponent {
1946
2081
  dialogRef.beforeClosed().subscribe((result) => {
1947
2082
  if (result) {
1948
2083
  this.setUserPendingStatus(user, 'Pending Activation');
1949
- // TODO: Replace with activation API once available.
1950
- timer(1500)
1951
- .pipe(takeUntil(this.destroy$))
2084
+ this.userService
2085
+ .getMigratedMigrationFormEntities(this.customerId, user.webexUUID || '', 'PERSON')
2086
+ .pipe(takeUntil(this.destroy$), map$1((entities) => {
2087
+ return Array.isArray(entities) ? entities[0] : entities || null;
2088
+ }), switchMap((entity) => {
2089
+ const formId = entity?.migrationFormId ?? entity?.id ?? null;
2090
+ if (!formId) {
2091
+ this.setUserPendingStatus(user, 'Inactive');
2092
+ this.notifications.error('Activation failed. Migration form not found.');
2093
+ return EMPTY;
2094
+ }
2095
+ const deviceMap = this.buildFirmwareDeviceMap(entity, user);
2096
+ console.log('device map ==> ', deviceMap);
2097
+ return this.userService.triggerFirmwareUpgrade(this.customerId, Number(formId), deviceMap);
2098
+ }), switchMap(() => timer(120000)))
1952
2099
  .subscribe({
1953
2100
  next: () => {
1954
2101
  this.setUserPendingStatus(user, 'Active');
@@ -1966,8 +2113,7 @@ class UsersListComponent {
1966
2113
  onRevertClicked(user) {
1967
2114
  if (user?.webexUUID) {
1968
2115
  this.setUserPendingStatus(user, 'Pending Deactivation');
1969
- this.userService.swapStatuses(this.customerId, user.email || '')
1970
- // this.userService.revertMigration(this.customerId, user.webexUUID)
2116
+ this.userService.revertMigration(this.customerId, user.webexUUID)
1971
2117
  .pipe(takeUntil(this.destroy$), switchMap(() => timer(2000)))
1972
2118
  .subscribe({
1973
2119
  next: () => {
@@ -2011,6 +2157,44 @@ class UsersListComponent {
2011
2157
  });
2012
2158
  this.subscriptions.push(subscription);
2013
2159
  }
2160
+ pollMigrationFormStatusByUserId(formId, userId, onCompleted) {
2161
+ const subscription = timer(0, 5000)
2162
+ .pipe(switchMap(() => this.userService.getMigrationFormStatus(this.customerId, formId)), takeUntil(this.destroy$), takeWhile((response) => {
2163
+ const status = response?.status;
2164
+ return !this.isMigrationStatusCompleted(status) && !this.isMigrationStatusFailed(status);
2165
+ }, true))
2166
+ .subscribe({
2167
+ next: (response) => {
2168
+ const status = response?.status;
2169
+ const index = this.getUserIndexById(userId);
2170
+ if (this.isMigrationStatusFailed(status)) {
2171
+ this.removeUserInMigrationProgress();
2172
+ if (index > -1) {
2173
+ this.setStatusToUser(index, 'Migration Error');
2174
+ }
2175
+ return;
2176
+ }
2177
+ if (this.isMigrationStatusCompleted(status)) {
2178
+ this.removeUserInMigrationProgress();
2179
+ if (index > -1) {
2180
+ this.setStatusToUser(index, 'Active');
2181
+ }
2182
+ onCompleted();
2183
+ }
2184
+ },
2185
+ error: () => {
2186
+ const index = this.getUserIndexById(userId);
2187
+ this.removeUserInMigrationProgress();
2188
+ if (index > -1) {
2189
+ this.setStatusToUser(index, 'Migration Error');
2190
+ }
2191
+ },
2192
+ });
2193
+ this.subscriptions.push(subscription);
2194
+ }
2195
+ getUserIndexById(userId) {
2196
+ return this.users?.findIndex((user) => user.userid === userId) ?? -1;
2197
+ }
2014
2198
  setOriginalUserStatus(email = '', status) {
2015
2199
  const originalUser = this.users.find((user) => user.email === email && !user.webexUUID);
2016
2200
  if (originalUser) {