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

Revamp Web UI #173

Open
wants to merge 1 commit into
base: release-3.0.0
Choose a base branch
from
Open

Revamp Web UI #173

wants to merge 1 commit into from

Conversation

luispfgarces
Copy link
Contributor

@luispfgarces luispfgarces commented Nov 1, 2024

Description

Recreates the Web UI for Rules.Framework using Blazor (interactive server). The main focus of this development has been to keep the same level of functionality offered by the previous Web UI.

Functionalities

  1. Multiple rules engine instances support

image

  1. View rules engine instance details

image

  1. List rulesets

image

Now it includes filtering, ordering, and paging out of the box. It also is possible to directly navigate to list the rules of a particular ruleset.

  1. Search rules

image

The search of rules is now even more powerful and intuitive, the filtering form has been replaced with the grid built-in filters. Sorting and paging is also supported.

This functionality also supports multi-ruleset search, by selecting multiple rulesets.

It is possible to see for each rule's conditions by expanding it. It is possible to view the condition is a JSON format and in a tree format.
image
image

  1. Export rules - as JSON

image

Available under the Actions menu on Search rules, a modal dialog is presented with all rules selected as JSON. The exported JSON takes into account the selected rulesets and the filters applied to the grid. It is also possible to change the destination filename.

How to use

Register the Web UI on dependency injection. You have to let the Web UI know which rules engine instances you want it to expose, providing a unique name for each instance configured.

var builder = WebApplication.CreateBuilder(args);

builder
    .Services
    .AddRulesFrameworkWebUI(registrar =>
    {
        // It is possible to register instances synchronously and asynchronously.
        registrar.AddInstance("Readme example", (sp, name) => new BasicRulesEngineExample().RulesEngine)
            .AddInstance("Random rules example", async (sp, name) =>
            {
                var rulesProvider = new RulesEngineProvider(new RulesBuilder(new List<IRuleSpecificationsProvider>()
                {
                    new RulesRandomFactory()
                }));

                return await rulesProvider.GetRulesEngineAsync();
            });
    });

You also have to add the Web UI to the IApplicationBuilder, optionally configuring the options.

var app = builder.Build();

...

app.UseRulesFrameworkWebUI(opt =>
{
    // Only option available for now. If not customized, assumes the default "Rules Framework".
    opt.DocumentTitle = "Sample rules";
});

Warning

BREAKING CHANGES:

  • It was possible to set up on which resource the Web UI was exposed (e.g. /rules or /xyz). Now it is statically exposed on /rules-ui without the possibility of configuring it - Blazor's rooting limitation. It might possible to configure it but it will require experimenting on creating custom Blazor routing discovery classes.
  • Multiple rules engine instances were exposed under different resources. Now all rules engine instances are exposed under the same resource /rules-ui.
  • The conditions "pretty print" was removed.

Change checklist

  • Code follows the code rules guidelines of this project
  • Commit messages follow the commit rules of this project
  • I have self-reviewed my changes before submitting this pull request
  • I have covered new/changed code with new tests and/or adjusted existent ones
  • I have made changes necessary to update the documentation accordingly

Please also check the I want to contribute guidelines and make sure you have done accordingly.

Disclaimer

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement

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

Successfully merging this pull request may close these issues.

2 participants