data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

⭐ [Enhancement]: Configuration Editor (UI)

Open JerryNixon opened this issue 1 year ago • 1 comments

What is it?

A UI designed to create, view & edit a dab-config.json file.

Why?

The configuration file is getting more complex, easier to get wrong.

  • Some customers have several hundred entities

Where?

As part of the dotnet tool install process.

How?

The configurator is a Blazor Server app. This is the same approach as the .NET Aspire dashboard. To host a Blazor Server app within a command-line console app (such as how Data API builder's CLI might host a configurator UI), simply use Kestrel, the web server that comes with ASP.NET Core which DAB already uses.

Basic flow:

  1. Configure WebHostBuilder inside the CLI to serve Blazor.
  2. When the CLI starts, spin up Kestrel, which serves Blazor.
  3. The CLI launches the browser to open the configurator.

Server Blazor

Blazor Server uses a persistent SignalR connection to handle UI interactions. UI events (like button clicks) are sent to the server, processed there, and the resulting changes are returned in real time. All app logic, event handling, data binding, and the component lifecycle are managed in C#, allowing you to write both client-side and server-side logic in C#. This eliminates the need for most JavaScript in web development. If needed, JavaScript interop allows optional integration with JavaScript libraries or browser APIs. Razor syntax (HTML + C#) renders dynamic content, and Blazor Server fully supports HTML and CSS, including CSS frameworks (like Bootstrap) and CSS isolation for scoped styling.

  • Blazor Server builds web apps in C# with minimal or no JavaScript.
  • It fully supports Razor, HTML, and CSS for the UI.
  • JavaScript Interop is available for optional integrations.

File system access

Blazor Server can access local files on the server-side because the app runs on the server. You can use C#'s standard file I/O operations (System.IO) to read, write, or modify files on the server where the Blazor Server app is hosted.

How to launch

From the CLI: dab edit -c dab-config.json

Requirements

  1. Cross-platform
  2. Browser-based (starting with Edge)
  3. Development-only, no authentication
  4. No prerequisites other than dotnet tools microsoft.dataapibuilder
  5. Support environment variables

Features

  1. Add additional data-sources
  2. Add entities from data-source
  3. Visualize relationships
  4. Visualize dab validate
  5. Generate Cosmos schema

Use Cases

Role Feature Purpose
Developer Get started from scratch Create a configuration file and set up entities array.
Developer Add an additional data source Introduce and manage a new data source.
Developer Add entities from database Add more entities to the configuration array.
Developer Validate entities in configuration Verify entities and relationships in the configuration.
Developer Update existing entity Modify an existing entity’s properties or relationships.
Developer Remove an entity Safely remove an entity from the configuration.
Developer Edit runtime settings Adjust performance, caching, or other runtime configurations.
Developer Manage authentication and authorization Configure security settings like authentication providers and role-based access.
Developer Rollback configuration changes Revert to fields or files to default values.

Questions

  • What UI standard should we use?
    • First choice, Visual Studio's new preview configuration editor
    • Second choice, VS Code's existing configuration editor
  • Is the configurator independent of the engine?
  • Does the configurator rely on hot reload?

Related issues that will be closed

  • #1757
  • Making entities optional is still a valid scenario.
  • #1654
  • This was the original specification. Still interesting, but this is the core Enhancement now.
  • #1622
  • This is no longer in scope as the configurator will load from the command line.
  • #1623
  • This is no longer in scope as the configurator will load from the command line.
  • #1133
  • This issue will be closed with "wontfix".

JerryNixon avatar Sep 05 '24 19:09 JerryNixon

Does the dab tool ship the ASP.NET Core runtime? I think it must.

JerryNixon avatar Oct 11 '24 15:10 JerryNixon