Creating Blazor-Based Frontend Plugins for the Battery Test System Web UI

Blazor is the main technology for integrators to develop Web UI environments to control and monitor the Battery Test System. Using Blazor, you can develop plugins that fully customize the appearance and functionality of the Web UI to suit your application.

To use Blazor-based Web UI plugins, you must install the following software in your development environment:

  • .NET 6.0.2 (SDK 6.0.200) or newer
  • Battery Test System Web Server 2022 or newer

To create Blazor-based Web UI plugins, you should have competence in the following development technologies:

  • Blazor
  • ASP .NET Core
  • C#/.NET

Additionally, NI recommends that you be familiar with the following technologies:

  • FluentUI: a library of UI components
  • Bulma: a CSS framework for user interfaces

To use Blazor-based plugins, you first need to install a project template. You can then develop the individual plugins. You need to install the project template on a system once; you can then create as many plugins as you need.

Complete the following steps to add a Blazor-based plugin to your Web UI environment. If you are creating a Blazor-based plugin for the first time, start from the beginning; if you have already completed first-time setup, skip to Blazor-Based Plugin Creation.

First-Time Setup for Blazor-Based Plugins
  1. Open a command prompt and install the project template for Blazor-based plugins with the following command:
    dotnet new --install "C:\Program Files\National Instruments\Battery Test System\PluginTemplates\BatteryTestUIPlugins.ProjectTemplates.1.0.0.nupkg"
  2. Verify that everything has installed correctly by running the following command:
    dotnet new --list --tag BatteryTest
    Your installation was successful if you receive the following message:


Blazor-Based Plugin Creation
  1. In the command prompt, change the directory to the folder that will contain the source code for your Blazor-based plugins.
  2. Create a page plugin project by running the following command:
    dotnet new batterytest-uiplugins --name <Plugin Name> --output <Plugin Folder Name>

    A new directory with the Plugin Folder Name you specify is created in your current directory, and a new Plugin Name.csproj file, along with supporting files, is created within the new directory.

    The default plugin that is created modifies the home page of the Web UI to implement a basic counter.

  3. Modify the plugin to suit your application. For plugin pages, consider editing the customizable settings in the specific PageItem class, for example, HomePageItem class. For plugin components, consider customizing the name given to your plugin in the AddCustomComponentPlugins function in the PluginServiceRegistrar class.
    Refer to Property Reference for Battery Test System Web UI Web Page Host Plugins for more information about customizing the properties.
  4. Build the new plugin project to generate a .dll, which the Web UI uses to incorporate the plugin.
    • Command prompt: Change the directory to the folder that contains the plugin and use dotnet build to build Plugin Name.csproj. Refer to Microsoft documentation on dotnet build for options.
    • VisualStudio: Open Plugin Name.csproj and build with Build » Plugin Name.
  5. For the BTS Server for Windows, do the following:
    1. (Windows) Create a folder named for the plugin you implemented in the following location: %Public%\Public Documents\National Instruments\Battery Test System\WebApplication\Web UI Plugins\Plugin Folder Name.
    2. Consider if you need to remove any existing plugins from %Public%\Public Documents\National Instruments\Battery Test System\WebApplication\Web UI Plugins. For instance, if your new plugin is for a new Home page, you can choose to remove any existing home page plugin dll.
    3. (Windows) Copy the plugin's .dll(s) and Resources folder, if applicable, into this new folder.
    4. (Windows) Restart the BTS Web UI service by opening the Windows Services Manager, selecting NI Battery Test System Web Server, and clicking Restart the service.
  6. For the BTS Server with SystemLink Enterprise, do the following:
    1. Zip all of the plugins into a zip file.
      Do not place the plugins in any nested folders when zipping. Individual plugin folders must be present directly at the root itself once zipped.

      In the following example, the BTS Server can only discover plugins in the correct case. In the incorrect case, the BTS Server cannot discover either plugin.

      CorrectIncorrect
      Plugin.zip
          Plugin-1
              (Plugin-1 files)
          Plugin-2
              (Plugin-2 files)
      Plugin.zip
          SomeIntermediateFolder    
              Plugin-1
                  (Plugin-1 files)
          SomeOtherIntermediateFolder
              Plugin-2
                  (Plugin-2 files)
    2. Upload the zip file to any storage which supports downloading a file using a URL.
    3. Specify the URL and the authentication information in the pluginDownloader section of the helm chart file.
  7. Verify that the new plugin appears correctly by viewing the Web UI URL in your browser. If there are errors loading your page, the browser's console window might show the errors. If there are errors loading your page, the browser's console window might show the errors.