@tuki-io/tuki-widgets 0.0.219-dev.58 → 0.0.219-dev.59
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/esm2020/workspaces/src/services/workspaces.service.mjs +40 -16
- package/fesm2015/tuki-io-tuki-widgets-workspaces.mjs +29 -11
- package/fesm2015/tuki-io-tuki-widgets-workspaces.mjs.map +1 -1
- package/fesm2020/tuki-io-tuki-widgets-workspaces.mjs +39 -15
- package/fesm2020/tuki-io-tuki-widgets-workspaces.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -293,20 +293,43 @@ function mergeDevices(a, b) {
|
|
|
293
293
|
webexUUID: b.webexUUID ?? a.webexUUID,
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
function toMacKey(value) {
|
|
297
|
+
return value ? withoutSep(value).replace(/[^0-9A-F]/g, '') : '';
|
|
298
|
+
}
|
|
299
|
+
function mergeCucmAndWebexWorkspaces(cucmWorkspaces, webexItems, webexWorkspaces) {
|
|
300
|
+
const result = [...cucmWorkspaces];
|
|
301
|
+
const cucmIndexByMac = new Map();
|
|
302
|
+
cucmWorkspaces.forEach((workspace, index) => {
|
|
303
|
+
const key = toMacKey(workspace.device.name);
|
|
304
|
+
if (key && !cucmIndexByMac.has(key)) {
|
|
305
|
+
cucmIndexByMac.set(key, index);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
webexWorkspaces.forEach((webexWorkspace, webexIndex) => {
|
|
309
|
+
const matchedMac = (webexItems[webexIndex].workspaceDevices || [])
|
|
310
|
+
.map(workspaceDevice => toMacKey(workspaceDevice.mac))
|
|
311
|
+
.find(key => key && cucmIndexByMac.has(key));
|
|
312
|
+
if (!matchedMac) {
|
|
313
|
+
result.push(webexWorkspace);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const cucmIndex = cucmIndexByMac.get(matchedMac);
|
|
317
|
+
cucmIndexByMac.delete(matchedMac);
|
|
318
|
+
const cucmWorkspace = result[cucmIndex];
|
|
319
|
+
result[cucmIndex] = {
|
|
320
|
+
...cucmWorkspace,
|
|
321
|
+
...webexWorkspace,
|
|
322
|
+
displayName: cucmWorkspace.displayName,
|
|
323
|
+
device: {
|
|
324
|
+
...mergeDevices(cucmWorkspace.device, webexWorkspace.device),
|
|
325
|
+
name: cucmWorkspace.device.name,
|
|
326
|
+
newName: cucmWorkspace.device.newName,
|
|
327
|
+
},
|
|
305
328
|
isHybrid: true,
|
|
306
|
-
cucmDeviceName:
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return
|
|
329
|
+
cucmDeviceName: cucmWorkspace.cucmDeviceName,
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
return result;
|
|
310
333
|
}
|
|
311
334
|
const FETCH_ALL_SIZE = 9999;
|
|
312
335
|
class WorkspacesService {
|
|
@@ -332,9 +355,10 @@ class WorkspacesService {
|
|
|
332
355
|
return forkJoin([cucm$, webex$]).pipe(map(([cucmResponse, webexResponse]) => {
|
|
333
356
|
const cucmParsed = parseResponse(cucmResponse);
|
|
334
357
|
const webexParsed = parseResponse(webexResponse);
|
|
358
|
+
const webexItems = webexParsed?.pageData || [];
|
|
335
359
|
const cucmWorkspaces = (cucmParsed?.pageData || []).map((item, index) => toWorkspace(item, index, true));
|
|
336
|
-
const webexWorkspaces =
|
|
337
|
-
const workspaces =
|
|
360
|
+
const webexWorkspaces = webexItems.map((item, index) => toWorkspace(item, index, false));
|
|
361
|
+
const workspaces = mergeCucmAndWebexWorkspaces(cucmWorkspaces, webexItems, webexWorkspaces);
|
|
338
362
|
return {
|
|
339
363
|
workspaces,
|
|
340
364
|
total: workspaces.length,
|