diff --git a/src/AltGen.Console/Generated/Constants.cs b/src/AltGen.Console/Generated/Constants.cs index 4d14333..6066b7a 100644 --- a/src/AltGen.Console/Generated/Constants.cs +++ b/src/AltGen.Console/Generated/Constants.cs @@ -3,4 +3,4 @@ namespace AltGen.Console.Generated; static class Constants { public const string AltGenApiUri = "https://localhost:7297"; -} \ No newline at end of file +} diff --git a/src/AltGen.Web.Client/AltGen.Web.Client.csproj b/src/AltGen.Web.Client/AltGen.Web.Client.csproj new file mode 100644 index 0000000..c2ddab3 --- /dev/null +++ b/src/AltGen.Web.Client/AltGen.Web.Client.csproj @@ -0,0 +1,15 @@ + + + + net9.0 + enable + enable + true + Default + + + + + + + diff --git a/src/AltGen.Web.Client/Components/Pages/Home.razor b/src/AltGen.Web.Client/Components/Pages/Home.razor new file mode 100644 index 0000000..b04083a --- /dev/null +++ b/src/AltGen.Web.Client/Components/Pages/Home.razor @@ -0,0 +1,24 @@ +@inject ILogger Logger +@page "/" +@rendermode InteractiveWebAssembly + +AltGen.Web + +

AI Generated Alt Text

+ +
+ + + + +@code { + private void LoadFiles(InputFileChangeEventArgs e) + { + var files = e.GetMultipleFiles(5); + + foreach (var file in files) + { + Logger.LogInformation("File loaded: {Name}, Size: {Size}", file.Name, file.Size); + } + } +} \ No newline at end of file diff --git a/src/AltGen.Web.Client/Program.cs b/src/AltGen.Web.Client/Program.cs new file mode 100644 index 0000000..519269f --- /dev/null +++ b/src/AltGen.Web.Client/Program.cs @@ -0,0 +1,5 @@ +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); + +await builder.Build().RunAsync(); diff --git a/src/AltGen.Web.Client/_Imports.razor b/src/AltGen.Web.Client/_Imports.razor new file mode 100644 index 0000000..0662d9c --- /dev/null +++ b/src/AltGen.Web.Client/_Imports.razor @@ -0,0 +1,9 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using AltGen.Web.Client diff --git a/src/AltGen.Web/AltGen.Web.csproj b/src/AltGen.Web/AltGen.Web.csproj new file mode 100644 index 0000000..469ac5c --- /dev/null +++ b/src/AltGen.Web/AltGen.Web.csproj @@ -0,0 +1,14 @@ + + + + net9.0 + enable + enable + + + + + + + + diff --git a/src/AltGen.Web/Components/App.razor b/src/AltGen.Web/Components/App.razor new file mode 100644 index 0000000..30088b9 --- /dev/null +++ b/src/AltGen.Web/Components/App.razor @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/AltGen.Web/Components/Layout/MainLayout.razor b/src/AltGen.Web/Components/Layout/MainLayout.razor new file mode 100644 index 0000000..96fbbe6 --- /dev/null +++ b/src/AltGen.Web/Components/Layout/MainLayout.razor @@ -0,0 +1,9 @@ +@inherits LayoutComponentBase + +@Body + +
+ An unhandled error has occurred. + Reload + 🗙 +
diff --git a/src/AltGen.Web/Components/Layout/MainLayout.razor.css b/src/AltGen.Web/Components/Layout/MainLayout.razor.css new file mode 100644 index 0000000..60cec92 --- /dev/null +++ b/src/AltGen.Web/Components/Layout/MainLayout.razor.css @@ -0,0 +1,20 @@ +#blazor-error-ui { + color-scheme: light only; + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + box-sizing: border-box; + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; + } diff --git a/src/AltGen.Web/Components/Pages/Error.razor b/src/AltGen.Web/Components/Pages/Error.razor new file mode 100644 index 0000000..576cc2d --- /dev/null +++ b/src/AltGen.Web/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +@page "/Error" +@using System.Diagnostics + +Error + +

Error.

+

An error occurred while processing your request.

+ +@if (ShowRequestId) +{ +

+ Request ID: @RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/src/AltGen.Web/Components/Routes.razor b/src/AltGen.Web/Components/Routes.razor new file mode 100644 index 0000000..84128a6 --- /dev/null +++ b/src/AltGen.Web/Components/Routes.razor @@ -0,0 +1,11 @@ + + + + + + + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/src/AltGen.Web/Components/_Imports.razor b/src/AltGen.Web/Components/_Imports.razor new file mode 100644 index 0000000..3cd206f --- /dev/null +++ b/src/AltGen.Web/Components/_Imports.razor @@ -0,0 +1,11 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using AltGen.Web +@using AltGen.Web.Client +@using AltGen.Web.Components diff --git a/src/AltGen.Web/Program.cs b/src/AltGen.Web/Program.cs new file mode 100644 index 0000000..5c5221b --- /dev/null +++ b/src/AltGen.Web/Program.cs @@ -0,0 +1,30 @@ +using AltGen.Web.Components; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveWebAssemblyComponents(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseWebAssemblyDebugging(); +} +else +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseAntiforgery(); + +app.MapStaticAssets(); +app.MapRazorComponents() + .AddInteractiveWebAssemblyRenderMode() + .AddAdditionalAssemblies(typeof(AltGen.Web.Client._Imports).Assembly); + +app.Run(); diff --git a/src/AltGen.Web/Properties/launchSettings.json b/src/AltGen.Web/Properties/launchSettings.json new file mode 100644 index 0000000..5454520 --- /dev/null +++ b/src/AltGen.Web/Properties/launchSettings.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7198;http://localhost:5183", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:5183", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + } +} \ No newline at end of file diff --git a/src/AltGen.Web/wwwroot/app.css b/src/AltGen.Web/wwwroot/app.css new file mode 100644 index 0000000..5388357 --- /dev/null +++ b/src/AltGen.Web/wwwroot/app.css @@ -0,0 +1,38 @@ +h1:focus { + outline: none; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid #e50000; +} + +.validation-message { + color: #e50000; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTk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kuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.darker-border-checkbox.form-check-input { + border-color: #929292; +} + +.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { + color: var(--bs-secondary-color); + text-align: end; +} + +.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { + text-align: start; +} \ No newline at end of file diff --git a/src/AltGen.sln b/src/AltGen.sln index 36f70b1..6bafee2 100644 --- a/src/AltGen.sln +++ b/src/AltGen.sln @@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltGen.Console", "AltGen.Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltGen.Console.Tests", "AltGen.Console.Tests\AltGen.Console.Tests.csproj", "{F7DC6A70-907B-448A-A69D-4E2E80FA3FD3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltGen.Web", "AltGen.Web\AltGen.Web.csproj", "{CD09C06D-AB87-4C4E-8AD7-2694ED9BF5C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltGen.Web.Client", "AltGen.Web.Client\AltGen.Web.Client.csproj", "{DCE07E79-23A4-490E-A796-EA140D2040C1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,5 +40,13 @@ Global {F7DC6A70-907B-448A-A69D-4E2E80FA3FD3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7DC6A70-907B-448A-A69D-4E2E80FA3FD3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F7DC6A70-907B-448A-A69D-4E2E80FA3FD3}.Release|Any CPU.Build.0 = Release|Any CPU + {CD09C06D-AB87-4C4E-8AD7-2694ED9BF5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD09C06D-AB87-4C4E-8AD7-2694ED9BF5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD09C06D-AB87-4C4E-8AD7-2694ED9BF5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD09C06D-AB87-4C4E-8AD7-2694ED9BF5C6}.Release|Any CPU.Build.0 = Release|Any CPU + {DCE07E79-23A4-490E-A796-EA140D2040C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DCE07E79-23A4-490E-A796-EA140D2040C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DCE07E79-23A4-490E-A796-EA140D2040C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DCE07E79-23A4-490E-A796-EA140D2040C1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal