Skip to content

Commit

Permalink
feat!: move buttons under graph property and include sequence events (#…
Browse files Browse the repository at this point in the history
…179)

* feat: add sequence events to buttons on_click

* feat!: move buttons under the graph property

* build: generate static draft schema

* docs: changelog
  • Loading branch information
eeberhard authored Oct 2, 2024
1 parent e133207 commit fbc22dc
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 86 deletions.
71 changes: 36 additions & 35 deletions docs/static/schemas/draft/2-0-0/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -391,7 +391,6 @@ export interface YAMLApplicationDescription {
on_start?: OnStart;
hardware?: HardwareInterfaces;
components?: Components;
buttons?: Buttons;
conditions?: Conditions;
sequences?: Sequences;
graph?: Graph;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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
*
Expand Down
99 changes: 51 additions & 48 deletions docs/static/schemas/draft/2-0-0/application.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions schemas/applications/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions schemas/applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions schemas/applications/schema/application.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@
"components": {
"$ref": "components.schema.json"
},
"buttons": {
"$ref": "buttons.schema.json"
},
"conditions": {
"$ref": "conditions.schema.json"
},
Expand Down
3 changes: 3 additions & 0 deletions schemas/applications/schema/buttons.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
},
"set": {
"$ref": "common/events/set.schema.json"
},
"sequence": {
"$ref": "common/events/sequence.schema.json"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions schemas/applications/schema/graph.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"type": "object",
"additionalProperties": false,
"properties": {
"buttons": {
"$ref": "buttons.schema.json"
},
"positions": {
"type": "object",
"additionalProperties": false,
Expand Down

0 comments on commit fbc22dc

Please sign in to comment.