ni / grafana-plugins

Grafana plugins and configuration for SystemLink Server
MIT License
2 stars 3 forks source link

[Notebooks] Add support for query variables #40

Closed mure closed 2 years ago

mure commented 2 years ago

https://ni.visualstudio.com/DevCentral/_workitems/edit/1820088

I extended from the API defined here, specifically the DataSourceVariableSupport class. This makes the QueryEditor component appear in the UI when adding a query variable, so users can use the output of a notebook to populate their variables:

152429457-6d4bfb13-353f-49f6-aea6-28904d45de24

By default, Grafana's internals uses the first string column in the resulting dataframe to populate the dataframe. So if your notebook result is image then the variable's values will be [Martha, Tim, Robert, Georgia]. I also added a new supported return type 'array' for notebooks to make setting variables more explicit. e.g.

array_result = {
    'type': 'array',
    'id': 'possible_animals',
    'data': ['dog', 'cat', 'cow', 'zebra', 'fish']
}
pvallone commented 2 years ago

Approving so I don't block this, but I'm still ramping up on typescript so please do wait for the other reviewers.