architwin 1.12.4 → 1.13.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 (44) hide show
  1. package/CORE_FEATURES.md +35 -0
  2. package/ONBOARDING.md +115 -0
  3. package/lib/architwin.d.ts +98 -6
  4. package/lib/architwin.js +1 -1
  5. package/lib/atwinui/components/toolbar/collapse.d.ts +18 -0
  6. package/lib/atwinui/components/toolbar/collapse.js +62 -0
  7. package/lib/atwinui/components/toolbar/i18n.js +52 -2
  8. package/lib/atwinui/components/toolbar/index.js +11 -1
  9. package/lib/atwinui/components/toolbar/menuBar.d.ts +1 -0
  10. package/lib/atwinui/components/toolbar/menuBar.js +11 -0
  11. package/lib/atwinui/components/toolbar/pipeFormPane.d.ts +31 -0
  12. package/lib/atwinui/components/toolbar/pipeFormPane.js +545 -0
  13. package/lib/atwinui/components/toolbar/pipeListPane.d.ts +19 -0
  14. package/lib/atwinui/components/toolbar/pipeListPane.js +388 -0
  15. package/lib/atwinui/components/toolbar/spaceUserListPane.d.ts +3 -0
  16. package/lib/atwinui/components/toolbar/spaceUserListPane.js +95 -0
  17. package/lib/atwinui/components/toolbar/tagIotForm.d.ts +20 -0
  18. package/lib/atwinui/components/toolbar/tagIotForm.js +391 -0
  19. package/lib/atwinui/components/toolbar/tagIotFormPane.d.ts +62 -0
  20. package/lib/atwinui/components/toolbar/tagIotFormPane.js +606 -0
  21. package/lib/atwinui/components/toolbar/tagMessagingPane.d.ts +4 -0
  22. package/lib/atwinui/components/toolbar/tagMessagingPane.js +117 -10
  23. package/lib/atwinui/components/toolbar/usersPane.d.ts +14 -0
  24. package/lib/atwinui/components/toolbar/usersPane.js +273 -0
  25. package/lib/atwinui/components/toolbar/viewingRemoteSpace.d.ts +7 -0
  26. package/lib/atwinui/components/toolbar/viewingRemoteSpace.js +77 -0
  27. package/lib/atwinui/events.d.ts +4 -1
  28. package/lib/atwinui/events.js +106 -26
  29. package/lib/atwinui/helpers.d.ts +15 -0
  30. package/lib/atwinui/helpers.js +49 -0
  31. package/lib/atwinui/index.js +2 -0
  32. package/lib/loaders/curosrMarkerLoader.d.ts +25 -0
  33. package/lib/loaders/curosrMarkerLoader.js +86 -0
  34. package/lib/loaders/index.d.ts +2 -1
  35. package/lib/loaders/index.js +2 -1
  36. package/lib/loaders/pathLoader.d.ts +99 -0
  37. package/lib/loaders/pathLoader.js +451 -0
  38. package/lib/tag.d.ts +1 -1
  39. package/lib/tag.js +2 -0
  40. package/lib/types.d.ts +80 -1
  41. package/lib/types.js +35 -0
  42. package/package.json +1 -1
  43. package/static/atwinui.css +267 -0
  44. package/static/utility.css +81 -1
@@ -0,0 +1,606 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { IOT_LINKED_SYSTEMS, SPACE_EVENTS, TAG_TYPE } from '../../../types';
11
+ import log from 'loglevel';
12
+ import i18n from './i18n';
13
+ import { dispatchSpaceEvent, _tagIotCategoryTypes, _tagIotDevices, _tags } from '../../../architwin';
14
+ import { stringContains } from "../../../utils";
15
+ import { batchAddEventListenerByClassName } from '../../events';
16
+ let selectedIoTCatOption;
17
+ let selectedIoTDeviceOption;
18
+ export let iotTagFormMode = "ADD" /* FORM_MODE.ADD */;
19
+ export let selectedIoTSystem = '';
20
+ export let selectedIotTag = undefined;
21
+ let tagIotName, iotModelName, iotSerialNumber, iotMfrName, iotSystemLink;
22
+ let selectedIoTCatId;
23
+ let linkedDevicesArray = [];
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
+ export function renderTagIOTFormPane() {
26
+ const element = document.createElement('div');
27
+ element.classList.add('at_container');
28
+ element.classList.add('at_w-12');
29
+ element.classList.add('at_h-full');
30
+ element.setAttribute('id', 'at-tag-iot-form-pane');
31
+ element.setAttribute('data-cy', 'at-tag-iot-form-pane');
32
+ element.innerHTML = `
33
+ <div class="at_panel_header" id="at-iot-form-title">
34
+ </div>
35
+
36
+ <div class="at_form_container at_scrollable_container at_h-min-70">
37
+ <label for="">${i18n.t('Linked Systems')}</label>
38
+ <div class="at_gap_2" style="display: inline-flex">
39
+ <label class="at_flex at_align_center at_text_xs at_gap_1">
40
+ <input type="radio" id="at-linked-radio-bemac" name="iot-link-system" checked value=${IOT_LINKED_SYSTEMS.BEMAC} selected />
41
+ ${i18n.t("BEMAC")}
42
+ </label>
43
+ <label class="at_flex at_align_center at_text_xs at_gap_1">
44
+ <input type="radio" id="at-linked-radio-hanasys" name="iot-link-system" value=${IOT_LINKED_SYSTEMS.HANASYS} />
45
+ ${i18n.t("HANASYS")}
46
+ </label>
47
+ <label class="at_flex at_align_center at_text_xs at_gap_1">
48
+ <input type="radio" id="at-linked-radio-link" name="iot-link-system" value=${IOT_LINKED_SYSTEMS.URL_LINK} />
49
+ ${i18n.t("URL Link")}
50
+ </label>
51
+ </div>
52
+
53
+ <div class="at_field at_flex_column">
54
+ <label for="">${i18n.t('Category')}</label>
55
+ <div id="at-iot-category-dropdown" data-cy="at-iot-category-dropdown">
56
+ <div id="at-iot-cat-filter-dropdown" class="at_dropdown at_flex at_flex_row at_space_between">
57
+ <div class="at_dropdown_toggle" id="at-iot-selected-cat" data-cy="at-iot-selected-cat">${i18n.t(selectedIoTCatOption)}</div>
58
+ <span class="mdi mdi-chevron-down at_chevron" id="at-iot-cat-filter-chevron" data-cy="at-iot-cat-filter-chevron"></span>
59
+ </div>
60
+
61
+ <div style="position:absolute;">
62
+ <div class="at_dropdown_options" id="at-iot-category-options" data-cy="at-iot-category-options">
63
+
64
+ </div>
65
+ </div>
66
+
67
+ </div>
68
+ </div>
69
+
70
+ <div class="at-field at_flex_row at_justify_between">
71
+ <label for="">${i18n.t('TagName')}</label>
72
+ <input class="at_field_input at_w-full" type="text" name="tag_name" id="at-iot-name-input" data-cy="at-iot-name-input" />
73
+ </div>
74
+
75
+ <div class="at-field at_flex_row at_justify_between">
76
+ <label for="">${i18n.t('Model Name')}</label>
77
+ <input class="at_field_input at_w-full" type="text" name="model_name" id="at-iot-model-input" data-cy="at-iot-model-input" />
78
+ </div>
79
+
80
+ <div class="at-field at_flex_row at_justify_between">
81
+ <label for="">${i18n.t('Serial Number')}</label>
82
+ <input class="at_field_input at_w-full" type="text" name="serial_name" id="at-iot-serial-input" data-cy="at-iot-serial-input" />
83
+ </div>
84
+
85
+ <div class="at-field at_flex_row at_justify_between">
86
+ <label for="">${i18n.t('Manufacturer Site')}</label>
87
+ <input class="at_field_input at_w-full" type="text" name="manufacturer_site" id="at-iot-manufacturer-input" data-cy="at-iot-manufacturer-input" />
88
+ </div>
89
+
90
+ <div class="at-field at_flex_row at_justify_between" id="at-iot-system-link-container" style="display: none">
91
+ <label for="">${i18n.t('System Link')}</label>
92
+ <input class="at_field_input at_w-full" type="text" name="system_link" id="at-iot-system-link-input" data-cy="at-iot-system-link-input" />
93
+ </div>
94
+
95
+ <div class="at_button at_ghost" id="at-iot-move-btn" data-cy="at-iot-move-btn" style="top: 4px !important">
96
+ <label for="" style="bottom: 10px !important" class="at_comment_unsend_container">${i18n.t('MoveTag')}</label>
97
+ <span class="mdi mdi-map-marker at_icon" style="bottom: 9px !important"></span>
98
+ </div>
99
+
100
+ <div class="at_field at_flex_column" id="at-iot-device-main-container">
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">
104
+ <div class="at_dropdown_toggle" id="at-iot-selected-device" data-cy="at-iot-selected-device">${i18n.t(selectedIoTDeviceOption)}</div>
105
+ <span class="mdi mdi-chevron-down at_chevron" id="at-iot-cat-filter-chevron" data-cy="at-iot-cat-filter-chevron"></span>
106
+ </div>
107
+
108
+ <div style="position:absolute;">
109
+ <div class="at_dropdown_options" id="at-iot-device-options" data-cy="at-iot-device-options">
110
+
111
+ </div>
112
+ </div>
113
+ </div>
114
+
115
+ <div class="at_partition_list_container at_h-min-40" id="at-iot-device-list-container" data-cy="at-iot-device-list-container">
116
+
117
+ <div class="at_partition_item_container at_scrollable_container" id="at-linked-device-container" data-cy="at-linked-device-container">
118
+
119
+ <div class="at_partition_title" style="padding-left: 20px !important;">
120
+ <div> </div>
121
+ <label for="">${i18n.t('Linked IOT Devices')}</label>
122
+ <div> </div>
123
+ </div>
124
+
125
+ <div class="at_linked_device_container" id="at-linked-device-row">
126
+ </div>
127
+
128
+ </div>
129
+
130
+ </div>
131
+
132
+ </div>
133
+ </div>
134
+
135
+ <div class="at_button_row at_justify_between">
136
+ <div class="at_button at_ghost at_comment_unsend_container" style="margin-top: auto;" id="at-cancel-iot-tag-form-btn" data-cy="at-cancel-iot-tag-form-btn" target-pane="at-tag-list-pane">
137
+ <label for="" id="at-cancel-tag-form-btn" class="at_comment_unsend_container">${i18n.t('Cancel')}</label>
138
+ <span class="mdi mdi-close-circle-outline at_comment_unsend_container" id="at-cancel-tag-form-btn"></span>
139
+ </div>
140
+
141
+ <div class="at_button at_ghost at_comment_unsend_container" id="at-save-iot-btn" data-cy="at-save-iot-btn">
142
+ <label for="" class="at_comment_unsend_container">${i18n.t('Save')}</label>
143
+ <span class="mdi mdi-plus-circle-outline at_comment_unsend_container"></span>
144
+ </div>
145
+ </div>
146
+ `;
147
+ return element;
148
+ }
149
+ /**
150
+ * Updates the form title based on the current form mode.
151
+ * Displays "Add IOT Tag" or "Edit IOT Tag" accordingly.
152
+ */
153
+ function displayFormTitle() {
154
+ const title = document.getElementById('at-iot-form-title');
155
+ title.innerHTML = '';
156
+ const span = document.createElement('span');
157
+ span.textContent = iotTagFormMode === "ADD" /* FORM_MODE.ADD */
158
+ ? i18n.t('Add IOT Tag')
159
+ : i18n.t('Edit IOT Tag');
160
+ title.appendChild(span);
161
+ }
162
+ function setSelectedIoTCat(payload) {
163
+ log.info('setSelectedIoTCat()', payload);
164
+ const selectedOption = document.getElementById('at-iot-selected-cat');
165
+ selectedOption.innerText = payload;
166
+ }
167
+ function setSelectedIoTDevice(payload) {
168
+ log.info('setSelectedIoTDevice()', payload);
169
+ const selectedDevice = document.getElementById('at-iot-selected-device');
170
+ selectedDevice.innerText = payload;
171
+ }
172
+ function setInputFields() {
173
+ log.info('setInputFields()');
174
+ tagIotName = document.getElementById('at-iot-name-input');
175
+ iotModelName = document.getElementById('at-iot-model-input');
176
+ iotSerialNumber = document.getElementById('at-iot-serial-input');
177
+ iotMfrName = document.getElementById('at-iot-manufacturer-input');
178
+ iotSystemLink = document.getElementById('at-iot-system-link-input');
179
+ }
180
+ export function setIotCategoryOptions() {
181
+ log.info('setIotCategoryOptions()');
182
+ 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
+ });
194
+ }
195
+ export function toggleIoTCategoryOptions() {
196
+ log.info('toggleIoTCategoryOptions');
197
+ const catDropdown = document.getElementById('at-iot-category-dropdown');
198
+ const catOptions = document.getElementById('at-iot-category-options');
199
+ catDropdown.addEventListener('click', () => {
200
+ catOptions.classList.toggle('open');
201
+ });
202
+ }
203
+ export function toggleIoTDevicesOptions() {
204
+ log.info('toggleIoTDevicesOptions()');
205
+ const devicesDropdown = document.getElementById('at-iot-devices-dropdown');
206
+ const deviceOptions = document.getElementById('at-iot-device-options');
207
+ devicesDropdown.addEventListener('click', () => {
208
+ deviceOptions.classList.toggle('open');
209
+ });
210
+ }
211
+ /**
212
+ * Sets Radio Button of the IoT's the Linked System
213
+ *
214
+ */
215
+ export function setSelectedIoTSystemRadio(payload) {
216
+ log.info('setSelectedIoTSystemRadio()');
217
+ const linkedDeviceContainer = document.getElementById('at-iot-device-main-container');
218
+ const systemLinkContainer = document.getElementById('at-iot-system-link-container');
219
+ let targetId = '';
220
+ if (payload == IOT_LINKED_SYSTEMS.BEMAC) {
221
+ targetId = 'at-linked-radio-bemac';
222
+ }
223
+ else if (payload == IOT_LINKED_SYSTEMS.HANASYS) {
224
+ targetId = 'at-linked-radio-hanasys';
225
+ }
226
+ else if (payload == IOT_LINKED_SYSTEMS.URL_LINK) {
227
+ targetId = 'at-linked-radio-link';
228
+ }
229
+ const linkedRadio = document.getElementById(targetId);
230
+ if (linkedRadio) {
231
+ selectedIoTSystem = payload;
232
+ linkedRadio.checked = true;
233
+ }
234
+ if (payload === IOT_LINKED_SYSTEMS.URL_LINK) {
235
+ log.info('payload == IOT_LINKED_SYSTEMS.URL_LINK', payload, IOT_LINKED_SYSTEMS.URL_LINK);
236
+ linkedDeviceContainer.style.display = 'none';
237
+ systemLinkContainer.style.display = 'block';
238
+ }
239
+ else {
240
+ linkedDeviceContainer.style.display = 'block';
241
+ systemLinkContainer.style.display = 'none';
242
+ }
243
+ }
244
+ /**
245
+ * Clears dropdowns for both Category and Devices
246
+ *
247
+ */
248
+ export function clearIoTDropdowns() {
249
+ log.info('clearIoTDropdowns()');
250
+ const catDropdown = document.getElementById('at-iot-selected-cat');
251
+ const devicesDropdown = document.getElementById('at-iot-selected-device');
252
+ catDropdown.innerText = i18n.t('NoSelection');
253
+ devicesDropdown.innerText = i18n.t('Select Device');
254
+ }
255
+ /**
256
+ * Initializes Form Data
257
+ * for both Add and Edit Modes
258
+ *
259
+ */
260
+ export function initIoTFormData(tagId) {
261
+ log.info('initIoTFormData()');
262
+ displayFormTitle();
263
+ // Add Mode
264
+ if (!tagId) {
265
+ log.info('initIoTFormData() tagId not Exist: ', iotTagFormMode);
266
+ if (iotTagFormMode == "ADD" /* FORM_MODE.ADD */) {
267
+ if (tagIotName === null || tagIotName == undefined) {
268
+ log.info('initIoTFormData() tagname check', tagIotName);
269
+ setInputFields();
270
+ }
271
+ tagIotName.value = '';
272
+ iotModelName.value = '';
273
+ iotSerialNumber.value = '';
274
+ iotMfrName.value = '';
275
+ iotSystemLink.value = '';
276
+ }
277
+ }
278
+ else {
279
+ const foundTag = _tags.find(tag => tag.json_data.id === tagId);
280
+ log.info('initIoTFormData() foundTag: ', foundTag, _tags);
281
+ if (foundTag) {
282
+ selectedIotTag = foundTag;
283
+ if (tagIotName === null || tagIotName == undefined) {
284
+ setInputFields();
285
+ }
286
+ tagIotName.value = foundTag.tag_name ? foundTag.tag_name : foundTag.json_data.label;
287
+ // const iotData = foundTag.json_data as SpaceMetadata
288
+ const iotData = foundTag.iot_tag;
289
+ //@ts-ignore
290
+ if (iotData) {
291
+ iotModelName.value = iotData.model_name;
292
+ iotSerialNumber.value = iotData.serial_number;
293
+ iotMfrName.value = iotData.manufacturer_site;
294
+ iotSystemLink.value = iotData.system_link;
295
+ if (iotData.linked_system) {
296
+ setSelectedIoTSystemRadio(iotData.linked_system);
297
+ }
298
+ else {
299
+ setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
300
+ }
301
+ if (iotData.iot_category) {
302
+ const cat = _tagIotCategoryTypes.find(cat => cat.name === iotData.iot_category);
303
+ if (cat) {
304
+ setSelectedIoTCat(cat.name);
305
+ selectedIoTCatId = cat.name;
306
+ }
307
+ else {
308
+ // for the Dummy data from App Side
309
+ setSelectedIoTCat(i18n.t('NoSelection'));
310
+ renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
311
+ }
312
+ }
313
+ log.info("iotData.linked_devices: ", iotData.linked_devices);
314
+ if (iotData.linked_devices && iotData.linked_devices.length > 0) {
315
+ // renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices)
316
+ setSelectedIoTDevice(iotData.linked_devices[0].name);
317
+ linkedDevicesArray = iotData.linked_devices;
318
+ log.info("EDIT linkedDevicesArray: ", linkedDevicesArray);
319
+ renderLinkedDevices(linkedDevicesArray);
320
+ }
321
+ else {
322
+ // log.info("@caroline NO linked devices")DeviceInfo
323
+ // for the Dummy data from App Side
324
+ // renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices)
325
+ }
326
+ }
327
+ else {
328
+ // this is due to selecting the tags created from James
329
+ log.info('initIoTFormData()', iotData);
330
+ setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
331
+ setSelectedIoTCat('No Selection');
332
+ renderIotCategoryDropdownOptions('at-iot-category-options', _tagIotCategoryTypes);
333
+ renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices);
334
+ }
335
+ }
336
+ }
337
+ }
338
+ export function renderIotCategoryDropdownOptions(elementId, items) {
339
+ const element = document.getElementById(elementId);
340
+ if (!element) {
341
+ console.error("Parameter element is undefined");
342
+ return;
343
+ }
344
+ if (!items) {
345
+ console.error("Parameter items is undefined");
346
+ return;
347
+ }
348
+ const isFilterDropdown = stringContains(elementId, 'filter');
349
+ //Clear previosly appended children
350
+ element.innerHTML = ``;
351
+ const selectedIotCategoryOption = document.getElementById(isFilterDropdown ? 'at-iot-category-filter-dropdown-toggle' : 'at-iot-category-dropdown-toggle');
352
+ if (selectedIotCategoryOption) {
353
+ selectedIotCategoryOption.textContent = `${i18n.t('NoSelection')}`;
354
+ selectedIoTCatOption = undefined;
355
+ }
356
+ //Add the no selection option
357
+ const noSelection = document.createElement('div');
358
+ noSelection.classList.add('at_option');
359
+ noSelection.setAttribute('iot-category-uuid', '');
360
+ noSelection.setAttribute('dropdown-type', 'iotcategory');
361
+ noSelection.innerHTML = `
362
+ <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
363
+ `;
364
+ noSelection.onclick = () => {
365
+ selectCatOption(noSelection, isFilterDropdown ? 'at-iot-category-filter-dropdown-toggle' : 'at-iot-category-filter-dropdown-toggle');
366
+ };
367
+ element.appendChild(noSelection);
368
+ if (items.length <= 0) {
369
+ console.log("No items to render");
370
+ return;
371
+ }
372
+ items.forEach((item, index) => {
373
+ const option = createCatOptionElement(item, 'iotcategory', index);
374
+ element.appendChild(option);
375
+ });
376
+ }
377
+ function createCatOptionElement(item, dropdownType, index) {
378
+ console.log("createCatOptionElement()", item, index);
379
+ const option = document.createElement('div');
380
+ option.style.display = 'flex';
381
+ option.style.flexDirection = 'row';
382
+ option.style.justifyContent = 'left';
383
+ option.style.alignItems = 'center';
384
+ option.style.gap = '2px';
385
+ option.classList.add('at_option');
386
+ option.classList.add('at_iot_cat_option');
387
+ option.setAttribute('iot-category-uuid', item.uuid);
388
+ option.setAttribute('dropdown-type', dropdownType);
389
+ option.setAttribute('data-cy', `at-iot-category-option-${item.uuid}`);
390
+ option.innerHTML = `
391
+ <span id="at-device-${item.name}" class="mdi ${iotCategoryIconList[index]}"></span>
392
+ ${i18n.t(item.name)}
393
+ `;
394
+ return option;
395
+ }
396
+ function selectCatOption(option, elementId) {
397
+ log.info('selectCatOption()', option, elementId);
398
+ }
399
+ export function setIotDeviceOptions() {
400
+ log.info('setIotDeviceOptions()');
401
+ dispatchSpaceEvent(SPACE_EVENTS.GET_IOT_DEVICES, { payload: 'hello from library' });
402
+ renderIotDeviceDropdownOptions('at-iot-device-options', _tagIotDevices);
403
+ batchAddEventListenerByClassName('at_iot_dev_option', (event) => {
404
+ //@ts-ignore
405
+ const selectedDev = event.target;
406
+ const parent = selectedDev.parentElement;
407
+ log.info('@caroline parent: ', parent);
408
+ 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);
415
+ });
416
+ }
417
+ export function renderIotDeviceDropdownOptions(elementId, items) {
418
+ log.info("renderIotDeviceDropdownOptions: ", items);
419
+ const element = document.getElementById(elementId);
420
+ if (!element) {
421
+ console.error("Parameter element is undefined");
422
+ return;
423
+ }
424
+ if (!items) {
425
+ console.error("Parameter items is undefined");
426
+ return;
427
+ }
428
+ const isFilterDropdown = stringContains(elementId, 'filter');
429
+ //Clear previosly appended children
430
+ element.innerHTML = ``;
431
+ const selectedIotDeviceOption = document.getElementById(isFilterDropdown ? 'at-iot-device-filter-dropdown-toggle' : 'at-iot-device-dropdown-toggle');
432
+ if (selectedIotDeviceOption) {
433
+ selectedIotDeviceOption.textContent = `${i18n.t('Select Device')}`;
434
+ selectedIoTDeviceOption = undefined;
435
+ }
436
+ //Add the no selection option
437
+ const selectDevice = document.createElement('div');
438
+ selectDevice.classList.add('at_iot_dev_option');
439
+ selectDevice.setAttribute('iot-device-uuid', '');
440
+ selectDevice.setAttribute('dropdown-type', 'iotdevice');
441
+ selectDevice.innerHTML = `
442
+ <span></span> ${i18n.t('Select Device')}
443
+ `;
444
+ selectDevice.onclick = () => {
445
+ log.info('@caroline onClick');
446
+ selectDeviceOption(selectDevice, isFilterDropdown ? 'at-iot-device-filter-dropdown-toggle' : 'at-iot-device-filter-dropdown-toggle');
447
+ };
448
+ element.appendChild(selectDevice);
449
+ if (items.length <= 0) {
450
+ console.log("No items to render");
451
+ return;
452
+ }
453
+ items.forEach(item => {
454
+ const option = createDeviceOptionElement(item, 'iotdevice');
455
+ element.appendChild(option);
456
+ });
457
+ }
458
+ function selectDeviceOption(option, elementId) {
459
+ log.info('selectDeviceOption()');
460
+ }
461
+ function createDeviceOptionElement(item, dropdownType) {
462
+ console.log("createDeviceOptionElement()", item, dropdownType);
463
+ const option = document.createElement('div');
464
+ option.style.display = 'flex';
465
+ option.style.flexDirection = 'row';
466
+ option.style.justifyContent = 'left';
467
+ option.style.alignItems = 'center';
468
+ option.style.gap = '2px';
469
+ option.classList.add('at_option');
470
+ option.classList.add('at_iot_dev_option');
471
+ option.setAttribute('iot-device-uuid', item.id);
472
+ option.setAttribute('dropdown-type', dropdownType);
473
+ 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
+ option.innerHTML = `
482
+ <span>${item.name}</span>
483
+ `;
484
+ return option;
485
+ }
486
+ /**
487
+ * Gets IoT TagData and used in events.ts
488
+ *
489
+ *
490
+ *
491
+ */
492
+ export function getIotTagFormData() {
493
+ log.info('getIotTagFormData()');
494
+ if (!tagIotName) {
495
+ setInputFields();
496
+ }
497
+ const formData = {
498
+ name: tagIotName.value,
499
+ modelName: iotModelName.value,
500
+ serialNumber: iotSerialNumber.value,
501
+ tagMf: iotMfrName.value,
502
+ tagCategoryId: selectedIoTCatId,
503
+ systemLink: iotSystemLink.value,
504
+ linkedDevices: linkedDevicesArray,
505
+ iotSystem: selectedIoTSystem,
506
+ tag_type: TAG_TYPE.IOT
507
+ };
508
+ return formData;
509
+ }
510
+ function renderLinkedDevices(linkedDevices) {
511
+ log.info('renderLinkedDevices()', linkedDevices);
512
+ if (linkedDevices) {
513
+ const devicesContainer = document.getElementById('at-linked-device-row');
514
+ if (linkedDevices.length > 0) {
515
+ devicesContainer.innerHTML = ``;
516
+ linkedDevices.forEach(device => {
517
+ log.info("@caroline device: ", device);
518
+ renderDeviceRow(device);
519
+ });
520
+ }
521
+ }
522
+ }
523
+ function renderDeviceRow(payload) {
524
+ log.info('renderDeviceRow()', payload);
525
+ const devicesContainer = document.getElementById('at-linked-device-row');
526
+ if (payload) {
527
+ const deviceRow = document.createElement('div');
528
+ deviceRow.classList.add('at_flex_row');
529
+ deviceRow.classList.add('at_partition_item');
530
+ deviceRow.innerHTML = `
531
+ <div class="at_icon_left">
532
+ <span class="mdi mdi-cube-outline"></span>
533
+ </div>
534
+
535
+ <div class="at_partition_name">
536
+ <div></div>
537
+ <label for="">${payload.name}</label>
538
+ <div></div>
539
+ </div>
540
+ <div class="at_icon_right">
541
+ <span class="mdi mdi-delete-outline at_delete_device_btn" id="at-delete-device-${payload.uuid}"></span>
542
+ </div>
543
+ `;
544
+ devicesContainer.appendChild(deviceRow);
545
+ batchAddEventListenerByClassName('at_delete_device_btn', (event) => __awaiter(this, void 0, void 0, function* () {
546
+ log.info('deleteSelectedLinkedDevice is clicked', event);
547
+ //@ts-ignore
548
+ const selectedDevice = document.getElementById(event.target.id);
549
+ 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);
560
+ }
561
+ }));
562
+ return;
563
+ }
564
+ }
565
+ /**
566
+ * Clears all Fields Input Fields including the Linked Devices Table
567
+ *
568
+ */
569
+ export function clearIotFields() {
570
+ log.info('clearIotFields()');
571
+ tagIotName = document.getElementById('at-iot-name-input');
572
+ iotModelName = document.getElementById('at-iot-model-input');
573
+ iotSerialNumber = document.getElementById('at-iot-serial-input');
574
+ iotMfrName = document.getElementById('at-iot-manufacturer-input');
575
+ iotSystemLink = document.getElementById('at-iot-system-link-input');
576
+ const deviceContainer = document.getElementById("linked-devices-container");
577
+ tagIotName.innerText = '';
578
+ iotModelName.innerText = '';
579
+ iotSerialNumber.innerText = '';
580
+ iotMfrName.innerText = '';
581
+ iotSystemLink.innerText = '';
582
+ linkedDevicesArray = [];
583
+ selectedIoTSystem = '';
584
+ setSelectedIoTSystemRadio(IOT_LINKED_SYSTEMS.BEMAC);
585
+ if (deviceContainer !== null) {
586
+ deviceContainer.innerHTML = '';
587
+ }
588
+ iotTagFormMode = "ADD" /* FORM_MODE.ADD */;
589
+ }
590
+ /**
591
+ * Sets the form mode for the IOT form.
592
+ * - The form mode can be one of the predefined FORM_MODE values (e.g., ADD, EDIT, etc.).
593
+ *
594
+ * @param {FORM_MODE} formType - The type of form mode to set.
595
+ */
596
+ export function setIoTFormMode(formType) {
597
+ iotTagFormMode = formType;
598
+ }
599
+ /**
600
+ * Gets the current form mode for the IOT form.
601
+ *
602
+ * @returns {FORM_MODE} - The current form mode.
603
+ */
604
+ export function getPartitionFormMode() {
605
+ return iotTagFormMode;
606
+ }
@@ -15,3 +15,7 @@ export declare function getTagMessageText(): string;
15
15
  export declare function clearTagMessageInput(): void;
16
16
  export declare function createTagMessage(): TagMessage;
17
17
  export declare function setTagMessagingDetails(tagId: string): void;
18
+ export declare function unsendComment(payload: any): void;
19
+ export declare function timedoutComment(payload: Array<TagMessage>): void;
20
+ export declare function checkTimeoutDifference(createdDateInput: Date, mode: string): boolean;
21
+ export declare function getTheseTagMessages(payload: Array<TagMessage>): TagMessage[];