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
Improvement/flow rule element UI improvement issue 584 (#603)
Jérôme Vervier4d5dfa3e3271
diff --git a/ui/component/or-attribute-picker/src/index.ts b/ui/component/or-attribute-picker/src/index.tsindex 202b1dce9..baf85df3b 100644--- a/ui/component/or-attribute-picker/src/index.ts+++ b/ui/component/or-attribute-picker/src/index.ts@@ -44,6 +44,7 @@ export class OrAttributePicker extends OrMwcDialog {public multiSelect?: boolean = false;public selectedAttributes: AttributeRef[] = [];+ public selectedAssets: string[] = [];@state()protected assetAttributes?: (Attribute<any>)[];@@ -100,6 +101,12 @@ export class OrAttributePicker extends OrMwcDialog {return this;}+ public setSelectedAssets(selectedAssets: string[]): OrAttributePicker {+ this.selectedAssets = selectedAssets;+ this.setDialogContent();+ return this;+ }+public setOpen(isOpen: boolean): OrAttributePicker {super.setOpen(isOpen);return this;@@ -166,11 +173,21 @@ export class OrAttributePicker extends OrMwcDialog {});};+ let selectedAttribute: ListItem | undefined = undefined;+ if (!this.multiSelect && this.selectedAttributes.length === 1 && this.selectedAttributes[0].name) {+ console.log('here');+ selectedAttribute = {+ text: Util.getAttributeLabel(undefined, this.selectedAttributes[0], undefined, true),+ value: this.selectedAttributes[0].name+ };+ }+ console.log(selectedAttribute);this.content = () => html`<div class="row" style="display: flex;height: 600px;width: 800px;border-top: 1px solid ${unsafeCSS(DefaultColor5)};"><div class="col" style="width: 260px;overflow: auto;border-right: 1px solid ${unsafeCSS(DefaultColor5)};"><or-asset-tree id="chart-asset-tree" readonly+ .selectedIds="${ this.selectedAssets.length > 0 ? this.selectedAssets : null }"@or-asset-tree-selection="${(ev: OrAssetTreeSelectionEvent) => this._onAssetSelectionChanged(ev)}"></or-asset-tree></div>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 c71736cf5..e60622dca 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@@ -13,6 +13,7 @@ import { PickerStyle } from "../styles/picker-styles";import { Util } from "@openremote/core";import { OrAttributePicker, OrAttributePickerPickedEvent } from "@openremote/or-attribute-picker";import { showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";@customElement("internal-picker")export class InternalPicker extends translate(i18next)(LitElement) {@@ -38,8 +39,41 @@ export class InternalPicker extends translate(i18next)(LitElement) {margin: 0;display: flex;flex-direction: column;+ --or-app-color4: var(--or-mwc-input-color);}`,- PickerStyle];+ PickerStyle,+ css`.attribute-label-white {+ background: #ffffff;+ }+ .selected-asset-container {+ display: flex;+ align-items: center;+ }+ .selected-asset-container:hover {+ cursor: pointer;+ background-color: #F9F9F9;+ }+ .selected-asset-label {+ padding: 5px;+ display: flex;+ flex-direction: column;+ line-height: 16px;+ justify-content: flex-start;+ font-size: 14px;+ text-align: left;+ }+ .selected-asset-label .asset {+ color: rgb(76, 76, 76);+ }+ .selected-asset-label .asset-attribute {+ color: grey;+ }+ .selected-asset-icon {+ display: flex;+ justify-content: center;+ padding: 0px 5px 0px 5px;+ --or-icon-width: 20px;+ }`];}protected firstUpdated() {@@ -123,7 +157,9 @@ export class InternalPicker extends translate(i18next)(LitElement) {const openDialog = () => {let _selectedAttributes : AttributeRef[] = [];+ let _selectedAssets: string[] = [];let val = this.node.internals![this.internalIndex].value;+if (val){_selectedAttributes = [{id: val.assetId,@@ -131,11 +167,16 @@ export class InternalPicker extends translate(i18next)(LitElement) {}];}+ if (this.selectedAsset && this.selectedAsset.id) {+ _selectedAssets = [ this.selectedAsset.id ];+ }+const dialog = showDialog(new OrAttributePicker().setShowOnlyRuleStateAttrs(true).setShowOnlyDatapointAttrs(false).setMultiSelect(false)- .setSelectedAttributes(_selectedAttributes));+ .setSelectedAttributes(_selectedAttributes))+ .setSelectedAssets(_selectedAssets);dialog.addEventListener(OrAttributePickerPickedEvent.NAME, async (ev: OrAttributePickerPickedEvent) => {const value: AttributeInternalValue = {@@ -154,14 +195,26 @@ export class InternalPicker extends translate(i18next)(LitElement) {const attrName = this.internal?.value?.attributeName;const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attrName, this.selectedAsset.type!);let attr = this.selectedAsset.attributes[attrName];- if (attr)- selectedAttrLabel = Util.getAttributeLabel(attr, attributeDescriptor, this.selectedAsset.type!, true)+ if (attr) {+ selectedAttrLabel = Util.getAttributeLabel(attr, attributeDescriptor, this.selectedAsset.type!, true);+ }}- return html`- ${(this.selectedAsset ? html`<span class="attribute-label">${selectedAttrLabel}</span>` : null)}- <or-mwc-input class="button" .type="${InputType.BUTTON}" label="${i18next.t("attribute")}" icon="format-list-bulleted-square" @click="${() => openDialog()}"></or-mwc-input>- `;+ const descriptor = this.selectedAsset ? AssetModelUtil.getAssetDescriptor(this.selectedAsset!.type!) : undefined;+ const myIcon = getAssetDescriptorIconTemplate(descriptor);++ return html`<div>+ ${(this.selectedAsset ?+ html`<div class="attribute-label attribute-label-white selected-asset-container" @click="${() => openDialog()}">+ <div class="selected-asset-icon">${myIcon}</div>+ <div class="selected-asset-label">+ <div class="asset">${this.selectedAsset.name}</div>+ <div class="asset-attribute">${selectedAttrLabel}</div>+ </div>+ </div>` :+ html`<or-mwc-input class="attribute-label-white" .type="${InputType.BUTTON}" label="${i18next.t("attribute")}" icon="plus" @click="${() => openDialog()}"></or-mwc-input>`+ )}+ </div>`;}private get colorInput(): TemplateResult {