VolkovLabs / business-text

The Business Text panel plugin allows you to construct a text visualization template from the values of a dataset returned by a data source query.
https://volkovlabs.io
Apache License 2.0
83 stars 13 forks source link

Cant access any children of data.data[0] anymore after update using mixed data panel #275

Closed craftzneko closed 9 months ago

craftzneko commented 9 months ago

Cant access any children of data.data[0] anymore after update using mixed data panel

I have a data source for postgres and SQL and have set mixed, set panel template to us all data. Previously i could access elements like this data.data[0].summaryjson.computername now i can only access data.data[0[ anything i try to access underneath just returns undefined

craftzneko commented 9 months ago

If in console i take data.data[0] and store as a global variable in the console i can access the child elements fine image But in the plugin trying to access any child element of data.data[0] just returns undefined. I know the structure is correct because of the test above

vitPinchuk commented 9 months ago

@craftzneko Hi.

I am trying to reproduce the issue with the following steps:

1) Set the DataSource to Grafana. 2) Select the Query Type as 'List Public Files'. 3) In the Editors section, add the following JS code under 'Before Content Rendering': console.log('console data >>>> ', data) console.log('console data.data[0].name >>>> ', data.data[0].name)

When using the 'All Rows' render template, I can see the result for data.data[0].name. However, when using the 'All Data' render template, I do not see the result for data.data[0].name.

2024-02-26_13-02

Could you please provide more information and check the template rendering? It's possible that the issue in the template rendering.

Thanks

craftzneko commented 9 months ago

HI @vitPinchuk that's what i am seeing, I actually figured out that if you use data.data[0][0].name it will then work. So its like its got another parent called [0] in between the parent and the child items

vitPinchuk commented 9 months ago

Hi @craftzneko. It's the current implementation to minimize the code base.

@mikhail-vl, I think we need to add an example to the documentation.

mikhail-vl commented 9 months ago

@vitPinchuk please open documentation PR with updates and examples.