diff --git a/docs/static/schemas/draft/2-0-0/application.d.ts b/docs/static/schemas/draft/2-0-0/application.d.ts index bd869d6a..c2df6596 100644 --- a/docs/static/schemas/draft/2-0-0/application.d.ts +++ b/docs/static/schemas/draft/2-0-0/application.d.ts @@ -194,10 +194,6 @@ export type NodeNamespace = string; * via the `patternProperty` "^[a-z]([a-z0-9_]?[a-z0-9])*$". */ export type InputTopics = string[]; -/** - * The human-readable name to display on the button - */ -export type ButtonDisplayName = string; /** * The human-readable name to display on the condition */ @@ -371,6 +367,10 @@ export type SequenceStep = Events | DelayStep | CheckConditionStep; * The ordered sequence steps to either trigger events, wait for a predefined time or check a condition */ export type SequenceSteps = SequenceStep[]; +/** + * The human-readable name to display on the button + */ +export type ButtonDisplayName = string; /** * The X position of the element on the graph */ @@ -391,7 +391,6 @@ export interface YAMLApplicationDescription { on_start?: OnStart; hardware?: HardwareInterfaces; components?: Components; - buttons?: Buttons; conditions?: Conditions; sequences?: Sequences; graph?: Graph; @@ -734,36 +733,6 @@ export interface ComponentPredicates { [k: string]: Events; } -/** - * A description of interactive buttons in the application graph - */ -export interface Buttons { - [k: string]: Button; -} - -/** - * A named interactive button - * - * This interface was referenced by `Buttons`'s JSON-Schema definition - * via the `patternProperty` "^[a-z]([a-z0-9_]?[a-z0-9])*$". - */ -export interface Button { - display_name?: ButtonDisplayName; - on_click?: OnClick; -} - -/** - * Events that are triggered when the button is pressed - */ -export interface OnClick { - load?: Load; - unload?: Unload; - call_service?: CallService; - lifecycle?: LifecycleEvent; - switch_controllers?: SwitchControllers; - set?: SetParameter; -} - /** * A description of logical conditions used to trigger events in the application */ @@ -901,6 +870,7 @@ export interface BlockingConditionStepWithTimeout { * Information for the graphical representation of the application */ export interface Graph { + buttons?: Buttons; positions?: { on_start?: Position; stop?: Position; @@ -922,6 +892,37 @@ export interface Graph { }; } +/** + * A description of interactive buttons in the application graph + */ +export interface Buttons { + [k: string]: Button; +} + +/** + * A named interactive button + * + * This interface was referenced by `Buttons`'s JSON-Schema definition + * via the `patternProperty` "^[a-z]([a-z0-9_]?[a-z0-9])*$". + */ +export interface Button { + display_name?: ButtonDisplayName; + on_click?: OnClick; +} + +/** + * Events that are triggered when the button is pressed + */ +export interface OnClick { + load?: Load; + unload?: Unload; + call_service?: CallService; + lifecycle?: LifecycleEvent; + switch_controllers?: SwitchControllers; + set?: SetParameter; + sequence?: ManageSequences; +} + /** * The position of the element on the graph * diff --git a/docs/static/schemas/draft/2-0-0/application.schema.json b/docs/static/schemas/draft/2-0-0/application.schema.json index d79f39ae..6c08ec0d 100644 --- a/docs/static/schemas/draft/2-0-0/application.schema.json +++ b/docs/static/schemas/draft/2-0-0/application.schema.json @@ -498,54 +498,6 @@ } } }, - "buttons": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Buttons", - "description": "A description of interactive buttons in the application graph", - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^[a-z]([a-z0-9_]?[a-z0-9])*$": { - "title": "Button", - "description": "A named interactive button", - "type": "object", - "additionalProperties": false, - "properties": { - "display_name": { - "title": "Button Display Name", - "description": "The human-readable name to display on the button", - "type": "string" - }, - "on_click": { - "title": "On Click", - "description": "Events that are triggered when the button is pressed", - "type": "object", - "additionalProperties": false, - "properties": { - "load": { - "$ref": "#/$defs/events/properties/load" - }, - "unload": { - "$ref": "#/$defs/events/properties/unload" - }, - "call_service": { - "$ref": "#/$defs/events/properties/call_service" - }, - "lifecycle": { - "$ref": "#/$defs/events/properties/lifecycle" - }, - "switch_controllers": { - "$ref": "#/$defs/events/properties/switch_controllers" - }, - "set": { - "$ref": "#/$defs/events/properties/set" - } - } - } - } - } - } - }, "conditions": { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Conditions", @@ -973,6 +925,57 @@ "type": "object", "additionalProperties": false, "properties": { + "buttons": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Buttons", + "description": "A description of interactive buttons in the application graph", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^[a-z]([a-z0-9_]?[a-z0-9])*$": { + "title": "Button", + "description": "A named interactive button", + "type": "object", + "additionalProperties": false, + "properties": { + "display_name": { + "title": "Button Display Name", + "description": "The human-readable name to display on the button", + "type": "string" + }, + "on_click": { + "title": "On Click", + "description": "Events that are triggered when the button is pressed", + "type": "object", + "additionalProperties": false, + "properties": { + "load": { + "$ref": "#/$defs/events/properties/load" + }, + "unload": { + "$ref": "#/$defs/events/properties/unload" + }, + "call_service": { + "$ref": "#/$defs/events/properties/call_service" + }, + "lifecycle": { + "$ref": "#/$defs/events/properties/lifecycle" + }, + "switch_controllers": { + "$ref": "#/$defs/events/properties/switch_controllers" + }, + "set": { + "$ref": "#/$defs/events/properties/set" + }, + "sequence": { + "$ref": "#/$defs/events/properties/sequence" + } + } + } + } + } + } + }, "positions": { "type": "object", "additionalProperties": false, diff --git a/schemas/applications/CHANGELOG.md b/schemas/applications/CHANGELOG.md index 420e688b..06b2facf 100644 --- a/schemas/applications/CHANGELOG.md +++ b/schemas/applications/CHANGELOG.md @@ -21,6 +21,7 @@ Release Versions: and additional packages - Application metadata can be defined under the top-level `metadata` property including a name, description and tags - Any additional user data can be included in an application under the top-level `userdata` property +- Interactive UI buttons and all position data is now defined under a top-level `graph` property - A running application can be stopped with the `application: stop` event from any event source - Components, controllers and hardware support dedicated transition events such as `on_load`, `on_activate` and `on_error` which behave as event triggers similar to predicates diff --git a/schemas/applications/README.md b/schemas/applications/README.md index f4261fe7..8a9ace4f 100644 --- a/schemas/applications/README.md +++ b/schemas/applications/README.md @@ -104,6 +104,32 @@ graph: y: 500 ``` +#### UI buttons + +The `buttons` property was previously a top-level field that defined the behavior of interactive UI elements in the +application graph. The definition of buttons have now been moved under the new `graph` property, as these elements +are only used by the application graph. + +Before: + +```yaml +buttons: + my_button: + on_click: + load: ... +``` + +After: + +```yaml +graph: + buttons: + my_button: + on_click: + load: ... +``` + + #### Events on start The `on_start` property is now only permitted to load components, load hardware and start sequences. Previously, it was diff --git a/schemas/applications/schema/application.schema.json b/schemas/applications/schema/application.schema.json index 9a94380c..6d49eb5f 100644 --- a/schemas/applications/schema/application.schema.json +++ b/schemas/applications/schema/application.schema.json @@ -136,9 +136,6 @@ "components": { "$ref": "components.schema.json" }, - "buttons": { - "$ref": "buttons.schema.json" - }, "conditions": { "$ref": "conditions.schema.json" }, diff --git a/schemas/applications/schema/buttons.schema.json b/schemas/applications/schema/buttons.schema.json index 20423423..a41a32bf 100644 --- a/schemas/applications/schema/buttons.schema.json +++ b/schemas/applications/schema/buttons.schema.json @@ -39,6 +39,9 @@ }, "set": { "$ref": "common/events/set.schema.json" + }, + "sequence": { + "$ref": "common/events/sequence.schema.json" } } } diff --git a/schemas/applications/schema/graph.schema.json b/schemas/applications/schema/graph.schema.json index 03a80638..70970d2f 100644 --- a/schemas/applications/schema/graph.schema.json +++ b/schemas/applications/schema/graph.schema.json @@ -5,6 +5,9 @@ "type": "object", "additionalProperties": false, "properties": { + "buttons": { + "$ref": "buttons.schema.json" + }, "positions": { "type": "object", "additionalProperties": false,