Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI updates: Various bug fixes see #201, #202, #203, #204, #205, #207

Rich Turneraa57a799b960
diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
index 3c888147e..8162389c2 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
@@ -671,9 +671,9 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(RULE_STATE, Values.create(true)),
new MetaItem(STORE_DATA_POINTS)
).addMeta(agentLinker.get()),
- new AssetAttribute("ozon", NUMBER)
+ new AssetAttribute("ozone", NUMBER)
.setMeta(
- new MetaItem(LABEL, Values.create("Ozon Level")),
+ new MetaItem(LABEL, Values.create("Ozone Level")),
new MetaItem(DESCRIPTION, Values.create("µg/m3")),
new MetaItem(READ_ONLY, Values.create(true)),
new MetaItem(RULE_STATE, Values.create(true)),
diff --git a/model/src/main/java/org/openremote/model/asset/AssetType.java b/model/src/main/java/org/openremote/model/asset/AssetType.java
index 4c4261976..756376131 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetType.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetType.java
@@ -124,8 +124,8 @@ public enum AssetType implements AssetDescriptor {
RULE_STATE,
STORE_DATA_POINTS
),
- new AttributeDescriptorImpl("ozon", NUMBER, Values.create(0),
- LABEL.withInitialValue(Values.create("Ozon Level")),
+ new AttributeDescriptorImpl("ozone", NUMBER, Values.create(0),
+ LABEL.withInitialValue(Values.create("Ozone Level")),
DESCRIPTION.withInitialValue(Values.create("µg/m3")),
READ_ONLY,
RULE_STATE,
@@ -155,34 +155,29 @@ public enum AssetType implements AssetDescriptor {
new AttributeDescriptorImpl("lightStatus", BOOLEAN, Values.create(false),
LABEL.withInitialValue(Values.create("Light status")),
DESCRIPTION.withInitialValue(Values.create("Indicates if the light is on or off")),
- READ_ONLY,
RULE_STATE,
STORE_DATA_POINTS
),
new AttributeDescriptorImpl("lightDimLevel", PERCENTAGE, Values.create(0),
LABEL.withInitialValue(Values.create("Light Dim Level")),
DESCRIPTION.withInitialValue(Values.create("The level of dimming of the light")),
- READ_ONLY,
RULE_STATE,
STORE_DATA_POINTS
),
new AttributeDescriptorImpl("colorGBW", OBJECT, Values.createObject(),
LABEL.withInitialValue(Values.create("Color RGBW")),
DESCRIPTION.withInitialValue(Values.create("The RGBW color of the light")),
- READ_ONLY,
RULE_STATE,
STORE_DATA_POINTS
),
new AttributeDescriptorImpl("groupNumber", NUMBER, null,
LABEL.withInitialValue(Values.create("Group number")),
DESCRIPTION.withInitialValue(Values.create("Which group this light belongs to")),
- READ_ONLY,
RULE_STATE
),
new AttributeDescriptorImpl("Scenario", NUMBER, Values.create(0),
LABEL.withInitialValue(Values.create("Scenario")),
DESCRIPTION.withInitialValue(Values.create("The scenario the light are setup to")),
- READ_ONLY,
RULE_STATE
)
),
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 570774e71..3916612a1 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -71,7 +71,7 @@ export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (
}
</style>
<or-map class="or-map" @or-map-clicked="${(ev: OrMapClickedEvent) => clickHandler(ev.detail)}" .center="${center}">
- <or-map-marker active .lng="${pos ? pos.lng : undefined}" .lat="${pos ? pos.lat : undefined}" .icon="${iconAndColor ? iconAndColor.icon : undefined}" .color="${iconAndColor ? iconAndColor.color : undefined}"></or-map-marker>
+ <or-map-marker active .lng="${pos ? pos.lng : undefined}" .lat="${pos ? pos.lat : undefined}" .icon="${iconAndColor ? iconAndColor.icon : undefined}" .activeColor="${iconAndColor ? "#" + iconAndColor.color : undefined}" .color="${iconAndColor ? "#" + iconAndColor.color : undefined}"></or-map-marker>
</or-map>
`;
}
@@ -118,6 +118,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
/* Copy of mdc text field helper text styles */
#helper-text {
+ min-width: 255px;
margin-top: 3px;
color: rgba(0, 0, 0, 0.6);
font-family: Roboto, sans-serif;
@@ -541,7 +542,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
}
this._valueFormat = Util.getAttributeValueFormat(this.attribute, this._attributeDescriptor, this._attributeValueDescriptor);
- this._showButton = !this.disableButton && this.inputTypeSupportsButton() && !!this._getAttributeRef();
+ this._showButton = !this._readonly && !this._disabled && !this.disableButton && this.inputTypeSupportsButton() && !!this._getAttributeRef();
}
}
@@ -575,7 +576,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
.helperText="${helperText}" .helperPersistent="${true}"
@keyup="${(e: KeyboardEvent) => {
if (e.code === "Enter" && this._inputType !== InputType.JSON && this._inputType !== InputType.TEXTAREA) {
- this._updateValue(this._attrInput.value)
+ this._updateValue(this._attrInput.value);
}
}}" @or-input-changed="${(e: OrInputChangedEvent) => {
e.stopPropagation();
@@ -609,7 +610,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
}
return html`
- <div id="wrapper" class="${this._showButton ? "" : "right-padding"}">
+ <div id="wrapper" class="${this._showButton || this.disableButton ? "no-padding" : "right-padding"}">
${content}
${loading
? html`<div id="scrim"><progress class="pure-material-progress-circular"></progress></div>`
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index e85c006d4..e6f442913 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -7,13 +7,14 @@ import {MDCRipple} from "@material/ripple";
import {MDCCheckbox} from "@material/checkbox";
import {MDCSwitch} from "@material/switch";
import {MDCSlider} from "@material/slider";
-import {MDCSelect, MDCSelectEvent } from "@material/select";
+import {MDCSelect, MDCSelectEvent} from "@material/select";
import {MDCList, MDCListActionEvent} from "@material/list";
import {MDCFormField, MDCFormFieldInput} from "@material/form-field";
import {MDCIconButtonToggle, MDCIconButtonToggleEventDetail} from "@material/icon-button";
import {DefaultColor4, DefaultColor8, Util} from "@openremote/core";
import i18next from "i18next";
+import moment from "moment";
// TODO: Add webpack/rollup to build so consumers aren't forced to use the same tooling
const buttonStyle = require("!!raw-loader!@material/button/dist/mdc.button.css");
@@ -195,6 +196,11 @@ const style = css`
color: var(--internal-or-input-color);
}
+ /* Give slider min width like select etc. */
+ .mdc-slider {
+ min-width: 200px;
+ }
+
#field {
height: 100%;
}
@@ -474,8 +480,8 @@ export class OrInput extends LitElement {
${hasHelper ? html`
<p id="component-helper-text" class="mdc-select-helper-text ${classMap(helperClasses)}" aria-hidden="true">
${showValidationMessage ? this.validationMessage : this.helperText}
- </p>` : ``}
</div>
+ </p>` : ``}
`;
case InputType.BUTTON_TOGGLE:
return html`
@@ -597,9 +603,11 @@ export class OrInput extends LitElement {
const offset = (new Date()).getTimezoneOffset() * 60000;
val = new Date(val - offset);
}
- if (val) {
- val = formatter(val, format);
+ if (val instanceof Date) {
+ val = moment(val).format(format);
}
+ } else if (val) {
+ val = formatter(val, format);
}
valMinMax[i] = val;
});
@@ -611,7 +619,9 @@ export class OrInput extends LitElement {
return html`
<div id="component" class="mdc-slider mdc-slider--discrete" tabindex="0" role="slider"
aria-valuemin="${ifDefined(valMinMax[1])}" aria-valuemax="${ifDefined(valMinMax[2])}"
- aria-valuenow="${ifDefined(valMinMax[0])}" aria-label="${ifDefined(this.label)}">
+ aria-valuenow="${ifDefined(valMinMax[0])}" aria-label="${ifDefined(this.label)}"
+ ?aria-disabled="${this.readonly || this.disabled}"
+ @MDCSlider:change="${() => this.onValueChange(undefined, (this._mdcComponent as MDCSlider).value)}">
<div class="mdc-slider__track-container">
<div class="mdc-slider__track"></div>
</div>
@@ -749,8 +759,17 @@ export class OrInput extends LitElement {
break;
}
}
- } else if (this.type === InputType.SELECT && this._mdcComponent) {
- (this._mdcComponent as MDCSelect).selectedIndex = this._selectedIndex;
+ } else {
+ if (this.type === InputType.SELECT && this._mdcComponent) {
+ (this._mdcComponent as MDCSelect).selectedIndex = this._selectedIndex;
+ }
+ if (this.type === InputType.RANGE && this._mdcComponent) {
+ const slider = this._mdcComponent as MDCSlider;
+ slider.disabled = this.disabled;
+ slider.min = this.min;
+ slider.max = this.max;
+ slider.value = this.value;
+ }
}
if (!this.type && this.value) {
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-condition.ts b/ui/component/or-rules/src/json-viewer/or-rule-condition.ts
index fbe547247..9e863f64f 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-condition.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-condition.ts
@@ -1,23 +1,16 @@
-import {customElement, html, css, LitElement, property, TemplateResult, query, PropertyValues} from "lit-element";
-import {AssetDescriptor, AssetQueryMatch, RuleCondition, AssetType} from "@openremote/model";
-import {
- ActionType,
- ConditionType,
- getAssetTypeFromQuery,
- RulesConfig
-} from "../index";
+import {css, customElement, html, LitElement, property, query, TemplateResult} from "lit-element";
+import {AssetDescriptor, AssetQueryMatch, AssetType, RuleCondition} from "@openremote/model";
+import {ConditionType, getAssetTypeFromQuery, RulesConfig} from "../index";
import "./or-rule-asset-query";
import "@openremote/or-mwc-components/dist/or-mwc-menu";
-import {MenuItem} from "@openremote/or-mwc-components/dist/or-mwc-menu";
+import {getContentWithMenuTemplate, MenuItem} from "@openremote/or-mwc-components/dist/or-mwc-menu";
import "@openremote/or-icon";
import "@openremote/or-translate";
-import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";
import {InputType} from "@openremote/or-input";
import {AssetModelUtil} from "@openremote/core";
import {i18next, translate} from "@openremote/or-translate";
import {OrRulesJsonRuleChangedEvent} from "./or-rule-json-viewer";
-import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/dist/or-mwc-menu";
-import { OrRuleAssetQuery } from "./or-rule-asset-query";
+import {OrRuleAssetQuery} from "./or-rule-asset-query";
const TIMER_COLOR = "4b87ea";
const DATE_TIME_COLOR = "6AEAA4";
@@ -164,7 +157,7 @@ class OrRuleCondition extends translate(i18next)(LitElement) {
`;
} else {
typeTemplate = html`
- <div id="type" style="color: #${buttonColor}">
+ <div id="type" style="--or-input-color: #${buttonColor}">
${getContentWithMenuTemplate(
html`<or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>`,
getWhenTypesMenu(this.config, this.assetDescriptors),
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
index bac575b40..1298ed96b 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
@@ -232,7 +232,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
`;
} else {
recurrenceTemplate = html`
- <div style="color: #${buttonColor}; margin-right: 6px;">
+ <div style="--or-input-color: #${buttonColor}; margin-right: 6px;">
${getContentWithMenuTemplate(
html`<or-input .type="${InputType.BUTTON}" .label="${i18next.t(value)}"></or-input>`,
getRecurrenceMenu(this.config),
@@ -296,7 +296,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
`;
} else {
typeTemplate = html`
- <div id="type" style="color: #${buttonColor}">
+ <div id="type" style="--or-input-color: #${buttonColor}">
${getContentWithMenuTemplate(
html`<or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>`,
getActionTypesMenu(this.config, this.assetDescriptors),
diff --git a/ui/component/or-rules/src/or-rule-viewer.ts b/ui/component/or-rules/src/or-rule-viewer.ts
index 45079aec3..6d0dc163c 100644
--- a/ui/component/or-rules/src/or-rule-viewer.ts
+++ b/ui/component/or-rules/src/or-rule-viewer.ts
@@ -172,7 +172,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {
<or-input .type="${InputType.SWITCH}" .value="${this.ruleset && this.ruleset.enabled}" ?disabled="${!this.ruleset.id}" @or-input-changed="${this._toggleEnabled}"></or-input>
</span>
- <or-input .type="${InputType.BUTTON}" id="save-btn" .label="${i18next.t("save")}" raised ?disabled="${this._cannotSave()}" @click="${this._doSave}" @or-input-changed="${this._doSave}"></or-input>
+ <or-input .type="${InputType.BUTTON}" id="save-btn" .label="${i18next.t("save")}" raised ?disabled="${this._cannotSave()}" @or-input-changed="${this._doSave}"></or-input>
</div>
</div>
@@ -283,4 +283,4 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {
this.requestUpdate();
}
}
-}
\ No newline at end of file
+}