architwin 1.18.6 → 1.18.8

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.
@@ -290,6 +290,7 @@ i18n
290
290
  "SuccessUpdatedFloorLevel": "Updated the partition's floor level",
291
291
  "DuplicatePartitionName": "This partition name is already used in this room. Please choose a different name.",
292
292
  "PleaseOnPolygonVisibility": "Action cannot be done, please turn on room visibility.",
293
+ "IoTType": "IoT Type"
293
294
  }
294
295
  },
295
296
  ja: {
@@ -574,7 +575,8 @@ i18n
574
575
  "IotCategoryRequired": "IoTカテゴリは必須です",
575
576
  "SuccessUpdatedFloorLevel": "区画のフロアオフセット値が更新されました",
576
577
  "DuplicatePartitionName": "このパーティション名は既にこの部屋で使用されています。別の名前を選択してください。",
577
- "PleaseOnPolygonVisibility": "操作を行う前に、部屋の表示をオンにしてください。"
578
+ "PleaseOnPolygonVisibility": "操作を行う前に、部屋の表示をオンにしてください。",
579
+ "IoTType": "IoTタイプ"
578
580
  }
579
581
  }
580
582
  },
@@ -1,4 +1,4 @@
1
- import { FORM_MODE, ITagCategory } from "../../../types";
1
+ import { FORM_MODE, ITagCategory, ITag } from "../../../types";
2
2
  export declare let tagFormMode: FORM_MODE;
3
3
  export declare let selectedTag: any;
4
4
  export declare function renderTagFormPane(): HTMLDivElement;
@@ -13,6 +13,8 @@ export declare function getTagFormData(): {
13
13
  export declare function setTagCategoriesOption(): void;
14
14
  export declare function toggleDropdown(elementId: string): void;
15
15
  export declare function clearInnerHTML(elementId: string): void;
16
+ export declare function hideTagsFromSpace(tags?: ITag[]): Promise<void>;
17
+ export declare function renderTagsInSpace(tags: ITag[], _withIcon?: boolean, iframeId?: string): Promise<void>;
16
18
  export declare function renderCategoryDropdownOptions(elementId: string, items: Array<ITagCategory>, toggleId?: string): void;
17
19
  export declare function renderSubcategoryDropdownOptions(elementId: string, items: Array<ITagCategory>): void;
18
20
  export declare function clearTagFormDropdown(): void;
@@ -1,8 +1,20 @@
1
- import { _tagCategories, _tags, getMpTags } from "../../../architwin";
2
- import { convertToCssRgb, stringContains } from "../../../utils";
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 { _atwin, _atwinConnections, _tagCategories, _tags, attachSandbox, disposeTags, getIoTDeviceTagIcons, getMpTags, renderTag, setTagIcon } from "../../../architwin";
11
+ import { convertToCssRgb, stringContains, useHexToRgb } from "../../../utils";
3
12
  import { TAG_TYPE } from "../../../types";
4
13
  import { renderTags, setSelectedCategoryFilter, setSelectedSubcategoryFilter, filterTagList, getAllSubcategories, selectedCategoryFilterId, sortTags, selectedTagSortOption } from './tagListPane';
5
14
  import i18n from './i18n';
15
+ import log from "loglevel";
16
+ import ShortUniqueId from "short-unique-id";
17
+ import * as _tag from './../../../tag';
6
18
  let mode = 'adding';
7
19
  let tagNameInput, tagDescriptionInput, tagEmbedInput, tagCategoryDropdown, tagSubcategoryDropdown;
8
20
  let selectedCategoryId = undefined;
@@ -168,7 +180,8 @@ export function getTagFormData() {
168
180
  }
169
181
  if (tagNameInput) {
170
182
  const tagName = tagNameInput.value;
171
- const tagDescription = tagDescriptionInput.value.split('\n')[0];
183
+ const tagDescription = tagDescriptionInput.value;
184
+ //const tagDescription = tagDescriptionInput.value.split('\n')[0]
172
185
  const tagEmbed = tagEmbedInput.value;
173
186
  const formData = {
174
187
  tagName: tagName,
@@ -260,109 +273,228 @@ export function clearInnerHTML(elementId) {
260
273
  targetElement.innerHTML = ``;
261
274
  }
262
275
  function selectOption(option, elementId, skipToggle = false) {
263
- console.log("selectOption()");
264
- //const dropdownToggle = document.querySelector('.at_dropdown_toggle');
265
- if (!elementId || elementId === '' || elementId == null) {
266
- console.error("ElementId is empty or undefined");
267
- return;
268
- }
269
- const dropdownToggle = document.getElementById(elementId);
270
- //dropdownToggle.textContent = option.textContent;
271
- dropdownToggle.innerHTML = option.innerHTML;
272
- //selectedText = option.textContent;
273
- const isFilterDropdown = stringContains(elementId, 'filter');
274
- const categoryUUID = option.getAttribute('category-uuid');
275
- const categoryType = option.getAttribute('dropdown-type');
276
- console.log("categoryUUID ", categoryUUID);
277
- console.log("categoryType ", categoryType);
278
- if (categoryUUID && categoryUUID !== null) {
279
- if (categoryType == 'category' && isFilterDropdown == false) {
280
- selectedCategoryId = categoryUUID;
281
- }
282
- else if (categoryType == 'category' && isFilterDropdown) {
283
- setSelectedCategoryFilter(categoryUUID);
284
- setSelectedSubcategoryFilter(undefined); //reset selected subcategory
285
- const tags = getMpTags();
286
- const filteredTags = filterTagList(tags);
287
- const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
288
- renderTags(sortedTags);
289
- }
290
- else if (categoryType == 'subcategory' && isFilterDropdown == false) {
291
- selectedSubCategoryId = categoryUUID;
292
- }
293
- else if (categoryType == 'subcategory' && isFilterDropdown) {
294
- setSelectedSubcategoryFilter(categoryUUID);
295
- const tags = getMpTags();
296
- const filteredTags = filterTagList(tags);
297
- const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
298
- renderTags(filteredTags);
299
- }
300
- //Populate subcategory dropdown
301
- const targetCategory = _tagCategories.find(cat => cat.uuid === categoryUUID);
302
- if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
303
- console.log("Subcategories found", targetCategory.subcategories);
304
- renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
276
+ var _a;
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ console.log("selectOption()");
279
+ //const dropdownToggle = document.querySelector('.at_dropdown_toggle');
280
+ if (!elementId || elementId === '' || elementId == null) {
281
+ console.error("ElementId is empty or undefined");
282
+ return;
305
283
  }
306
- else {
307
- if (categoryType == 'category') {
308
- const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
309
- const subcatToggleId = isFilterDropdown ? 'at-subcategory-filter-dropdown-toggle' : 'at-subcategory-dropdown-toggle';
310
- const subcategoryToggle = document.getElementById(elementId);
311
- const subcatDropdownToggle = document.getElementById(subcatToggleId);
312
- subcategoryToggle.innerHTML = `
284
+ const dropdownToggle = document.getElementById(elementId);
285
+ //dropdownToggle.textContent = option.textContent;
286
+ dropdownToggle.innerHTML = option.innerHTML;
287
+ //selectedText = option.textContent;
288
+ const isFilterDropdown = stringContains(elementId, 'filter');
289
+ const categoryUUID = option.getAttribute('category-uuid');
290
+ const categoryType = option.getAttribute('dropdown-type');
291
+ console.log("categoryUUID ", categoryUUID);
292
+ console.log("categoryType ", categoryType);
293
+ if (categoryUUID && categoryUUID !== null) {
294
+ if (categoryType == 'category' && isFilterDropdown == false) {
295
+ selectedCategoryId = categoryUUID;
296
+ }
297
+ else if (categoryType == 'category' && isFilterDropdown) {
298
+ setSelectedCategoryFilter(categoryUUID);
299
+ setSelectedSubcategoryFilter(undefined); //reset selected subcategory
300
+ const tags = getMpTags();
301
+ const filteredTags = filterTagList(tags);
302
+ const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
303
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
304
+ // remove tags that is not part in the sorted Tags
305
+ yield hideTagsFromSpace(removeTags);
306
+ // show filtered tags only
307
+ yield renderTagsInSpace(sortedTags, true);
308
+ log.info("sortedTags", sortedTags);
309
+ renderTags(sortedTags);
310
+ }
311
+ else if (categoryType == 'subcategory' && isFilterDropdown == false) {
312
+ selectedSubCategoryId = categoryUUID;
313
+ }
314
+ else if (categoryType == 'subcategory' && isFilterDropdown) {
315
+ setSelectedSubcategoryFilter(categoryUUID);
316
+ const tags = getMpTags();
317
+ const filteredTags = filterTagList(tags);
318
+ const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
319
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
320
+ // remove tags that is not part in the sorted Tags
321
+ yield hideTagsFromSpace(removeTags);
322
+ // show filtered tags only
323
+ yield renderTagsInSpace(filteredTags, true);
324
+ renderTags(filteredTags);
325
+ }
326
+ //Populate subcategory dropdown
327
+ const targetCategory = _tagCategories.find(cat => cat.uuid === categoryUUID);
328
+ if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
329
+ console.log("Subcategories found", targetCategory.subcategories);
330
+ renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
331
+ }
332
+ else {
333
+ if (categoryType == 'category') {
334
+ const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
335
+ const subcatToggleId = isFilterDropdown ? 'at-subcategory-filter-dropdown-toggle' : 'at-subcategory-dropdown-toggle';
336
+ const subcategoryToggle = document.getElementById(elementId);
337
+ const subcatDropdownToggle = document.getElementById(subcatToggleId);
338
+ subcategoryToggle.innerHTML = `
313
339
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
314
340
  `;
315
- subcatDropdownToggle.innerHTML = `
341
+ subcatDropdownToggle.innerHTML = `
316
342
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
317
343
  `;
344
+ }
318
345
  }
319
346
  }
320
- }
321
- else {
322
- console.log("categoryUUID is undefined");
323
- if (categoryType == 'category' && isFilterDropdown) {
324
- console.log("Clearing subcategory filter");
325
- const subcategoryToggle = document.getElementById('at-subcategory-filter-dropdown-toggle');
326
- subcategoryToggle.textContent = `${i18n.t('NoSelection')}`;
327
- subcategoryToggle.innerHTML = `
347
+ else {
348
+ console.log("categoryUUID is undefined");
349
+ if (categoryType == 'category' && isFilterDropdown) {
350
+ console.log("Clearing subcategory filter");
351
+ const subcategoryToggle = document.getElementById('at-subcategory-filter-dropdown-toggle');
352
+ subcategoryToggle.textContent = `${i18n.t('NoSelection')}`;
353
+ subcategoryToggle.innerHTML = `
328
354
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
329
355
  `;
330
- setSelectedCategoryFilter(undefined);
356
+ setSelectedCategoryFilter(undefined);
357
+ }
358
+ if (isFilterDropdown) {
359
+ setSelectedSubcategoryFilter(undefined); //reset selected subcategory
360
+ }
361
+ //Populate subcategory dropdown
362
+ const targetCategory = _tagCategories.find(cat => cat.uuid === selectedCategoryFilterId);
363
+ if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
364
+ console.log("Subcategories found", targetCategory.subcategories);
365
+ renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
366
+ }
367
+ else {
368
+ const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
369
+ clearInnerHTML(elementId);
370
+ }
371
+ let tags = getMpTags().filter(tag => !tag.tag_type || tag.tag_type !== TAG_TYPE.IOT);
372
+ const filteredTags = (_a = filterTagList(tags)) !== null && _a !== void 0 ? _a : [];
373
+ const sortedTags = sortTags(filteredTags.length ? filteredTags : tags, selectedTagSortOption);
374
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
375
+ if (filteredTags.length > 0) {
376
+ // remove tags that is not part in the sorted Tags
377
+ yield hideTagsFromSpace(removeTags);
378
+ }
379
+ // show filtered tags only
380
+ yield renderTagsInSpace(sortedTags, true);
381
+ renderTags(sortedTags);
382
+ }
383
+ let toggleId = '';
384
+ if (elementId === 'at-category-dropdown-toggle') {
385
+ toggleId = 'at-category-options';
386
+ }
387
+ else if (elementId === 'at-subcategory-dropdown-toggle') {
388
+ toggleId = 'at-subcategory-options';
389
+ }
390
+ else if (elementId === 'at-category-filter-dropdown-toggle') {
391
+ toggleId = 'at-category-filter-options';
331
392
  }
332
- if (isFilterDropdown) {
333
- setSelectedSubcategoryFilter(undefined); //reset selected subcategory
393
+ else if (elementId === 'at-subcategory-filter-dropdown-toggle') {
394
+ toggleId = 'at-subcategory-filter-options';
334
395
  }
335
- //Populate subcategory dropdown
336
- const targetCategory = _tagCategories.find(cat => cat.uuid === selectedCategoryFilterId);
337
- if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
338
- console.log("Subcategories found", targetCategory.subcategories);
339
- renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
396
+ if (skipToggle == false) {
397
+ toggleDropdown(toggleId);
398
+ }
399
+ });
400
+ }
401
+ export function hideTagsFromSpace(tags = null) {
402
+ return __awaiter(this, void 0, void 0, function* () {
403
+ log.info('hideTagsFromSpace', tags);
404
+ if (tags != null) {
405
+ tags.map((tag) => __awaiter(this, void 0, void 0, function* () {
406
+ yield _tag.disposeTag({ tagId: tag.json_data.id, sdk: _atwin, tags: _tags });
407
+ }));
340
408
  }
341
409
  else {
342
- const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
343
- clearInnerHTML(elementId);
410
+ disposeTags();
344
411
  }
345
- let tags = getMpTags().filter(tag => !tag.tag_type || tag.tag_type !== TAG_TYPE.IOT);
346
- const filteredTags = filterTagList(tags);
347
- const sortedTags = sortTags(filteredTags ? filteredTags : tags, selectedTagSortOption);
348
- renderTags(sortedTags);
349
- }
350
- let toggleId = '';
351
- if (elementId === 'at-category-dropdown-toggle') {
352
- toggleId = 'at-category-options';
353
- }
354
- else if (elementId === 'at-subcategory-dropdown-toggle') {
355
- toggleId = 'at-subcategory-options';
356
- }
357
- else if (elementId === 'at-category-filter-dropdown-toggle') {
358
- toggleId = 'at-category-filter-options';
359
- }
360
- else if (elementId === 'at-subcategory-filter-dropdown-toggle') {
361
- toggleId = 'at-subcategory-filter-options';
362
- }
363
- if (skipToggle == false) {
364
- toggleDropdown(toggleId);
365
- }
412
+ });
413
+ }
414
+ // render tags to space
415
+ export function renderTagsInSpace(tags, _withIcon = false, iframeId = undefined) {
416
+ var _a;
417
+ return __awaiter(this, void 0, void 0, function* () {
418
+ log.info('renderTagsInSpace', tags);
419
+ let renderedTagIds = [];
420
+ const sdk = iframeId ? _atwinConnections[iframeId] : _atwin;
421
+ for (let tag of tags) {
422
+ log.info('tag', tag);
423
+ const isDuplicate = renderedTagIds.includes(tag.json_data.id);
424
+ const rsid = new ShortUniqueId({ length: 10 });
425
+ if (isDuplicate) {
426
+ //assign a different unique id if the existing tag id is a duplicate
427
+ tag.json_data.id = rsid.rnd();
428
+ }
429
+ renderedTagIds.push(tag.json_data.id);
430
+ try {
431
+ const renderedTag = yield renderTag({ tag: tag.json_data }, false, iframeId);
432
+ }
433
+ catch (error) {
434
+ log.info("Tag is already rendered in space");
435
+ continue;
436
+ }
437
+ // check if tag needs tag icon display
438
+ if (_withIcon && tag.tag_icon_base64 !== '') {
439
+ // set tag icon
440
+ log.info("__@ showTags: ", tags);
441
+ yield setTagIcon({ tag: tag.json_data, iconName: tag.tag_icon_name, iconUrl: tag.tag_icon_base64, color: tag.json_data.color, iframeId });
442
+ }
443
+ if (tag.media_url && tag.media_url !== '') {
444
+ try {
445
+ const attachments = [tag.media_url];
446
+ yield _tag.attachTagMedia({ sdk, tag: tag.json_data, attachments });
447
+ }
448
+ catch (error) {
449
+ log.warn(error);
450
+ }
451
+ }
452
+ if (tag.sandboxId) {
453
+ try {
454
+ yield attachSandbox({ sandboxId: tag.sandboxId, tagIds: [tag.json_data.id] });
455
+ }
456
+ catch (error) {
457
+ log.error("Attach sandbox error ", error);
458
+ }
459
+ }
460
+ if (tag.tag_type === TAG_TYPE.IOT) {
461
+ const icons = getIoTDeviceTagIcons();
462
+ let iconUrl = icons.normal;
463
+ let iconName = "normal.png";
464
+ let color = { r: 0.3, g: 0.5, b: 1.0 }; // default soft royal blue
465
+ for (const device of tag.iot_tag.linked_devices) {
466
+ if (!device)
467
+ continue;
468
+ const { quality, status } = device;
469
+ // If any device is offline, override color to gray and stop checking further
470
+ if (status === "offline") {
471
+ iconUrl = icons.normal;
472
+ iconName = "normal.png";
473
+ color = useHexToRgb("667c89"); // gray
474
+ break;
475
+ }
476
+ // If any device is alert (highest priority), set red and stop
477
+ if (quality === 2) {
478
+ iconUrl = icons.alert;
479
+ iconName = "alert.png";
480
+ color = { r: 1, g: 0, b: 0 }; // red
481
+ break;
482
+ }
483
+ // If any device is attention, set orange but keep checking in case of alert
484
+ if (quality === 3) {
485
+ iconUrl = icons.alert;
486
+ iconName = "normal.png";
487
+ color = useHexToRgb("ffae42"); // orange
488
+ // continue loop to see if alert is present
489
+ }
490
+ }
491
+ tag.tag_icon_url = iconUrl;
492
+ tag.tag_icon_name = iconName;
493
+ tag.json_data.color = color;
494
+ yield setTagIcon({ tag: tag.json_data, iconName: (_a = tag.tag_icon_base64) !== null && _a !== void 0 ? _a : '', iconUrl: tag.tag_icon_url, color: tag.json_data.color });
495
+ }
496
+ }
497
+ });
366
498
  }
367
499
  function createOptionElement(item, dropdownType) {
368
500
  console.log("createOptionElement");
@@ -51,7 +51,7 @@ export function renderTagIOTFormPane() {
51
51
  </div>
52
52
  </div>
53
53
 
54
- <label for="">${i18n.t('Category')}</label>
54
+ <label for="">${i18n.t('IoTType')}</label>
55
55
  <div id="at-iot-category-dropdown" data-cy="at-iot-category-dropdown">
56
56
  <div id="at-iot-cat-filter-dropdown" class="at_dropdown at_flex at_flex_row at_space_between">
57
57
  <div class="at_dropdown_toggle" id="at-iot-selected-cat" data-cy="at-iot-selected-cat">${i18n.t(selectedIoTCatOption)}</div>
@@ -32,6 +32,6 @@ export declare function initializeTagVisibility(): void;
32
32
  export declare function updateShowAllButton(): void;
33
33
  export declare function clearTagVisibilityStorage(): void;
34
34
  export declare function setIotCategoryFilterOptions(): void;
35
- export declare function filterIotTagByCategory(tags: ITag[]): void;
35
+ export declare function filterIotTagByCategory(tags: ITag[]): Promise<void>;
36
36
  export declare function setSelectedIoTCategoryFilter(payload: ITagIOTCategory): void;
37
37
  export declare function renderIotCategoryDropdownFilterOptions(elementId: string, items: Array<ITagIOTCategory>): void;
@@ -11,7 +11,7 @@ import { SPACE_EVENTS, sortTagOptions, TAG_TYPE } from "../../../types";
11
11
  import { batchAddEventListenerByClassName, toggleDisplayPane, batchAddEventListenerByDataAttribute } from "../../events";
12
12
  import { convertToCssRgb, getBundleVersion, stringContains } from "../../../utils";
13
13
  import { gotoTag, disposeTag, dispatchSpaceEvent, _tags, getUserAssignedCategories, _mpConfig, moveTag, getAtwinSdk, toggleVisibilityTag, _tagIotCategoryTypes } from "../../../architwin";
14
- import { initFormData, toggleDropdown } from "./tagFormPane";
14
+ import { hideTagsFromSpace, initFormData, renderTagsInSpace, toggleDropdown } from "./tagFormPane";
15
15
  import { toggleModal, setModalAction } from "./modal";
16
16
  import { initIoTFormData, setIoTFormMode } from './tagIotFormPane';
17
17
  import { Notyf } from 'notyf';
@@ -121,7 +121,7 @@ export function renderTagListPane() {
121
121
  </div>
122
122
 
123
123
  <div class="at_field at_flex_column" id="at-custom-iot-category-filter-dropdown-container">
124
- <label for="">${i18n.t('Category')}</label>
124
+ <label for="">${i18n.t('IoTType')}</label>
125
125
  <div id="at-custom-iot-category-filter-dropdown" data-cy="at-custom-iot-category-filterdropdown">
126
126
  <div id="at-custom-iot-cat-filter-dropdown" class="at_dropdown at_flex at_flex_row at_space_between">
127
127
  <div class="at_dropdown_toggle" id="at-custom-iot-selected-filter-category" data-cy="at-custom-iot-selected-filter-category">${i18n.t('NoSelection')}</div>
@@ -853,7 +853,7 @@ export function setIotCategoryFilterOptions() {
853
853
  log.info('setIotCategoryOptions()');
854
854
  if (_tagIotCategoryTypes) {
855
855
  renderIotCategoryDropdownFilterOptions('at-iot-category-filter-options', _tagIotCategoryTypes);
856
- batchAddEventListenerByClassName('at_iot_cat_filter_option', (event) => {
856
+ batchAddEventListenerByClassName('at_iot_cat_filter_option', (event) => __awaiter(this, void 0, void 0, function* () {
857
857
  log.info("category filter clicked");
858
858
  //@ts-ignore
859
859
  const selectedCat = event.target;
@@ -863,6 +863,7 @@ export function setIotCategoryFilterOptions() {
863
863
  // no selection selected
864
864
  selectedIoTCategoryFilter = { uuid: '', name: 'NoSelection' };
865
865
  setSelectedIoTCategoryFilter(selectedIoTCategoryFilter);
866
+ yield renderTagsInSpace(iotTags, true);
866
867
  renderTags(iotTags);
867
868
  }
868
869
  const getCatName = _tagIotCategoryTypes.find(cat => cat.uuid === catUUID);
@@ -873,13 +874,18 @@ export function setIotCategoryFilterOptions() {
873
874
  filterIotTagByCategory(iotTags);
874
875
  }
875
876
  toggleDropdown('at-iot-category-filter-options');
876
- });
877
+ }));
877
878
  }
878
879
  }
879
880
  export function filterIotTagByCategory(tags) {
880
- log.info("selectedIoTCategoryFilter", selectedIoTCategoryFilter, _tags);
881
- const filteredTags = tags.filter(tag => tag.iot_tag.iot_category == selectedIoTCategoryFilter.name);
882
- renderTags(filteredTags);
881
+ return __awaiter(this, void 0, void 0, function* () {
882
+ log.info("selectedIoTCategoryFilter", selectedIoTCategoryFilter, _tags);
883
+ const filteredTags = tags.filter(tag => tag.iot_tag.iot_category == selectedIoTCategoryFilter.name);
884
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.IOT);
885
+ yield hideTagsFromSpace(removeTags);
886
+ yield renderTagsInSpace(filteredTags, true);
887
+ renderTags(filteredTags);
888
+ });
883
889
  }
884
890
  // displays selected Category in the dropdown
885
891
  export function setSelectedIoTCategoryFilter(payload) {
@@ -14,7 +14,7 @@ import { getTargetPosition, addMediaScreen, _3DXObjects, selectedObject, setTran
14
14
  import { Notyf } from 'notyf';
15
15
  import 'notyf/notyf.min.css';
16
16
  import { SPACE_EVENTS, COORDINATE_SYSTEM, UNITS, DEGREE, MAP_OPTIONS, sortTagOptions, sortObjectOptions, CUSTOM_MAP_MODE, TAG_TYPE } from "../types";
17
- import { initFormData, setTagFormMode } from "./components/toolbar/tagFormPane";
17
+ import { initFormData, hideTagsFromSpace, renderTagsInSpace, setTagFormMode } from "./components/toolbar/tagFormPane";
18
18
  import { renderObjectList, resetSelectedObjectSortOption, selectedObjectSortOption, sortShowcaseObjects, updateSelectedObjectSortOption } from "./components/toolbar/objectListPane";
19
19
  import { renderLibraryList } from "./components/toolbar/libraryPane";
20
20
  import { renderObjectCard } from "./components/toolbar/card";
@@ -3281,37 +3281,35 @@ function handleClearSearchTagName() {
3281
3281
  log.info('handleClearSearchTagName()');
3282
3282
  const searchTagName = document.getElementById('at-clear-search-tag-name');
3283
3283
  if (searchTagName) {
3284
- searchTagName.addEventListener('click', () => {
3284
+ searchTagName.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
3285
3285
  searchClearfield();
3286
3286
  // commented out due to iot Dummy Data
3287
3287
  // const tags = getMpTags()
3288
3288
  const tags = [..._tags];
3289
- const filteredTags = filterTagList(tags);
3290
3289
  if (selectedCategoryFilterId || selectedSubCategoryFilterId && isTagPaneActive) {
3291
- const filteredTags = filterTagList(tags);
3290
+ const filteredTags = filterTagList(tags).filter(tag => tag.tag_type === TAG_TYPE.MP);
3291
+ // show filtered tags only
3292
+ yield renderTagsInSpace(filteredTags, true);
3292
3293
  renderTags(filteredTags);
3293
3294
  }
3294
3295
  else if (tags.length > 0 && isTagPaneActive) {
3295
- renderTags(tags, true);
3296
+ const filteredMPTags = tags.filter(tag => tag.tag_type === TAG_TYPE.MP);
3297
+ yield renderTagsInSpace(filteredMPTags, true);
3298
+ renderTags(filteredMPTags, true);
3296
3299
  }
3297
3300
  else if (!isTagPaneActive) {
3298
3301
  const filteredIotTags = filterIotTagList(tags);
3302
+ yield renderTagsInSpace(filteredIotTags, true);
3299
3303
  renderTags(filteredIotTags);
3300
- // if (selectedCategoryFilterId || selectedSubCategoryFilterId) {
3301
- // const sortedTags = sortTags(filteredTags, {by: 'label', order: 'asc'})
3302
- // renderTags(sortedTags)
3303
- // } else if (tags.length > 0) {
3304
- // const sortedTags = sortTags(tags, {by: 'label', order: 'asc'})
3305
- // renderTags(sortedTags,true)
3306
3304
  }
3307
- });
3305
+ }));
3308
3306
  }
3309
3307
  }
3310
3308
  function handleSearchFromTagListButton() {
3311
3309
  log.info('handleSearchFromTagListButton()');
3312
3310
  const searchTagNameButton = document.getElementById('at-search-tag-button');
3313
3311
  if (searchTagNameButton) {
3314
- searchTagNameButton.addEventListener('click', () => {
3312
+ searchTagNameButton.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
3315
3313
  const tags = getMpTags();
3316
3314
  const tagSearch = getSearchTagTerm();
3317
3315
  if (tagSearch) {
@@ -3321,18 +3319,36 @@ function handleSearchFromTagListButton() {
3321
3319
  if (foundTag) {
3322
3320
  if (selectedCategoryFilterId || selectedSubCategoryFilterId && isTagPaneActive) {
3323
3321
  const filteredTags = filterTagList(foundTag);
3322
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
3323
+ log.info("removeTags", removeTags);
3324
+ // remove tags that is not part in the sorted Tags
3325
+ yield hideTagsFromSpace(removeTags);
3326
+ // show filtered tags only
3327
+ yield renderTagsInSpace(filteredTags, true);
3324
3328
  renderTags(filteredTags);
3325
3329
  }
3326
3330
  else if (foundTag.length > 0 && isTagPaneActive) {
3331
+ const removeTags = tags.filter(tag => !foundTag.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
3332
+ log.info("removeTags", removeTags);
3333
+ // remove tags that is not part in the sorted Tags
3334
+ yield hideTagsFromSpace(removeTags);
3335
+ // show filtered tags only
3336
+ yield renderTagsInSpace(foundTag, true);
3327
3337
  renderTags(foundTag, true);
3328
3338
  }
3329
3339
  else if (!isTagPaneActive) {
3330
3340
  const filteredIotTags = filterIotTagList(foundTag);
3341
+ const removeTags = tags.filter(tag => !filteredIotTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.IOT);
3342
+ log.info("removeTags", removeTags);
3343
+ // remove tags that is not part in the sorted Tags
3344
+ yield hideTagsFromSpace(removeTags);
3345
+ // show filtered tags only
3346
+ yield renderTagsInSpace(filteredIotTags, true);
3331
3347
  renderTags(filteredIotTags);
3332
3348
  }
3333
3349
  }
3334
3350
  }
3335
- });
3351
+ }));
3336
3352
  }
3337
3353
  }
3338
3354
  function handleCustomMapFloorImageUploaded(payload) {
@@ -0,0 +1,8 @@
1
+ import { IMattertagsResponse } from "./types";
2
+ /**
3
+ * Sends a GraphQL query to the Matterport API to retrieve all mattertags and their associated data for a given model ID and application key.
4
+ * @param modelId - Id of the model space
5
+ * @param appKey - Matterport app key
6
+ * @returns
7
+ */
8
+ export declare function getTagAndTagData(modelId: string, appKey: string): Promise<IMattertagsResponse>;
package/lib/graphql.js ADDED
@@ -0,0 +1,60 @@
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
+ /**
11
+ * Sends a GraphQL query to the Matterport API to retrieve all mattertags and their associated data for a given model ID and application key.
12
+ * @param modelId - Id of the model space
13
+ * @param appKey - Matterport app key
14
+ * @returns
15
+ */
16
+ export function getTagAndTagData(modelId, appKey) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ var query = `{
19
+ model(id: "${modelId}") {
20
+ mattertags(includeDisabled: true) {
21
+ id
22
+ floor { id }
23
+ created
24
+ modified
25
+ enabled
26
+ color
27
+ icon
28
+ keywords
29
+ label
30
+ description
31
+ media
32
+ mediaType
33
+ position { x, y, z }
34
+ anchorPosition { x, y, z }
35
+ discPosition { x, y, z }
36
+ stemNormal { x, y, z }
37
+ stemLength
38
+ stemEnabled
39
+ stemDirection { x, y, z } # Deprecated, use stemNormal and stemLength
40
+
41
+ }
42
+ }
43
+ }`;
44
+ var headers = {
45
+ 'Content-Type': 'application/graphql',
46
+ 'x-matterport-application-key': appKey,
47
+ };
48
+ var options = {
49
+ method: 'POST',
50
+ mode: 'cors',
51
+ headers: headers,
52
+ body: query,
53
+ redirect: 'follow',
54
+ };
55
+ var url = 'https://my.matterport.com/api/mp/models/graph';
56
+ //@ts-ignore
57
+ const response = yield fetch(url, options);
58
+ return yield response.json();
59
+ });
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.18.6",
3
+ "version": "1.18.8",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",