cockpit icon indicating copy to clipboard operation
cockpit copied to clipboard

Allow importing/providing custom widgets for dynamic loading

Open ES-Alexander opened this issue 1 year ago • 4 comments

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

  • [X] I have checked to make sure that a similar request has not already been filed or fixed.

ES-Alexander avatar Sep 16 '24 14:09 ES-Alexander

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.

ES-Alexander avatar Sep 19 '24 07:09 ES-Alexander

An interim option could be to allow loading widget templates from JSON files / from the BlueOS Bag of Holdings, which could be provided by Extensions (or manually by users) to create basic data display/input interfaces, with URLs defining where value changes should come from / be sent to.

Related to the functionality @ArturoManzoli is making for #1291

ES-Alexander avatar Sep 23 '24 20:09 ES-Alexander

Some vaguely related functionality was added in #1499

ES-Alexander avatar Jan 28 '25 14:01 ES-Alexander

With the inclusion of Actions and the Data Lake in Cockpit, it is no longer sufficient to just import the code for a widget (akin to what is provided by a DIY widget).

Full support for importing custom widgets would require something like the import unification process mentioned here, which has also been discussed to some extent in this forum thread.

ES-Alexander avatar Sep 10 '25 18:09 ES-Alexander