architwin 1.18.10 → 1.19.1

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.
@@ -40,6 +40,20 @@ export function renderGeneralSettingsMenu() {
40
40
  <span class="at_text_xxs at_mx-w-16 mdi mdi-information-slab-circle" id="at-general-settings-note">
41
41
  ${i18n.t("Due to restrictions, original minimap is unavailable in password protected spaces. Please select and setup a custom minimap instead.")}
42
42
  </span>
43
+
44
+ <div class="at_field at_flex_column">
45
+ <span class="at_text_base">${i18n.t("ImportMTagHeader")}</span>
46
+ <div id="at-import-mattertags" data-cy="at-import-mattertags">
47
+ <div class="at_button at_import_matterport_btn at_ghost" id="at-import-mattertag-btn" data-cy="at-import-mattertag-btn">
48
+ ${i18n.t('ImportMTButton')}
49
+ <span class="mdi mdi-tray-arrow-down" id="at-import-mattertag-btn"></span>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <span class="at_text_xxs at_mx-w-16 mdi mdi-information-slab-circle" id="at-import-mattertag-note">
54
+ ${i18n.t("ImportMTagInfo")}
55
+ </span>
56
+
43
57
  <div class="at_scrollable_container at_h-min-45"></div>
44
58
  </div>
45
59
  </div>
@@ -290,6 +290,14 @@ 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",
294
+ "ImportMTagHeader": "Import Mattertags",
295
+ "ImportMTButton": "Import",
296
+ "ImportMTagInfo": "Importing the same tags more than once from your Matterport Space will cause duplicates",
297
+ "ImportResultPartial": "Failed to import {{errorCount}} tag(s).",
298
+ "ImportResultNone": "Failed to import any tags.",
299
+ "ImportResultSuccess": "Successfully imported {{count}} tag(s).",
300
+ "NothingToImport": "Nothing to import.",
293
301
  }
294
302
  },
295
303
  ja: {
@@ -574,7 +582,15 @@ i18n
574
582
  "IotCategoryRequired": "IoTカテゴリは必須です",
575
583
  "SuccessUpdatedFloorLevel": "区画のフロアオフセット値が更新されました",
576
584
  "DuplicatePartitionName": "このパーティション名は既にこの部屋で使用されています。別の名前を選択してください。",
577
- "PleaseOnPolygonVisibility": "操作を行う前に、部屋の表示をオンにしてください。"
585
+ "PleaseOnPolygonVisibility": "操作を行う前に、部屋の表示をオンにしてください。",
586
+ "IoTType": "IoTタイプ",
587
+ "ImportMTagHeader": "Mattertagsインポート",
588
+ "ImportMTButton": "インポート",
589
+ "ImportMTagInfo": "Matterportから複数回インポートすると、タグの重複が発生します。",
590
+ "ImportResultPartial": "{{errorCount}}個のタグのインポートに失敗しました",
591
+ "ImportResultNone": "タグのインポートに失敗しました",
592
+ "ImportResultSuccess": "{{count}}個のタグのインポートに成功しました",
593
+ "NothingToImport": "インポートするタグがありませんでした"
578
594
  }
579
595
  }
580
596
  },
@@ -1,7 +1,7 @@
1
1
  import { IToolbarData } from "../../../types";
2
2
  import { setActiveMenu, clearActiveMenu, getObjectListStatus } from "./menuBar";
3
3
  import { renderObjectCards, removeObjectCard } from "./objectListPane";
4
- import { getTagFormData, setTagCategoriesOption, tagFormMode, selectedTag, renderCategoryDropdownOptions, toggleDropdown } from "./tagFormPane";
4
+ import { getTagFormData, setTagCategoriesOption, tagFormMode, selectedTag, renderCategoryDropdownOptions, toggleDropdown, originalTagBackup } from "./tagFormPane";
5
5
  import { renderTags, renderTagRow, addClickEventToTagRow, setTagLink, getTagLink, selectedCategoryFilterId, selectedSubCategoryFilterId, filterTagList } from "./tagListPane";
6
6
  import { renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal } from "./previewModal";
7
7
  import { setActiveActionBtn, clearActiveActionBtn, toggleActionBarButtons } from "./actionBar";
@@ -22,4 +22,4 @@ declare let actionBar: HTMLElement;
22
22
  */
23
23
  declare function setPreferredLanguage(): void;
24
24
  declare function renderToolbarUI(payload: IToolbarData): void;
25
- export { actionBar, tagFormMode, selectedTag, selectedCategoryFilterId, selectedSubCategoryFilterId, renderToolbarUI, renderObjectCards, setActiveMenu, clearActiveMenu, setActiveActionBtn, renderLibraryCards, renderTags, getTagFormData, renderTagRow, addClickEventToTagRow, setTagCategoriesOption, setActiveThemeCard, setActiveCard, setActiveLibraryCard, clearActiveCard, clearActiveLibraryCard, removeObjectCard, renderRecepientOptions, renderTagMessages, createTagMessage, renderCategoryDropdownOptions, toggleDropdown, setTagLink, getTagLink, setTagMessagingDetails, clearTagFormDropdown, clearTagFilterDropdown, getObjectListStatus, toggleModal, setModalAction, toggleModelControl, toggleActionSettings, clearActiveActionBtn, toggleActionBarButtons, filterTagList, setPreferredLanguage, renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal };
25
+ export { actionBar, tagFormMode, selectedTag, originalTagBackup, selectedCategoryFilterId, selectedSubCategoryFilterId, renderToolbarUI, renderObjectCards, setActiveMenu, clearActiveMenu, setActiveActionBtn, renderLibraryCards, renderTags, getTagFormData, renderTagRow, addClickEventToTagRow, setTagCategoriesOption, setActiveThemeCard, setActiveCard, setActiveLibraryCard, clearActiveCard, clearActiveLibraryCard, removeObjectCard, renderRecepientOptions, renderTagMessages, createTagMessage, renderCategoryDropdownOptions, toggleDropdown, setTagLink, getTagLink, setTagMessagingDetails, clearTagFormDropdown, clearTagFilterDropdown, getObjectListStatus, toggleModal, setModalAction, toggleModelControl, toggleActionSettings, clearActiveActionBtn, toggleActionBarButtons, filterTagList, setPreferredLanguage, renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal };
@@ -5,7 +5,7 @@ import { renderObjectListPane, renderObjectCards, removeObjectCard } from "./obj
5
5
  import { renderSpaceUserListPane } from "./spaceUserListPane";
6
6
  import { renderViewingRemoteSpace } from "./viewingRemoteSpace";
7
7
  import { renderAddObjectPane } from "./addObjectPane";
8
- import { renderTagFormPane, getTagFormData, setTagCategoriesOption, tagFormMode, selectedTag, renderCategoryDropdownOptions, toggleDropdown } from "./tagFormPane";
8
+ import { renderTagFormPane, getTagFormData, setTagCategoriesOption, tagFormMode, selectedTag, renderCategoryDropdownOptions, toggleDropdown, originalTagBackup } from "./tagFormPane";
9
9
  import { renderTagListPane, renderTags, renderTagRow, addClickEventToTagRow, setTagLink, getTagLink, selectedCategoryFilterId, selectedSubCategoryFilterId, filterTagList } from "./tagListPane";
10
10
  import { renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal } from "./previewModal";
11
11
  import { renderAddMediascreenFormPane } from "./addMediascreenFormPane";
@@ -167,4 +167,4 @@ function renderToolbarUI(payload) {
167
167
  themeManager(config);
168
168
  }
169
169
  }
170
- export { actionBar, tagFormMode, selectedTag, selectedCategoryFilterId, selectedSubCategoryFilterId, renderToolbarUI, renderObjectCards, setActiveMenu, clearActiveMenu, setActiveActionBtn, renderLibraryCards, renderTags, getTagFormData, renderTagRow, addClickEventToTagRow, setTagCategoriesOption, setActiveThemeCard, setActiveCard, setActiveLibraryCard, clearActiveCard, clearActiveLibraryCard, removeObjectCard, renderRecepientOptions, renderTagMessages, createTagMessage, renderCategoryDropdownOptions, toggleDropdown, setTagLink, getTagLink, setTagMessagingDetails, clearTagFormDropdown, clearTagFilterDropdown, getObjectListStatus, toggleModal, setModalAction, toggleModelControl, toggleActionSettings, clearActiveActionBtn, toggleActionBarButtons, filterTagList, setPreferredLanguage, renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal };
170
+ export { actionBar, tagFormMode, selectedTag, originalTagBackup, selectedCategoryFilterId, selectedSubCategoryFilterId, renderToolbarUI, renderObjectCards, setActiveMenu, clearActiveMenu, setActiveActionBtn, renderLibraryCards, renderTags, getTagFormData, renderTagRow, addClickEventToTagRow, setTagCategoriesOption, setActiveThemeCard, setActiveCard, setActiveLibraryCard, clearActiveCard, clearActiveLibraryCard, removeObjectCard, renderRecepientOptions, renderTagMessages, createTagMessage, renderCategoryDropdownOptions, toggleDropdown, setTagLink, getTagLink, setTagMessagingDetails, clearTagFormDropdown, clearTagFilterDropdown, getObjectListStatus, toggleModal, setModalAction, toggleModelControl, toggleActionSettings, clearActiveActionBtn, toggleActionBarButtons, filterTagList, setPreferredLanguage, renderPreviewModal, togglePreviewModal, closePreviewModal, setPreviewModalAction, activePreviewModal };
@@ -1,6 +1,7 @@
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
+ export declare let originalTagBackup: any;
4
5
  export declare function renderTagFormPane(): HTMLDivElement;
5
6
  export declare function initFormData(tagId?: string): void;
6
7
  export declare function getTagFormData(): {
@@ -13,8 +14,12 @@ export declare function getTagFormData(): {
13
14
  export declare function setTagCategoriesOption(): void;
14
15
  export declare function toggleDropdown(elementId: string): void;
15
16
  export declare function clearInnerHTML(elementId: string): void;
17
+ export declare function hideTagsFromSpace(tags?: ITag[]): Promise<void>;
18
+ export declare function renderTagsInSpace(tags: ITag[], _withIcon?: boolean, iframeId?: string): Promise<void>;
16
19
  export declare function renderCategoryDropdownOptions(elementId: string, items: Array<ITagCategory>, toggleId?: string): void;
17
20
  export declare function renderSubcategoryDropdownOptions(elementId: string, items: Array<ITagCategory>): void;
18
21
  export declare function clearTagFormDropdown(): void;
19
22
  export declare function clearTagFilterDropdown(): void;
20
23
  export declare function setTagFormMode(formMode: FORM_MODE): void;
24
+ export declare function clearSelectedTag(): void;
25
+ export declare function setSelectedTag(tag: any): 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, editTagColor, 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;
@@ -10,6 +22,7 @@ let selectedSubCategoryId = undefined;
10
22
  let isChevronEventAdded = false;
11
23
  export let tagFormMode = "NONE" /* FORM_MODE.NONE */;
12
24
  export let selectedTag = undefined;
25
+ export let originalTagBackup = null;
13
26
  export function renderTagFormPane() {
14
27
  const element = document.createElement('div');
15
28
  element.classList.add('at_container');
@@ -92,15 +105,12 @@ export function initFormData(tagId) {
92
105
  const targetTag = _tags.find(tag => tag.json_data.id === tagId);
93
106
  console.log("targetTag", targetTag);
94
107
  selectedTag = targetTag;
108
+ // keep a deep copy of original tag data so we can revert on cancel
109
+ originalTagBackup = targetTag ? JSON.parse(JSON.stringify(targetTag.json_data)) : null;
95
110
  if (targetTag) {
96
111
  if (!tagNameInput) {
97
112
  setInputElements();
98
113
  }
99
- const tagCategory = _tagCategories.find((category) => {
100
- const tagCategory = category.subcategories.find(subcategory => subcategory.uuid === targetTag.category_uuid);
101
- return tagCategory;
102
- });
103
- console.log('tagCategoryId', tagCategory, tagCategory.uuid);
104
114
  tagNameInput.value = targetTag.json_data.label;
105
115
  tagDescriptionInput.value = targetTag.json_data.description;
106
116
  tagEmbedInput.value = targetTag.media_url && targetTag.media_url !== '' ? targetTag.media_url : '';
@@ -130,6 +140,8 @@ export function initFormData(tagId) {
130
140
  tagNameInput.value = '';
131
141
  tagDescriptionInput.value = '';
132
142
  tagEmbedInput.value = '';
143
+ // clear any previous edit backup when entering add mode
144
+ originalTagBackup = null;
133
145
  }
134
146
  const categoryChevron = document.getElementById('at-category-dropdown');
135
147
  const subcategoryChevron = document.getElementById('at-subcategory-dropdown');
@@ -261,109 +273,237 @@ export function clearInnerHTML(elementId) {
261
273
  targetElement.innerHTML = ``;
262
274
  }
263
275
  function selectOption(option, elementId, skipToggle = false) {
264
- console.log("selectOption()");
265
- //const dropdownToggle = document.querySelector('.at_dropdown_toggle');
266
- if (!elementId || elementId === '' || elementId == null) {
267
- console.error("ElementId is empty or undefined");
268
- return;
269
- }
270
- const dropdownToggle = document.getElementById(elementId);
271
- //dropdownToggle.textContent = option.textContent;
272
- dropdownToggle.innerHTML = option.innerHTML;
273
- //selectedText = option.textContent;
274
- const isFilterDropdown = stringContains(elementId, 'filter');
275
- const categoryUUID = option.getAttribute('category-uuid');
276
- const categoryType = option.getAttribute('dropdown-type');
277
- console.log("categoryUUID ", categoryUUID);
278
- console.log("categoryType ", categoryType);
279
- if (categoryUUID && categoryUUID !== null) {
280
- if (categoryType == 'category' && isFilterDropdown == false) {
281
- selectedCategoryId = categoryUUID;
282
- }
283
- else if (categoryType == 'category' && isFilterDropdown) {
284
- setSelectedCategoryFilter(categoryUUID);
285
- setSelectedSubcategoryFilter(undefined); //reset selected subcategory
286
- const tags = getMpTags();
287
- const filteredTags = filterTagList(tags);
288
- const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
289
- renderTags(sortedTags);
290
- }
291
- else if (categoryType == 'subcategory' && isFilterDropdown == false) {
292
- selectedSubCategoryId = categoryUUID;
293
- }
294
- else if (categoryType == 'subcategory' && isFilterDropdown) {
295
- setSelectedSubcategoryFilter(categoryUUID);
296
- const tags = getMpTags();
297
- const filteredTags = filterTagList(tags);
298
- const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
299
- renderTags(filteredTags);
300
- }
301
- //Populate subcategory dropdown
302
- const targetCategory = _tagCategories.find(cat => cat.uuid === categoryUUID);
303
- if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
304
- console.log("Subcategories found", targetCategory.subcategories);
305
- 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;
306
283
  }
307
- else {
308
- if (categoryType == 'category') {
309
- const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
310
- const subcatToggleId = isFilterDropdown ? 'at-subcategory-filter-dropdown-toggle' : 'at-subcategory-dropdown-toggle';
311
- const subcategoryToggle = document.getElementById(elementId);
312
- const subcatDropdownToggle = document.getElementById(subcatToggleId);
313
- 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
+ // updates the tag icon color
314
+ const targetCategory = _tagCategories.find(cat => cat.uuid === selectedCategoryId);
315
+ if (targetCategory && selectedTag != undefined) {
316
+ yield editTagColor({ tagId: selectedTag.json_data.id, color: targetCategory.json_data.color.rgb });
317
+ _atwin.Tag.editPosition(selectedTag.json_data.id, {
318
+ anchorPosition: selectedTag.json_data.anchorPosition,
319
+ stemVector: Object.assign({}, selectedTag.json_data.stemVector),
320
+ });
321
+ }
322
+ }
323
+ else if (categoryType == 'subcategory' && isFilterDropdown) {
324
+ setSelectedSubcategoryFilter(categoryUUID);
325
+ const tags = getMpTags();
326
+ const filteredTags = filterTagList(tags);
327
+ const sortedTags = sortTags(filteredTags, { by: 'label', order: 'asc' });
328
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
329
+ // remove tags that is not part in the sorted Tags
330
+ yield hideTagsFromSpace(removeTags);
331
+ // show filtered tags only
332
+ yield renderTagsInSpace(filteredTags, true);
333
+ renderTags(filteredTags);
334
+ }
335
+ //Populate subcategory dropdown
336
+ const targetCategory = _tagCategories.find(cat => cat.uuid === categoryUUID);
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);
340
+ }
341
+ else {
342
+ if (categoryType == 'category') {
343
+ const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
344
+ const subcatToggleId = isFilterDropdown ? 'at-subcategory-filter-dropdown-toggle' : 'at-subcategory-dropdown-toggle';
345
+ const subcategoryToggle = document.getElementById(elementId);
346
+ const subcatDropdownToggle = document.getElementById(subcatToggleId);
347
+ subcategoryToggle.innerHTML = `
314
348
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
315
349
  `;
316
- subcatDropdownToggle.innerHTML = `
350
+ subcatDropdownToggle.innerHTML = `
317
351
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
318
352
  `;
353
+ }
319
354
  }
320
355
  }
321
- }
322
- else {
323
- console.log("categoryUUID is undefined");
324
- if (categoryType == 'category' && isFilterDropdown) {
325
- console.log("Clearing subcategory filter");
326
- const subcategoryToggle = document.getElementById('at-subcategory-filter-dropdown-toggle');
327
- subcategoryToggle.textContent = `${i18n.t('NoSelection')}`;
328
- subcategoryToggle.innerHTML = `
356
+ else {
357
+ console.log("categoryUUID is undefined");
358
+ if (categoryType == 'category' && isFilterDropdown) {
359
+ console.log("Clearing subcategory filter");
360
+ const subcategoryToggle = document.getElementById('at-subcategory-filter-dropdown-toggle');
361
+ subcategoryToggle.textContent = `${i18n.t('NoSelection')}`;
362
+ subcategoryToggle.innerHTML = `
329
363
  <span class="mdi mdi-circle-slice-1"></span> ${i18n.t('NoSelection')}
330
364
  `;
331
- setSelectedCategoryFilter(undefined);
365
+ setSelectedCategoryFilter(undefined);
366
+ }
367
+ if (isFilterDropdown) {
368
+ setSelectedSubcategoryFilter(undefined); //reset selected subcategory
369
+ }
370
+ //Populate subcategory dropdown
371
+ const targetCategory = _tagCategories.find(cat => cat.uuid === selectedCategoryFilterId);
372
+ if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
373
+ console.log("Subcategories found", targetCategory.subcategories);
374
+ renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
375
+ }
376
+ else {
377
+ const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
378
+ clearInnerHTML(elementId);
379
+ }
380
+ let tags = getMpTags().filter(tag => !tag.tag_type || tag.tag_type !== TAG_TYPE.IOT);
381
+ const filteredTags = (_a = filterTagList(tags)) !== null && _a !== void 0 ? _a : [];
382
+ const sortedTags = sortTags(filteredTags.length ? filteredTags : tags, selectedTagSortOption);
383
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.MP);
384
+ if (filteredTags.length > 0) {
385
+ // remove tags that is not part in the sorted Tags
386
+ yield hideTagsFromSpace(removeTags);
387
+ }
388
+ // show filtered tags only
389
+ yield renderTagsInSpace(sortedTags, true);
390
+ renderTags(sortedTags);
391
+ }
392
+ let toggleId = '';
393
+ if (elementId === 'at-category-dropdown-toggle') {
394
+ toggleId = 'at-category-options';
395
+ }
396
+ else if (elementId === 'at-subcategory-dropdown-toggle') {
397
+ toggleId = 'at-subcategory-options';
398
+ }
399
+ else if (elementId === 'at-category-filter-dropdown-toggle') {
400
+ toggleId = 'at-category-filter-options';
332
401
  }
333
- if (isFilterDropdown) {
334
- setSelectedSubcategoryFilter(undefined); //reset selected subcategory
402
+ else if (elementId === 'at-subcategory-filter-dropdown-toggle') {
403
+ toggleId = 'at-subcategory-filter-options';
335
404
  }
336
- //Populate subcategory dropdown
337
- const targetCategory = _tagCategories.find(cat => cat.uuid === selectedCategoryFilterId);
338
- if (targetCategory && targetCategory.subcategories && targetCategory.subcategories.length > 0) {
339
- console.log("Subcategories found", targetCategory.subcategories);
340
- renderSubcategoryDropdownOptions(isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options', targetCategory.subcategories);
405
+ if (skipToggle == false) {
406
+ toggleDropdown(toggleId);
407
+ }
408
+ });
409
+ }
410
+ export function hideTagsFromSpace(tags = null) {
411
+ return __awaiter(this, void 0, void 0, function* () {
412
+ log.info('hideTagsFromSpace', tags);
413
+ if (tags != null) {
414
+ tags.map((tag) => __awaiter(this, void 0, void 0, function* () {
415
+ yield _tag.disposeTag({ tagId: tag.json_data.id, sdk: _atwin, tags: _tags });
416
+ }));
341
417
  }
342
418
  else {
343
- const elementId = isFilterDropdown ? 'at-subcategory-filter-options' : 'at-subcategory-options';
344
- clearInnerHTML(elementId);
419
+ disposeTags();
345
420
  }
346
- let tags = getMpTags().filter(tag => !tag.tag_type || tag.tag_type !== TAG_TYPE.IOT);
347
- const filteredTags = filterTagList(tags);
348
- const sortedTags = sortTags(filteredTags ? filteredTags : tags, selectedTagSortOption);
349
- renderTags(sortedTags);
350
- }
351
- let toggleId = '';
352
- if (elementId === 'at-category-dropdown-toggle') {
353
- toggleId = 'at-category-options';
354
- }
355
- else if (elementId === 'at-subcategory-dropdown-toggle') {
356
- toggleId = 'at-subcategory-options';
357
- }
358
- else if (elementId === 'at-category-filter-dropdown-toggle') {
359
- toggleId = 'at-category-filter-options';
360
- }
361
- else if (elementId === 'at-subcategory-filter-dropdown-toggle') {
362
- toggleId = 'at-subcategory-filter-options';
363
- }
364
- if (skipToggle == false) {
365
- toggleDropdown(toggleId);
366
- }
421
+ });
422
+ }
423
+ // render tags to space
424
+ export function renderTagsInSpace(tags, _withIcon = false, iframeId = undefined) {
425
+ var _a;
426
+ return __awaiter(this, void 0, void 0, function* () {
427
+ log.info('renderTagsInSpace', tags);
428
+ let renderedTagIds = [];
429
+ const sdk = iframeId ? _atwinConnections[iframeId] : _atwin;
430
+ for (let tag of tags) {
431
+ log.info('tag', tag);
432
+ const isDuplicate = renderedTagIds.includes(tag.json_data.id);
433
+ const rsid = new ShortUniqueId({ length: 10 });
434
+ if (isDuplicate) {
435
+ //assign a different unique id if the existing tag id is a duplicate
436
+ tag.json_data.id = rsid.rnd();
437
+ }
438
+ renderedTagIds.push(tag.json_data.id);
439
+ try {
440
+ const renderedTag = yield renderTag({ tag: tag.json_data }, false, iframeId);
441
+ }
442
+ catch (error) {
443
+ log.info("Tag is already rendered in space");
444
+ continue;
445
+ }
446
+ // check if tag needs tag icon display
447
+ if (_withIcon && tag.tag_icon_base64 !== '') {
448
+ // set tag icon
449
+ log.info("__@ showTags: ", tags);
450
+ yield setTagIcon({ tag: tag.json_data, iconName: tag.tag_icon_name, iconUrl: tag.tag_icon_base64, color: tag.json_data.color, iframeId });
451
+ }
452
+ if (tag.media_url && tag.media_url !== '') {
453
+ try {
454
+ const attachments = [tag.media_url];
455
+ yield _tag.attachTagMedia({ sdk, tag: tag.json_data, attachments });
456
+ }
457
+ catch (error) {
458
+ log.warn(error);
459
+ }
460
+ }
461
+ if (tag.sandboxId) {
462
+ try {
463
+ yield attachSandbox({ sandboxId: tag.sandboxId, tagIds: [tag.json_data.id] });
464
+ }
465
+ catch (error) {
466
+ log.error("Attach sandbox error ", error);
467
+ }
468
+ }
469
+ if (tag.tag_type === TAG_TYPE.IOT) {
470
+ const icons = getIoTDeviceTagIcons();
471
+ let iconUrl = icons.normal;
472
+ let iconName = "normal.png";
473
+ let color = { r: 0.3, g: 0.5, b: 1.0 }; // default soft royal blue
474
+ for (const device of tag.iot_tag.linked_devices) {
475
+ if (!device)
476
+ continue;
477
+ const { quality, status } = device;
478
+ // If any device is offline, override color to gray and stop checking further
479
+ if (status === "offline") {
480
+ iconUrl = icons.normal;
481
+ iconName = "normal.png";
482
+ color = useHexToRgb("667c89"); // gray
483
+ break;
484
+ }
485
+ // If any device is alert (highest priority), set red and stop
486
+ if (quality === 2) {
487
+ iconUrl = icons.alert;
488
+ iconName = "alert.png";
489
+ color = { r: 1, g: 0, b: 0 }; // red
490
+ break;
491
+ }
492
+ // If any device is attention, set orange but keep checking in case of alert
493
+ if (quality === 3) {
494
+ iconUrl = icons.alert;
495
+ iconName = "normal.png";
496
+ color = useHexToRgb("ffae42"); // orange
497
+ // continue loop to see if alert is present
498
+ }
499
+ }
500
+ tag.tag_icon_url = iconUrl;
501
+ tag.tag_icon_name = iconName;
502
+ tag.json_data.color = color;
503
+ 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 });
504
+ }
505
+ }
506
+ });
367
507
  }
368
508
  function createOptionElement(item, dropdownType) {
369
509
  console.log("createOptionElement");
@@ -539,3 +679,9 @@ export function clearTagFilterDropdown() {
539
679
  export function setTagFormMode(formMode) {
540
680
  tagFormMode = formMode;
541
681
  }
682
+ export function clearSelectedTag() {
683
+ selectedTag = undefined;
684
+ }
685
+ export function setSelectedTag(tag) {
686
+ selectedTag = tag;
687
+ }
@@ -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>
@@ -190,12 +190,10 @@ export function renderTags(tags, showOwnTagsOnly = false) {
190
190
  tags.forEach(tag => {
191
191
  console.log('@caroline render tag checking: ', tag);
192
192
  if (showOwnTagsOnly) {
193
- if (isTagPartOfCategory(tag.category_uuid)) {
194
- const row = renderTagRow(tag.json_data, tag.tag_icon_url, tag.tag_type);
195
- tagContainer.appendChild(row);
196
- addTagButton.classList.remove('at_disabled');
197
- visibilityTagButton.classList.remove('at_disabled');
198
- }
193
+ const row = renderTagRow(tag.json_data, tag.tag_icon_url, tag.tag_type);
194
+ tagContainer.appendChild(row);
195
+ addTagButton.classList.remove('at_disabled');
196
+ visibilityTagButton.classList.remove('at_disabled');
199
197
  }
200
198
  else {
201
199
  console.log('@caroline render tag checking 2: ', tag);
@@ -853,7 +851,7 @@ export function setIotCategoryFilterOptions() {
853
851
  log.info('setIotCategoryOptions()');
854
852
  if (_tagIotCategoryTypes) {
855
853
  renderIotCategoryDropdownFilterOptions('at-iot-category-filter-options', _tagIotCategoryTypes);
856
- batchAddEventListenerByClassName('at_iot_cat_filter_option', (event) => {
854
+ batchAddEventListenerByClassName('at_iot_cat_filter_option', (event) => __awaiter(this, void 0, void 0, function* () {
857
855
  log.info("category filter clicked");
858
856
  //@ts-ignore
859
857
  const selectedCat = event.target;
@@ -863,6 +861,7 @@ export function setIotCategoryFilterOptions() {
863
861
  // no selection selected
864
862
  selectedIoTCategoryFilter = { uuid: '', name: 'NoSelection' };
865
863
  setSelectedIoTCategoryFilter(selectedIoTCategoryFilter);
864
+ yield renderTagsInSpace(iotTags, true);
866
865
  renderTags(iotTags);
867
866
  }
868
867
  const getCatName = _tagIotCategoryTypes.find(cat => cat.uuid === catUUID);
@@ -873,13 +872,18 @@ export function setIotCategoryFilterOptions() {
873
872
  filterIotTagByCategory(iotTags);
874
873
  }
875
874
  toggleDropdown('at-iot-category-filter-options');
876
- });
875
+ }));
877
876
  }
878
877
  }
879
878
  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);
879
+ return __awaiter(this, void 0, void 0, function* () {
880
+ log.info("selectedIoTCategoryFilter", selectedIoTCategoryFilter, _tags);
881
+ const filteredTags = tags.filter(tag => tag.iot_tag.iot_category == selectedIoTCategoryFilter.name);
882
+ const removeTags = tags.filter(tag => !filteredTags.some(ft => ft.id === tag.id) && tag.tag_type === TAG_TYPE.IOT);
883
+ yield hideTagsFromSpace(removeTags);
884
+ yield renderTagsInSpace(filteredTags, true);
885
+ renderTags(filteredTags);
886
+ });
883
887
  }
884
888
  // displays selected Category in the dropdown
885
889
  export function setSelectedIoTCategoryFilter(payload) {