@tuki-io/tuki-widgets 0.0.205 → 0.0.206

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 +2 -1
  6. package/esm2020/users-list/src/services/user.service.mjs +10 -5
  7. package/esm2020/users-list/src/users-list.component.mjs +185 -10
  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 +195 -12
  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 +193 -12
  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 +1 -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,6 +75,7 @@ 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",
80
81
  REVERT: "/api/webex/provisioning/customers/:customerId/persons/:personId/revertmigration",
@@ -457,6 +458,11 @@ class UserService {
457
458
  .replace(':formId', String(formId));
458
459
  return this.apiWebexService.fetch(url);
459
460
  }
461
+ getMigratedMigrationFormEntities(customerId, webexUUID, feature = 'PERSON') {
462
+ const url = API.MIGRATION_FORM_ENTITIES_MIGRATED
463
+ .replace(':customerId', String(customerId));
464
+ return this.apiWebexService.fetch(url, { webexUUID, feature });
465
+ }
460
466
  getMoveUserBody(customerId, user) {
461
467
  return {
462
468
  customerId: customerId,
@@ -532,12 +538,12 @@ class UserService {
532
538
  }
533
539
  }
534
540
  triggerFirmwareUpgrade(customerId, migrationFormId, deviceMap, customerType) {
535
- const migrationType = CUSTOMER_DESTINATION_MIGTATION_TYPE[customerType].toUpperCase();
541
+ // const migrationType = CUSTOMER_DESTINATION_MIGTATION_TYPE[customerType].toUpperCase();
536
542
  const url = API.TRIGGER_FIRMWARE_MIGRATION
537
- .replace(':migrationType', migrationType)
543
+ .replace(':migrationType', 'webex'.toUpperCase())
538
544
  .replace(':customerId', String(customerId))
539
545
  .replace(':migrationFormId', String(migrationFormId));
540
- return this.apiService
546
+ return this.apiWebexService
541
547
  .post(url, deviceMap);
542
548
  // .pipe(this.handleError(true, true));
543
549
  }
@@ -1650,11 +1656,14 @@ class UsersListComponent {
1650
1656
  }
1651
1657
  this.openUser.emit(user);
1652
1658
  }
1653
- moveUserToMT(user, index) {
1659
+ moveUserToMT(user) {
1654
1660
  if (user && user.siteId && user.userid) {
1655
1661
  this.moveUserPending = true;
1656
1662
  this.moveInProgressUserId = user.userid;
1657
- this.setStatusToUser(index, 'In Progress');
1663
+ const currentIndex = this.getUserIndexById(user.userid);
1664
+ if (currentIndex > -1) {
1665
+ this.setStatusToUser(currentIndex, 'In Progress');
1666
+ }
1658
1667
  localStorage.setItem(LOCAL_STORAGE.USER_IN_MIGRATION, user.userid);
1659
1668
  const subscription = this.userService
1660
1669
  .moveUserToMT(this.customerId, user)
@@ -1663,14 +1672,14 @@ class UsersListComponent {
1663
1672
  this.moveUserIndex = null;
1664
1673
  if (formId) {
1665
1674
  localStorage.setItem(LOCAL_STORAGE.MIGRATION_FORM_ID, String(formId));
1666
- this.pollMigrationFormStatus(formId, index, () => this.getMigratedUsers());
1675
+ this.pollMigrationFormStatusByUserId(formId, user.userid, () => this.getMigratedUsers());
1667
1676
  }
1668
1677
  else {
1669
1678
  this.getMigratedUsers();
1670
1679
  }
1671
1680
  }, () => {
1672
1681
  this.removeUserInMigrationProgress();
1673
- this.setStatusToUser(index, 'Migration Error');
1682
+ this.setStatusToUser(this.getUserIndexById(user.userid), 'Migration Error');
1674
1683
  });
1675
1684
  this.subscriptions.push(subscription);
1676
1685
  }
@@ -1823,7 +1832,7 @@ class UsersListComponent {
1823
1832
  if (result) {
1824
1833
  switch (type) {
1825
1834
  case 'QuickMove':
1826
- this.moveUserToMT(user, index);
1835
+ this.moveUserToMT(user);
1827
1836
  break;
1828
1837
  case 'MT':
1829
1838
  this.moveUser = user;
@@ -1930,6 +1939,128 @@ class UsersListComponent {
1930
1939
  const value = user?.webexUUID;
1931
1940
  return value !== null && value !== undefined && String(value).trim().length > 0;
1932
1941
  }
1942
+ buildFirmwareDeviceMap(entity, user) {
1943
+ const deviceMap = {};
1944
+ const mappedDevices = this.getActivationDevices(entity, user);
1945
+ console.log(mappedDevices);
1946
+ const devices = [];
1947
+ mappedDevices.forEach((rawDevice) => {
1948
+ const device = rawDevice;
1949
+ // @ts-ignore
1950
+ const isEligible = device.isRegistered || device.deviceToUpgrade || device.isEligible;
1951
+ devices.push({
1952
+ userId: user.userid,
1953
+ deviceName: device.name || '',
1954
+ deviceType: device.product || device.model || '',
1955
+ status: isEligible ? 'ELIGIBLE_TO_UPGRADE' : 'UNREGISTERED',
1956
+ errorDescription: '',
1957
+ cucmId: user.cucmId,
1958
+ feature: 'PERSON',
1959
+ selectable: true,
1960
+ disabledReason: false ? 'FIRMWARE_UPGRADE.DEVICE_NOT_MIGRATED' : '',
1961
+ });
1962
+ });
1963
+ if (!Object.keys(deviceMap).length) {
1964
+ console.debug('Firmware activation: no usable devices found to build deviceMap.');
1965
+ }
1966
+ devices.forEach((device) => {
1967
+ if (!deviceMap[device.cucmId]) {
1968
+ deviceMap[device.cucmId] = {};
1969
+ }
1970
+ if (!deviceMap[device.cucmId][device.feature]) {
1971
+ deviceMap[device.cucmId][device.feature] = [];
1972
+ }
1973
+ deviceMap[device.cucmId][device.feature].push(device.deviceName);
1974
+ });
1975
+ console.log("dev map ==> ", deviceMap);
1976
+ return deviceMap;
1977
+ }
1978
+ getActivationDevices(entity, user) {
1979
+ const migratedEntityDevices = Array.isArray(entity?.devices)
1980
+ ? (entity?.devices ?? [])
1981
+ : [];
1982
+ const entityDevices = Array.isArray(entity?.webexMigrationDevices)
1983
+ ? (entity?.webexMigrationDevices ?? [])
1984
+ : [];
1985
+ const allEntityDevices = [...migratedEntityDevices, ...entityDevices];
1986
+ if (allEntityDevices.length) {
1987
+ return allEntityDevices;
1988
+ }
1989
+ // Fallback for partial responses where only list-user devices are available.
1990
+ return [
1991
+ ...(Array.isArray(user?.devices) ? user.devices : []),
1992
+ ...(Array.isArray(user?.deviceProfiles) ? user.deviceProfiles : []),
1993
+ ];
1994
+ }
1995
+ unwrapMigratedDevice(rawDevice) {
1996
+ const candidate = rawDevice;
1997
+ if (candidate?.device) {
1998
+ return {
1999
+ ...candidate.device,
2000
+ ...candidate,
2001
+ };
2002
+ }
2003
+ return candidate || {};
2004
+ }
2005
+ isMigratedDeviceEligible(device) {
2006
+ const hasEligibilitySignal = device?.isRegistered !== undefined
2007
+ || device?.deviceToUpgrade !== undefined
2008
+ || device?.isEligible !== undefined;
2009
+ if (!hasEligibilitySignal) {
2010
+ return true;
2011
+ }
2012
+ return !!(device?.isRegistered || device?.deviceToUpgrade || device?.isEligible);
2013
+ }
2014
+ extractCucmId(entity, device, user) {
2015
+ const deviceCucmId = Number(device?.cucmId);
2016
+ if (Number.isFinite(deviceCucmId) && deviceCucmId > 0) {
2017
+ return deviceCucmId;
2018
+ }
2019
+ const userCucmId = Number(user?.cucmId);
2020
+ if (Number.isFinite(userCucmId)) {
2021
+ return userCucmId;
2022
+ }
2023
+ const entityCucmId = Number(entity?.cucmId);
2024
+ if (Number.isFinite(entityCucmId)) {
2025
+ return entityCucmId;
2026
+ }
2027
+ return null;
2028
+ }
2029
+ resolveMigratedDeviceKey(device) {
2030
+ return String(device?.name ||
2031
+ device?.mac ||
2032
+ device?.deviceId ||
2033
+ device?.cisUuid ||
2034
+ device?.id ||
2035
+ '').trim();
2036
+ }
2037
+ extractMigratedDeviceLines(device) {
2038
+ const values = new Set();
2039
+ const lineAssociations = Array.isArray(device?.lineAssociations) ? device.lineAssociations : [];
2040
+ lineAssociations.forEach((lineAssociation) => {
2041
+ const directoryNumber = lineAssociation?.directoryNumber?.directoryNumber;
2042
+ const templateDirectoryNumber = lineAssociation?.directoryNumber?.templateDirectoryNumber;
2043
+ const e164Mask = lineAssociation?.e164Mask;
2044
+ [directoryNumber, templateDirectoryNumber, e164Mask].forEach((value) => {
2045
+ const normalized = String(value || '').trim();
2046
+ if (normalized) {
2047
+ values.add(normalized);
2048
+ }
2049
+ });
2050
+ });
2051
+ const lines = Array.isArray(device?.lines) ? device.lines : [];
2052
+ lines.forEach((line) => {
2053
+ const directoryNumber = line?.directoryNumber?.directoryNumber;
2054
+ const templateDirectoryNumber = line?.directoryNumber?.templateDirectoryNumber;
2055
+ [directoryNumber, templateDirectoryNumber].forEach((value) => {
2056
+ const normalized = String(value || '').trim();
2057
+ if (normalized) {
2058
+ values.add(normalized);
2059
+ }
2060
+ });
2061
+ });
2062
+ return Array.from(values);
2063
+ }
1933
2064
  onFirmwareUpgradeClicked(user) {
1934
2065
  if (!this.isValidWebexUuid(user) || user.status !== 'Inactive') {
1935
2066
  return;
@@ -1946,9 +2077,21 @@ class UsersListComponent {
1946
2077
  dialogRef.beforeClosed().subscribe((result) => {
1947
2078
  if (result) {
1948
2079
  this.setUserPendingStatus(user, 'Pending Activation');
1949
- // TODO: Replace with activation API once available.
1950
- timer(1500)
1951
- .pipe(takeUntil(this.destroy$))
2080
+ this.userService
2081
+ .getMigratedMigrationFormEntities(this.customerId, user.webexUUID || '', 'PERSON')
2082
+ .pipe(takeUntil(this.destroy$), map$1((entities) => {
2083
+ return Array.isArray(entities) ? entities[0] : entities || null;
2084
+ }), switchMap((entity) => {
2085
+ const formId = entity?.migrationFormId ?? entity?.id ?? null;
2086
+ if (!formId) {
2087
+ this.setUserPendingStatus(user, 'Inactive');
2088
+ this.notifications.error('Activation failed. Migration form not found.');
2089
+ return EMPTY;
2090
+ }
2091
+ const deviceMap = this.buildFirmwareDeviceMap(entity, user);
2092
+ console.log('device map ==> ', deviceMap);
2093
+ return this.userService.triggerFirmwareUpgrade(this.customerId, Number(formId), deviceMap);
2094
+ }), switchMap(() => timer(120000)))
1952
2095
  .subscribe({
1953
2096
  next: () => {
1954
2097
  this.setUserPendingStatus(user, 'Active');
@@ -2011,6 +2154,44 @@ class UsersListComponent {
2011
2154
  });
2012
2155
  this.subscriptions.push(subscription);
2013
2156
  }
2157
+ pollMigrationFormStatusByUserId(formId, userId, onCompleted) {
2158
+ const subscription = timer(0, 5000)
2159
+ .pipe(switchMap(() => this.userService.getMigrationFormStatus(this.customerId, formId)), takeUntil(this.destroy$), takeWhile((response) => {
2160
+ const status = response?.status;
2161
+ return !this.isMigrationStatusCompleted(status) && !this.isMigrationStatusFailed(status);
2162
+ }, true))
2163
+ .subscribe({
2164
+ next: (response) => {
2165
+ const status = response?.status;
2166
+ const index = this.getUserIndexById(userId);
2167
+ if (this.isMigrationStatusFailed(status)) {
2168
+ this.removeUserInMigrationProgress();
2169
+ if (index > -1) {
2170
+ this.setStatusToUser(index, 'Migration Error');
2171
+ }
2172
+ return;
2173
+ }
2174
+ if (this.isMigrationStatusCompleted(status)) {
2175
+ this.removeUserInMigrationProgress();
2176
+ if (index > -1) {
2177
+ this.setStatusToUser(index, 'Active');
2178
+ }
2179
+ onCompleted();
2180
+ }
2181
+ },
2182
+ error: () => {
2183
+ const index = this.getUserIndexById(userId);
2184
+ this.removeUserInMigrationProgress();
2185
+ if (index > -1) {
2186
+ this.setStatusToUser(index, 'Migration Error');
2187
+ }
2188
+ },
2189
+ });
2190
+ this.subscriptions.push(subscription);
2191
+ }
2192
+ getUserIndexById(userId) {
2193
+ return this.users?.findIndex((user) => user.userid === userId) ?? -1;
2194
+ }
2014
2195
  setOriginalUserStatus(email = '', status) {
2015
2196
  const originalUser = this.users.find((user) => user.email === email && !user.webexUUID);
2016
2197
  if (originalUser) {