eez-open / studio

Cross-platform low-code GUI and automation
https://www.envox.eu/studio/studio-introduction/
GNU General Public License v3.0
622 stars 101 forks source link

[Dashboard] New widget for tabular display of data #379

Closed mvladic closed 5 months ago

mvladic commented 6 months ago

Add new widget for tabular display of data from the database or imported files.

Table cells should be able to contain:

Enable:

Allow inserting table into instrument history.

More tasks:

fietser28 commented 6 months ago

I would like to have a button to 'load column from data': If I specify a structure type variable in the data field pressing this button will disable auto column and defines all the columns based on the elements of the structure pointed to in the data field. This allows to quickly make an editor/display for existing data structures.

Manually performing this action is very cumbersome, also because I don't know how to display both the definition of the structure and the definition of the table column at the same time. So for each element I have to switch in UI.

fietser28 commented 6 months ago

The auto column mode doesn't resolve enumerations. It shows numbers.

Found a workaround: Set type to lookup and manually define what to display:

image

This doesn't work if the field is editable: During edit the field is a number again.

fietser28 commented 6 months ago

Using a array of struct (in screenshots: profiles is array of batteryProfile struct) as data input: If the struct contains a double the value displayed is incorrect, both when using plaintext and money (which appears to the number formatting type):

image image image image

I think this is a very important use case.

mvladic commented 6 months ago

The auto column mode doesn't resolve enumerations. It shows numbers.

Auto column is implemented by the Tabulator library. But, it makes sense if input data comes from array:struct:... to override tabulator implementation since in this case Studio knows better.

fietser28 commented 6 months ago

The auto column mode doesn't resolve enumerations. It shows numbers.

Auto column is implemented by the Tabulator library. But, it makes sense if input data comes from array:struct:... to override tabulator implementation since in this case Studio knows better.

I agree but think the user knows even better but it is a lot of work to manually define all the columns that represent the struct elements. If there is a button that generates the column definitions with some sensible defaults, the users can easily customize the column afterwards. Pressing the button is a 1 time action.

mvladic commented 6 months ago

Sure, both features should be added.

fietser28 commented 6 months ago

Using a array of struct (in screenshots: profiles is array of batteryProfile struct) as data input: If the struct contains a double the value displayed is incorrect, both when using plaintext and money (which appears to the number formatting type):

Juist noticed this problem is also present in the JSON Stringify action. So probably this is a more generic issue regarding internal struct -> json conversion:

image
fietser28 commented 6 months ago

Using a array of struct (in screenshots: profiles is array of batteryProfile struct) as data input: If the struct contains a double the value displayed is incorrect, both when using plaintext and money (which appears to the number formatting type):

Juist noticed this problem is also present in the JSON Stringify action. So probably this is a more generic issue regarding internal struct -> json conversion:

Did some more test. It appears only Double type is not working, other variable types work fine:

image image
mvladic commented 6 months ago

I found what is the problem with doubles in struct. It only appears when struct is defined through "Default value". If you make a struct with Flow.makeValue("struct:mystruct", { ... }) it will work fine. The root cause for the problem is that doubles are not 8 byte aligned. I will commit the fix soon.

mvladic commented 6 months ago

Fix for doubles commited.

fietser28 commented 6 months ago

It works for all my use cases.

mvladic commented 6 months ago

I added command "Build From Structure Definition":

image

Also, when "Auto columns" is enabled we will override auto columns feature from Tabulator in case when table data is of structure type and infer columns info from Structure definition.

For now, only Title and Field is inferred. In the future we will try to infer other Column properties, please be free to suggest it.

mvladic commented 6 months ago

I forgot enum types, we should build formatter property from that.

fietser28 commented 6 months ago

This is how I'm now manually configured enum (still working out the exact settings for my case):

image

I think the generation/sync of the parameter list is important/convenient.

mvladic commented 6 months ago

It doesn't sync for now. For sync we should have a new property:

Auto columns         [ ]
Sync columns with structure definition: [x] ____my_struct [V]
mvladic commented 6 months ago

This is required because if you build from structure and changed some column property you don't want sync to overwrite it. So you are all for sync or no sync.

fietser28 commented 6 months ago

Working on my example I'm hitting a limitation when working with selections. Selections are nice to allow for the deletion, duplication, etc of rows in my use case:

image

Please add 'row selected' and 'row deselected' events to the widget. The event should return the index number of the index of the row selected (not the displayed order but the index of the data array given to the tablulator). See https://tabulator.info/docs/6.2/events#select

These events will allow me to implement a 'delete row' , 'duplicate row' and a 'use row' functions.

mvladic commented 6 months ago

I have added ON_ROW_SELECTED and ON_ROW_DESELECTED events. Both events outputs json value:

{
  index: number, // 0-based index in table data
  position: number // 1-based position in displayed rows
}

You will use .index.

mvladic commented 6 months ago

Also, columns properties for enum types are also generated:

image

But, this is still work in progress.

prasimix commented 5 months ago

Fixed