diff --git a/COMETwebapp.Tests/Shared/TopMenuEntry/AboutMenuTestFixture.cs b/COMETwebapp.Tests/Shared/TopMenuEntry/AboutMenuTestFixture.cs index cc73d4e3d..7e82e9ab9 100644 --- a/COMETwebapp.Tests/Shared/TopMenuEntry/AboutMenuTestFixture.cs +++ b/COMETwebapp.Tests/Shared/TopMenuEntry/AboutMenuTestFixture.cs @@ -55,6 +55,7 @@ public void Setup() this.versionService = new Mock(); this.versionService.Setup(x => x.GetVersion()).Returns("1.1.2"); this.context.Services.AddSingleton(this.versionService.Object); + this.context.Services.AddSingleton(new Mock().Object); this.context.ConfigureDevExpressBlazor(); } diff --git a/COMETwebapp.sln.DotSettings b/COMETwebapp.sln.DotSettings index 10dc2de53..2fcc68ae1 100644 --- a/COMETwebapp.sln.DotSettings +++ b/COMETwebapp.sln.DotSettings @@ -251,30 +251,7 @@ True True True - -------------------------------------------------------------------------------------------------------------------- - <copyright file="$FILENAME$" company="RHEA System S.A."> - Copyright (c) $CURRENT_YEAR$ RHEA System S.A. - - Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine - - This file is part of COMET WEB Community Edition - The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. - - The COMET WEB Community Edition is free software; you can redistribute it and/or - modify it under the terms of the GNU Affero General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - The COMET WEB Community Edition is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - </copyright> - -------------------------------------------------------------------------------------------------------------------- - + True False False @@ -282,6 +259,18 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + True + C:\CODE\COMET\COMET-WEB-Community-Edition\CommonLibrary.DotSettings + ..\CommonLibrary.DotSettings + True + C:\CODE\COMET\COMET-WEB-Community-Edition\WebAppHeader.DotSettings + ..\WebAppHeader.DotSettings + True + CommonLibraryHeader + False + 1 + True + 2 True True True diff --git a/COMETwebapp/COMETwebapp.csproj b/COMETwebapp/COMETwebapp.csproj index bddc29e29..3265c4e3e 100644 --- a/COMETwebapp/COMETwebapp.csproj +++ b/COMETwebapp/COMETwebapp.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -21,8 +21,6 @@ - - @@ -30,4 +28,10 @@ + + + Always + + + diff --git a/COMETwebapp/Components/Shared/About.razor.cs b/COMETwebapp/Components/Shared/About.razor.cs index 0a988477e..07f07907d 100644 --- a/COMETwebapp/Components/Shared/About.razor.cs +++ b/COMETwebapp/Components/Shared/About.razor.cs @@ -49,10 +49,10 @@ public partial class About private string license = string.Empty; /// - /// The + /// The /// [Inject] - public HttpClient HttpClient { get; set; } + public IHttpClientFactory HttpClientFactory { get; set; } /// /// The @@ -66,7 +66,8 @@ public partial class About protected override async Task OnInitializedAsync() { this.cometWebVersion = this.VersionService.GetVersion(); - this.license = await this.HttpClient.GetStringAsync(GitUrl); + var httpClient = this.HttpClientFactory.CreateClient("About"); + this.license = await httpClient.GetStringAsync(GitUrl); } } } diff --git a/COMETwebapp/Dockerfile b/COMETwebapp/Dockerfile index 9e11258b8..ec9b5e232 100644 --- a/COMETwebapp/Dockerfile +++ b/COMETwebapp/Dockerfile @@ -14,7 +14,8 @@ RUN dotnet build COMETwebapp -c Release -o /app/build --no-restore FROM build AS publish RUN dotnet publish COMETwebapp -c Release -o /app/publish -FROM nginx:alpine AS final -WORKDIR /usr/share/nginx/html -COPY --from=publish /app/publish/wwwroot . -COPY COMETwebapp/nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS final +WORKDIR /app +COPY --from=publish /app/publish . + +ENTRYPOINT ["dotnet", "COMETwebapp.dll"] \ No newline at end of file diff --git a/COMETwebapp/Extensions/ServiceCollectionExtensions.cs b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 000000000..c78ffcc4b --- /dev/null +++ b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,89 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 RHEA System S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine +// +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Extensions +{ + using COMETwebapp.Model.Viewer; + using COMETwebapp.Services.Interoperability; + using COMETwebapp.Services.ShowHideDeprecatedThingsService; + using COMETwebapp.Services.SubscriptionService; + using COMETwebapp.Utilities; + using COMETwebapp.ViewModels.Components.BookEditor; + using COMETwebapp.ViewModels.Components.ModelDashboard; + using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues; + using COMETwebapp.ViewModels.Components.ModelEditor; + using COMETwebapp.ViewModels.Components.ParameterEditor; + using COMETwebapp.ViewModels.Components.ReferenceData; + using COMETwebapp.ViewModels.Components.SubscriptionDashboard; + using COMETwebapp.ViewModels.Components.SystemRepresentation; + using COMETwebapp.ViewModels.Components.UserManagement; + using COMETwebapp.ViewModels.Components.Viewer; + using COMETwebapp.ViewModels.Shared.TopMenuEntry; + + /// + /// Extension class for the + /// + public static class ServiceCollectionExtensions + { + /// + /// Register all services required to run the application inside the + /// + /// The + public static void RegisterServices(this IServiceCollection serviceCollection) + { + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddHttpClient(); + serviceCollection.AddAntDesign(); + } + + /// + /// Register all view models required to run the application inside the + /// + /// The + public static void RegisterViewModels(this IServiceCollection serviceCollection) + { + serviceCollection.AddScoped(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + } + } +} diff --git a/COMETwebapp/Pages/Error.cshtml b/COMETwebapp/Pages/Error.cshtml new file mode 100644 index 000000000..098b5d1ea --- /dev/null +++ b/COMETwebapp/Pages/Error.cshtml @@ -0,0 +1,50 @@ +@page + +@model COMETwebapp.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (this.Model.ShowRequestId) + { +

+ Request ID: @(this.Model.RequestId) +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays 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. +

+
+
+ + + \ No newline at end of file diff --git a/COMETwebapp/Pages/Error.cshtml.cs b/COMETwebapp/Pages/Error.cshtml.cs new file mode 100644 index 000000000..3fdc7eec2 --- /dev/null +++ b/COMETwebapp/Pages/Error.cshtml.cs @@ -0,0 +1,58 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 RHEA System S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine +// +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 +// Annex A and Annex C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Pages +{ + using System.Diagnostics; + + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.RazorPages; + + /// + /// Data model that provide information about request when an error occurs + /// + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + /// + /// Gets or sets the request id + /// + public string RequestId { get; set; } + + /// + /// Gets the assert the the should be shown + /// + public bool ShowRequestId => !string.IsNullOrEmpty(this.RequestId); + + /// + /// Sets the based on context + /// + public void OnGet() + { + this.RequestId = Activity.Current?.Id ?? this.HttpContext.TraceIdentifier; + } + } +} diff --git a/COMETwebapp/Pages/Index.razor b/COMETwebapp/Pages/Index.razor index 731fed467..a9fec8c61 100644 --- a/COMETwebapp/Pages/Index.razor +++ b/COMETwebapp/Pages/Index.razor @@ -20,4 +20,4 @@ // along with this program. If not, see http://www.gnu.org/licenses/. -------------------------------------------------------------------------------> @page "/" - \ No newline at end of file + diff --git a/COMETwebapp/Pages/_Host.cshtml b/COMETwebapp/Pages/_Host.cshtml new file mode 100644 index 000000000..553cb9218 --- /dev/null +++ b/COMETwebapp/Pages/_Host.cshtml @@ -0,0 +1,106 @@ +@page "/" + +@using COMET.Web.Common +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Mvc.TagHelpers +@namespace COMETwebapp.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + CDP4-COMET Community Edition + + + + + + + + + + + + + + + + + + +
+ An unhandled error has occurred. + Reload + �� +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/COMETwebapp/Program.cs b/COMETwebapp/Program.cs index 943652baa..e057e5a2c 100644 --- a/COMETwebapp/Program.cs +++ b/COMETwebapp/Program.cs @@ -24,37 +24,15 @@ namespace COMETwebapp { - using COMET.Web.Common.Extensions; - - using COMETwebapp.Model; - using COMETwebapp.Model.Viewer; - using COMETwebapp.Services.Interoperability; - using COMETwebapp.Services.ShowHideDeprecatedThingsService; - using COMETwebapp.Services.SubscriptionService; - using COMETwebapp.Shared.TopMenuEntry; - using COMETwebapp.Utilities; - using COMETwebapp.ViewModels.Components.ModelDashboard; - using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues; - using COMETwebapp.ViewModels.Components.ModelEditor; - using COMETwebapp.ViewModels.Components.ParameterEditor; - using COMETwebapp.ViewModels.Components.ReferenceData; - using COMETwebapp.ViewModels.Components.SubscriptionDashboard; - using COMETwebapp.ViewModels.Components.SystemRepresentation; - using COMETwebapp.ViewModels.Components.UserManagement; - using COMETwebapp.ViewModels.Components.Viewer; - using COMETwebapp.ViewModels.Shared.TopMenuEntry; - - using Microsoft.AspNetCore.Components.WebAssembly.Hosting; - using System.Diagnostics.CodeAnalysis; using System.Reflection; - using COMET.Web.Common; + using COMET.Web.Common.Extensions; using COMET.Web.Common.Shared.TopMenuEntry; - using COMETwebapp.ViewModels.Components.BookEditor; - - using Microsoft.AspNetCore.Components.Web; + using COMETwebapp.Extensions; + using COMETwebapp.Model; + using COMETwebapp.Shared.TopMenuEntry; /// /// Point of entry of the application @@ -67,69 +45,29 @@ public class Program /// public static async Task Main(string[] args) { - var builder = WebAssemblyHostBuilder.CreateDefault(args); + var builder = WebApplication.CreateBuilder(args); - builder.RootComponents.Add("#app"); - builder.RootComponents.Add("head::after"); + builder.Services.AddRazorPages(); + builder.Services.AddServerSideBlazor(); - builder.Services.RegisterCommonLibrary(false, options => + builder.Services.RegisterCommonLibrary(true, options => { options.Applications = Applications.ExistingApplications; options.AdditionalAssemblies.Add(Assembly.GetAssembly(typeof(Program))); - options.AdditionalMenuEntries.AddRange(new List{ typeof(ApplicationMenu), typeof(ModelMenu), typeof(SessionMenu), typeof(ShowHideDeprecatedThings), typeof(AboutMenu)}); - }); - - builder.Services.AddScoped(_ => new HttpClient() - { - BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) + options.AdditionalMenuEntries.AddRange(new List { typeof(ApplicationMenu), typeof(ModelMenu), typeof(SessionMenu), typeof(ShowHideDeprecatedThings), typeof(AboutMenu) }); }); - RegisterServices(builder); - RegisterViewModels(builder); + builder.Services.RegisterServices(); + builder.Services.RegisterViewModels(); - var host = builder.Build(); - await host.Services.InitializeServices(); - await host.RunAsync(); - } + var app = builder.Build(); + app.UseStaticFiles(); + app.UseRouting(); + app.MapBlazorHub(); + app.MapFallbackToPage("/_Host"); - /// - /// Register all services required to run the application inside the - /// - /// The - public static void RegisterServices(WebAssemblyHostBuilder builder) - { - builder.Services.AddScoped(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddAntDesign(); - } - - /// - /// Register all view models required to run the application inside the - /// - /// The - public static void RegisterViewModels(WebAssemblyHostBuilder builder) - { - builder.Services.AddSingleton(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); + await app.Services.InitializeServices(); + await app.RunAsync(); } } } diff --git a/COMETwebapp/Properties/launchSettings.json b/COMETwebapp/Properties/launchSettings.json index ab56c665a..1204e0a3c 100644 --- a/COMETwebapp/Properties/launchSettings.json +++ b/COMETwebapp/Properties/launchSettings.json @@ -8,23 +8,21 @@ } }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", + "http": { + "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:5136", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, - "COMETwebapp": { - "commandName": "Project", - "dotnetRunMessages": "true", + "IIS Express": { + "commandName": "IISExpress", "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5136" + } } } -} \ No newline at end of file +} diff --git a/COMETwebapp/_Imports.razor b/COMETwebapp/_Imports.razor index 9af0a01d7..a658abe92 100644 --- a/COMETwebapp/_Imports.razor +++ b/COMETwebapp/_Imports.razor @@ -12,7 +12,6 @@ @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web.Virtualization -@using Microsoft.AspNetCore.Components.WebAssembly.Http @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.JSInterop @using COMETwebapp diff --git a/COMETwebapp/appsettings.Development.json b/COMETwebapp/appsettings.Development.json new file mode 100644 index 000000000..b90915095 --- /dev/null +++ b/COMETwebapp/appsettings.Development.json @@ -0,0 +1,3 @@ +{ + "DetailedErrors": true +} diff --git a/COMETwebapp/appsettings.json b/COMETwebapp/appsettings.json new file mode 100644 index 000000000..0b634009d --- /dev/null +++ b/COMETwebapp/appsettings.json @@ -0,0 +1,11 @@ +{ + "AllowedHosts": "*", + "StringTablePath": "wwwroot/DefaultTextConfiguration.json", + "ServerConfiguration": { + "ServerAddress": "", + "BookInputConfiguration": { + "ShowName": true, + "ShowShortName": true + } + } +} diff --git a/COMETwebapp/nginx.conf b/COMETwebapp/nginx.conf deleted file mode 100644 index 787420c4f..000000000 --- a/COMETwebapp/nginx.conf +++ /dev/null @@ -1,15 +0,0 @@ -events { } -http { - - include mime.types; - - server { - listen 80; - - location / { - add_header blazor-environment Production; - root /usr/share/nginx/html; - try_files $uri $uri/ /index.html =404; - } - } -} \ No newline at end of file diff --git a/COMETwebapp/wwwroot/DefaultTextConfiguration.json b/COMETwebapp/wwwroot/DefaultTextConfiguration.json new file mode 100644 index 000000000..4b39342ba --- /dev/null +++ b/COMETwebapp/wwwroot/DefaultTextConfiguration.json @@ -0,0 +1,12 @@ +{ + "OpenEngineeringModelPlaceholder": "Select an Engineering Model", + "OpenIterationPlaceholder": "Select an Iteration", + "OpenDomainOfExpertisePlaceholder": "Select a Domain of Expertise", + "ModelTitleCaption": "Model", + "IterationTitleCaption": "Iteration", + "DomainTitleCaption": "Domain", + "LandingPageTitle": "", + "NavigationApplicationSelectorTitle": "Application", + "NavigationModelSelectorTitle": "Models", + "ModelOpenButtonCaption": "Open Model" +} diff --git a/COMETwebapp/wwwroot/index.html b/COMETwebapp/wwwroot/index.html deleted file mode 100644 index f76a344be..000000000 --- a/COMETwebapp/wwwroot/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - CDP4-COMET Community Edition - - - - - - - - - - - - - - -
- -
-
-
CDP4-COMET Community Edition
-
Loading...
-
-
- -
- An unhandled error has occurred. - Reload - �� -
- - - - - - - - - - - - - - - - diff --git a/CommonLibrary.DotSettings b/CommonLibrary.DotSettings new file mode 100644 index 000000000..cf31dfd4b --- /dev/null +++ b/CommonLibrary.DotSettings @@ -0,0 +1,26 @@ + + -------------------------------------------------------------------------------------------------------------------- + <copyright file="${File.FileName}" company="RHEA System S.A."> + Copyright (c) ${CurrentDate.Year} RHEA System S.A. + + Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine + + This file is part of COMET WEB Community Edition + The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 + Annex A and Annex C. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + </copyright> + -------------------------------------------------------------------------------------------------------------------- + True \ No newline at end of file diff --git a/WebAppHeader.DotSettings b/WebAppHeader.DotSettings new file mode 100644 index 000000000..de5cc1c57 --- /dev/null +++ b/WebAppHeader.DotSettings @@ -0,0 +1,25 @@ + + -------------------------------------------------------------------------------------------------------------------- + <copyright file="${File.FileName}" company="RHEA System S.A."> + Copyright (c) ${CurrentDate.Year} RHEA System S.A. + + Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine + + This file is part of COMET WEB Community Edition + The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. + + The COMET WEB Community Edition is free software; you can redistribute it and/or + modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + The COMET WEB Community Edition is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + </copyright> + -------------------------------------------------------------------------------------------------------------------- + \ No newline at end of file