2023-10-18 23:03:55 +00:00
|
|
|
using System.Text.Json;
|
|
|
|
|
using Elsa.Studio.Dashboard.Extensions;
|
|
|
|
|
using Elsa.Studio.Shell;
|
|
|
|
|
using Elsa.Studio.Shell.Extensions;
|
|
|
|
|
using Elsa.Studio.Workflows.Extensions;
|
|
|
|
|
using Elsa.Studio.Contracts;
|
|
|
|
|
using Elsa.Studio.Core.BlazorWasm.Extensions;
|
2023-11-20 21:32:20 +00:00
|
|
|
using Elsa.Studio.Extensions;
|
2023-10-18 23:03:55 +00:00
|
|
|
using Elsa.Studio.Login.BlazorWasm.Extensions;
|
2023-12-09 21:10:16 +00:00
|
|
|
using Elsa.Studio.Login.HttpMessageHandlers;
|
2023-11-20 21:32:20 +00:00
|
|
|
using Elsa.Studio.Options;
|
2023-10-18 23:03:55 +00:00
|
|
|
using Elsa.Studio.Workflows.Designer.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Microsoft.JSInterop;
|
|
|
|
|
|
|
|
|
|
// Build the host.
|
|
|
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
|
|
|
|
|
|
// Register root components.
|
|
|
|
|
builder.RootComponents.Add<App>("#app");
|
|
|
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
|
|
|
|
builder.RootComponents.RegisterCustomElsaStudioElements();
|
|
|
|
|
|
|
|
|
|
// Register shell services and modules.
|
|
|
|
|
builder.Services.AddCore();
|
|
|
|
|
builder.Services.AddShell();
|
2023-12-29 20:54:27 +00:00
|
|
|
builder.Services.AddRemoteBackend(elsaClient => elsaClient.AuthenticationHandler = typeof(AuthenticatingApiHttpMessageHandler));
|
2023-10-18 23:03:55 +00:00
|
|
|
builder.Services.AddLoginModule();
|
|
|
|
|
builder.Services.AddDashboardModule();
|
|
|
|
|
builder.Services.AddWorkflowsModule();
|
|
|
|
|
|
|
|
|
|
// Build the application.
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Apply client config.
|
|
|
|
|
var js = app.Services.GetRequiredService<IJSRuntime>();
|
|
|
|
|
var clientConfig = await js.InvokeAsync<JsonElement>("getClientConfig");
|
|
|
|
|
var apiUrl = clientConfig.GetProperty("apiUrl").GetString()!;
|
|
|
|
|
app.Services.GetRequiredService<IOptions<BackendOptions>>().Value.Url = new Uri(apiUrl);
|
|
|
|
|
|
|
|
|
|
// Run each startup task.
|
|
|
|
|
var startupTaskRunner = app.Services.GetRequiredService<IStartupTaskRunner>();
|
|
|
|
|
await startupTaskRunner.RunStartupTasksAsync();
|
|
|
|
|
|
|
|
|
|
// Run the application.
|
|
|
|
|
await app.RunAsync();
|