architwin 1.13.2 → 1.13.3

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.
@@ -11,7 +11,7 @@ import { IOT_LINKED_SYSTEMS, SPACE_EVENTS, TAG_TYPE } from '../../../types';
11
11
  import log from 'loglevel';
12
12
  import i18n from './i18n';
13
13
  import { dispatchSpaceEvent, _tagIotCategoryTypes, _tagIotDevices, _tags } from '../../../architwin';
14
- import { stringContains } from "../../../utils";
14
+ import { stringContains, generateUUID } from "../../../utils";
15
15
  import { batchAddEventListenerByClassName } from '../../events';
16
16
  let selectedIoTCatOption;
17
17
  let selectedIoTDeviceOption;
@@ -19,7 +19,7 @@ export let iotTagFormMode = "ADD" /* FORM_MODE.ADD */;
19
19
  export let selectedIoTSystem = '';
20
20
  export let selectedIotTag = undefined;
21
21
  let tagIotName, iotModelName, iotSerialNumber, iotMfrName, iotSystemLink;
22
- let selectedIoTCatId;
22
+ let selectedIoTCat;
23
23
  let linkedDevicesArray = [];
24
24
  let iotCategoryIconList = ['mdi-power', 'mdi-thermometer', 'mdi-water-percent', 'mdi-gauge', 'mdi-leak', 'mdi-water', 'mdi-lightbulb-on', 'mdi-gas-cylinder', 'mdi-flask', 'mdi-meter-electric', 'mdi-information-symbol', 'mdi-sine-wave'];
25
25
  export function renderTagIOTFormPane() {
@@ -99,8 +99,8 @@ export function renderTagIOTFormPane() {
99
99
 
100
100
  <div class="at_field at_flex_column" id="at-iot-device-main-container">
101
101
  <label for="">${i18n.t('IOT Devices')}</label>
102
- <div id="at-iot-devices-dropdown" data-cy="at-iot-devices-dropdown">
103
- <div id="at-setting-map-filter-dropdown" class="at_dropdown at_flex at_flex_row at_space_between">
102
+ <div id="at-iot-devices-dropdown" data-cy="at-iot-devices-dropdown" class="at-device-dropdown">
103
+ <div id="at-iot-devices-filter-dropdown" class="at_dropdown at_flex at_flex_row at_space_between">
104
104
  <div class="at_dropdown_toggle" id="at-iot-selected-device" data-cy="at-iot-selected-device">${i18n.t(selectedIoTDeviceOption)}</div>
105
105
  <span class="mdi mdi-chevron-down at_chevron" id="at-iot-cat-filter-chevron" data-cy="at-iot-cat-filter-chevron"></span>
106
106
  </div>
@@ -122,7 +122,9 @@ export function renderTagIOTFormPane() {
122
122
  <div> </div>
123
123
  </div>
124
124
 
125
- <div class="at_linked_device_container" id="at-linked-device-row">
125
+ <div>
126
+ <div class="at_linked_device_container" id="at-device-item-container">
127
+ </div>
126
128
  </div>
127
129
 
128
130
  </div>
@@ -155,19 +157,24 @@ function displayFormTitle() {
155
157
  title.innerHTML = '';
156
158
  const span = document.createElement('span');
157
159
  span.textContent = iotTagFormMode === "ADD" /* FORM_MODE.ADD */
158
- ? i18n.t('Add IOT Tag')
159
- : i18n.t('Edit IOT Tag');
160
+ ? i18n.t('AddIoTTag')
161
+ : i18n.t('EditIoTTag');
160
162
  title.appendChild(span);
161
163
  }
164
+ // displays selected Category in the dropdown
162
165
  function setSelectedIoTCat(payload) {
163
166
  log.info('setSelectedIoTCat()', payload);
164
167
  const selectedOption = document.getElementById('at-iot-selected-cat');
165
- selectedOption.innerText = payload;
168
+ selectedOption.innerText = payload.name;
166
169
  }
170
+ // displays selected Device in the dropdown
167
171
  function setSelectedIoTDevice(payload) {
168
172
  log.info('setSelectedIoTDevice()', payload);
169
173
  const selectedDevice = document.getElementById('at-iot-selected-device');
170
- selectedDevice.innerText = payload;
174
+ selectedDevice.innerText = '';
175
+ if (payload) {
176
+ selectedDevice.innerText = payload;
177
+ }
171
178
  }
172
179
  function setInputFields() {
173
180
  log.info('setInputFields()');
@@ -180,17 +187,34 @@ function setInputFields() {
180
187
  export function setIotCategoryOptions() {
181
188
  log.info('setIotCategoryOptions()');
182
189
  dispatchSpaceEvent(SPACE_EVENTS.GET_IOT_CATEGORIES, { payload: 'hello from library' });
183
- renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
184
- batchAddEventListenerByClassName('at_iot_cat_option', (event) => {
185
- //@ts-ignore
186
- const selectedCat = event.target;
187
- const dataCy = selectedCat.getAttribute('data-cy');
188
- const match = dataCy.match(/^at-iot-category-option-(.+)$/);
189
- const selectedId = match ? match[1] : null;
190
- selectedIoTCatId = selectedCat.innerText; // this is set to inner text as uuid for category changes due to dummy data
191
- setSelectedIoTCat(selectedCat.innerText);
192
- log.info('cat id: ', selectedIoTCatId);
193
- });
190
+ if (_tagIotCategoryTypes) {
191
+ renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
192
+ batchAddEventListenerByClassName('at_iot_cat_option', (event) => {
193
+ //@ts-ignore
194
+ const selectedCat = event.target;
195
+ const catUUID = selectedCat.getAttribute('iot-category-uuid');
196
+ selectedIoTCat = { uuid: catUUID, name: selectedCat.innerText };
197
+ setSelectedIoTCat(selectedIoTCat);
198
+ log.info('cat id: ', selectedIoTCat);
199
+ });
200
+ }
201
+ }
202
+ // gets selected Category and returns the object
203
+ export function getIotCategoryOption() {
204
+ log.info('getIotCategoryOption()');
205
+ let foundCat = {};
206
+ if (linkedDevicesArray.length > 1) {
207
+ foundCat = _tagIotCategoryTypes.find((cat) => {
208
+ return i18n.t(cat.name) === 'Multiple';
209
+ });
210
+ }
211
+ else {
212
+ foundCat = _tagIotCategoryTypes.find((cat) => {
213
+ return i18n.t(cat.uuid) === selectedIoTCat.uuid;
214
+ });
215
+ }
216
+ log.info('foundCat: ', foundCat);
217
+ return foundCat;
194
218
  }
195
219
  export function toggleIoTCategoryOptions() {
196
220
  log.info('toggleIoTCategoryOptions');
@@ -260,12 +284,14 @@ export function clearIoTDropdowns() {
260
284
  export function initIoTFormData(tagId) {
261
285
  log.info('initIoTFormData()');
262
286
  displayFormTitle();
287
+ const iotSave = document.getElementById('at-save-iot-btn');
288
+ iotSave.classList.remove('at_disabled');
263
289
  // Add Mode
264
290
  if (!tagId) {
265
- log.info('initIoTFormData() tagId not Exist: ', iotTagFormMode);
291
+ clearIoTDropdowns();
292
+ clearIotFields();
266
293
  if (iotTagFormMode == "ADD" /* FORM_MODE.ADD */) {
267
294
  if (tagIotName === null || tagIotName == undefined) {
268
- log.info('initIoTFormData() tagname check', tagIotName);
269
295
  setInputFields();
270
296
  }
271
297
  tagIotName.value = '';
@@ -273,11 +299,12 @@ export function initIoTFormData(tagId) {
273
299
  iotSerialNumber.value = '';
274
300
  iotMfrName.value = '';
275
301
  iotSystemLink.value = '';
302
+ linkedDevicesArray = [];
303
+ setIotDeviceOptions();
276
304
  }
277
305
  }
278
306
  else {
279
307
  const foundTag = _tags.find(tag => tag.json_data.id === tagId);
280
- log.info('initIoTFormData() foundTag: ', foundTag, _tags);
281
308
  if (foundTag) {
282
309
  selectedIotTag = foundTag;
283
310
  if (tagIotName === null || tagIotName == undefined) {
@@ -299,23 +326,23 @@ export function initIoTFormData(tagId) {
299
326
  setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
300
327
  }
301
328
  if (iotData.iot_category) {
302
- const cat = _tagIotCategoryTypes.find(cat => cat.name === iotData.iot_category);
329
+ const cat = _tagIotCategoryTypes.find(cat => cat.name.toLocaleLowerCase() === iotData.iot_category.toLocaleLowerCase());
303
330
  if (cat) {
304
- setSelectedIoTCat(cat.name);
305
- selectedIoTCatId = cat.name;
331
+ setSelectedIoTCat({ uuid: cat.uuid, name: cat.name });
332
+ selectedIoTCat = { uuid: cat.uuid, name: cat.name };
306
333
  }
307
334
  else {
308
335
  // for the Dummy data from App Side
309
- setSelectedIoTCat(i18n.t('NoSelection'));
336
+ setSelectedIoTCat({ uuid: generateUUID(), name: i18n.t('NoSelection') });
310
337
  renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
311
338
  }
312
339
  }
313
340
  log.info("iotData.linked_devices: ", iotData.linked_devices);
314
341
  if (iotData.linked_devices && iotData.linked_devices.length > 0) {
342
+ setIotDeviceOptions();
315
343
  // renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices)
316
344
  setSelectedIoTDevice(iotData.linked_devices[0].name);
317
345
  linkedDevicesArray = iotData.linked_devices;
318
- log.info("EDIT linkedDevicesArray: ", linkedDevicesArray);
319
346
  renderLinkedDevices(linkedDevicesArray);
320
347
  }
321
348
  else {
@@ -328,7 +355,7 @@ export function initIoTFormData(tagId) {
328
355
  // this is due to selecting the tags created from James
329
356
  log.info('initIoTFormData()', iotData);
330
357
  setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
331
- setSelectedIoTCat('No Selection');
358
+ setSelectedIoTCat({ uuid: generateUUID(), name: i18n.t('NoSelection') });
332
359
  renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
333
360
  renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices);
334
361
  }
@@ -370,8 +397,10 @@ export function renderIotCategoryDropdownOptions(elementId, items) {
370
397
  return;
371
398
  }
372
399
  items.forEach((item, index) => {
373
- const option = createCatOptionElement(item, 'iotcategory', index);
374
- element.appendChild(option);
400
+ if (item.name != 'Multiple') {
401
+ const option = createCatOptionElement(item, 'iotcategory', index);
402
+ element.appendChild(option);
403
+ }
375
404
  });
376
405
  }
377
406
  function createCatOptionElement(item, dropdownType, index) {
@@ -394,28 +423,33 @@ function createCatOptionElement(item, dropdownType, index) {
394
423
  return option;
395
424
  }
396
425
  function selectCatOption(option, elementId) {
397
- log.info('selectCatOption()', option, elementId);
426
+ dispatchSpaceEvent(SPACE_EVENTS.GET_IOT_CAT_ICON, { payload: option });
398
427
  }
428
+ // selects Devices from Arrayat-device-item-container
399
429
  export function setIotDeviceOptions() {
400
430
  log.info('setIotDeviceOptions()');
401
431
  dispatchSpaceEvent(SPACE_EVENTS.GET_IOT_DEVICES, { payload: 'hello from library' });
402
432
  renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices);
403
433
  batchAddEventListenerByClassName('at_iot_dev_option', (event) => {
404
434
  //@ts-ignore
405
- const selectedDev = event.target;
406
- const parent = selectedDev.parentElement;
407
- log.info('@caroline parent: ', parent);
435
+ const selectedDev = document.getElementById(event.target.id);
436
+ const parent = selectedDev.closest('div');
408
437
  const deviceId = parent.getAttribute('iot-device-uuid');
409
- log.info('@caroline deviceId: ', deviceId);
410
- const device = _tagIotDevices.find(device => device.id == deviceId);
411
- log.info("device", device);
412
- setSelectedIoTDevice(selectedDev.innerText);
413
- linkedDevicesArray.push(device);
414
- renderLinkedDevices(linkedDevicesArray);
438
+ // adds selected device to array
439
+ const devFound = _tagIotDevices.find(device => device.id === deviceId);
440
+ if (devFound) {
441
+ selectedDev.setAttribute('disabled', 'true');
442
+ setSelectedIoTDevice(selectedDev.innerText);
443
+ linkedDevicesArray.push(devFound);
444
+ //hides the selected device in dropdown
445
+ parent.style.display = 'none'; //hides
446
+ renderDeviceRow(devFound);
447
+ selectedDev.setAttribute('disabled', 'false');
448
+ }
415
449
  });
416
450
  }
417
451
  export function renderIotDeviceDropdownOptions(elementId, items) {
418
- log.info("renderIotDeviceDropdownOptions: ", items);
452
+ log.info("renderIotDeviceDropdownOptions: ");
419
453
  const element = document.getElementById(elementId);
420
454
  if (!element) {
421
455
  console.error("Parameter element is undefined");
@@ -442,7 +476,7 @@ export function renderIotDeviceDropdownOptions(elementId, items) {
442
476
  <span></span> ${i18n.t('Select Device')}
443
477
  `;
444
478
  selectDevice.onclick = () => {
445
- log.info('@caroline onClick');
479
+ log.info('item selected: ', selectDevice, linkedDevicesArray);
446
480
  selectDeviceOption(selectDevice, isFilterDropdown ? 'at-iot-device-filter-dropdown-toggle' : 'at-iot-device-filter-dropdown-toggle');
447
481
  };
448
482
  element.appendChild(selectDevice);
@@ -471,16 +505,18 @@ function createDeviceOptionElement(item, dropdownType) {
471
505
  option.setAttribute('iot-device-uuid', item.id);
472
506
  option.setAttribute('dropdown-type', dropdownType);
473
507
  option.setAttribute('data-cy', `at-iot-category-option-${item.id}`);
474
- if (dropdownType == 'category') {
475
- option.innerHTML = `
476
- <span class="at_colored-indicator"></span>
477
- ${item.name}
478
- `;
479
- return option;
480
- }
481
508
  option.innerHTML = `
482
- <span>${item.name}</span>
509
+ <span style="width: 100%" id="${item.id}">${item.name}</span>
483
510
  `;
511
+ if (selectedIotTag) {
512
+ const iotTag = selectedIotTag.iot_tag;
513
+ const hideOption = iotTag.linked_devices.find((dev) => {
514
+ return dev.id === item.id;
515
+ });
516
+ if (hideOption != undefined) {
517
+ option.style.setProperty('display', 'none', 'important');
518
+ }
519
+ }
484
520
  return option;
485
521
  }
486
522
  /**
@@ -499,7 +535,8 @@ export function getIotTagFormData() {
499
535
  modelName: iotModelName.value,
500
536
  serialNumber: iotSerialNumber.value,
501
537
  tagMf: iotMfrName.value,
502
- tagCategoryId: selectedIoTCatId,
538
+ // tagCategoryId: selectedIoTCat.uuid,
539
+ tagCategoryId: selectedIoTCat.name,
503
540
  systemLink: iotSystemLink.value,
504
541
  linkedDevices: linkedDevicesArray,
505
542
  iotSystem: selectedIoTSystem,
@@ -508,21 +545,19 @@ export function getIotTagFormData() {
508
545
  return formData;
509
546
  }
510
547
  function renderLinkedDevices(linkedDevices) {
511
- log.info('renderLinkedDevices()', linkedDevices);
548
+ log.info('renderLinkedDevices()');
512
549
  if (linkedDevices) {
513
- const devicesContainer = document.getElementById('at-linked-device-row');
550
+ const devicesContainer = document.getElementById('at-device-item-container');
514
551
  if (linkedDevices.length > 0) {
515
- devicesContainer.innerHTML = ``;
516
552
  linkedDevices.forEach(device => {
517
- log.info("@caroline device: ", device);
518
553
  renderDeviceRow(device);
519
554
  });
520
555
  }
521
556
  }
522
557
  }
523
558
  function renderDeviceRow(payload) {
524
- log.info('renderDeviceRow()', payload);
525
- const devicesContainer = document.getElementById('at-linked-device-row');
559
+ log.info('renderDeviceRow()');
560
+ const devicesContainer = document.getElementById('at-device-item-container');
526
561
  if (payload) {
527
562
  const deviceRow = document.createElement('div');
528
563
  deviceRow.classList.add('at_flex_row');
@@ -538,25 +573,37 @@ function renderDeviceRow(payload) {
538
573
  <div></div>
539
574
  </div>
540
575
  <div class="at_icon_right">
541
- <span class="mdi mdi-delete-outline at_delete_device_btn" id="at-delete-device-${payload.uuid}"></span>
576
+ <span class="mdi mdi-delete-outline at_delete_device_btn" id="at-delete-device-${payload.id}"></span>
542
577
  </div>
543
578
  `;
544
579
  devicesContainer.appendChild(deviceRow);
545
580
  batchAddEventListenerByClassName('at_delete_device_btn', (event) => __awaiter(this, void 0, void 0, function* () {
546
- log.info('deleteSelectedLinkedDevice is clicked', event);
547
581
  //@ts-ignore
548
- const selectedDevice = document.getElementById(event.target.id);
582
+ const selectedDevice = event.target;
549
583
  if (selectedDevice) {
550
- log.info('deleteSelectedLinkedDevice', selectedDevice);
551
- // will be tested when using live data
552
- // const devId = extractUUID(selectedDevice.id)
553
- const devId = selectedDevice.id.split('at-delete-partition-')[1];
554
- const findDevice = linkedDevicesArray.findIndex(dev => dev.id == devId);
555
- log.info('deleteSelectedLinkedDevice found device', findDevice, devId);
556
- linkedDevicesArray.splice(findDevice, 1);
557
- const parent = selectedDevice.closest('.at_partition_item');
558
- parent.style.display = 'none';
559
- log.info('deleteSelectedLinkedDevice parent', parent);
584
+ // gets the device id
585
+ const devId = selectedDevice.id.split('at-delete-device-')[1];
586
+ // finds the index of the selected device
587
+ const findDevice = linkedDevicesArray.findIndex(dev => dev.id === devId);
588
+ if (findDevice > -1) {
589
+ selectedDevice.setAttribute('disabled', 'true');
590
+ const parent = selectedDevice.closest('.at_partition_item');
591
+ if (parent) {
592
+ // displays delete Device back in Dropdown List
593
+ const findHideDev = document.querySelector(`div[iot-device-uuid="${devId}"]`);
594
+ const devicesDropdown = document.getElementById('at-iot-selected-device');
595
+ if (findHideDev) {
596
+ findHideDev.style.display = "block";
597
+ parent.style.display = 'none';
598
+ linkedDevicesArray.splice(findDevice, 1);
599
+ }
600
+ if (linkedDevicesArray.length === 0) {
601
+ devicesDropdown.innerText = i18n.t('Select Device');
602
+ setIotDeviceOptions();
603
+ }
604
+ }
605
+ selectedDevice.setAttribute('disabled', 'false');
606
+ }
560
607
  }
561
608
  }));
562
609
  return;
@@ -573,7 +620,7 @@ export function clearIotFields() {
573
620
  iotSerialNumber = document.getElementById('at-iot-serial-input');
574
621
  iotMfrName = document.getElementById('at-iot-manufacturer-input');
575
622
  iotSystemLink = document.getElementById('at-iot-system-link-input');
576
- const deviceContainer = document.getElementById("linked-devices-container");
623
+ const deviceContainer = document.getElementById('at-device-item-container');
577
624
  tagIotName.innerText = '';
578
625
  iotModelName.innerText = '';
579
626
  iotSerialNumber.innerText = '';
@@ -582,10 +629,9 @@ export function clearIotFields() {
582
629
  linkedDevicesArray = [];
583
630
  selectedIoTSystem = '';
584
631
  setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
585
- if (deviceContainer !== null) {
586
- deviceContainer.innerHTML = '';
587
- }
632
+ deviceContainer.innerHTML = '';
588
633
  iotTagFormMode = "ADD" /* FORM_MODE.ADD */;
634
+ selectedIotTag = undefined;
589
635
  }
590
636
  /**
591
637
  * Sets the form mode for the IOT form.
@@ -1,7 +1,7 @@
1
- import { ISpaceUser } from "../../../types";
1
+ import { ScreenShareUser } from "../../../types";
2
2
  export declare function renderViewingRemoteSpace(): HTMLElement;
3
3
  /**
4
4
  * Render the viewing remote space panel for the user sharing their screen.
5
5
  * @param user The user who is currently sharing their screen
6
6
  */
7
- export declare function renderRemoteSpaceViewing(user: ISpaceUser): void;
7
+ export declare function renderRemoteSpaceViewing(user: ScreenShareUser): void;
@@ -35,6 +35,7 @@ export function renderRemoteSpaceViewing(user) {
35
35
  if (!container && !maincontainer)
36
36
  return;
37
37
  maincontainer.style.display = 'block';
38
+ maincontainer.style.zIndex = '2';
38
39
  container.innerHTML = '';
39
40
  // === Main Card ===
40
41
  const card = document.createElement('div');
@@ -61,7 +62,7 @@ export function renderRemoteSpaceViewing(user) {
61
62
  circle.style.width = '15px';
62
63
  circle.style.height = '15px';
63
64
  circle.style.borderRadius = '50%';
64
- circle.style.backgroundColor = user.isActive ? '#22c55e' : '#ffffff';
65
+ circle.style.backgroundColor = user.onlineStatus == 'online' || user.onlineStatus == 'in_session' ? '#22c55e' : '#ffffff';
65
66
  circle.style.border = '1px solid #ccc';
66
67
  circle.style.marginRight = '10px';
67
68
  // Combine into card
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",