100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI fix: Resolved or-attribute-picker export issues (#1891)
Martin Peeters3434b218edbe
diff --git a/ui/app/manager/src/pages/page-export.ts b/ui/app/manager/src/pages/page-export.tsindex 254dd3ad3..f56f89636 100644--- a/ui/app/manager/src/pages/page-export.ts+++ b/ui/app/manager/src/pages/page-export.ts@@ -7,7 +7,7 @@ import {AppStateKeyed} from "@openremote/or-app";import {i18next} from "@openremote/or-translate";import manager, { DefaultColor3, Util } from "@openremote/core";import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";-import {OrAttributePickerPickedEvent, OrAttributePicker } from "@openremote/or-attribute-picker";+import {OrAssetAttributePickerPickedEvent, OrAssetAttributePicker} from "@openremote/or-attribute-picker";import { AttributeRef } from "@openremote/model";import moment from "moment";import { buttonStyle } from "@openremote/or-rules";@@ -357,13 +357,13 @@ export class PageExport extends Page<AppStateKeyed> {protected _openDialog() {- const dialog = showDialog(new OrAttributePicker()+ const dialog = showDialog(new OrAssetAttributePicker().setShowOnlyDatapointAttrs(true).setMultiSelect(true).setSelectedAttributes(this.config.selectedAttributes));- dialog.addEventListener(OrAttributePickerPickedEvent.NAME, async (ev: OrAttributePickerPickedEvent) => {+ dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, async (ev: OrAssetAttributePickerPickedEvent) => {const selectedAttributes = ev.detail;await this.renderTable(selectedAttributes);this.config = {diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.tsindex 749c3becf..5fdd01118 100644--- a/ui/component/or-attribute-card/src/index.ts+++ b/ui/component/or-attribute-card/src/index.ts@@ -26,7 +26,7 @@ import "@openremote/or-attribute-picker";import moment from "moment";import {OrAssetTreeSelectionEvent} from "@openremote/or-asset-tree";import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";-import {OrAttributePicker, OrAttributePickerPickedEvent} from "@openremote/or-attribute-picker";+import {OrAssetAttributePicker, OrAssetAttributePickerPickedEvent} from "@openremote/or-attribute-picker";import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/or-mwc-menu";import {when} from "lit/directives/when.js";import {debounce} from "lodash";@@ -543,10 +543,10 @@ export class OrAttributeCard extends LitElement {});break;default:- dialog = new OrAttributePicker()+ dialog = new OrAssetAttributePicker().setHeading(i18next.t("selectAttribute"));- dialog.addEventListener(OrAttributePickerPickedEvent.NAME, async (ev: OrAttributePickerPickedEvent) => {+ dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, async (ev: OrAssetAttributePickerPickedEvent) => {// handle selected attrsconst attrRef = ev.detail[0];try {diff --git a/ui/component/or-attribute-picker/src/assettype-attribute-picker.ts b/ui/component/or-attribute-picker/src/assettype-attribute-picker.tsindex b6f02ba05..aa42091dd 100644--- a/ui/component/or-attribute-picker/src/assettype-attribute-picker.ts+++ b/ui/component/or-attribute-picker/src/assettype-attribute-picker.ts@@ -1,4 +1,4 @@-import {property, state} from "lit/decorators.js";+import {customElement, property, state} from "lit/decorators.js";import {AttributePicker, AttributePickerPickedEvent} from "./attribute-picker";import {PropertyValues, html, unsafeCSS} from "lit";import {DefaultColor5, Util} from "@openremote/core";@@ -13,12 +13,12 @@ import "./assettype-list";* Custom Event that is dispatched upon closing the dialog.* Contains a map that is keyed by {@link AssetDescriptor.name}, with an array of {@link AttributeDescriptor}s of the selected attributes.*/-export class AssetTypeAttributePickerPickedEvent extends AttributePickerPickedEvent {+export class OrAssetTypeAttributePickerPickedEvent extends AttributePickerPickedEvent {public static readonly NAME = "or-asset-type-attribute-picker-picked";constructor(attrDescriptors: Map<string, AttributeDescriptor[]>) {- super(AssetTypeAttributePickerPickedEvent.NAME, {+ super(OrAssetTypeAttributePickerPickedEvent.NAME, {bubbles: true,composed: true,detail: attrDescriptors@@ -28,7 +28,7 @@ export class AssetTypeAttributePickerPickedEvent extends AttributePickerPickedEvdeclare global {export interface HTMLElementEventMap {- [AssetTypeAttributePickerPickedEvent.NAME]: AssetTypeAttributePickerPickedEvent;+ [OrAssetTypeAttributePickerPickedEvent.NAME]: OrAssetTypeAttributePickerPickedEvent;}}@@ -37,10 +37,9 @@ declare global {** @attribute {object} assetTypeFilter -Callback method for consumers to filter the asset type list shown. Returning true will make the asset type visible, returning false hides it.* @attribute {object} attributeFilter - Callback method for consumers to filter the attribute list shown. Returning true will make the attribute visible, returning false hides it.- *- * @remarks TODO: In the future this should be a separate component named "or-assettype-attribute-picker"*/-export class AssetTypeAttributePicker extends AttributePicker {+@customElement("or-assettype-attribute-picker")+export class OrAssetTypeAttributePicker extends AttributePicker {@property()public assetTypeFilter?: (descriptor: AssetDescriptor) => boolean;@@ -185,7 +184,7 @@ export class AssetTypeAttributePicker extends AttributePicker {<or-mwc-input id="add-btn" class="button" label="add" .type="${InputType.BUTTON}"></or-mwc-input>`,action: () => {if (!this.addBtn.disabled) {- this.dispatchEvent(new AssetTypeAttributePickerPickedEvent(this.selectedAttributes));+ this.dispatchEvent(new OrAssetTypeAttributePickerPickedEvent(this.selectedAttributes));}}}diff --git a/ui/component/or-attribute-picker/src/index.ts b/ui/component/or-attribute-picker/src/index.tsindex bb5d876ec..ceff05a28 100644--- a/ui/component/or-attribute-picker/src/index.ts+++ b/ui/component/or-attribute-picker/src/index.ts@@ -1,10 +1,9 @@import {customElement} from "lit/decorators.js";import {OrAssetAttributePicker, OrAssetAttributePickerPickedEvent} from "./asset-attribute-picker";-import {AssetTypeAttributePickerPickedEvent, AssetTypeAttributePicker} from "./assettype-attribute-picker";/*** {@link CustomEvent} that triggers once attributes have been selected, and the user closes the dialog.- * @deprecated Replaced this class with an abstract {@link OrAssetAttributePickerPickedEvent}, that is inherited by other classes like {@link OrAssetAttributePicker} and {@link AssetTypeAttributePicker}.+ * @deprecated Replaced this class with an abstract {@link OrAssetAttributePickerPickedEvent}, that is inherited by other classes like {@link OrAssetAttributePicker} and {@link OrAssetTypeAttributePicker}.*/export class OrAttributePickerPickedEvent extends OrAssetAttributePickerPickedEvent {@@ -18,17 +17,5 @@ export class OrAttributePickerPickedEvent extends OrAssetAttributePickerPickedEvexport class OrAttributePicker extends OrAssetAttributePicker {}-/**- * TODO: Remove this, and export the ./assettype-attribute-picker file- */-export class OrAssetTypeAttributePickerPickedEvent extends AssetTypeAttributePickerPickedEvent {--}--/**- * TODO: Remove this, and export the ./assettype-attribute-picker file- */-@customElement("or-assettype-attribute-picker")-export class OrAssetTypeAttributePicker extends AssetTypeAttributePicker {--}+export * from "./asset-attribute-picker";+export * from "./assettype-attribute-picker";diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex 32fcbf121..5021011e4 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -46,7 +46,7 @@ import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";import ChartAnnotation, {AnnotationOptions} from "chartjs-plugin-annotation";import "chartjs-adapter-moment";import {GenericAxiosResponse, isAxiosError} from "@openremote/rest";-import {OrAttributePicker, OrAttributePickerPickedEvent} from "@openremote/or-attribute-picker";+import {OrAssetAttributePicker, OrAssetAttributePickerPickedEvent} from "@openremote/or-attribute-picker";import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {cache} from "lit/directives/cache.js";import {throttle} from "lodash";@@ -900,12 +900,12 @@ export class OrChart extends translate(i18next)(LitElement) {}protected _openDialog() {- const dialog = showDialog(new OrAttributePicker()+ const dialog = showDialog(new OrAssetAttributePicker().setShowOnlyDatapointAttrs(true).setMultiSelect(true).setSelectedAttributes(this._getSelectedAttributes()));- dialog.addEventListener(OrAttributePickerPickedEvent.NAME, (ev: any) => this._addAttribute(ev.detail));+ dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, (ev: any) => this._addAttribute(ev.detail));}protected _openTimeDialog(startTimestamp?: number, endTimestamp?: number) {diff --git a/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts b/ui/component/or-dashboard-builder/src/panels/attributes-panel.tsindex c635c3a0a..fc3f19829 100644--- a/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts+++ b/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts@@ -10,7 +10,7 @@ import "@openremote/or-translate";import {InputType} from "@openremote/or-mwc-components/or-mwc-input";import manager, {DefaultColor5, Util} from "@openremote/core";import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";-import {OrAttributePicker, OrAttributePickerPickedEvent} from "@openremote/or-attribute-picker";+import {OrAssetAttributePicker, OrAssetAttributePickerPickedEvent} from "@openremote/or-attribute-picker";import {showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";@@ -226,13 +226,13 @@ export class AttributesPanel extends LitElement {}protected openAttributeSelector(attributeRefs: AttributeRef[], multi: boolean, onlyDataAttrs = true, attributeFilter?: (attribute: Attribute<any>) => boolean) {- let dialog: OrAttributePicker;+ let dialog: OrAssetAttributePicker;if (attributeRefs != null) {- dialog = showDialog(new OrAttributePicker().setMultiSelect(multi).setSelectedAttributes(attributeRefs).setShowOnlyDatapointAttrs(onlyDataAttrs).setAttributeFilter(attributeFilter));+ dialog = showDialog(new OrAssetAttributePicker().setMultiSelect(multi).setSelectedAttributes(attributeRefs).setShowOnlyDatapointAttrs(onlyDataAttrs).setAttributeFilter(attributeFilter));} else {- dialog = showDialog(new OrAttributePicker().setMultiSelect(multi).setShowOnlyDatapointAttrs(onlyDataAttrs))+ dialog = showDialog(new OrAssetAttributePicker().setMultiSelect(multi).setShowOnlyDatapointAttrs(onlyDataAttrs))}- dialog.addEventListener(OrAttributePickerPickedEvent.NAME, (event: CustomEvent) => {+ dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, (event: CustomEvent) => {this.attributeRefs = event.detail;})}diff --git a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts b/ui/component/or-rules/src/flow-viewer/components/internal-picker.tsindex 09a94f14f..473d7ff4d 100644--- a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts+++ b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts@@ -11,7 +11,7 @@ import { NodeUtilities } from "../node-structure";import { translate, i18next } from "@openremote/or-translate";import { PickerStyle } from "../styles/picker-styles";import { Util } from "@openremote/core";-import { OrAttributePicker, OrAttributePickerPickedEvent } from "@openremote/or-attribute-picker";+import {OrAssetAttributePicker, OrAssetAttributePickerPickedEvent} from "@openremote/or-attribute-picker";import { showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";import {ifDefined} from "lit/directives/if-defined.js";@@ -174,14 +174,14 @@ export class InternalPicker extends translate(i18next)(LitElement) {_selectedAssets = [ this.selectedAsset.id ];}- const dialog = showDialog(new OrAttributePicker()+ const dialog = showDialog(new OrAssetAttributePicker().setShowOnlyRuleStateAttrs(true).setShowOnlyDatapointAttrs(false).setMultiSelect(false).setSelectedAttributes(_selectedAttributes)).setSelectedAssets(_selectedAssets);- dialog.addEventListener(OrAttributePickerPickedEvent.NAME, async (ev: OrAttributePickerPickedEvent) => {+ dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, async (ev: OrAssetAttributePickerPickedEvent) => {const value: AttributeInternalValue = {assetId: ev.detail[0].id,attributeName: ev.detail[0].name