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: Fix model references and styling

Rich Turnerd1db277f9246
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index bcebc1413..ff47c6f8d 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -69,5 +69,7 @@
"status": "Status",
"name": "Name",
"deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
- "confirmDeleteAssets": "Remove assets?"
+ "confirmDeleteAssets": "Remove assets?",
+ "ok": "ok",
+ "cancel": "cancel"
}
\ No newline at end of file
diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.json
index 81125edf6..0d66aba92 100644
--- a/deployment/manager/shared/locales/nl/or.json
+++ b/deployment/manager/shared/locales/nl/or.json
@@ -69,5 +69,7 @@
"status": "Status",
"name": "Naam",
"deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
- "confirmDeleteAssets": "Asset verwijderen?"
+ "confirmDeleteAssets": "Asset verwijderen?",
+ "ok": "ok",
+ "cancel": "cancel"
}
\ No newline at end of file
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 08caaad28..9b5672366 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -238,7 +238,7 @@ export class OrAssetTree extends LitElement {
<or-translate value="deleteAssetsNoChildrenAllowed"></or-translate>
</p>
<div class="modal-btns">
- <span class="btn" @click="${() => this._deleteNotAllowedModal.toggleAttribute("data-visible")}">OK</span>
+ <span class="btn" @click="${() => this._deleteNotAllowedModal.toggleAttribute("data-visible")}"><or-translate value="ok"></or-translate></span>
</div>
</div>
</div>
@@ -250,8 +250,8 @@ export class OrAssetTree extends LitElement {
<or-translate value="confirmDeleteAssets"></or-translate>
</p>
<div class="modal-btns">
- <span class="btn" @click="${() => this._deleteConfirmModal.toggleAttribute("data-visible")}">CANCEL</span>
- <span class="btn" @click="${() => this._doDelete()}">OK</span>
+ <span class="btn" @click="${() => this._deleteConfirmModal.toggleAttribute("data-visible")}"><or-translate value="cancel"></or-translate></span>
+ <span class="btn" @click="${() => this._doDelete()}"><or-translate value="ok"></or-translate></span>
</div>
</div>
</div>
diff --git a/ui/component/or-asset-tree/src/style.ts b/ui/component/or-asset-tree/src/style.ts
index f92851141..9c41df365 100644
--- a/ui/component/or-asset-tree/src/style.ts
+++ b/ui/component/or-asset-tree/src/style.ts
@@ -165,10 +165,11 @@ export const style = css`
.modal-btns .btn {
font-weight: bolder;
cursor: pointer;
+ text-transform: uppercase;
}
.modal-btns .btn + .btn {
- margin-left: 30px;
+ margin-left: 15px;
}
#sort-menu {
@@ -221,7 +222,7 @@ export const style = css`
.node-container {
display: flex;
flex-direction: row;
- border-left: 4px solid transparent;
+ border-left: 6px solid transparent;
user-select: none;
cursor: pointer;
height: var(--internal-or-asset-tree-item-height);
diff --git a/ui/component/or-header/src/style.ts b/ui/component/or-header/src/style.ts
index 7f4235752..02eeabe3d 100644
--- a/ui/component/or-header/src/style.ts
+++ b/ui/component/or-header/src/style.ts
@@ -7,7 +7,7 @@ export const style = css`
:host {
--internal-or-header-color: var(--or-header-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
--internal-or-header-selected-color: var(--or-header-selected-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
- --internal-or-header-text-color: var(--or-header-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));
+ --internal-or-header-text-color: var(--or-header-text-color, var(--or-app-color3, inherit));
--internal-or-header-height: var(--or-header-height, ${unsafeCSS(DefaultHeaderHeight)});
--internal-or-header-logo-margin: var(--or-header-logo-margin, 0);
--internal-or-header-logo-height: var(--or-header-logo-height, var(--internal-or-header-height, ${unsafeCSS(DefaultHeaderHeight)}));
diff --git a/ui/component/or-rules-editor/src/index.ts b/ui/component/or-rules-editor/src/index.ts
index dad373440..6f50d4e77 100644
--- a/ui/component/or-rules-editor/src/index.ts
+++ b/ui/component/or-rules-editor/src/index.ts
@@ -6,13 +6,13 @@ import {
AssetDescriptor,
AttributeDescriptor,
AttributeValueDescriptor,
- AssetQueryOperator,
+ AssetQueryOperator as AQO,
JsonRulesetDefinition,
LogicGroup,
MetaItemDescriptor,
MetaItemType,
- NewAssetQuery,
- Rule,
+ AssetQuery,
+ JsonRule,
RuleActionTarget,
RuleActionUnion,
RuleCondition,
@@ -115,11 +115,11 @@ export interface RulesConfig {
action?: RulesDescriptorSection;
};
templates?: {
- rule?: Rule;
+ rule?: JsonRule;
rulesetName?: string;
whenGroup?: LogicGroup<RuleCondition>;
whenCondition?: RuleCondition;
- whenAssetQuery?: NewAssetQuery;
+ whenAssetQuery?: AssetQuery;
then?: RuleActionUnion;
};
}
@@ -178,7 +178,7 @@ export function getDescriptorValueType(descriptor?: AttributeDescriptor) {
return descriptor.valueDescriptor.valueType;
}
-export function getAssetTypeFromQuery(query?: NewAssetQuery) {
+export function getAssetTypeFromQuery(query?: AssetQuery) {
return query && query.types && query.types.length > 0 && query.types[0] ? query.types[0].value : undefined;
}
@@ -346,7 +346,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
private isValidRule?: boolean;
private _activeRuleset?: TenantRuleset;
- private _activeRules?: Rule[];
+ private _activeRules?: JsonRule[];
private _activeModified: boolean = false;
private _whenAssetDescriptors?: AssetDescriptor[];
private _actionAssetDescriptors?: AssetDescriptor[];
@@ -384,7 +384,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
this.addEventListener("rules:delete-rule", this.deleteRuleset);
}
- protected ruleEditorPanelTemplate(rule: Rule) {
+ protected ruleEditorPanelTemplate(rule: JsonRule) {
const thenTemplate = this.config && this.config.templates && this.config.templates.then ? this.config.templates.then : undefined;
const targetTypeMap = this.getTargetTypeMap();
const whenDescriptors = this.getAssetDescriptors(false);
@@ -538,7 +538,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
return true;
}
- protected validateRuleActions(rule: Rule, actions?: RuleActionUnion[]): boolean {
+ protected validateRuleActions(rule: JsonRule, actions?: RuleActionUnion[]): boolean {
if (!actions) {
return true;
}
@@ -580,7 +580,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
return true;
}
- protected validateAssetTarget(rule: Rule, target?: RuleActionTarget): boolean {
+ protected validateAssetTarget(rule: JsonRule, target?: RuleActionTarget): boolean {
if (!target) {
return true;
}
@@ -601,7 +601,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
return true;
}
- protected validateAssetQuery(query?: NewAssetQuery): boolean {
+ protected validateAssetQuery(query?: AssetQuery): boolean {
if (!query) {
return true;
}
@@ -646,7 +646,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
return valuePredicate.predicates !== undefined && valuePredicate.predicates.length > 0 && valuePredicate.predicates.findIndex((p) => !p.match || p.value === undefined) === 0;
case "datetime":
case "number":
- return valuePredicate.operator !== undefined && valuePredicate.value !== undefined && (valuePredicate.operator !== AssetQueryOperator.BETWEEN || valuePredicate.rangeValue !== undefined);
+ return valuePredicate.operator !== undefined && valuePredicate.value !== undefined && (valuePredicate.operator !== AQO.BETWEEN || valuePredicate.rangeValue !== undefined);
case "radial":
return valuePredicate.radius !== undefined && valuePredicate.lat !== undefined && valuePredicate.lng !== undefined;
case "rect":
@@ -688,7 +688,7 @@ class OrRulesEditor extends translate(i18next)(LitElement) {
if (this._rulesets) {
- let rule = this.config && this.config.templates && this.config.templates.rule ? JSON.parse(JSON.stringify(this.config.templates.rule)) as Rule : undefined;
+ let rule = this.config && this.config.templates && this.config.templates.rule ? JSON.parse(JSON.stringify(this.config.templates.rule)) as JsonRule : undefined;
if (!rule) {
rule = {};
diff --git a/ui/component/or-rules-editor/src/or-rule-asset-query.ts b/ui/component/or-rules-editor/src/or-rule-asset-query.ts
index a7feb42d2..dd0b711cd 100644
--- a/ui/component/or-rules-editor/src/or-rule-asset-query.ts
+++ b/ui/component/or-rules-editor/src/or-rule-asset-query.ts
@@ -4,13 +4,13 @@ import {
AttributePredicate,
AttributeValueType,
AssetQueryMatch,
- AssetQueryOperator,
- NewAssetQuery,
+ AssetQueryOperator as AQO,
+ AssetQuery,
ValuePredicateUnion,
ValueType,
AttributeValueDescriptor,
AssetDescriptor,
- RuleOperator,
+ LogicGroupOperator,
LogicGroup
} from "@openremote/model";
import {
@@ -31,7 +31,7 @@ import i18next from "i18next";
class OrRuleAssetQuery extends LitElement {
@property({type: Object})
- public query?: NewAssetQuery;
+ public query?: AssetQuery;
public readonly?: boolean;
@@ -87,7 +87,7 @@ class OrRuleAssetQuery extends LitElement {
case "datetime":
return html `<span>NOT IMPLEMENTED</span>`;
case "number":
- if (valuePredicate.operator === AssetQueryOperator.BETWEEN) {
+ if (valuePredicate.operator === AQO.BETWEEN) {
return html`
<or-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.value ? valuePredicate.value : null}" ?readonly="${this.readonly}"></or-input>
<span style="display: inline-flex; align-items: center;">&</span>
@@ -157,7 +157,7 @@ class OrRuleAssetQuery extends LitElement {
return html`
<div class="attribute-item">
- <button @click="${() => this.toggleAttributeGroup(this.query!.attributes!)}" class="button-clear operator"><span>${i18next.t(!this.query!.attributes!.operator || this.query!.attributes!.operator === RuleOperator.AND ? "and" : "or")}</span></button>
+ <button @click="${() => this.toggleAttributeGroup(this.query!.attributes!)}" class="button-clear operator"><span>${i18next.t(!this.query!.attributes!.operator || this.query!.attributes!.operator === LogicGroupOperator.AND ? "and" : "or")}</span></button>
<div class="attribute">
${this.attributePredicateEditorTemplate(assetDescriptor, attributePredicate)}
${showRemoveAttribute ? html`
@@ -294,17 +294,17 @@ class OrRuleAssetQuery extends LitElement {
case "datetime":
case "number":
switch (valuePredicate.operator) {
- case AssetQueryOperator.EQUALS:
+ case AQO.EQUALS:
return valuePredicate.negate ? AssetQueryOperator.NOT_EQUALS : AssetQueryOperator.EQUALS;
- case AssetQueryOperator.GREATER_THAN:
+ case AQO.GREATER_THAN:
return valuePredicate.negate ? AssetQueryOperator.LESS_EQUALS : AssetQueryOperator.GREATER_THAN;
- case AssetQueryOperator.GREATER_EQUALS:
+ case AQO.GREATER_EQUALS:
return valuePredicate.negate ? AssetQueryOperator.LESS_THAN : AssetQueryOperator.GREATER_EQUALS;
- case AssetQueryOperator.LESS_THAN:
+ case AQO.LESS_THAN:
return valuePredicate.negate ? AssetQueryOperator.GREATER_EQUALS : AssetQueryOperator.LESS_THAN;
- case AssetQueryOperator.LESS_EQUALS:
+ case AQO.LESS_EQUALS:
return valuePredicate.negate ? AssetQueryOperator.GREATER_THAN : AssetQueryOperator.LESS_EQUALS;
- case AssetQueryOperator.BETWEEN:
+ case AQO.BETWEEN:
return valuePredicate.negate ? AssetQueryOperator.NOT_BETWEEN : AssetQueryOperator.BETWEEN;
}
return;
@@ -458,14 +458,14 @@ class OrRuleAssetQuery extends LitElement {
if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
- operator: AssetQueryOperator.BETWEEN,
+ operator: AQO.BETWEEN,
negate: true
};
} else {
// Assume datetime
predicate = {
predicateType: "datetime",
- operator: AssetQueryOperator.BETWEEN,
+ operator: AQO.BETWEEN,
negate: true
};
}
@@ -480,13 +480,13 @@ class OrRuleAssetQuery extends LitElement {
if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
- operator: key as AssetQueryOperator
+ operator: key as AQO
};
} else {
// Assume datetime
predicate = {
predicateType: "datetime",
- operator: key as AssetQueryOperator
+ operator: key as AQO
};
}
break;
@@ -498,13 +498,13 @@ class OrRuleAssetQuery extends LitElement {
predicate = {
predicateType: "datetime",
negate: value === AssetQueryOperator.NOT_EQUALS,
- operator: AssetQueryOperator.EQUALS
+ operator: AQO.EQUALS
};
} else if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
negate: value === AssetQueryOperator.NOT_EQUALS,
- operator: AssetQueryOperator.EQUALS
+ operator: AQO.EQUALS
};
} else if (valueType === ValueType.STRING) {
predicate = {
@@ -578,10 +578,10 @@ class OrRuleAssetQuery extends LitElement {
}
protected toggleAttributeGroup(group: LogicGroup<AttributePredicate>) {
- if (group.operator === RuleOperator.OR) {
- group.operator = RuleOperator.AND;
+ if (group.operator === LogicGroupOperator.OR) {
+ group.operator = LogicGroupOperator.AND;
} else {
- group.operator = RuleOperator.OR;
+ group.operator = LogicGroupOperator.OR;
}
this.dispatchEvent(new OrRuleChangedEvent());
this.requestUpdate();
diff --git a/ui/component/or-rules-editor/src/or-rule-header.ts b/ui/component/or-rules-editor/src/or-rule-header.ts
index 2eb71e223..ce25e273a 100644
--- a/ui/component/or-rules-editor/src/or-rule-header.ts
+++ b/ui/component/or-rules-editor/src/or-rule-header.ts
@@ -1,9 +1,9 @@
-import {html, LitElement, property, customElement} from "lit-element";
+import {customElement, html, LitElement, property} from "lit-element";
import "@openremote/or-translate";
import "@openremote/or-input";
import "@openremote/or-select";
import "@openremote/or-icon";
-import {TenantRuleset, Rule} from "@openremote/model";
+import {TenantRuleset} from "@openremote/model";
import {headerStyle} from "./style";
import {OrRuleChangedEvent} from "./index";
diff --git a/ui/component/or-rules-editor/src/or-rule-list.ts b/ui/component/or-rules-editor/src/or-rule-list.ts
index 0d70f19f7..19f56d629 100644
--- a/ui/component/or-rules-editor/src/or-rule-list.ts
+++ b/ui/component/or-rules-editor/src/or-rule-list.ts
@@ -1,5 +1,5 @@
import {html, LitElement, property} from "lit-element";
-import {TenantRuleset, Rule, RuleCondition} from "@openremote/model";
+import {TenantRuleset, JsonRule, RuleCondition} from "@openremote/model";
import {ruleListStyle} from "./style";
import moment from "moment";
@@ -47,7 +47,7 @@ class OrRulesList extends LitElement {
let status = ruleset.enabled ? "bg-green" : "bg-red";
if(ruleset.rules && ruleset.enabled) {
- const rule: Rule = JSON.parse(ruleset.rules).rules[0];
+ const rule: JsonRule = JSON.parse(ruleset.rules).rules[0];
// HACK/WIP: the status of a rule should be better thought over see issue #95
// currently only checks the date of the first whenCondition
diff --git a/ui/component/or-rules-editor/src/or-rule-when.ts b/ui/component/or-rules-editor/src/or-rule-when.ts
index c89daacf5..a135f9a15 100644
--- a/ui/component/or-rules-editor/src/or-rule-when.ts
+++ b/ui/component/or-rules-editor/src/or-rule-when.ts
@@ -1,5 +1,5 @@
import {customElement, html, LitElement, TemplateResult, property} from "lit-element";
-import {LogicGroup, Rule, RuleCondition, RuleOperator, AssetDescriptor} from "@openremote/model";
+import {LogicGroup, JsonRule, RuleCondition, AssetDescriptor, LogicGroupOperator} from "@openremote/model";
import {OrRuleChangedEvent, RulesConfig} from "./index";
import {whenStyle} from "./style";
import "./or-rule-condition";
@@ -13,7 +13,7 @@ class OrRuleWhen extends LitElement {
}
@property({type: Object})
- public rule?: Rule;
+ public rule?: JsonRule;
public readonly?: boolean;
@@ -21,7 +21,7 @@ class OrRuleWhen extends LitElement {
public assetDescriptors?: AssetDescriptor[];
- protected groupAddTemplate(parent: Rule | LogicGroup<RuleCondition>) {
+ protected groupAddTemplate(parent: JsonRule | LogicGroup<RuleCondition>) {
return html`<button class="button-clear add-button" @click="${() => this.addGroup(parent)}"><or-icon icon="plus-circle"></or-icon><or-translate value="rulesEditorAddGroup"></or-translate></button>`;
}
@@ -49,7 +49,7 @@ class OrRuleWhen extends LitElement {
${group.items && group.items.length > 0 ? group.items.map((condition: RuleCondition) => {
return html `
<div class="rule-group-item">
- <button @click="${() => this.toggleGroup(group)}" class="button-clear operator"><span>${i18next.t(!group.operator || group.operator === RuleOperator.AND ? "and" : "or")}</span></button>
+ <button @click="${() => this.toggleGroup(group)}" class="button-clear operator"><span>${i18next.t(!group.operator || group.operator === LogicGroupOperator.AND ? "and" : "or")}</span></button>
<div class="rule-condition">
<or-rule-condition .config="${this.config}" .assetDescriptors="${this.assetDescriptors}" .ruleCondition="${condition}" .readonly="${this.readonly}" ></or-rule-condition>
${showRemoveCondition ? html`
@@ -63,7 +63,7 @@ class OrRuleWhen extends LitElement {
${group.groups && group.groups.length > 0 ? html`
${group.groups.map((childGroup: LogicGroup<RuleCondition>) => html`
<div class="rule-group-item">
- <button @click="${() => this.toggleGroup(group)}" class="button-clear operator"><span>${i18next.t(!group.operator || group.operator === RuleOperator.AND ? "and" : "or")}</span></button>
+ <button @click="${() => this.toggleGroup(group)}" class="button-clear operator"><span>${i18next.t(!group.operator || group.operator === LogicGroupOperator.AND ? "and" : "or")}</span></button>
${this.ruleGroupTemplate(childGroup, group)}
</div>
`)}
@@ -93,16 +93,16 @@ class OrRuleWhen extends LitElement {
}
private toggleGroup(group: LogicGroup<RuleCondition>) {
- if (group.operator === RuleOperator.OR) {
- group.operator = RuleOperator.AND;
+ if (group.operator === LogicGroupOperator.OR) {
+ group.operator = LogicGroupOperator.AND;
} else {
- group.operator = RuleOperator.OR;
+ group.operator = LogicGroupOperator.OR;
}
this.dispatchEvent(new OrRuleChangedEvent());
this.requestUpdate();
}
- private addGroup(parent: Rule | LogicGroup<RuleCondition>) {
+ private addGroup(parent: JsonRule | LogicGroup<RuleCondition>) {
if (!parent) {
return;
}
@@ -113,8 +113,8 @@ class OrRuleWhen extends LitElement {
newGroup = JSON.parse(JSON.stringify(this.config.templates.whenGroup)) as LogicGroup<RuleCondition>;
}
- if ((parent as Rule).name !== undefined) {
- const rule = parent as Rule;
+ if ((parent as JsonRule).name !== undefined) {
+ const rule = parent as JsonRule;
rule.when = newGroup;
} else {
const condition = parent as LogicGroup<RuleCondition>;
diff --git a/ui/component/or-smart-notify/src/index.ts b/ui/component/or-smart-notify/src/index.ts
index 8eb49aaa5..08e7bc98b 100644
--- a/ui/component/or-smart-notify/src/index.ts
+++ b/ui/component/or-smart-notify/src/index.ts
@@ -7,7 +7,7 @@ import {faClock} from "@fortawesome/free-regular-svg-icons";
import {faTimes} from "@fortawesome/free-solid-svg-icons";
import REST from "@openremote/rest";
-import {AssetQuery, AssetQueryInclude} from "@openremote/model";
+import {AssetQuery} from "@openremote/model";
import openremote from "@openremote/core";
@customElement("or-smart-notify")
@@ -50,8 +50,17 @@ class OrSmartNotify extends LitElement {
const self: any = this;
return new Promise((resolve: any, reject: any) => {
const smartNotifyQuery: AssetQuery = {
- name: {predicateType: "string", value: "SMART_NOTIFY_ASSET"},
- select: {include: AssetQueryInclude.ALL_EXCEPT_PATH}
+ names: [{predicateType: "string", value: "SMART_NOTIFY_ASSET"}],
+ select: {
+ excludePath: true,
+ excludeAttributes: false,
+ excludeParentInfo: false,
+ excludeRealm: false,
+ excludeAttributeMeta: false,
+ excludeAttributeType: false,
+ excludeAttributeValue: false,
+ excludeAttributeTimestamp: false
+ }
};
REST.api.AssetResource.queryAssets(smartNotifyQuery).then((response: any) => {
console.log("Setting Smart Notify");