Examples › dataclass viewer › Dataclass viewer: a synthetic facility
Dataclass viewer: a synthetic facility
A synthetic facility's inputs, DEMO_FACILITY and the belt and pick move it references (made-up example values,
not real data), as an outline that folds, a sheet per field with its range, basis and source, a form that edits a value inside its range, and the
viewer's Rows table.
The .base file and its data
Every tab above is one entry of this file; the views read these rows. ⋯ in the toolbar copies the current view as YAML.
# A synthetic facility's inputs (made-up example values): py_dataclass_viewer's Outline, Sheet and Controls views
# (py_dataclass_viewer/static/app.js) over DEMO_FACILITY as rows. Obsidian Bases grammar plus data-ui's keys (docs/CONTRACT.md §5).
data: facility.json
views:
- type: list
name: Outline
tree: { parent: parent }
order: [name, value, refers_to]
markers: none
separator: " "
- type: list
name: Outline with sources
tree: { parent: parent }
order: [name, value, measured_by, file]
markers: none
indentProperties: true
- type: record
name: Field
filters: 'kind == "value"'
record:
sections:
- { name: Value, properties: [value, measured_by] }
- { name: Where it lives, properties: [path, class, type, file, hidden] }
- type: record
name: Edit
filters: 'kind == "value"'
edit: true
record:
sections:
- { name: Value, properties: [value, measured_by] }
- { name: Where it lives, properties: [path, file] }
- type: table
name: Rows
filters: 'kind == "value"'
order: [name, value, measured_by, file]
groupBy: { property: class }
edit: true
record:
sections:
- { name: Value, properties: [value, measured_by] }
- { name: Where it lives, properties: [path, file] }
- type: table
name: Outline table
tree: { parent: parent }
order: [name, value, kind, measured_by, file]
// facility.json: 16 rows, 9 KB; the first 3
{
"id": "demo-facility",
"title": "A synthetic facility's inputs (example values)",
"titleProperty": "name",
"source": "SYNTHETIC: written by source/make.py for this example; not real facility data",
"properties": {
"name": {
"type": "text",
"label": "Field",
"readOnly": true
},
"path": {
"type": "text",
"label": "Path",
"readOnly": true,
"note": "the dotted name the viewer's edit API addresses"
},
"parent": {
"type": "text",
"label": "Parent",
"hidden": true,
"readOnly": true
},
"kind": {
"type": "text",
"label": "Kind",
"display": "badge",
"readOnly": true,
"colors": {
"instance": 7,
"reference": 1,
"nested": 3,
"value": 0
}
},
"class": {
"type": "text",
"label": "Class",
"readOnly": true
},
"type": {
"type": "text",
"label": "Type",
"readOnly": true
},
"value": {
"type": "number",
"label": "Value",
"note": "Value(value, unit, low=, high=, basis=, source=, notes=)"
},
"measured_by": {
"type": "text",
"label": "Measured by",
"note": "what would measure it (the Value's measured_by)"
},
"refers_to": {
"type": "text",
"label": "Refers to",
"readOnly": true
},
"file": {
"type": "text",
"label": "File",
"readOnly": true
},
"hidden": {
"type": "boolean",
"label": "Hidden in the view",
"readOnly": true,
"note": "the class's view_hidden"
}
},
"rows": [
{
"id": "DEMO_FACILITY",
"name": "DEMO_FACILITY",
"path": "DEMO_FACILITY",
"parent": null,
"kind": "instance",
"class": "Facility",
"type": "Facility",
"value": null,
"measured_by": null,
"file": "facility.py",
"hidden": false,
"refers_to": null
},
{
"id": "DEMO_FACILITY.belt",
"name": "belt",
"path": "DEMO_FACILITY.belt",
"parent": "DEMO_FACILITY",
"kind": "reference",
"class": "Belt",
"type": "Belt",
"value": null,
"measured_by": null,
"file": "belt.py",
"hidden": false,
"refers_to": "DEMO_BELT"
},
{
"id": "DEMO_FACILITY.belt.width_m",
"name": "width_m",
"path": "DEMO_FACILITY.belt.width_m",
"parent": "DEMO_FACILITY.belt",
"kind": "value",
"class": "Belt",
"type": "float",
"value": {
"value": 0.9,
"unit": "m",
"low": 0.5,
"high": 1.6,
"basis": "chosen",
"source": "SYNTHETIC example value, not real data: a mid-size conveyor",
"note": "A chosen design input (synthetic)"
},
"measured_by": "a layout drawing",
"file": "belt.py",
"hidden": false,
"refers_to": null
}
]
}README.md
# Dataclass viewer: a synthetic facility
A synthetic facility's inputs, `DEMO_FACILITY` and the belt and pick move it references (made-up example values,
not real data), as an outline that folds, a sheet per field with its range, basis and source, a form that edits a value inside its range, and the
viewer's Rows table.
- **App:** dataclass viewer
- **Replaces:** the hand-rolled data views of py_dataclass_viewer (`static/app.js` in `~/py_dataclass_viewer`):
the Outline (`outlineView`, `treeNodes`), the Sheet and the Controls (`controlsView`, `ctlRow`). The viewer keeps
its file tree, its CodeMirror source and its byte-splice writes; the views over the values are the kit's.
- **Shows:** `type: list` with `tree: {parent}` (an outline; references and nested classes fold),
`indentProperties`, the same outline as a table (`type: table` with `tree:`), `type: record` with sections (each `Value(...)` as a value, its range, basis mark and source),
and `edit: true`: a number input bounded by the Value's own `low` / `high`, structural fields read-only. This case's `site.json` makes the page
`editable`, so a save lands in memory and shows in every view; a read-only host refuses it and says why. In the
viewer, the host's `acceptEdit` would be its `apply()`. The Rows table carries the same `record.sections` and
`edit: true`, so a row's side peek is that form too (the viewer's Controls beside its rows).
- **Data:** `facility.json`, 16 rows written by `source/make.py`. Every value, range, source and "measured by" is
SYNTHETIC: made up for this example and labelled so, in the shape of the viewer's `Value(...)` fields (an instance,
a referenced belt and pick move, their fields). No real facility or simulation input is published here.
The original UI it replaces
the hand-rolled data views of py_dataclass_viewer (static/app.js in ~/py_dataclass_viewer): the Outline (outlineView, treeNodes), the Sheet and the Controls (controlsView, ctlRow). The viewer keeps its file tree, its CodeMirror source and its byte-splice writes; the views over the values are the kit's.
What it shows
type: list with tree: {parent} (an outline; references and nested classes fold), indentProperties, the same outline as a table (type: table with tree:), type: record with sections (each Value(...) as a value, its range, basis mark and source), and edit: true: a number input bounded by the Value's own low / high, structural fields read-only. This case's site.json makes the page editable, so a save lands in memory and shows in every view; a read-only host refuses it and says why. In the viewer, the host's acceptEdit would be its apply(). The Rows table carries the same record.sections and edit: true, so a row's side peek is that form too (the viewer's Controls beside its rows).
Data
facility.json, 16 rows written by source/make.py. Every value, range, source and "measured by" is SYNTHETIC: made up for this example and labelled so, in the shape of the viewer's Value(...) fields (an instance, a referenced belt and pick move, their fields). No real facility or simulation input is published here.