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 updates: JSON forms updates
Rich Turnerd73e9bae7fbb
diff --git a/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java b/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.javaindex 9e5dea041..c84a30bb2 100644--- a/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java+++ b/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java@@ -41,7 +41,7 @@ public class SimulatorReplayDatapoint implements Serializable {}public Optional<Long> getTimestamp() {- return Optional.ofNullable(timestamp);+ return Optional.of(timestamp);}public Optional<Object> getValue() {diff --git a/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java b/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.javaindex e32222cd6..a9e5681b9 100644--- a/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java+++ b/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java@@ -98,7 +98,7 @@ public class JSONSchemaUtil {typesNode = arrNode;}- return wrapped ? ValueUtil.JSON.createObjectNode().set("types", typesNode) : typesNode;+ return wrapped ? ValueUtil.JSON.createObjectNode().set("type", typesNode) : typesNode;}public static JsonSchemaConfig getJsonSchemaConfig() {@@ -116,7 +116,7 @@ public class JSONSchemaUtil {false,Collections.emptySet(),new HashMap<Class<?>, Class<?>>(){{- put(Object.class, PatternPropertiesSimpleKeyAnyType.class);+ put(Object.class, AnyType.class);put(ObjectNode.class, PatternPropertiesSimpleKeyAnyType.class);}},new HashMap<String, Supplier<JsonNode>>() {{diff --git a/ui/component/or-attribute-input/package.json b/ui/component/or-attribute-input/package.jsonindex 9ec2d2e42..d67b9bd81 100644--- a/ui/component/or-attribute-input/package.json+++ b/ui/component/or-attribute-input/package.json@@ -14,6 +14,7 @@"dependencies": {"@openremote/core": "^1.0.3","@openremote/or-mwc-components": "^1.0.3",+ "@openremote/or-components": "^1.0.3","@openremote/or-map": "^1.0.4","@openremote/or-translate": "^1.0.3","@openremote/or-json-forms": "^1.0.3",diff --git a/ui/component/or-attribute-input/src/agent-link-json-forms-renderer.ts b/ui/component/or-attribute-input/src/agent-link-json-forms-renderer.tsindex 84820db6b..952d58996 100644--- a/ui/component/or-attribute-input/src/agent-link-json-forms-renderer.ts+++ b/ui/component/or-attribute-input/src/agent-link-json-forms-renderer.ts@@ -16,7 +16,7 @@ import { html } from "lit";import "@openremote/or-mwc-components/or-mwc-input";import { i18next } from "@openremote/or-translate";import { until } from "lit/directives/until";-+import { showOkCancelDialog } from "@openremote/or-mwc-components/or-mwc-dialog";/*** This function creates a short lived cache for loading the list of agents; this is useful when multiple instances@@ -85,17 +85,25 @@ const agentIdRenderer = (state: JsonFormsStateContext, props: ControlProps) => {};const onAgentChanged = (agent: Agent | undefined) => {- props.handleChange(props.path, agent ? agent.id : undefined);+ if (!!props.data) {+ showOkCancelDialog(i18next.t("loseChanges"), i18next.t("confirmContinueAssetModified"), i18next.t("discard"))+ .then((ok) => {+ if (ok) {+ props.handleChange(props.path, agent ? agent.id : undefined);+ }+ });+ } else {+ props.handleChange(props.path, agent ? agent.id : undefined);+ }return;};const loadedTemplatePromise = loadAgents().then(agents => {const options: [string, string][] = agents.map(agent => [agent.id!, agent.name + " (" + agent.id + ")"]);- const readonly = !!props.data;return html`- <or-mwc-input .readonly="${readonly}" .label="${i18next.t("agentId")}" required class="agent-id-picker" @or-mwc-input-changed="${(ev: OrInputChangedEvent) => onAgentChanged(agents.find((agent) => agent.id === ev.detail.value))}" type="${InputType.SELECT}" .value="${props.data}" .placeholder="${i18next.t("selectAgent")}" .options="${options}"></or-mwc-input>+ <or-mwc-input .label="${i18next.t("agentId")}" required class="agent-id-picker" @or-mwc-input-changed="${(ev: OrInputChangedEvent) => onAgentChanged(agents.find((agent) => agent.id === ev.detail.value))}" type="${InputType.SELECT}" .value="${props.data}" .placeholder="${i18next.t("selectAgent")}" .options="${options}"></or-mwc-input>`;});@@ -110,15 +118,7 @@ const agentIdRenderer = (state: JsonFormsStateContext, props: ControlProps) => {${until(loadedTemplatePromise, html`<or-mwc-input class="agent-id-picker" .type="${InputType.SELECT}"></or-mwc-input>`)}`;- let deleteHandler: undefined | (() => void);- if (!props.required && props.path) {- const { handleChange } = mapDispatchToControlProps(state.dispatch);- deleteHandler = () => {- handleChange(props.path, undefined);- }- }-- return getTemplateWrapper(template, deleteHandler);+ return getTemplateWrapper(template, undefined);};export const agentIdRendererRegistryEntry: JsonFormsRendererRegistryEntry = {diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex e6fac25a1..3c0bcd5d3 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -19,6 +19,8 @@ import {} from "@openremote/model";import manager, {AssetModelUtil, DefaultColor4, subscribe, Util} from "@openremote/core";import "@openremote/or-mwc-components/or-mwc-input";+import "@openremote/or-components/or-loading-wrapper";+import {OrLoadingWrapper} from "@openremote/or-components/src/or-loading-wrapper";import {getValueHolderInputTemplateProvider,InputType,@@ -123,114 +125,109 @@ export const jsonFormsInputTemplateProvider: (fallback: ValueInputProvider) => V// Agent link needs some special handling as we need an agent picker no matter whatif (valueDescriptor.name === WellknownValueTypes.AGENTLINK) {- const templateFunction: ValueInputTemplateFunction = (value, focused, loading, sending, error, helperText) => {- const jsonForms: Ref<OrJSONForms> = createRef();- const containerDiv: Ref<HTMLDivElement> = createRef();- let agentLink: AgentLink | undefined = value as AgentLink;- let loadedAgents: Agent[] = [];- const successDeferred: Util.Deferred<Agent | undefined> = new Util.Deferred();- const errorDeferred: Util.Deferred<ErrorMessage> = new Util.Deferred();- const schemaTemplatePromise: PromiseLike<TemplateResult> = successDeferred.promise.then((agent) => {-- const onAgentLinkChanged = (dataAndErrors: {errors: ErrorObject[] | undefined, data: any}) => {- let newAgentLink: AgentLink | undefined = dataAndErrors.data;-- if (newAgentLink && !newAgentLink.id) {- newAgentLink = undefined;- }-- if (newAgentLink) {- const agent = loadedAgents.find((agnt) => agnt.id === newAgentLink!.id);- if (!agent) {- newAgentLink = undefined;- } else {- const newAgentDescriptor = AssetModelUtil.getAssetDescriptor(agent.type) as AgentDescriptor;- if (!newAgentDescriptor) {- newAgentLink = undefined;- } else {- newAgentLink.type = newAgentDescriptor.agentLinkType!;- }- }- }+ // Apply a custom UI schema to remove the outer VerticalLayout+ const uiSchema: any = {type: "Control", scope: "#"};+ let schema: any;+ const jsonForms: Ref<OrJSONForms> = createRef();+ const loadingWrapper: Ref<OrLoadingWrapper> = createRef();+ let loadedAgents: Agent[] = [];+ let initialised = false;+ let agentLink: AgentLink | undefined;++ const onAgentLinkChanged = (dataAndErrors: {errors: ErrorObject[] | undefined, data: any}) => {+ if (!initialised) {+ return;+ }- valueChangeNotifier({- value: newAgentLink- });- };+ const newAgentLink: AgentLink | undefined = dataAndErrors.data;- // Apply a custom UI schema to remove the outer VerticalLayout- const uiSchema: any = {type: "Control", scope: "#"};+ if (newAgentLink) {+ const agent = loadedAgents.find((agnt) => agnt.id === newAgentLink!.id);+ if (agent) {+ const newAgentDescriptor = AssetModelUtil.getAssetDescriptor(agent.type) as AgentDescriptor;+ if (newAgentDescriptor) {+ newAgentLink.type = newAgentDescriptor.agentLinkType!;+ }+ }+ }- const config: any = {- hideAnyOfPicker: false- };+ if (!Util.objectsEqual(newAgentLink, agentLink)) {+ agentLink = newAgentLink;+ valueChangeNotifier({+ value: newAgentLink+ });+ }+ };- // TODO: Load agent link schema from AssetModelUtil- const schema = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Agent Link\",\"oneOf\":[{\"$ref\":\"#/definitions/SNMPAgentLink\"},{\"$ref\":\"#/definitions/DefaultAgentLink\"},{\"$ref\":\"#/definitions/HTTPAgentLink\"},{\"$ref\":\"#/definitions/MockAgentLink\"},{\"$ref\":\"#/definitions/WebsocketAgentLink\"},{\"$ref\":\"#/definitions/KNXAgentLink\"},{\"$ref\":\"#/definitions/ZWaveAgentLink\"},{\"$ref\":\"#/definitions/SimulatorAgentLink\"},{\"$ref\":\"#/definitions/VelbusAgentLink\"}],\"definitions\":{\"SNMPAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"SNMPAgentLink\"],\"default\":\"SNMPAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"oid\":{\"type\":\"string\"}},\"title\":\"SNMPAgentLink\",\"required\":[\"type\",\"oid\"]},\"regex\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"regex\"],\"default\":\"regex\"},\"pattern\":{\"type\":\"string\"},\"matchGroup\":{\"type\":\"integer\"},\"matchIndex\":{\"type\":\"integer\"}},\"title\":\"regex\",\"required\":[\"type\"]},\"substring\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"substring\"],\"default\":\"substring\"},\"beginIndex\":{\"type\":\"integer\"},\"endIndex\":{\"type\":\"integer\"}},\"title\":\"substring\",\"required\":[\"type\",\"beginIndex\"]},\"jsonPath\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"jsonPath\"],\"default\":\"jsonPath\"},\"path\":{\"type\":\"string\"},\"returnFirst\":{\"type\":\"boolean\"},\"returnLast\":{\"type\":\"boolean\"}},\"title\":\"jsonPath\",\"required\":[\"type\",\"path\",\"returnFirst\",\"returnLast\"]},\"PatternPropertiesSimpleKeyAnyType\":{\"type\":\"object\",\"additionalProperties\":true,\"patternProperties\":{\"^[a-zA-Z][a-zA-Z0-9]*\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}},\"properties\":{}},\"StringPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"string\"],\"default\":\"string\"},\"match\":{\"type\":\"string\",\"enum\":[\"EXACT\",\"BEGIN\",\"END\",\"CONTAINS\"]},\"caseSensitive\":{\"type\":\"boolean\"},\"value\":{\"type\":\"string\"},\"negate\":{\"type\":\"boolean\"}},\"title\":\"string\",\"required\":[\"predicateType\",\"caseSensitive\",\"negate\"]},\"BooleanPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"boolean\"],\"default\":\"boolean\"},\"value\":{\"type\":\"boolean\"}},\"title\":\"boolean\",\"required\":[\"predicateType\",\"value\"]},\"DateTimePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"datetime\"],\"default\":\"datetime\"},\"value\":{\"type\":\"string\"},\"rangeValue\":{\"type\":\"string\"},\"operator\":{\"type\":\"string\",\"enum\":[\"EQUALS\",\"GREATER_THAN\",\"GREATER_EQUALS\",\"LESS_THAN\",\"LESS_EQUALS\",\"BETWEEN\"]},\"negate\":{\"type\":\"boolean\"}},\"title\":\"datetime\",\"required\":[\"predicateType\",\"negate\"]},\"NumberPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"number\"],\"default\":\"number\"},\"value\":{\"type\":\"number\"},\"rangeValue\":{\"type\":\"number\"},\"operator\":{\"type\":\"string\",\"enum\":[\"EQUALS\",\"GREATER_THAN\",\"GREATER_EQUALS\",\"LESS_THAN\",\"LESS_EQUALS\",\"BETWEEN\"]},\"negate\":{\"type\":\"boolean\"}},\"title\":\"number\",\"required\":[\"predicateType\",\"negate\"]},\"RadialGeofencePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"radial\"],\"default\":\"radial\"},\"radius\":{\"type\":\"integer\"},\"lat\":{\"type\":\"number\"},\"lng\":{\"type\":\"number\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"radial\",\"required\":[\"predicateType\",\"radius\",\"lat\",\"lng\",\"negated\"]},\"RectangularGeofencePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"rect\"],\"default\":\"rect\"},\"latMin\":{\"type\":\"number\"},\"lngMin\":{\"type\":\"number\"},\"latMax\":{\"type\":\"number\"},\"lngMax\":{\"type\":\"number\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"rect\",\"required\":[\"predicateType\",\"latMin\",\"lngMin\",\"latMax\",\"lngMax\",\"negated\"]},\"ArrayPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"array\"],\"default\":\"array\"},\"value\":{\"$ref\":\"#/definitions/PatternPropertiesSimpleKeyAnyType\"},\"index\":{\"type\":\"integer\"},\"lengthEquals\":{\"type\":\"integer\"},\"lengthGreaterThan\":{\"type\":\"integer\"},\"lengthLessThan\":{\"type\":\"integer\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"array\",\"required\":[\"predicateType\",\"negated\"]},\"ValueEmptyPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"value-empty\"],\"default\":\"value-empty\"}},\"title\":\"value-empty\",\"required\":[\"predicateType\"]},\"ValueNotEmptyPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"value-not-empty\"],\"default\":\"value-not-empty\"}},\"title\":\"value-not-empty\",\"required\":[\"predicateType\"]},\"CalendarEventPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"calendar-event\"],\"default\":\"calendar-event\"},\"timestamp\":{\"type\":\"integer\",\"format\":\"utc-millisec\"}},\"title\":\"calendar-event\",\"required\":[\"predicateType\"]},\"DefaultAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"DefaultAgentLink\"],\"default\":\"DefaultAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"}},\"title\":\"DefaultAgentLink\",\"required\":[\"type\"]},\"HTTPAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"HTTPAgentLink\"],\"default\":\"HTTPAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"description\":\"A JSON object of headers to be added to HTTP request; the key represents the name of the header and for each string value supplied a new header will be added with the key name and specified string value\"},\"queryParameters\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"description\":\"A JSON object of query parameters to be added to HTTP request URL; the key represents the name of the query parameter and for each string value supplied a new query parameter will be added with the key name and specified string value (e.g. 'https://..../?test=1&test2\"},\"pollingMillis\":{\"type\":\"integer\",\"description\":\"Indicates that this HTTP request is used to update the linked attribute; this value indicates how frequently the HTTP request is made in order to update the linked attribute value\"},\"pagingMode\":{\"type\":\"boolean\",\"description\":\"Indicates that the HTTP server supports pagination using the standard Link header mechanism\"},\"path\":{\"type\":\"string\",\"description\":\"The URL path to append to the agents Base URL when making requests for this linked attribute\"},\"method\":{\"type\":\"string\",\"enum\":[\"GET\",\"POST\",\"PUT\",\"DELETE\",\"OPTIONS\",\"PATCH\"],\"description\":\"The HTTP method to use when making requests for this linked attribute\"},\"contentType\":{\"type\":\"string\",\"description\":\"The content type header value to use when making requests for this linked attribute (shortcut alternative to using headers parameter)\"},\"pollingAttribute\":{\"type\":\"string\",\"description\":\"Allows the polled response to be written to another attribute with the specified name on the same asset as the linked attribute\"}},\"title\":\"HTTPAgentLink\",\"required\":[\"type\"]},\"MockAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"MockAgentLink\"],\"default\":\"MockAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"requiredValue\":{\"type\":\"string\"}},\"title\":\"MockAgentLink\",\"required\":[\"type\"]},\"WebsocketAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"WebsocketAgentLink\"],\"default\":\"WebsocketAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"websocketSubscriptions\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/websocket\"},{\"$ref\":\"#/definitions/http\"}]}}},\"title\":\"WebsocketAgentLink\",\"required\":[\"type\"]},\"websocket\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"websocket\"],\"default\":\"websocket\"},\"body\":{\"$ref\":\"#/definitions/PatternPropertiesSimpleKeyAnyType\"}},\"title\":\"websocket\",\"required\":[\"type\"]},\"http\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"http\"],\"default\":\"http\"},\"body\":{\"$ref\":\"#/definitions/PatternPropertiesSimpleKeyAnyType\"},\"method\":{\"type\":\"string\",\"enum\":[\"GET\",\"PUT\",\"POST\"]},\"contentType\":{\"type\":\"string\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"uri\":{\"type\":\"string\"}},\"title\":\"http\",\"required\":[\"type\"]},\"KNXAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"KNXAgentLink\"],\"default\":\"KNXAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"dpt\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}\\\\.\\\\d{1,3}$\"},\"actionGroupAddress\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$\"},\"statusGroupAddress\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$\"}},\"title\":\"KNXAgentLink\",\"required\":[\"type\",\"dpt\"]},\"ZWaveAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"ZWaveAgentLink\"],\"default\":\"ZWaveAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"deviceNodeId\":{\"type\":\"integer\"},\"deviceEndpoint\":{\"type\":\"integer\"},\"deviceValue\":{\"type\":\"string\"}},\"title\":\"ZWaveAgentLink\",\"required\":[\"type\"]},\"SimulatorAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"SimulatorAgentLink\"],\"default\":\"SimulatorAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"replayData\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/SimulatorReplayDatapoint\"},\"description\":\"Used to store 24h dataset of values that should be replayed (i.e. written to the linked attribute) in a continuous loop.\"}},\"title\":\"SimulatorAgentLink\",\"required\":[\"type\"]},\"SimulatorReplayDatapoint\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"timestamp\":{\"type\":\"integer\"},\"value\":{\"$ref\":\"#/definitions/PatternPropertiesSimpleKeyAnyType\"}},\"required\":[\"timestamp\"]},\"VelbusAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"VelbusAgentLink\"],\"default\":\"VelbusAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"deviceAddress\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":255},\"deviceValueLink\":{\"type\":\"string\",\"pattern\":\"^.*\\\\S+.*$\",\"minLength\":1},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"}},\"title\":\"VelbusAgentLink\",\"required\":[\"type\",\"deviceAddress\",\"deviceValueLink\"]}}}");- if (!agent || !agentLink) {- agentLink = {- id: "",- type: "DefaultAgentLink"- };- }+ const doLoad = async (link: AgentLink) => {- // Remove disabled class from container- if (containerDiv.value) {- containerDiv.value!.classList.remove("disabled");- }+ if (!initialised) {+ agentLink = link;+ }+ initialised = true;- return html`- <or-json-forms .renderers="${jsonFormsAttributeRenderers}" ${ref(jsonForms)} .config="${config}"- .disabled="${disabled}" .readonly="${readonly}" .label="${label}"- .schema="${schema}" label="Agent link" .uischema="${uiSchema}" .onChange="${onAgentLinkChanged}"- .data="${agentLink}"></or-json-forms>- `;- });- const errorTemplatePromise: PromiseLike<TemplateResult> = errorDeferred.promise.then((error) => {- return html`- <or-translate .value="${error}"></or-translate>- `;- });+ if (!schema) {+ // TODO: Load agent link schema from AssetModelUtil+ schema = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Agent Link\",\"oneOf\":[{\"$ref\":\"#/definitions/SNMPAgentLink\"},{\"$ref\":\"#/definitions/DefaultAgentLink\"},{\"$ref\":\"#/definitions/HTTPAgentLink\"},{\"$ref\":\"#/definitions/MockAgentLink\"},{\"$ref\":\"#/definitions/ZWaveAgentLink\"},{\"$ref\":\"#/definitions/WebsocketAgentLink\"},{\"$ref\":\"#/definitions/KNXAgentLink\"},{\"$ref\":\"#/definitions/SimulatorAgentLink\"},{\"$ref\":\"#/definitions/VelbusAgentLink\"}],\"definitions\":{\"SNMPAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"SNMPAgentLink\"],\"default\":\"SNMPAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"oid\":{\"type\":\"string\"}},\"title\":\"SNMPAgentLink\",\"required\":[\"type\",\"oid\"]},\"regex\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"regex\"],\"default\":\"regex\"},\"pattern\":{\"type\":\"string\"},\"matchGroup\":{\"type\":\"integer\"},\"matchIndex\":{\"type\":\"integer\"}},\"title\":\"regex\",\"required\":[\"type\"]},\"substring\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"substring\"],\"default\":\"substring\"},\"beginIndex\":{\"type\":\"integer\"},\"endIndex\":{\"type\":\"integer\"}},\"title\":\"substring\",\"required\":[\"type\",\"beginIndex\"]},\"jsonPath\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"jsonPath\"],\"default\":\"jsonPath\"},\"path\":{\"type\":\"string\"},\"returnFirst\":{\"type\":\"boolean\"},\"returnLast\":{\"type\":\"boolean\"}},\"title\":\"jsonPath\",\"required\":[\"type\",\"path\",\"returnFirst\",\"returnLast\"]},\"PatternPropertiesSimpleKeyAnyType\":{\"type\":\"object\",\"additionalProperties\":true,\"patternProperties\":{\"^[a-zA-Z][a-zA-Z0-9]*\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}},\"properties\":{}},\"StringPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"string\"],\"default\":\"string\"},\"match\":{\"type\":\"string\",\"enum\":[\"EXACT\",\"BEGIN\",\"END\",\"CONTAINS\"]},\"caseSensitive\":{\"type\":\"boolean\"},\"value\":{\"type\":\"string\"},\"negate\":{\"type\":\"boolean\"}},\"title\":\"string\",\"required\":[\"predicateType\",\"caseSensitive\",\"negate\"]},\"BooleanPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"boolean\"],\"default\":\"boolean\"},\"value\":{\"type\":\"boolean\"}},\"title\":\"boolean\",\"required\":[\"predicateType\",\"value\"]},\"DateTimePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"datetime\"],\"default\":\"datetime\"},\"value\":{\"type\":\"string\"},\"rangeValue\":{\"type\":\"string\"},\"operator\":{\"type\":\"string\",\"enum\":[\"EQUALS\",\"GREATER_THAN\",\"GREATER_EQUALS\",\"LESS_THAN\",\"LESS_EQUALS\",\"BETWEEN\"]},\"negate\":{\"type\":\"boolean\"}},\"title\":\"datetime\",\"required\":[\"predicateType\",\"negate\"]},\"NumberPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"number\"],\"default\":\"number\"},\"value\":{\"type\":\"number\"},\"rangeValue\":{\"type\":\"number\"},\"operator\":{\"type\":\"string\",\"enum\":[\"EQUALS\",\"GREATER_THAN\",\"GREATER_EQUALS\",\"LESS_THAN\",\"LESS_EQUALS\",\"BETWEEN\"]},\"negate\":{\"type\":\"boolean\"}},\"title\":\"number\",\"required\":[\"predicateType\",\"negate\"]},\"RadialGeofencePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"radial\"],\"default\":\"radial\"},\"radius\":{\"type\":\"integer\"},\"lat\":{\"type\":\"number\"},\"lng\":{\"type\":\"number\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"radial\",\"required\":[\"predicateType\",\"radius\",\"lat\",\"lng\",\"negated\"]},\"RectangularGeofencePredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"rect\"],\"default\":\"rect\"},\"latMin\":{\"type\":\"number\"},\"lngMin\":{\"type\":\"number\"},\"latMax\":{\"type\":\"number\"},\"lngMax\":{\"type\":\"number\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"rect\",\"required\":[\"predicateType\",\"latMin\",\"lngMin\",\"latMax\",\"lngMax\",\"negated\"]},\"ArrayPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"array\"],\"default\":\"array\"},\"value\":{\"$ref\":\"#/definitions/AnyType\"},\"index\":{\"type\":\"integer\"},\"lengthEquals\":{\"type\":\"integer\"},\"lengthGreaterThan\":{\"type\":\"integer\"},\"lengthLessThan\":{\"type\":\"integer\"},\"negated\":{\"type\":\"boolean\"}},\"title\":\"array\",\"required\":[\"predicateType\",\"negated\"]},\"AnyType\":{\"additionalProperties\":true,\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"],\"properties\":{}},\"ValueEmptyPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"value-empty\"],\"default\":\"value-empty\"}},\"title\":\"value-empty\",\"required\":[\"predicateType\"]},\"ValueNotEmptyPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"value-not-empty\"],\"default\":\"value-not-empty\"}},\"title\":\"value-not-empty\",\"required\":[\"predicateType\"]},\"CalendarEventPredicate\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"predicateType\":{\"type\":\"string\",\"enum\":[\"calendar-event\"],\"default\":\"calendar-event\"},\"timestamp\":{\"type\":\"integer\",\"format\":\"utc-millisec\"}},\"title\":\"calendar-event\",\"required\":[\"predicateType\"]},\"DefaultAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"DefaultAgentLink\"],\"default\":\"DefaultAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"}},\"title\":\"DefaultAgentLink\",\"required\":[\"type\"]},\"HTTPAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"HTTPAgentLink\"],\"default\":\"HTTPAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"description\":\"A JSON object of headers to be added to HTTP request; the key represents the name of the header and for each string value supplied a new header will be added with the key name and specified string value\"},\"queryParameters\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"description\":\"A JSON object of query parameters to be added to HTTP request URL; the key represents the name of the query parameter and for each string value supplied a new query parameter will be added with the key name and specified string value (e.g. 'https://..../?test=1&test2\"},\"pollingMillis\":{\"type\":\"integer\",\"description\":\"Indicates that this HTTP request is used to update the linked attribute; this value indicates how frequently the HTTP request is made in order to update the linked attribute value\"},\"pagingMode\":{\"type\":\"boolean\",\"description\":\"Indicates that the HTTP server supports pagination using the standard Link header mechanism\"},\"path\":{\"type\":\"string\",\"description\":\"The URL path to append to the agents Base URL when making requests for this linked attribute\"},\"method\":{\"type\":\"string\",\"enum\":[\"GET\",\"POST\",\"PUT\",\"DELETE\",\"OPTIONS\",\"PATCH\"],\"description\":\"The HTTP method to use when making requests for this linked attribute\"},\"contentType\":{\"type\":\"string\",\"description\":\"The content type header value to use when making requests for this linked attribute (shortcut alternative to using headers parameter)\"},\"pollingAttribute\":{\"type\":\"string\",\"description\":\"Allows the polled response to be written to another attribute with the specified name on the same asset as the linked attribute\"}},\"title\":\"HTTPAgentLink\",\"required\":[\"type\"]},\"MockAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"MockAgentLink\"],\"default\":\"MockAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"requiredValue\":{\"type\":\"string\"}},\"title\":\"MockAgentLink\",\"required\":[\"type\"]},\"ZWaveAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"ZWaveAgentLink\"],\"default\":\"ZWaveAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"deviceNodeId\":{\"type\":\"integer\"},\"deviceEndpoint\":{\"type\":\"integer\"},\"deviceValue\":{\"type\":\"string\"}},\"title\":\"ZWaveAgentLink\",\"required\":[\"type\"]},\"WebsocketAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"WebsocketAgentLink\"],\"default\":\"WebsocketAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"websocketSubscriptions\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/websocket\"},{\"$ref\":\"#/definitions/http\"}]}}},\"title\":\"WebsocketAgentLink\",\"required\":[\"type\"]},\"websocket\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"websocket\"],\"default\":\"websocket\"},\"body\":{\"$ref\":\"#/definitions/AnyType\"}},\"title\":\"websocket\",\"required\":[\"type\"]},\"http\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"http\"],\"default\":\"http\"},\"body\":{\"$ref\":\"#/definitions/AnyType\"},\"method\":{\"type\":\"string\",\"enum\":[\"GET\",\"PUT\",\"POST\"]},\"contentType\":{\"type\":\"string\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"uri\":{\"type\":\"string\"}},\"title\":\"http\",\"required\":[\"type\"]},\"KNXAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"KNXAgentLink\"],\"default\":\"KNXAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"dpt\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}\\\\.\\\\d{1,3}$\"},\"actionGroupAddress\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$\"},\"statusGroupAddress\":{\"type\":\"string\",\"pattern\":\"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$\"}},\"title\":\"KNXAgentLink\",\"required\":[\"type\",\"dpt\"]},\"SimulatorAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"SimulatorAgentLink\"],\"default\":\"SimulatorAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"},\"replayData\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/SimulatorReplayDatapoint\"},\"description\":\"Used to store 24h dataset of values that should be replayed (i.e. written to the linked attribute) in a continuous loop.\"}},\"title\":\"SimulatorAgentLink\",\"required\":[\"type\"]},\"SimulatorReplayDatapoint\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"timestamp\":{\"type\":\"integer\"},\"value\":{\"$ref\":\"#/definitions/AnyType\"}},\"required\":[\"timestamp\"]},\"VelbusAgentLink\":{\"type\":\"object\",\"additionalProperties\":true,\"properties\":{\"type\":{\"type\":\"string\",\"enum\":[\"VelbusAgentLink\"],\"default\":\"VelbusAgentLink\"},\"id\":{\"type\":\"string\",\"format\":\"or-agent-id\"},\"deviceAddress\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":255},\"deviceValueLink\":{\"type\":\"string\",\"pattern\":\"^.*\\\\S+.*$\",\"minLength\":1},\"valueFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order\"},\"valueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValueConverter\":{\"type\":\"object\",\"patternProperties\":{\".+\":{\"type\":[\"null\",\"number\",\"integer\",\"boolean\",\"string\",\"array\",\"object\"]}}},\"writeValue\":{\"type\":\"string\",\"description\":\"String to be used for attribute writes and can contain '{$value}' placeholders to allow the written value to be injected into the string or to even hardcode the value written to the protocol (particularly useful for executable attributes)\"},\"messageMatchPredicate\":{\"oneOf\":[{\"$ref\":\"#/definitions/StringPredicate\"},{\"$ref\":\"#/definitions/BooleanPredicate\"},{\"$ref\":\"#/definitions/DateTimePredicate\"},{\"$ref\":\"#/definitions/NumberPredicate\"},{\"$ref\":\"#/definitions/RadialGeofencePredicate\"},{\"$ref\":\"#/definitions/RectangularGeofencePredicate\"},{\"$ref\":\"#/definitions/ArrayPredicate\"},{\"$ref\":\"#/definitions/ValueEmptyPredicate\"},{\"$ref\":\"#/definitions/ValueNotEmptyPredicate\"},{\"$ref\":\"#/definitions/CalendarEventPredicate\"}],\"description\":\"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters\"},\"messageMatchFilters\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"$ref\":\"#/definitions/regex\"},{\"$ref\":\"#/definitions/substring\"},{\"$ref\":\"#/definitions/jsonPath\"}]},\"description\":\"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate\"}},\"title\":\"VelbusAgentLink\",\"required\":[\"type\",\"deviceAddress\",\"deviceValueLink\"]}}}");+ }- loadAgents().then((agents) => {- loadedAgents = agents;+ loadedAgents = await loadAgents();- if (!agents) {- console.warn("Failed to load agents for agent link");- return;- }+ if (!loadedAgents) {+ console.warn("Failed to load agents for agent link");+ return;+ }- if (!agentLink) {- successDeferred.resolve(undefined);- return;+ if (link) {+ if (link.id) {+ const matchedAgent = loadedAgents.find(agent => agent.id === link.id);+ if (!matchedAgent) {+ console.warn("Agent link: linked agent could not be found");+ link.id = "";+ }+ } else {+ link.id = "";}+ }- const matchedAgent = agents.find(agent => agent.id === agentLink!.id);- let error: ErrorMessage | undefined;+ // let error: ErrorMessage | undefined;+ //+ // if (!matchedAgent) {+ // console.warn("Linked agent cannot be found: " + agentLink);+ // error = "agentNotFound";+ // } else {+ // // Check agent link type+ // const agentDescriptor = AssetModelUtil.getAssetDescriptor(matchedAgent.type) as AgentDescriptor;+ // if (!agentDescriptor) {+ // console.warn("Failed to load agent descriptor for agent link: " + agentLink);+ // error = "agentNotFound";+ // } else if (agentDescriptor.agentLinkType !== agentLink.type) {+ // console.warn("Agent link type does not match agent descriptor agent link type: " + agentLink);+ // error = "agentTypeMismatch";+ // }+ // }++ if (jsonForms.value && loadingWrapper.value) {+ const forms = jsonForms.value;+ forms.schema = schema;+ forms.data = link;+ loadingWrapper.value.loading = false;+ }+ };- if (!matchedAgent) {- console.warn("Linked agent cannot be found: " + agentLink);- error = "agentNotFound";- } else {- // Check agent link type- const agentDescriptor = AssetModelUtil.getAssetDescriptor(matchedAgent.type) as AgentDescriptor;- if (!agentDescriptor) {- console.warn("Failed to load agent descriptor for agent link: " + agentLink);- error = "agentNotFound";- } else if (agentDescriptor.agentLinkType !== agentLink.type) {- console.warn("Agent link type does not match agent descriptor agent link type: " + agentLink);- error = "agentTypeMismatch";- }- }+ const templateFunction: ValueInputTemplateFunction = (value, focused, loading, sending, error, helperText) => {- if (error) {- errorDeferred.resolve(error);- return;- }+ // Need to have a value so that the agent ID picker is shown+ if (!value) {+ value = {+ id: "",+ type: "DefaultAgentLink"+ };+ }- successDeferred.resolve(matchedAgent);- });+ // Schedule loading+ window.setTimeout(() => doLoad(value as AgentLink), 0);return html`<style>@@ -238,10 +235,15 @@ export const jsonFormsInputTemplateProvider: (fallback: ValueInputProvider) => Vopacity: 0.5;pointer-events: none;}+ or-loading-wrapper {+ width: 100%;+ }</style>- <div ${ref(containerDiv)} class="disabled" style="flex: 1;">- ${until(errorTemplatePromise, schemaTemplatePromise, html``)}- </div>+ <or-loading-wrapper ${ref(loadingWrapper)} .loading="${true}">+ <or-json-forms .renderers="${jsonFormsAttributeRenderers}" ${ref(jsonForms)}+ .disabled="${disabled}" .readonly="${readonly}" .label="${label}"+ .schema="${schema}" label="Agent link" .uischema="${uiSchema}" .onChange="${onAgentLinkChanged}"></or-json-forms>+ </or-loading-wrapper>`;};diff --git a/ui/component/or-attribute-input/tsconfig.json b/ui/component/or-attribute-input/tsconfig.jsonindex 210ada43f..b3701c2e9 100644--- a/ui/component/or-attribute-input/tsconfig.json+++ b/ui/component/or-attribute-input/tsconfig.json@@ -14,6 +14,7 @@{ "path": "../or-translate" },{ "path": "../or-map" },{ "path": "../or-mwc-components" },+ { "path": "../or-components" },{ "path": "../or-json-forms" }]}diff --git a/ui/component/or-components/src/or-collapsible-panel.ts b/ui/component/or-components/src/or-collapsible-panel.tsindex d084a8e5f..27d8fa738 100644--- a/ui/component/or-components/src/or-collapsible-panel.ts+++ b/ui/component/or-components/src/or-collapsible-panel.ts@@ -1,18 +1,78 @@import {css, html, LitElement, PropertyValues, unsafeCSS} from "lit";import {customElement, property, query} from "lit/decorators.js";-import {DefaultColor2} from "@openremote/core";+import {DefaultColor2, DefaultColor5} from "@openremote/core";// language=CSSconst style = css`:host {display: block;+ box-sizing: content-box;+ margin: 0;+ overflow: hidden;+ transition: margin 225ms cubic-bezier(0.4, 0, 0.2, 1),box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);+ position: relative;+ border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});+ border-radius: 4px;+ border-width: 1px;+ border-style: solid;}:host([hidden]) {display: none;}++ #header {+ cursor: pointer;+ display: flex;+ height: 48px;+ flex-direction: row;+ font-family: Roboto,Helvetica Neue,sans-serif;+ font-size: 15px;+ font-weight: 400;+ align-items: center;+ padding: 0 24px;+ border-radius: inherit;+ transition: height 225ms cubic-bezier(0.4, 0, 0.2, 1);+ }++ #header.expanded {+ height: 64px;+ }++ #header.expanded > #indicator {+ transform: rotate(180deg);+ }++ .clickable {+ cursor: pointer;+ }++ #header-content {+ flex: 1;+ display: flex;+ flex-direction: row;+ overflow: hidden;+ }++ #header-title, #header-description {+ margin-right: 16px;+ display: inline-flex;+ align-items: center;+ }+ #header-title {+ flex: 0;+ }++ #header-description {+ flex-grow: 2;+ }++ #indicator {+ align-self: center;+ }+#indicator::after {border-style: solid;border-width: 0 2px 2px 0;@@ -22,39 +82,49 @@ const style = css`transform: rotate(45deg);vertical-align: middle;}++ #content {+ display: flex;+ height: 0;+ visibility: hidden;+ }++ #content.expanded {+ height: unset;+ visibility: visible;+ }`;@customElement("or-collapsible-panel")export class OrCollapsiblePanel extends LitElement {static get styles() {- return style;+ return [+ style+ ];}@property({type: Boolean})expanded: boolean = false;+ @query("#header")+ protected headerElem!: HTMLDivElement;protected _onHeaderClicked(ev: MouseEvent) {ev.preventDefault();-- if ((ev.currentTarget as HTMLElement).id !== "header") {- return;- }--+ this.expanded = !this.expanded;}render() {return html`- <div id="header" @click="${(ev:MouseEvent) => this._onHeaderClicked(ev)}">- <span>- <slot name="header"></slot>- <slot name="header-content"></slot>+ <div id="header" class="${this.expanded ? "expanded" : ""}" @click="${(ev:MouseEvent) => this._onHeaderClicked(ev)}">+ <span id="header-content">+ <span id="header-title" class="clickable"><slot name="header"></slot></span>+ <span id="header-description"><slot name="header-description"></slot></span></span>- <span id="indicator"></span>+ <span id="indicator" class="clickable"></span></div>- <div>+ <div id="content" class="${this.expanded ? "expanded" : ""}"><slot name="content"></slot></div>`;diff --git a/ui/component/or-components/src/or-loading-wrapper.ts b/ui/component/or-components/src/or-loading-wrapper.tsnew file mode 100644index 000000000..f7068f785--- /dev/null+++ b/ui/component/or-components/src/or-loading-wrapper.ts@@ -0,0 +1,64 @@+import {css, html, LitElement, TemplateResult } from "lit";+import { customElement, property } from "lit/decorators.js";++/**+ * A simple loading wrapper around some other content that will hide the content whilst loading property is true+ */+@customElement("or-loading-wrapper")+export class OrLoadingWrapper extends LitElement {++ @property({type: Number})+ public loadingHeight?: number;++ @property({type: Boolean})+ public loadDom: boolean = true;++ @property({type: Boolean})+ public fadeContent: boolean = false;++ @property({type: Boolean})+ public loading: boolean = false;++ @property({type: Object, attribute: false})+ public content?: TemplateResult;++ // language=CSS+ public static get styles() {+ return css`+ :host {+ display: block;+ }++ .hidden {+ display: none;+ }++ .faded {+ opacity: 0.5;+ }++ #wrapper {+ position: relative;+ }++ #loader {+ position: absolute;+ width: 100%;+ height: 100%;+ }+ `;+ }++ render() {+ return html`+ <div id="wrapper">+ ${this.loading ? html`<div id="loader">LOADING</div>` : ``}+ ${this.loadDom || !this.loading? html`+ <div id="content-wrapper" class="${this.loading ? this.fadeContent ? "faded" : "hidden" : ""}">+ <slot></slot>+ ${this.content || ``}+ </div>` : ``}+ </div>+ `;+ }+}diff --git a/ui/component/or-json-forms/package.json b/ui/component/or-json-forms/package.jsonindex ffb2433d4..b354f4d44 100644--- a/ui/component/or-json-forms/package.json+++ b/ui/component/or-json-forms/package.json@@ -15,8 +15,7 @@"dependencies": {"@openremote/or-mwc-components": "^1.0.3","@polymer/polymer": "^3.3.1",- "lit": "^2.0.0-rc.2",- "haunted": "^4.8.1"+ "lit": "^2.0.0-rc.2"},"devDependencies": {"@jsonforms/core": "^3.0.0-alpha.1",diff --git a/ui/component/or-json-forms/src/controls/control-array-element.ts b/ui/component/or-json-forms/src/controls/control-array-element.tsindex b4d85c978..84817b255 100644--- a/ui/component/or-json-forms/src/controls/control-array-element.ts+++ b/ui/component/or-json-forms/src/controls/control-array-element.ts@@ -3,6 +3,7 @@ import {createDefaultValue,JsonSchema,mapDispatchToArrayControlProps,+ OwnPropsOfRenderer,Paths,RendererProps,Resolve,@@ -15,7 +16,7 @@ import {InputType, OrMwcInput} from "@openremote/or-mwc-components/or-mwc-input"import {i18next} from "@openremote/or-translate";import {showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import "@openremote/or-mwc-components/or-mwc-list";-import {addItemOrParameterDialogStyle, baseStyle} from "../styles";+import {addItemOrParameterDialogStyle, baseStyle, panelStyle} from "../styles";import {ListItem, OrMwcListChangedEvent} from "@openremote/or-mwc-components/or-mwc-list";import {DefaultColor4, DefaultColor5} from "@openremote/core";import "../json-editor";@@ -26,7 +27,7 @@ import {AdditionalProps} from "../base-element";// language=CSSconst style = css`- :host, .item-border, .drag-handle {+ .item-border, .drag-handle {border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});border-radius: 4px;border-width: 1px;@@ -37,100 +38,47 @@ const style = css`display: flex;}- .item-container {+ .item-wrapper > .item-container {flex: 1;}- .item-border {- flex: 1;- border-top-left-radius: 0;- border-bottom-left-radius: 0;- }-- #expander {- --or-icon-width: 20px;- --or-icon-height: 20px;- cursor: pointer;- flex: 1 1 auto;- }-- #expander > * {- pointer-events: none;- }-- #expander > or-icon {- vertical-align: middle;- margin-right: 6px;- margin-left: -5px;+ .item-wrapper + .item-wrapper {+ padding-top: 10px;}- #header {- display: flex;- align-items: center;- height: 50px;- }-- #content {- display: flex;- flex-direction: column;- }-- #content .item-container:first-child {- margin-top: 0;- }-- #add-parameter {- margin: 10px 0 0 4px;- }-- :host, .padded {- padding: 10px 16px;- }-- .item-border > .item-container {+ .item-wrapper > .item-container > .item-container {margin: 0;+ flex: 1;}-- .item-border > .item-container > .delete-container {++ .item-wrapper > .item-container > .item-container > .delete-container {display: none;}- .item-border > .item-container :first-child {- border: 0;+ .item-wrapper > .item-container > .item-container :first-child {padding: 0;margin: 0;flex: 1;}- .draggable.dragging {+ .item-wrapper.dragging > .item-container {opacity: 0.5;}-- .draggable.indicator-after {++ .item-wrapper.dragging.indicator-after {border-bottom-width: 3px;border-bottom-style: solid;border-bottom-color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});}-- .draggable.indicator-before {++ .item-wrapper.dragging.indicator-before {border-top-width: 3px;border-top-style: solid;border-top-color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});}- .drag-handle {- border-top-right-radius: 0;- border-bottom-right-radius: 0;- border-right: 0;+ .drag-container > button {cursor: grab;- flex: 0 0 auto;- width: 20px;- padding: 3px;- }-- .drag-handle > div {- height: 100%;- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cg%3E%3Cellipse fill='%23cecece' cx='5' cy='5' rx='2.5' ry='2.5'/%3E%3C/g%3E%3C/svg%3E");}`;@@ -148,6 +96,7 @@ export class ControlArrayElement extends ControlBaseElement {public static get styles() {return [baseStyle,+ panelStyle,style];}@@ -195,77 +144,74 @@ export class ControlArrayElement extends ControlBaseElement {const maxItems = this.schema.maxItems ?? Number.MAX_SAFE_INTEGER;const itemCount = Array.isArray(this.data) ? (this.data as []).length : 0;- return html`- <div id="panel">- ${this.minimal ? html`` : html`- <div id="header">- <div id="expander"><or-icon icon="chevron-right"></or-icon><span>${this.label ? computeLabel(this.label, this.required, false) : ""}</span></div>- <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${() => this._showJson()}"></or-mwc-input></div>- </div>- `}+ const header = this.minimal ? `` : html`+ <span slot="header">${this.label ? computeLabel(this.label, this.required, false) : ""}</span>+ <div id="header-description" slot="header-description">+ <div id="errors">+ ${!this.errors ? `` : html`<or-icon icon="alert"></or-icon><span>${this.errors}</span>`}+ </div>+ <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${(ev: MouseEvent) => this._showJson(ev)}"></or-mwc-input></div>+ </div>+ `;++ const content = html`+ ${header}+ <div id="content-wrapper" slot="content"><div id="content" @dragover="${(ev: DragEvent) => this._onDragOver(ev)}">${!Array.isArray(this.data) ? `` : (this.data as any[]).map((item, index) => {-+const childPath = Paths.compose(this.path, "" + index);- const constProp = this.itemInfos && this.itemInfos.length > 0 ? this.itemInfos[0].constProperty : undefined;- const childConstValue = constProp ? item[constProp] : undefined;- const childMatchedItemInfo = childConstValue ? this.itemInfos?.find(itemInfo => itemInfo.constValue === childConstValue) : undefined;- const childLabel = childMatchedItemInfo ? childMatchedItemInfo.title : "";-- const props: RendererProps & AdditionalProps = {++ const props: OwnPropsOfRenderer | AdditionalProps = {renderers: this.renderers,uischema: controlWithoutLabel("#"),- enabled: this.enabled,- visible: this.visible,- path: childPath,schema: this.resolvedSchema,- label: childLabel,- required: false- };-+ path: childPath+ }+return this.getArrayItemWrapper(getTemplateFromProps(this.state, props), index);})}</div>-- <div id="add-parameter">- <or-mwc-input .disabled="${itemCount && itemCount >= maxItems}" .type="${InputType.BUTTON}" .label="${i18next.t("addItem")}" icon="plus" @click="${() => this.doAddItem()}"></or-mwc-input>- </div>+ ${this.errors ? `` : html`+ <div id="footer">+ <or-mwc-input .disabled="${itemCount && itemCount >= maxItems}" .type="${InputType.BUTTON}" .label="${i18next.t("addItem")}" icon="plus" @click="${() => this.doAddItem()}"></or-mwc-input>+ </div>+ `}</div>`;++ return this.minimal ? html`<div>${content}</div>` : html`<or-collapsible-panel>${content}</or-collapsible-panel>`;}protected getArrayItemWrapper(elementTemplate: TemplateResult, index: number) {- elementTemplate = html`- <div class="drag-handle">- <div></div>- </div>- <div class="item-border padded">- ${elementTemplate}- </div>- `;-return html`- <div class="item-wrapper draggable" data-index="${index}" draggable="true" @dragstart="${(ev: DragEvent) => this._onDragStart(ev)}" @dragend="${(ev: DragEvent) => this._onDragEnd(ev)}">+ <div class="item-wrapper" data-index="${index}">+ <div class="drag-container">+ <button draggable="true" @dragstart="${(ev: DragEvent) => this._onDragStart(ev)}" @dragend="${(ev: DragEvent) => this._onDragEnd(ev)}" class="draggable button-clear"><or-icon icon="menu"></or-icon></input>+ </div>${getTemplateWrapper(elementTemplate, () => this.removeItem(index))}</div>`;}protected _onDragStart(ev: DragEvent) {- const dragging = ev.currentTarget as HTMLDivElement;- dragging.classList.add("dragging");+ const buttonElem = ev.currentTarget as HTMLButtonElement;+ const itemWrapperElem = buttonElem!.parentElement!.parentElement as HTMLDivElement;+ itemWrapperElem.classList.add("dragging");+ const itemContainerElem = itemWrapperElem!.lastElementChild!;+ ev.dataTransfer!.setDragImage(itemContainerElem, (itemContainerElem.getBoundingClientRect().width/2) - 50, 0);}protected _onDragEnd(ev: DragEvent) {- const container = this.shadowRoot!.getElementById("content") as HTMLDivElement;- const draggables = [...(container.children as any)] as HTMLDivElement[];- const dragging = ev.currentTarget as HTMLDivElement;- dragging.classList.remove("dragging");- const index = Number(dragging.getAttribute("data-index"));- const afterIndex = dragging.getAttribute("data-after-index") !== null ? Number(dragging.getAttribute("data-after-index")) : (this.data as []).length - 1;+ const draggables = [...((this.shadowRoot!.querySelectorAll(".item-wrapper") as any) as HTMLDivElement[])];+ const buttonElem = ev.currentTarget as HTMLButtonElement;+ const itemWrapperElem = buttonElem!.parentElement!.parentElement as HTMLDivElement;+ itemWrapperElem.classList.remove("dragging");+ const index = Number(itemWrapperElem.getAttribute("data-index"));+ const afterIndex = Math.max(0, (itemWrapperElem.getAttribute("data-after-index") !== null ? Number(itemWrapperElem.getAttribute("data-after-index")) : draggables.length) - 1);draggables.forEach(draggable => draggable.classList.remove("indicator-before", "indicator-after"));@@ -284,8 +230,8 @@ export class ControlArrayElement extends ControlBaseElement {}ev.preventDefault();- const container = ev.currentTarget as HTMLDivElement;- const draggables = [...((this.shadowRoot!.querySelectorAll(".draggable:not(.dragging)") as any) as HTMLDivElement[])];++ const draggables = [...((this.shadowRoot!.querySelectorAll(".item-wrapper:not(.dragging)") as any) as HTMLDivElement[])];const initial = {offset: Number.NEGATIVE_INFINITY, element: null} as {offset: number,element: HTMLDivElement | null@@ -307,17 +253,15 @@ export class ControlArrayElement extends ControlBaseElement {draggables[draggables.length-1].classList.add("indicator-after");dragging.removeAttribute("data-after-index");} else {- const afterIndex = afterItem.getAttribute("data-index");afterItem.classList.add("indicator-before");- if (afterIndex !== null) {- dragging.setAttribute("data-after-index", afterIndex);- } else {- dragging.removeAttribute("data-after-index");- }+ const afterIndex = afterItem.getAttribute("data-index");+ dragging.setAttribute("data-after-index", afterIndex!);}}- protected _showJson() {+ protected _showJson(ev: MouseEvent) {+ ev.stopPropagation();+const dialog = showDialog({content: html`diff --git a/ui/component/or-json-forms/src/controls/control-input-element.ts b/ui/component/or-json-forms/src/controls/control-input-element.tsindex c799c8eb9..cc9296f80 100644--- a/ui/component/or-json-forms/src/controls/control-input-element.ts+++ b/ui/component/or-json-forms/src/controls/control-input-element.ts@@ -78,11 +78,6 @@ export class ControlInputElement extends ControlBaseElement {this.inputType = InputType.SELECT;if (isEnumControl(uischema, schema)) {- if (getSchemaConst(schema) !== undefined) {- // Don't show const- return html``;- }-options = schema.enum!.map(enm => {return [JSON.stringify(enm), String(enm)];});diff --git a/ui/component/or-json-forms/src/haunted-element.ts b/ui/component/or-json-forms/src/haunted-element.tsdeleted file mode 100644index 1b09763d7..000000000--- a/ui/component/or-json-forms/src/haunted-element.ts+++ /dev/null@@ -1,34 +0,0 @@-/**- * This adds haunted (react style hooks) to lit element- */-import { LitElement, PropertyValues } from "lit";-import { State } from "haunted";--const defer = Promise.resolve().then.bind(Promise.resolve());--export class HauntedLitElement extends LitElement {-- protected haunted: State;-- constructor() {- super();- this.haunted = new State(() => this.requestUpdate(), this);- }-- update(_changedProperties: PropertyValues) {- this.haunted.run(() => {- super.update(_changedProperties);- });- }-- updated(_changedProperties: PropertyValues) {- super.updated(_changedProperties);- this.haunted.runLayoutEffects();- defer(() => this.haunted.runEffects());- }-- disconnectedCallback() {- this.haunted.teardown();- super.disconnectedCallback();- }-}\ No newline at end of filediff --git a/ui/component/or-json-forms/src/index.ts b/ui/component/or-json-forms/src/index.tsindex bf89f7e4f..e0b31a3b6 100644--- a/ui/component/or-json-forms/src/index.ts+++ b/ui/component/or-json-forms/src/index.ts@@ -1,8 +1,7 @@-import {css, html} from "lit";-import {customElement, property} from "lit/decorators.js";+import {css, html, LitElement, PropertyValues} from "lit";+import {customElement, property, state} from "lit/decorators.js";import {guard} from "lit/directives/guard";import {ErrorObject} from "ajv";-import {HauntedLitElement} from "./haunted-element";import {Actions,configReducer,@@ -13,6 +12,7 @@ import {generateDefaultUISchema,generateJsonSchema,JsonFormsCellRendererRegistryEntry,+ JsonFormsCore,JsonFormsProps,JsonFormsRendererRegistryEntry,JsonFormsSubStates,@@ -21,6 +21,7 @@ import {mapDispatchToControlProps,mapStateToJsonFormsRendererProps,OwnPropsOfJsonFormsRenderer,+ setConfig,StatePropsOfJsonFormsRenderer,UISchemaElement} from "@jsonforms/core";@@ -79,7 +80,7 @@ const useEffectAfterFirstRender = (};@customElement("or-json-forms")-export class OrJSONForms extends HauntedLitElement implements OwnPropsOfJsonFormsRenderer, AdditionalProps {+export class OrJSONForms extends LitElement implements OwnPropsOfJsonFormsRenderer, AdditionalProps {@property({type: Object})public uischema?: UISchemaElement;@@ -87,7 +88,7 @@ export class OrJSONForms extends HauntedLitElement implements OwnPropsOfJsonForm@property({type: Object})public schema?: JsonSchema;- @property({type: String, attribute: false})+ @property({type: Object, attribute: false})public data: any;@property({type: Array})@@ -121,71 +122,86 @@ export class OrJSONForms extends HauntedLitElement implements OwnPropsOfJsonForm];}- render() {+ @state()+ protected core?: JsonFormsCore;+ @state()+ protected contextValue?: JsonFormsSubStates;+ protected previousData: any;+ protected previousErrors: ErrorObject[] = [];++ shouldUpdate(_changedProperties: PropertyValues) {+ super.shouldUpdate(_changedProperties);++ if (!this.schema) {+ this.schema = this.data !== undefined ? generateJsonSchema(this.data) : {};+ }++ if (!this.uischema) {+ this.uischema = generateDefaultUISchema(this.schema!);+ }- const schemaToUse = useMemo(- () => (this.schema !== undefined ? this.schema : this.data !== undefined ? generateJsonSchema(this.data) : {}),- [this.schema, this.data]- );-- const uischemaToUse = useMemo(- () => typeof this.uischema === "object" ? this.uischema : generateDefaultUISchema(schemaToUse),- [this.uischema, schemaToUse]- );-- const [core, coreDispatch] = useReducer(- coreReducer,- undefined,- () => coreReducer(- {- ajv: createAjv({useDefaults: true, format: false}),- data: {},- schema: schemaToUse,- uischema: uischemaToUse- },- Actions.init(this.data, schemaToUse, uischemaToUse)- )- );-- useEffect(() => {- coreDispatch(- Actions.updateCore(this.data, schemaToUse, uischemaToUse)+ if (!this.core) {+ this.core = {+ ajv: createAjv({useDefaults: true, format: false}),+ data: {},+ schema: this.schema!,+ uischema: this.uischema!+ };+ this.updateCore(Actions.init(this.data, this.schema, this.uischema));+ this.config = configReducer(undefined, setConfig(this.config));+ }++ if (_changedProperties.has("data") || _changedProperties.has("schema") || _changedProperties.has("uischema")) {+ this.updateCore(+ Actions.updateCore(this.data, this.schema, this.uischema));- }, [this.data, schemaToUse, uischemaToUse]);-- const [config, configDispatch] = useReducer(- configReducer,- undefined,- () => configReducer(undefined, Actions.setConfig(this.config))- );-- useEffectAfterFirstRender(() => {- configDispatch(Actions.setConfig(this.config));- }, [this.config]);-- const contextValue: JsonFormsSubStates = useMemo(() => ({- core,- renderers: this.renderers,- cells: this.cells,- config: config,- uischemas: this.uischemas,- readonly: this.readonly,- dispatch: coreDispatch- }), [core, this.renderers, this.cells, config, this.readonly]);-- useEffect(() => {- if (this.onChange && !Util.objectsEqual(core.data, this.data, true)) {- this.onChange({data: core.data, errors: core.errors});+ }++ if (!this.contextValue || _changedProperties.has("core") || _changedProperties.has("renderers") || _changedProperties.has("cells") || _changedProperties.has("config") || _changedProperties.has("readonly")) {+ this.contextValue = {+ core: this.core,+ renderers: this.renderers,+ cells: this.cells,+ config: this.config,+ uischemas: this.uischemas,+ readonly: this.readonly,+ dispatch: (action: CoreActions) => this.updateCore(action)}- }, [core.data, core.errors]);-- return html`${guard([contextValue], () => {- const props: JsonFormsProps & AdditionalProps = {- ...mapStateToJsonFormsRendererProps({jsonforms: {...contextValue}}, this),- label: getLabel(schemaToUse, schemaToUse, this.label, undefined) || "",- required: this.required- };- return getTemplateFromProps(contextValue, props);- })}`;+ }++ if (_changedProperties.has("core")) {+ const data = this.core!.data;+ const errors = this.core!.errors;++ if (this.onChange && (!Util.objectsEqual(data, this.previousData, true) || (errors && !Util.objectsEqual(errors, this.previousErrors, true)))) {+ this.previousErrors = errors || [];+ this.previousData = data;+ this.onChange({data: data, errors: errors});+ }+ }++ return true;+ }++ updateCore<T extends CoreActions>(coreAction: T): T {+ const coreState = coreReducer(this.core, coreAction);+ if(coreState !== this.core) {+ this.core = coreState;+ }+ return coreAction;+ }++ render() {++ if (!this.contextValue) {+ return html``;+ }++ const props: JsonFormsProps & AdditionalProps = {+ ...mapStateToJsonFormsRendererProps({jsonforms: {...this.contextValue}}, this),+ label: getLabel(this.schema!, this.uischema!, this.label, undefined) || "",+ required: this.required+ };+ return getTemplateFromProps(this.contextValue, props);}}diff --git a/ui/component/or-json-forms/src/layouts/layout-base-element.ts b/ui/component/or-json-forms/src/layouts/layout-base-element.tsindex c87f7513c..01bb1a8dc 100644--- a/ui/component/or-json-forms/src/layouts/layout-base-element.ts+++ b/ui/component/or-json-forms/src/layouts/layout-base-element.ts@@ -1,4 +1,5 @@-import {Layout, LayoutProps, OwnPropsOfLayout, OwnPropsOfRenderer, UISchemaElement} from "@jsonforms/core";+import {Layout, LayoutProps, mapStateToJsonFormsRendererProps, OwnPropsOfLayout, OwnPropsOfRenderer,+ Resolve, UISchemaElement} from "@jsonforms/core";import {property} from "lit/decorators.js";import {BaseElement} from "../base-element";diff --git a/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts b/ui/component/or-json-forms/src/layouts/layout-vertical-element.tsindex c508d2dec..51f4ba43b 100644--- a/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts+++ b/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts@@ -7,6 +7,8 @@ import {isControl,JsonSchema,mapStateToControlProps,+ mapStateToControlWithDetailProps,+ mapStateToJsonFormsRendererProps,OwnPropsOfControl,OwnPropsOfRenderer,Paths,@@ -22,7 +24,8 @@ import {InputType, OrInputChangedEvent, OrMwcInput} from "@openremote/or-mwc-comimport {i18next} from "@openremote/or-translate";import {showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import "@openremote/or-mwc-components/or-mwc-list";-import {addItemOrParameterDialogStyle, baseStyle} from "../styles";+import "@openremote/or-components/or-collapsible-panel";+import {addItemOrParameterDialogStyle, baseStyle, panelStyle} from "../styles";import {ListItem, OrMwcListChangedEvent} from "@openremote/or-mwc-components/or-mwc-list";import {DefaultColor5} from "@openremote/core";import "../json-editor";@@ -31,55 +34,6 @@ import {AdditionalProps} from "../base-element";// language=CSSconst style = css`- :host {- border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});- border-radius: 4px;- border-width: 1px;- border-style: solid;- }-- #expander {- --or-icon-width: 20px;- --or-icon-height: 20px;- cursor: pointer;- flex: 1 1 auto;- }- #expander > * {- pointer-events: none;- }- #expander > or-icon {- vertical-align: middle;- margin-right: 6px;- margin-left: -5px;- }-- #errors {- color: red;- margin-right: 10px;- }-- #errors > or-icon {- margin-right: 10px;- }-- #header {- display: flex;- align-items: center;- height: 50px;- }-- #content {- display: flex;- flex-direction: column;- }-- #add-parameter {- margin: 10px 0 0 4px;- }-- :host, .padded {- padding: 10px 16px;- }#dynamic-wrapper {display: table;@@ -105,10 +59,6 @@ const style = css`.key-container or-mwc-input, .value-container or-mwc-input {display: block;}-- .delete-container {- vertical-align: middle;- }.value-container > .item-container {margin: 0;@@ -140,6 +90,7 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Grpublic static get styles() {return [baseStyle,+ panelStyle,style];}@@ -165,55 +116,55 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Gr}}- return html`- <div id="panel">- ${this.minimal ? html`` : html`- <div id="header">- <div id="expander">- <or-icon icon="chevron-right"></or-icon>- <span>${this.label ? computeLabel(this.label, this.required, false) : ""}</span>- </div>- ${!this.errors ? `` : html`<div id="errors"><or-icon icon="alert"></or-icon><span>${this.errors}</span></div>`}- <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${() => this._showJson()}"></or-mwc-input></div>- </div>- `}+ const header = this.minimal ? `` : html`+ <span slot="header">${this.label ? computeLabel(this.label, this.required, false) : ""}</span>+ <div id="header-description" slot="header-description">+ <div id="errors">+ ${!this.errors ? `` : html`<or-icon icon="alert"></or-icon><span>${this.errors}</span>`}+ </div>+ <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${(ev: MouseEvent) => this._showJson(ev)}"></or-mwc-input></div>+ </div>+ `;++ const content = html`+ ${header}+ <div id="content-wrapper" slot="content"><div id="content">-- ${this.errors ? ``- : dynamic && dynamicValueSchema ?- this._getDynamicContentTemplate(dynamicPropertyRegex, dynamicValueSchema)- : this.getChildProps().map((props: OwnPropsOfRenderer) => {-- const contentProps: OwnPropsOfRenderer & AdditionalProps = {- ...props,- label: "",- required: false- };-- if (isControl(props.uischema)) {-- const controlProps = props as OwnPropsOfControl;- const stateControlProps = mapStateToControlProps(jsonFormsState, controlProps);- stateControlProps.label = stateControlProps.label || getLabel(this.schema, rootSchema, undefined, (props.uischema as ControlElement).scope) || "";- contentProps.label = stateControlProps.label;- contentProps.required = !!stateControlProps.required;- if (!stateControlProps.required && stateControlProps.data === undefined) {- // Optional property with no data so show this in the add parameter dialog- optionalProps.push(stateControlProps);- return html``;+ ${dynamic && dynamicValueSchema ?+ this._getDynamicContentTemplate(dynamicPropertyRegex, dynamicValueSchema)+ : this.getChildProps().map((childProps: OwnPropsOfRenderer & AdditionalProps) => {++ if (childProps.schema) {+ // Make root schema definitions available to this schema+ childProps.schema.definitions = rootSchema.definitions;+ }++ if (isControl(childProps.uischema)) {++ const controlProps = childProps as OwnPropsOfControl;+ const stateControlProps = mapStateToControlProps(jsonFormsState, controlProps);+ stateControlProps.label = stateControlProps.label || getLabel(this.schema, rootSchema, undefined, (childProps.uischema as ControlElement).scope) || "";+ childProps.label = stateControlProps.label;+ childProps.required = !!stateControlProps.required;+ if (!stateControlProps.required && stateControlProps.data === undefined) {+ // Optional property with no data so show this in the add parameter dialog+ optionalProps.push(stateControlProps);+ return html``;+ }}- }-- return getTemplateFromProps(this.state, contentProps);- })}++ return getTemplateFromProps(this.state, childProps);+ })}</div>-- ${this.errors ? `` : html`- <div id="add-parameter">- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addParameter")}" icon="plus" .disabled="${!dynamic && optionalProps.length === 0}" @click="${() => this._addParameter(optionalProps, dynamicPropertyRegex, dynamicValueSchema)}"></or-mwc-input>- </div>`}++ ${this.errors || (optionalProps.length === 0 && !dynamic) ? `` : html`+ <div id="footer">+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addParameter")}" icon="plus" @click="${() => this._addParameter(optionalProps, dynamicPropertyRegex, dynamicValueSchema)}"></or-mwc-input>+ </div>`}</div>`;++ return this.minimal ? html`<div>${content}</div>` : html`<or-collapsible-panel>${content}</or-collapsible-panel>`;}protected _getDynamicContentTemplate(dynamicPropertyRegex: string, dynamicValueSchema: JsonSchema): TemplateResult {@@ -284,7 +235,9 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Gr`;}- protected _showJson() {+ protected _showJson(ev: MouseEvent) {+ ev.stopPropagation();+const dialog = showDialog({content: html`diff --git a/ui/component/or-json-forms/src/standard-renderers.ts b/ui/component/or-json-forms/src/standard-renderers.tsindex b0b4045c7..8e5b92ccf 100644--- a/ui/component/or-json-forms/src/standard-renderers.ts+++ b/ui/component/or-json-forms/src/standard-renderers.ts@@ -109,9 +109,19 @@ export const verticalLayoutRenderer = (state: JsonFormsStateContext, props: OwnPreturn getTemplateWrapper(template, deleteHandler);};+export const constTester: RankedTester = rankWith(+ 6,+ schemaMatches(schema => getSchemaConst(schema) !== undefined)+);+export const constRenderer = (state: JsonFormsStateContext, props: OwnPropsOfJsonFormsRenderer) => {+ // Don't render const+ return html``;+};+export const inputControlTester: RankedTester = rankWith(3,or(+ schemaMatches(schema => Array.isArray(schema.type) && schema.type.length === 7),isStringControl,isBooleanControl,isNumberControl,@@ -366,6 +376,7 @@ export function unknownTemplate() {export const StandardRenderers: JsonFormsRendererRegistryEntry[] = [{tester: verticalOrGroupLayoutTester, renderer: verticalLayoutRenderer},+ {tester: constTester, renderer: constRenderer},{tester: inputControlTester, renderer: inputControlRenderer},{tester: objectControlTester, renderer: objectControlRenderer},{tester: arrayControlTester, renderer: arrayControlRenderer},diff --git a/ui/component/or-json-forms/src/styles.ts b/ui/component/or-json-forms/src/styles.tsindex d39f2dbab..3e7f9d604 100644--- a/ui/component/or-json-forms/src/styles.ts+++ b/ui/component/or-json-forms/src/styles.ts@@ -9,16 +9,16 @@ export const baseStyle = css`.item-container {display: flex;- margin: 10px 0 10px 10px;}- .delete-container {+ .delete-container, .drag-container {width: 30px;display: flex;+ vertical-align: middle;}- .item-container:hover .button-clear {- visibility: visible;+ .item-container:hover .button-clear, .item-wrapper:hover .button-clear {+ visibility: visible;}.button-clear {@@ -45,6 +45,54 @@ export const baseStyle = css`width: 100%;min-width: 200px;}++ #errors {+ color: red;+ margin-right: 10px;+ flex: 1;+ display: flex;+ align-items: center;+ }++ #errors > or-icon {+ margin-right: 5px;+ }+`;++// language=CSS+export const panelStyle = css`+ #header-description {+ flex: 1;+ display: flex;+ flex-direction: row;+ }++ #header-buttons {+ flex: 0;+ }++ #content-wrapper {+ flex: 1;+ padding: 0 10px 10px 10px;+ }++ #content {+ display: flex;+ flex-direction: column;+ }++ #content > * {+ flex: 1;+ }++ .item-container + .item-container {+ padding-top: 10px;+ }++ #footer {+ margin-top: 10px;+ }+`;// language=HTML