bluerobotics / cockpit

An intuitive and customizable cross-platform ground control station for remote vehicles of all types.
https://blueos.cloud/docs/extensions/cockpit/1.0/overview
Other
54 stars 20 forks source link

Allow importing/providing custom widgets for dynamic loading #1341

Open ES-Alexander opened 3 days ago

ES-Alexander commented 3 days ago

Current behaviour

The only available widgets (standard and mini) are currently those that are built into Cockpit, which limits the functionality users can access, and means that widgets that don't belong in the mainstream Cockpit binary need to be maintained in custom Cockpit forks, which is inefficient and problematic to the unity of the project.

This has been part of the idea of Cockpit from the start - I just realised we don't actually have an Issue for it that people can keep track of.

Expected or desired behaviour

The most practical mechanism I can think of for this would be via file-based add-ons, that a user can either manually add to (and modify within) a folder, or "install" via a system like the proposed BlueOS Bazaar, which Cockpit can then look for and load as relevant (e.g. on startup, or on frontend refresh depending on the View).

This could start simple with just "put a Vue file [here] and Cockpit will load it", but fleshed out support should

  1. include detailed documentation of the Cockpit APIs that widgets have access to (e.g. for data sources/inputs, output/display formats, filtering pipelines, etc)
  2. allow defining relevant widget configuration parameters
  3. allow defining/declaring custom input sources and outputs that can be re-used in other widgets
  4. allow defining Actions that can be used elsewhere in Cockpit (e.g. via a joystick button)
    • this may be better suited as independent add-ons that can be installed as some form of bundle with the widget
  5. include some kind of tracking that could be used to replicate a given View/Profile by someone who does not currently have the relevant custom widgets (assuming they are installable from a known/common location)
    • this may require version management/tracking in some form of database, and hashes/checksums for validation
    • it could also be supported by the View/Profile save and download options including the custom widget files as relevant, although that could be inefficient, and potentially problematic if there are version or naming conflicts

Prerequisites

ES-Alexander commented 14 hours ago

Widgets API should include access to things like Cockpit's settings for data display, so that if a user chooses to view data in imperial units then the extension can also do that without needing an independent setting for it.

Thought of that use-case because of this.