Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect all easy data maps #152

Open
Alerinos opened this issue Sep 21, 2022 · 0 comments
Open

Detect all easy data maps #152

Alerinos opened this issue Sep 21, 2022 · 0 comments

Comments

@Alerinos
Copy link

Hi, my system is split into plugins.
Each plug-in has a separate database.
Easy data is loaded during initialization.
I have a separate project as a dashboard, everything happens automatically there. Unfortunately, it needs a method to discover all MapEasyData endpoints.

                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapEasyData(options =>
                    {
                        options.Endpoint = "/_crud/culture";
                        options.UseDbContext<Stand.Plugins.Culture.Context>(opts =>
                        {
                            opts.CustomizeModel(model =>
                            {
                                model.Entity<Stand.Plugins.Culture.Models.Country>()
                                    .Attribute(o => o.Language).SetShowInLookup(true);
                            });
                        });
                    });

                    endpoints.MapEasyData(options =>
                    {
                        options.Endpoint = "/_crud/places";
                        options.UseDbContext<Stand.Plugins.Places.Context>();
                    });
                });

How can I do this?
I need it to generate navigation, so if we have 10 endpoints, I can do this:

foreach(var map in EasyData.GetAllEndPoints){
<a href="database/{map.Name}">{map.Name}</a>
}

My database.razor:

@page "/database/{module}/{url?}"
@layout MainLayout
@implements IAsyncDisposable
@inject IJSRuntime JSRuntime

@attribute [Authorize] 

<Card Bordered="true">
    <div id="EasyDataContainer"></div>
</Card>

@code {

    [Parameter]
    public string Module { get; set; } = "";

    [Parameter]
    public string Url { get; set; } = "";

    private bool first = true;

    protected override async Task OnParametersSetAsync()
    {
        if(first == false)
        {
            await this.OnAfterRenderAsync(true);
        }

        //JSRuntime.InvokeVoidAsync("blazorExtensions.EasyData", Module);
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender) {
            await JSRuntime.InvokeVoidAsync("stopEasyData");
            await JSRuntime.InvokeVoidAsync("runEasyData", Module.ToLower());
            first = false;
        }
        await base.OnAfterRenderAsync(firstRender);
    }
    
    private bool _disposed = false;

    public async ValueTask DisposeAsync()
    {
        if (!_disposed)
        {
            _disposed = true;

            await JSRuntime.InvokeVoidAsync("stopEasyData");
        }
    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant