Hello,
I’m currently working on a small plugin that visualizes data from a database. However, I’ve come to a point where I need to create options that allow users to filter data using several keys. These filtering keys should be obtained from the same data source that is selected for the panel. Unfortunately, I’m facing some difficulties in this area.
Here’s a rough outline of my code:
const fetchSites = async (context: FieldOverrideContext): Promise<Array<SelectableValue<string>>> => {
try {
const panelDataSourceID = // **??? how**
if (panelDataSourceID !== undefined) {
const dataSource = await getDataSourceSrv().get(panelDataSourceID);
const qResult = dataSource.query(...);
const result: = // convert qResult to the correct data type, as covered.
return result;
} else {
return [];
}
} catch (error) {
console.error('Error fetching data:', error);
}
return [];
}
export const plugin = new PanelPlugin<MyPanelOptions>(MyPanel)
.setPanelOptions((builder) => {
return builder
.addSelect({
path: 'optionName',
name: 'Name of the option',
settings: {
options: [],
getOptions: fetchOpts,
},
})
});
Could you please help me understand if achieving the expected outcome is even possible? Your guidance would be greatly appreciated.