Skip to content
Permalink
Browse files

UI updates: Updated to latest model

  • Loading branch information...
richturner committed Sep 1, 2019
1 parent 0d6db5b commit 731a0592400b4ece9175ed8429bc5b4ccf00528b
@@ -6,7 +6,7 @@ import {
AssetDescriptor,
AttributeDescriptor,
AttributeValueDescriptor,
BaseAssetQueryOperator,
AssetQueryOperator,
JsonRulesetDefinition,
LogicGroup,
MetaItemDescriptor,
@@ -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 !== BaseAssetQueryOperator.BETWEEN || valuePredicate.rangeValue !== undefined);
return valuePredicate.operator !== undefined && valuePredicate.value !== undefined && (valuePredicate.operator !== AssetQueryOperator.BETWEEN || valuePredicate.rangeValue !== undefined);
case "radial":
return valuePredicate.radius !== undefined && valuePredicate.lat !== undefined && valuePredicate.lng !== undefined;
case "rect":
@@ -3,8 +3,8 @@ import {
AttributeDescriptor,
AttributePredicate,
AttributeValueType,
BaseAssetQueryMatch,
BaseAssetQueryOperator,
AssetQueryMatch,
AssetQueryOperator,
NewAssetQuery,
ValuePredicateUnion,
ValueType,
@@ -87,7 +87,7 @@ class OrRuleAssetQuery extends LitElement {
case "datetime":
return html `<span>NOT IMPLEMENTED</span>`;
case "number":
if (valuePredicate.operator === BaseAssetQueryOperator.BETWEEN) {
if (valuePredicate.operator === AssetQueryOperator.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>
@@ -200,7 +200,7 @@ class OrRuleAssetQuery extends LitElement {
};
}

attributePredicate!.name.match = BaseAssetQueryMatch.EXACT;
attributePredicate!.name.match = AssetQueryMatch.EXACT;
attributePredicate!.name.value = attributeName;
this.dispatchEvent(new OrRuleChangedEvent());
this.requestUpdate();
@@ -277,13 +277,13 @@ class OrRuleAssetQuery extends LitElement {
switch (valuePredicate.predicateType) {
case "string":
switch (valuePredicate.match) {
case BaseAssetQueryMatch.EXACT:
case AssetQueryMatch.EXACT:
return valuePredicate.negate ? AssetQueryOperator.NOT_EQUALS : AssetQueryOperator.EQUALS;
case BaseAssetQueryMatch.BEGIN:
case AssetQueryMatch.BEGIN:
return valuePredicate.negate ? AssetQueryOperator.NOT_STARTS_WITH : AssetQueryOperator.STARTS_WITH;
case BaseAssetQueryMatch.END:
case AssetQueryMatch.END:
return valuePredicate.negate ? AssetQueryOperator.NOT_ENDS_WITH : AssetQueryOperator.ENDS_WITH;
case BaseAssetQueryMatch.CONTAINS:
case AssetQueryMatch.CONTAINS:
return valuePredicate.negate ? AssetQueryOperator.NOT_CONTAINS : AssetQueryOperator.CONTAINS;
}
return;
@@ -294,17 +294,17 @@ class OrRuleAssetQuery extends LitElement {
case "datetime":
case "number":
switch (valuePredicate.operator) {
case BaseAssetQueryOperator.EQUALS:
case AssetQueryOperator.EQUALS:
return valuePredicate.negate ? AssetQueryOperator.NOT_EQUALS : AssetQueryOperator.EQUALS;
case BaseAssetQueryOperator.GREATER_THAN:
case AssetQueryOperator.GREATER_THAN:
return valuePredicate.negate ? AssetQueryOperator.LESS_EQUALS : AssetQueryOperator.GREATER_THAN;
case BaseAssetQueryOperator.GREATER_EQUALS:
case AssetQueryOperator.GREATER_EQUALS:
return valuePredicate.negate ? AssetQueryOperator.LESS_THAN : AssetQueryOperator.GREATER_EQUALS;
case BaseAssetQueryOperator.LESS_THAN:
case AssetQueryOperator.LESS_THAN:
return valuePredicate.negate ? AssetQueryOperator.GREATER_EQUALS : AssetQueryOperator.LESS_THAN;
case BaseAssetQueryOperator.LESS_EQUALS:
case AssetQueryOperator.LESS_EQUALS:
return valuePredicate.negate ? AssetQueryOperator.GREATER_THAN : AssetQueryOperator.LESS_EQUALS;
case BaseAssetQueryOperator.BETWEEN:
case AssetQueryOperator.BETWEEN:
return valuePredicate.negate ? AssetQueryOperator.NOT_BETWEEN : AssetQueryOperator.BETWEEN;
}
return;
@@ -438,7 +438,7 @@ class OrRuleAssetQuery extends LitElement {
predicate = {
predicateType: "string",
negate: value === AssetQueryOperator.NOT_STARTS_WITH,
match: BaseAssetQueryMatch.BEGIN
match: AssetQueryMatch.BEGIN
};
}
break;
@@ -448,7 +448,7 @@ class OrRuleAssetQuery extends LitElement {
predicate = {
predicateType: "string",
negate: value === AssetQueryOperator.NOT_ENDS_WITH,
match: BaseAssetQueryMatch.END
match: AssetQueryMatch.END
};
}
break;
@@ -458,14 +458,14 @@ class OrRuleAssetQuery extends LitElement {
if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
operator: BaseAssetQueryOperator.BETWEEN,
operator: AssetQueryOperator.BETWEEN,
negate: true
};
} else {
// Assume datetime
predicate = {
predicateType: "datetime",
operator: BaseAssetQueryOperator.BETWEEN,
operator: AssetQueryOperator.BETWEEN,
negate: true
};
}
@@ -480,13 +480,13 @@ class OrRuleAssetQuery extends LitElement {
if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
operator: key as BaseAssetQueryOperator
operator: key as AssetQueryOperator
};
} else {
// Assume datetime
predicate = {
predicateType: "datetime",
operator: key as BaseAssetQueryOperator
operator: key as AssetQueryOperator
};
}
break;
@@ -498,19 +498,19 @@ class OrRuleAssetQuery extends LitElement {
predicate = {
predicateType: "datetime",
negate: value === AssetQueryOperator.NOT_EQUALS,
operator: BaseAssetQueryOperator.EQUALS
operator: AssetQueryOperator.EQUALS
};
} else if (valueType === ValueType.NUMBER) {
predicate = {
predicateType: "number",
negate: value === AssetQueryOperator.NOT_EQUALS,
operator: BaseAssetQueryOperator.EQUALS
operator: AssetQueryOperator.EQUALS
};
} else if (valueType === ValueType.STRING) {
predicate = {
predicateType: "string",
negate: value === AssetQueryOperator.NOT_EQUALS,
match: BaseAssetQueryMatch.EXACT
match: AssetQueryMatch.EXACT
};
}
break;
@@ -535,7 +535,7 @@ class OrRuleAssetQuery extends LitElement {
predicate = {
predicateType: "string",
negate: value === AssetQueryOperator.NOT_CONTAINS,
match: BaseAssetQueryMatch.CONTAINS
match: AssetQueryMatch.CONTAINS
};
}
}
@@ -1,6 +1,6 @@
import {customElement, html, LitElement, TemplateResult, property} from "lit-element";
import {
BaseAssetQueryMatch,
AssetQueryMatch,
RuleCondition,
AssetDescriptor,
} from "@openremote/model";
@@ -163,7 +163,7 @@ class OrRuleCondition extends LitElement {
if (!this.ruleCondition!.assets!.types || this.ruleCondition!.assets!.types.length === 0) {
this.ruleCondition!.assets!.types = [{
predicateType: "string",
match: BaseAssetQueryMatch.EXACT
match: AssetQueryMatch.EXACT
}];
}

@@ -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, BaseAssetQueryInclude} from "@openremote/model";
import {AssetQuery, AssetQueryInclude} from "@openremote/model";
import openremote from "@openremote/core";

@customElement("or-smart-notify")
@@ -51,7 +51,7 @@ class OrSmartNotify extends LitElement {
return new Promise((resolve: any, reject: any) => {
const smartNotifyQuery: AssetQuery = {
name: {predicateType: "string", value: "SMART_NOTIFY_ASSET"},
select: {include: BaseAssetQueryInclude.ALL_EXCEPT_PATH}
select: {include: AssetQueryInclude.ALL_EXCEPT_PATH}
};
REST.api.AssetResource.queryAssets(smartNotifyQuery).then((response: any) => {
console.log("Setting Smart Notify");
@@ -1,20 +1,20 @@
import {Asset, AssetQuery, BaseAssetQueryMatch, BaseAssetQueryInclude} from "@openremote/model";
import {Asset, AssetQuery, AssetQueryMatch, AssetQueryInclude} from "@openremote/model";
import rest from "@openremote/rest";

export async function getApartment1Asset(): Promise<Asset | undefined> {
const query: AssetQuery = {
name: {
predicateType: "string",
match: BaseAssetQueryMatch.EXACT,
match: AssetQueryMatch.EXACT,
value: "Apartment 1"
},
type: {
predicateType: "string",
match: BaseAssetQueryMatch.EXACT,
match: AssetQueryMatch.EXACT,
value: "urn:openremote:asset:residence"
},
select: {
include: BaseAssetQueryInclude.ONLY_ID_AND_NAME
include: AssetQueryInclude.ONLY_ID_AND_NAME
}
};

@@ -5,8 +5,8 @@ import "@openremote/or-thermostat";
import {
AssetQuery,
AttributeEvent,
BaseAssetQueryInclude,
BaseAssetQueryMatch,
AssetQueryInclude,
AssetQueryMatch,
EventSubscription,
Asset
} from "@openremote/model";
@@ -17,19 +17,19 @@ async function initApartment1Asset(): Promise<string|undefined> {
let query: AssetQuery = {
name: {
predicateType: "string",
match: BaseAssetQueryMatch.EXACT,
match: AssetQueryMatch.EXACT,
value: "Living Room"
},
parent: {
name: "Apartment 1"
},
type: {
predicateType: "string",
match: BaseAssetQueryMatch.EXACT,
match: AssetQueryMatch.EXACT,
value: "urn:openremote:asset:room"
},
select: {
include: BaseAssetQueryInclude.ONLY_ID_AND_NAME
include: AssetQueryInclude.ONLY_ID_AND_NAME
}
};

0 comments on commit 731a059

Please sign in to comment.
You can’t perform that action at this time.