WebVella/WebVella-ERP

Configure form and chart data sources

Closed this issue · 5 comments

Hello, this was very nice and easy to setup.

Driver side note/suggestion, I would recommend a different driver from Postgres for .Net it was much easier to setup and run and much more currently maintained. We can add it as a package right here, so it auto updates on a new release. Is it ok with you if I add the suggestions here on the Wiki?


Goal: I was trying to setup a simple dashboard with 6 charts and test web hooks.
New page: I was able to create a site page and add a chart and form. It was smooth like WP elementor and easy.

But, I got stuck in how to change the chart type and set X,Y or Z values to the dimensions. I looked at the home page.

image

Example you can get from the kitchensink app of the component project here: https://github.com/WebVella/TagHelpers

In general it is an object following the api of echarts, the have plenty good docummentation here:
https://echarts.apache.org/en/api.html#echarts

thanks for the help @bzashev, Im sorry my question was poorly worded.

I really like your options to configure data source. Its well thought out and well implement, just need some clarification. Do you want my help with some code/documentation when I have some free time.

Question: Inside the data source, I was asking when to select which data source option.

Is this correct (from GUI) below?

  • Step 1: Select data source
  • Step 2: I want Select which belongs to X and which belongs to Y.

Hey,
there are two things to consider first:

  1. Datasource creation - datasources could be created either from the UI or by code. More here https://webvella.com/documents/developer/data-sources/overview
  2. Datasource usage - on most places you can provide info by a datasource (there is an icon button on the right of the fields that support it). In general there you just need to click the icon button, be sure the DataSource option is selected and from there on it is a typeahead. There is something that you need to do first though. You need to add the datasource to the PageModel, from the page management tabs. While adding it, you can provide a different name if needed, and setup options.

So data sources can only be inside an SDK, and then inside as an entity, correct?

I previously mistook data sources and thought it would show a list of controller Get Actions.. / web API

there is an api controller and mehtod that can get you data based on data sources, but the assumption is that if you already are outside of a PageModel, you will just use a service method.
If you are in a PageModel - you can get the added datasources or any other property from it. This is widely used when developing components.
Each Page component if done properly receives
public async Task<IViewComponentResult> InvokeAsync(PageComponentContext context)
the context as a parameter. Then you can get a page model property by:
var currentRecord = context.DataModel.GetProperty("Record") as EntityRecord;
you can also get a datasource the same way as once added to the pagemodel it is just another property.

From there EQL datasources are mainly used for quick data selections. Code datasources are preferred when either a more complex logic needs to be applied or it is used on many places, and it is better for support to be on one place.

Have in mind that there is also alternatives to providing data - like code or the new one - code snippet. (not documented yet).
In your plugin make a Snippets folder. There you can create a code file with the same contents that the "code" template is suggesting. Something like this:
public class CodeDataSourceSnippet : ICodeVariable { public object Evaluate(BaseErpPageModel pageModel){} }
After app rebuild this file name will appear in the Snippet tab typeahead. Very useful when you want to create a code datasource, but you need the entire pagemodel and do not want to bother providing it as parameters each time you use it.