From ecafebae7f0d80faf17b01e0bf842d79d77096de Mon Sep 17 00:00:00 2001 From: MarcoE Date: Wed, 4 Feb 2026 17:31:00 +0100 Subject: [PATCH] Prima configurazione e struttura --- .../.idea/deploymentTargetSelector.xml | 10 + .../androidx_collection_collection_jvm.xml | 9 + ...ndroidx_lifecycle_lifecycle_common_jvm.xml | 9 + SteUp.Maui/App.xaml | 11 +- SteUp.Maui/App.xaml.cs | 9 +- SteUp.Maui/Core/CoreModule.cs | 35 +++ SteUp.Maui/{ => Core}/Services/FormFactor.cs | 4 +- .../Core/System/Network/NetworkService.cs | 12 + SteUp.Maui/MainPage.xaml | 5 +- SteUp.Maui/MainPage.xaml.cs | 2 +- SteUp.Maui/MauiProgram.cs | 33 ++- SteUp.Maui/Platforms/Android/MainActivity.cs | 2 +- .../Platforms/Android/MainApplication.cs | 2 +- .../Android/Resources/values/colors.xml | 6 +- .../Platforms/MacCatalyst/AppDelegate.cs | 4 +- SteUp.Maui/Platforms/MacCatalyst/Program.cs | 2 +- SteUp.Maui/Platforms/Tizen/Main.cs | 2 +- SteUp.Maui/Platforms/Tizen/tizen-manifest.xml | 2 +- SteUp.Maui/Platforms/Windows/App.xaml.cs | 2 +- SteUp.Maui/Platforms/Windows/app.manifest | 2 +- SteUp.Maui/Platforms/iOS/AppDelegate.cs | 2 +- SteUp.Maui/Platforms/iOS/Program.cs | 2 +- SteUp.Maui/Resources/AppIcon/appicon.svg | 5 +- SteUp.Maui/Resources/AppIcon/appiconfg.svg | 9 +- SteUp.Maui/Resources/Splash/splash.svg | 9 +- SteUp.Maui/SteUp.Maui.csproj | 193 +++++++------- SteUp.Maui/wwwroot/index.html | 62 ++--- .../Components/Layout/MainLayout.razor | 168 ++++++++++++- .../Components/Layout/MainLayout.razor.css | 42 ++-- SteUp.Shared/Components/Layout/NavBar.razor | 40 --- .../Components/Layout/NavBar.razor.css | 81 ------ SteUp.Shared/Components/Layout/NavMenu.razor | 106 +++++--- .../Layout/Spinner/SpinnerLayout.razor | 8 + .../Layout/Spinner/SpinnerLayout.razor.css | 43 ++++ SteUp.Shared/Components/Pages/Counter.razor | 16 -- .../Components/Pages/DeviceFormFactor.razor | 23 -- SteUp.Shared/Components/Pages/Home.razor | 17 +- SteUp.Shared/Components/Pages/Home.razor.css | 1 + .../Components/Pages/Impostazioni.razor | 6 - SteUp.Shared/Components/Pages/Index.razor | 13 + SteUp.Shared/Components/Pages/Log Book.razor | 10 - SteUp.Shared/Components/Pages/Login.razor | 6 + SteUp.Shared/Components/Pages/Login.razor.css | 1 + SteUp.Shared/Components/Pages/Weather.razor | 61 ----- SteUp.Shared/Components/Pages/Workout.razor | 12 - .../Components/Pages/Workout.razor.css | 0 SteUp.Shared/Components/Routes.razor | 54 +++- .../Modal/ExceptionModal/ExceptionModal.razor | 59 +++++ .../ExceptionModal/ExceptionModal.razor.css | 61 +++++ .../Core/Authorization/Enum/KeyGroupEnum.cs | 13 + .../Interface}/IFormFactor.cs | 2 +- .../IntegryApi/IIntegryApiService.cs | 6 + .../System/Network/INetworkService.cs | 8 + .../AppAuthenticationStateProvider.cs | 56 +++++ .../Core/Services/IntegryApiService.cs | 22 ++ SteUp.Shared/InteractiveRenderSettings.cs | 2 +- SteUp.Shared/SteUp.Shared.csproj | 40 +-- SteUp.Shared/_Imports.razor | 13 +- SteUp.Shared/wwwroot/css/app.css | 237 +++++++++++++++--- SteUp.Shared/wwwroot/css/default-theme.css | 4 +- SteUp.Web/Components/App.razor | 20 +- SteUp.Web/Components/Pages/Error.razor | 14 +- SteUp.Web/Components/_Imports.razor | 6 +- SteUp.Web/Program.cs | 53 ++-- SteUp.Web/Services/FormFactor.cs | 4 +- SteUp.Web/SteUp.Web.csproj | 25 +- 66 files changed, 1153 insertions(+), 645 deletions(-) create mode 100644 .idea/.idea.SteUp/.idea/deploymentTargetSelector.xml create mode 100644 .idea/.idea.SteUp/.idea/libraries/androidx_collection_collection_jvm.xml create mode 100644 .idea/.idea.SteUp/.idea/libraries/androidx_lifecycle_lifecycle_common_jvm.xml create mode 100644 SteUp.Maui/Core/CoreModule.cs rename SteUp.Maui/{ => Core}/Services/FormFactor.cs (78%) create mode 100644 SteUp.Maui/Core/System/Network/NetworkService.cs delete mode 100644 SteUp.Shared/Components/Layout/NavBar.razor delete mode 100644 SteUp.Shared/Components/Layout/NavBar.razor.css create mode 100644 SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor create mode 100644 SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor.css delete mode 100644 SteUp.Shared/Components/Pages/Counter.razor delete mode 100644 SteUp.Shared/Components/Pages/DeviceFormFactor.razor create mode 100644 SteUp.Shared/Components/Pages/Home.razor.css delete mode 100644 SteUp.Shared/Components/Pages/Impostazioni.razor create mode 100644 SteUp.Shared/Components/Pages/Index.razor delete mode 100644 SteUp.Shared/Components/Pages/Log Book.razor create mode 100644 SteUp.Shared/Components/Pages/Login.razor create mode 100644 SteUp.Shared/Components/Pages/Login.razor.css delete mode 100644 SteUp.Shared/Components/Pages/Weather.razor delete mode 100644 SteUp.Shared/Components/Pages/Workout.razor delete mode 100644 SteUp.Shared/Components/Pages/Workout.razor.css create mode 100644 SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor create mode 100644 SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor.css create mode 100644 SteUp.Shared/Core/Authorization/Enum/KeyGroupEnum.cs rename SteUp.Shared/{Interfaces => Core/Interface}/IFormFactor.cs (72%) create mode 100644 SteUp.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs create mode 100644 SteUp.Shared/Core/Interface/System/Network/INetworkService.cs create mode 100644 SteUp.Shared/Core/Services/AppAuthenticationStateProvider.cs create mode 100644 SteUp.Shared/Core/Services/IntegryApiService.cs diff --git a/.idea/.idea.SteUp/.idea/deploymentTargetSelector.xml b/.idea/.idea.SteUp/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..e4966f8 --- /dev/null +++ b/.idea/.idea.SteUp/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.SteUp/.idea/libraries/androidx_collection_collection_jvm.xml b/.idea/.idea.SteUp/.idea/libraries/androidx_collection_collection_jvm.xml new file mode 100644 index 0000000..752f240 --- /dev/null +++ b/.idea/.idea.SteUp/.idea/libraries/androidx_collection_collection_jvm.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.SteUp/.idea/libraries/androidx_lifecycle_lifecycle_common_jvm.xml b/.idea/.idea.SteUp/.idea/libraries/androidx_lifecycle_lifecycle_common_jvm.xml new file mode 100644 index 0000000..e62e5d3 --- /dev/null +++ b/.idea/.idea.SteUp/.idea/libraries/androidx_lifecycle_lifecycle_common_jvm.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/SteUp.Maui/App.xaml b/SteUp.Maui/App.xaml index 500235a..447c2b2 100644 --- a/SteUp.Maui/App.xaml +++ b/SteUp.Maui/App.xaml @@ -1,12 +1,13 @@ + xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls" + android:Application.WindowSoftInputModeAdjust="Resize" + x:Class="SteUp.Maui.App"> - #512bdf + #dff2ff White - + \ No newline at end of file diff --git a/SteUp.Maui/App.xaml.cs b/SteUp.Maui/App.xaml.cs index 613d687..3c9760e 100644 --- a/SteUp.Maui/App.xaml.cs +++ b/SteUp.Maui/App.xaml.cs @@ -1,12 +1,15 @@ -namespace Template.Maui +namespace SteUp.Maui { - public partial class App : Application + public partial class App { public App() { InitializeComponent(); + } - MainPage = new MainPage(); + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new MainPage()); } } } diff --git a/SteUp.Maui/Core/CoreModule.cs b/SteUp.Maui/Core/CoreModule.cs new file mode 100644 index 0000000..6b69bdb --- /dev/null +++ b/SteUp.Maui/Core/CoreModule.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Components.Authorization; +using SteUp.Maui.Core.Services; +using SteUp.Maui.Core.System.Network; +using SteUp.Shared.Core.Interface; +using SteUp.Shared.Core.Interface.IntegryApi; +using SteUp.Shared.Core.Interface.System.Network; +using SteUp.Shared.Core.Services; + +namespace SteUp.Maui.Core; + +public static class CoreModule +{ + public static void RegisterAppServices(this MauiAppBuilder builder) + { + builder.Services.AddSingleton(); + } + + public static void RegisterIntegryServices(this MauiAppBuilder builder) + { + builder.Services.AddScoped(); + } + + public static void RegisterSystemService(this MauiAppBuilder builder) + { + builder.Services.AddSingleton(); + } + + public static void AddAuthorizationCore(this MauiAppBuilder builder) + { + builder.Services.AddAuthorizationCore(); + builder.Services.AddScoped(); + builder.Services.AddScoped(provider => + provider.GetRequiredService()); + } +} \ No newline at end of file diff --git a/SteUp.Maui/Services/FormFactor.cs b/SteUp.Maui/Core/Services/FormFactor.cs similarity index 78% rename from SteUp.Maui/Services/FormFactor.cs rename to SteUp.Maui/Core/Services/FormFactor.cs index 8e22d6c..e365285 100644 --- a/SteUp.Maui/Services/FormFactor.cs +++ b/SteUp.Maui/Core/Services/FormFactor.cs @@ -1,6 +1,6 @@ -using Template.Shared.Interfaces; +using SteUp.Shared.Core.Interface; -namespace Template.Maui.Services; +namespace SteUp.Maui.Core.Services; public class FormFactor : IFormFactor { diff --git a/SteUp.Maui/Core/System/Network/NetworkService.cs b/SteUp.Maui/Core/System/Network/NetworkService.cs new file mode 100644 index 0000000..2de0af2 --- /dev/null +++ b/SteUp.Maui/Core/System/Network/NetworkService.cs @@ -0,0 +1,12 @@ +using SteUp.Shared.Core.Interface.System.Network; + +namespace SteUp.Maui.Core.System.Network; + +public class NetworkService : INetworkService +{ + public bool ConnectionAvailable { get; set; } + + public bool IsNetworkAvailable() => + Connectivity.Current.NetworkAccess == NetworkAccess.Internet; + +} \ No newline at end of file diff --git a/SteUp.Maui/MainPage.xaml b/SteUp.Maui/MainPage.xaml index 222124c..c12ce68 100644 --- a/SteUp.Maui/MainPage.xaml +++ b/SteUp.Maui/MainPage.xaml @@ -1,9 +1,8 @@ diff --git a/SteUp.Maui/MainPage.xaml.cs b/SteUp.Maui/MainPage.xaml.cs index d398a31..740b7a5 100644 --- a/SteUp.Maui/MainPage.xaml.cs +++ b/SteUp.Maui/MainPage.xaml.cs @@ -1,4 +1,4 @@ -namespace Template.Maui +namespace SteUp.Maui { public partial class MainPage : ContentPage { diff --git a/SteUp.Maui/MauiProgram.cs b/SteUp.Maui/MauiProgram.cs index 9f066ce..0138b81 100644 --- a/SteUp.Maui/MauiProgram.cs +++ b/SteUp.Maui/MauiProgram.cs @@ -1,19 +1,17 @@ +using CommunityToolkit.Maui; using IntegryApiClient.MAUI; using Microsoft.Extensions.Logging; -using Template.Maui.Services; -using Template.Shared; -using Template.Shared.Interfaces; +using MudBlazor.Services; +using SteUp.Maui.Core; +using SteUp.Maui.Core.Services; +using SteUp.Shared; +using SteUp.Shared.Core.Interface; -namespace Template.Maui +namespace SteUp.Maui { public static class MauiProgram { -#if DEBUG - private const string BaseRestServicesEndpoint = "https://devservices.studioml.it/ems-api/"; - //private const string BaseRestServicesEndpoint = "http://192.168.2.23:8080/ems-api/"; -#else - private const string BaseRestServicesEndpoint = "https://services.studioml.it/ems-api/"; -#endif + private const string AppToken = "4fef1843-793d-499b-a7ed-1edd8cac465c"; public static MauiApp CreateMauiApp() { @@ -22,21 +20,22 @@ namespace Template.Maui var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() - .UseIntegry(BaseRestServicesEndpoint) - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); + .UseIntegry(appToken: AppToken, useLoginAzienda: true) + .UseMauiCommunityToolkit() + .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); }); builder.Services.AddMauiBlazorWebView(); - builder.Services.AddBlazorBootstrap(); + builder.Services.AddMudServices(); #if DEBUG builder.Services.AddBlazorWebViewDeveloperTools(); builder.Logging.AddDebug(); #endif - builder.Services.AddSingleton(); + builder.AddAuthorizationCore(); + builder.RegisterAppServices(); + builder.RegisterIntegryServices(); + builder.RegisterSystemService(); return builder.Build(); } diff --git a/SteUp.Maui/Platforms/Android/MainActivity.cs b/SteUp.Maui/Platforms/Android/MainActivity.cs index 8b0f78b..f83e978 100644 --- a/SteUp.Maui/Platforms/Android/MainActivity.cs +++ b/SteUp.Maui/Platforms/Android/MainActivity.cs @@ -2,7 +2,7 @@ using Android.App; using Android.Content.PM; using Android.OS; -namespace Template.Maui +namespace SteUp.Maui { [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] public class MainActivity : MauiAppCompatActivity diff --git a/SteUp.Maui/Platforms/Android/MainApplication.cs b/SteUp.Maui/Platforms/Android/MainApplication.cs index 9e63b56..150e642 100644 --- a/SteUp.Maui/Platforms/Android/MainApplication.cs +++ b/SteUp.Maui/Platforms/Android/MainApplication.cs @@ -1,7 +1,7 @@ using Android.App; using Android.Runtime; -namespace Template.Maui +namespace SteUp.Maui { [Application] public class MainApplication : MauiApplication diff --git a/SteUp.Maui/Platforms/Android/Resources/values/colors.xml b/SteUp.Maui/Platforms/Android/Resources/values/colors.xml index fbaa64a..236b2f5 100644 --- a/SteUp.Maui/Platforms/Android/Resources/values/colors.xml +++ b/SteUp.Maui/Platforms/Android/Resources/values/colors.xml @@ -1,6 +1,6 @@ - #512BD4 - #2B0B98 - #2B0B98 + #ec4c41 + #d02315 + #d02315 diff --git a/SteUp.Maui/Platforms/MacCatalyst/AppDelegate.cs b/SteUp.Maui/Platforms/MacCatalyst/AppDelegate.cs index 60c4810..edfc013 100644 --- a/SteUp.Maui/Platforms/MacCatalyst/AppDelegate.cs +++ b/SteUp.Maui/Platforms/MacCatalyst/AppDelegate.cs @@ -1,7 +1,7 @@ using Foundation; -using Template.Maui; +using SteUp.Maui; -namespace Template.Maui +namespace SteUp.Maui { [Register("AppDelegate")] public class AppDelegate : MauiUIApplicationDelegate diff --git a/SteUp.Maui/Platforms/MacCatalyst/Program.cs b/SteUp.Maui/Platforms/MacCatalyst/Program.cs index dc39375..a243f7f 100644 --- a/SteUp.Maui/Platforms/MacCatalyst/Program.cs +++ b/SteUp.Maui/Platforms/MacCatalyst/Program.cs @@ -1,7 +1,7 @@ using ObjCRuntime; using UIKit; -namespace Template.Maui +namespace SteUp.Maui { public class Program { diff --git a/SteUp.Maui/Platforms/Tizen/Main.cs b/SteUp.Maui/Platforms/Tizen/Main.cs index 2c4e844..aae43c4 100644 --- a/SteUp.Maui/Platforms/Tizen/Main.cs +++ b/SteUp.Maui/Platforms/Tizen/Main.cs @@ -2,7 +2,7 @@ using System; using Microsoft.Maui; using Microsoft.Maui.Hosting; -namespace Template.Maui +namespace SteUp.Maui { internal class Program : MauiApplication { diff --git a/SteUp.Maui/Platforms/Tizen/tizen-manifest.xml b/SteUp.Maui/Platforms/Tizen/tizen-manifest.xml index a5a25be..b248a89 100644 --- a/SteUp.Maui/Platforms/Tizen/tizen-manifest.xml +++ b/SteUp.Maui/Platforms/Tizen/tizen-manifest.xml @@ -1,7 +1,7 @@ - + maui-appicon-placeholder diff --git a/SteUp.Maui/Platforms/Windows/App.xaml.cs b/SteUp.Maui/Platforms/Windows/App.xaml.cs index 957515f..da8b6b8 100644 --- a/SteUp.Maui/Platforms/Windows/App.xaml.cs +++ b/SteUp.Maui/Platforms/Windows/App.xaml.cs @@ -3,7 +3,7 @@ using Microsoft.UI.Xaml; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. -namespace Template.Maui.WinUI +namespace SteUp.Maui.WinUI { /// /// Provides application-specific behavior to supplement the default Application class. diff --git a/SteUp.Maui/Platforms/Windows/app.manifest b/SteUp.Maui/Platforms/Windows/app.manifest index 7e2916c..3dd32f0 100644 --- a/SteUp.Maui/Platforms/Windows/app.manifest +++ b/SteUp.Maui/Platforms/Windows/app.manifest @@ -1,6 +1,6 @@ - + diff --git a/SteUp.Maui/Platforms/iOS/AppDelegate.cs b/SteUp.Maui/Platforms/iOS/AppDelegate.cs index 176c6b4..5a72e1c 100644 --- a/SteUp.Maui/Platforms/iOS/AppDelegate.cs +++ b/SteUp.Maui/Platforms/iOS/AppDelegate.cs @@ -1,6 +1,6 @@ using Foundation; -namespace Template.Maui +namespace SteUp.Maui { [Register("AppDelegate")] public class AppDelegate : MauiUIApplicationDelegate diff --git a/SteUp.Maui/Platforms/iOS/Program.cs b/SteUp.Maui/Platforms/iOS/Program.cs index dc39375..a243f7f 100644 --- a/SteUp.Maui/Platforms/iOS/Program.cs +++ b/SteUp.Maui/Platforms/iOS/Program.cs @@ -1,7 +1,7 @@ using ObjCRuntime; using UIKit; -namespace Template.Maui +namespace SteUp.Maui { public class Program { diff --git a/SteUp.Maui/Resources/AppIcon/appicon.svg b/SteUp.Maui/Resources/AppIcon/appicon.svg index 456d120..4f6f00f 100644 --- a/SteUp.Maui/Resources/AppIcon/appicon.svg +++ b/SteUp.Maui/Resources/AppIcon/appicon.svg @@ -1,4 +1 @@ - - - - + \ No newline at end of file diff --git a/SteUp.Maui/Resources/AppIcon/appiconfg.svg b/SteUp.Maui/Resources/AppIcon/appiconfg.svg index 14f4932..e185188 100644 --- a/SteUp.Maui/Resources/AppIcon/appiconfg.svg +++ b/SteUp.Maui/Resources/AppIcon/appiconfg.svg @@ -1,8 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/SteUp.Maui/Resources/Splash/splash.svg b/SteUp.Maui/Resources/Splash/splash.svg index 14f4932..bbaba0d 100644 --- a/SteUp.Maui/Resources/Splash/splash.svg +++ b/SteUp.Maui/Resources/Splash/splash.svg @@ -1,8 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/SteUp.Maui/SteUp.Maui.csproj b/SteUp.Maui/SteUp.Maui.csproj index de478fd..ee60661 100644 --- a/SteUp.Maui/SteUp.Maui.csproj +++ b/SteUp.Maui/SteUp.Maui.csproj @@ -1,126 +1,129 @@  - - $(TargetFrameworks);net8.0-android - $(TargetFrameworks);net8.0-ios - $(TargetFrameworks);net8.0-maccatalyst - $(TargetFrameworks);net8.0-windows10.0.19041.0 - - + + $(TargetFrameworks);net9.0-android + $(TargetFrameworks);net9.0-ios + + + + - - + - Exe - SteUp.Maui - true - true - enable - false - enable + Exe + SteUp.Maui + true + true + enable + false + enable - - SteUp.Maui + + SteUP - - it.integry.SteUp.maui + + it.integry.SteUp - - 1.0 - 1 + + 1.0 + 1 - 14.2 - - 14.0 - - 24.0 - 10.0.17763.0 - 10.0.17763.0 - - - + 14.2 + + + + 24.0 + + + + + - - $(DefineConstants);PLATFORM - 26.0 - 34 + + $(DefineConstants);PLATFORM + 26.0 + 35 - + - + - + - - - + + + - - - true - true - true - + + + true + true + true + - - 14.2 - $(DefineConstants);APPLE;PLATFORM - + + 14.2 + $(DefineConstants);APPLE;PLATFORM + - - Apple Development: Massimo Fausto Morelli (6C2CUM53BT) - VS: WildCard Development - + + Apple Development: Massimo Fausto Morelli (6C2CUM53BT) + VS: WildCard Development + - - - + + + + --> + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - - - - - + + + + + + + + + + - - - + + + \ No newline at end of file diff --git a/SteUp.Maui/wwwroot/index.html b/SteUp.Maui/wwwroot/index.html index 82d02fb..f60d2e2 100644 --- a/SteUp.Maui/wwwroot/index.html +++ b/SteUp.Maui/wwwroot/index.html @@ -1,48 +1,48 @@ - - - Template.Maui - + + + SteUp.Maui + - - - - - - + - - - - - + + + + + + + + + -
+
-
Loading...
- -
- An unhandled error has occurred. - Reload - 🗙 +
+
+
+
- - - - - - - - - +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + diff --git a/SteUp.Shared/Components/Layout/MainLayout.razor b/SteUp.Shared/Components/Layout/MainLayout.razor index 3da63fd..76ab0c2 100644 --- a/SteUp.Shared/Components/Layout/MainLayout.razor +++ b/SteUp.Shared/Components/Layout/MainLayout.razor @@ -1,16 +1,170 @@ -@inherits LayoutComponentBase +@using System.Globalization +@using SteUp.Shared.Core.Interface.IntegryApi +@using SteUp.Shared.Core.Interface.System.Network +@inherits LayoutComponentBase +@inject INetworkService NetworkService +@inject IIntegryApiService IntegryApiService + + + + +
- @**@ -
-
+
@Body
+
-
\ No newline at end of file +@code { + private MudThemeProvider _mudThemeProvider = null!; + private bool IsDarkMode { get; set; } + private string _mainContentClass = ""; + + //Connection state + private bool _isNetworkAvailable; + private bool _servicesIsDown; + private bool _showWarning; + + private DateTime _lastApiCheck = DateTime.MinValue; + private const int DelaySeconds = 90; + + private CancellationTokenSource? _cts; + + private bool ServicesIsDown + { + get => _servicesIsDown; + set + { + if (_servicesIsDown == value) return; + _servicesIsDown = value; + StateHasChanged(); + } + } + + private bool IsNetworkAvailable + { + get => _isNetworkAvailable; + set + { + if (_isNetworkAvailable == value) return; + _isNetworkAvailable = value; + StateHasChanged(); + } + } + + private bool ShowWarning + { + get => _showWarning; + set + { + if (_showWarning == value) return; + _showWarning = value; + StateHasChanged(); + } + } + + private readonly MudTheme _currentTheme = new() + { + PaletteLight = new PaletteLight() + { + Primary = "#ec4c41", + Secondary = "#002339", + Tertiary = "#dff2ff", + TextPrimary = "#000" + }, + PaletteDark = new PaletteDark + { + Primary = "#ec4c41", + Secondary = "#002339", + Tertiary = "#dff2ff", + Surface = "#000406", + Background = "#000406", + TextPrimary = "#fff", + GrayDark = "#E0E0E0" + } + }; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + // if (firstRender) + // { + // var isDarkMode = LocalStorage.GetString("isDarkMode"); + + // if (isDarkMode == null && _mudThemeProvider != null) + // { + // IsDarkMode = await _mudThemeProvider.GetSystemPreference(); + // await _mudThemeProvider.WatchSystemPreference(OnSystemPreferenceChanged); + // LocalStorage.SetString("isDarkMode", IsDarkMode.ToString()); + // StateHasChanged(); + // } + // else + // { + // IsDarkMode = bool.Parse(isDarkMode!); + // } + + // if (IsDarkMode) + // { + // _mainContentClass += "is-dark"; + // StateHasChanged(); + // } + // } + } + + private async Task OnSystemPreferenceChanged(bool newValue) + { + IsDarkMode = newValue; + } + + protected override void OnInitialized() + { + _cts = new CancellationTokenSource(); + _ = CheckConnectionState(_cts.Token); + + var culture = new CultureInfo("it-IT", false); + + CultureInfo.CurrentCulture = culture; + CultureInfo.CurrentUICulture = culture; + } + + private Task CheckConnectionState(CancellationToken token) + { + return Task.Run(async () => + { + while (!token.IsCancellationRequested) + { + var isNetworkAvailable = NetworkService.IsNetworkAvailable(); + var servicesDown = ServicesIsDown; + + if (isNetworkAvailable && (DateTime.UtcNow - _lastApiCheck).TotalSeconds >= DelaySeconds) + { + servicesDown = !await IntegryApiService.SystemOk(); + _lastApiCheck = DateTime.UtcNow; + } + + await InvokeAsync(async () => + { + IsNetworkAvailable = isNetworkAvailable; + ServicesIsDown = servicesDown; + + await Task.Delay(1500, token); + ShowWarning = !(IsNetworkAvailable && !ServicesIsDown); + NetworkService.ConnectionAvailable = !ShowWarning; + }); + + await Task.Delay(500, token); + } + }, token); + } + + public void Dispose() + { + _cts?.Cancel(); + _cts?.Dispose(); + } + +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/MainLayout.razor.css b/SteUp.Shared/Components/Layout/MainLayout.razor.css index 8521145..b179f89 100644 --- a/SteUp.Shared/Components/Layout/MainLayout.razor.css +++ b/SteUp.Shared/Components/Layout/MainLayout.razor.css @@ -21,29 +21,29 @@ main { align-items: center; } - .top-row ::deep a, .top-row ::deep .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - text-decoration: none; - } +.top-row ::deep a, .top-row ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; +} - .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { - text-decoration: underline; - } +.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { + text-decoration: underline; +} - .top-row ::deep a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } +.top-row ::deep a:first-child { + overflow: hidden; + text-overflow: ellipsis; +} @media (max-width: 640.98px) { .top-row { justify-content: space-between; } - .top-row ::deep a, .top-row ::deep .btn-link { - margin-left: 0; - } + .top-row ::deep a, .top-row ::deep .btn-link { + margin-left: 0; + } } @media (min-width: 641px) { @@ -64,14 +64,14 @@ main { z-index: 1; } - .top-row.auth ::deep a:first-child { - flex: 1; - text-align: right; - width: 0; - } + .top-row.auth ::deep a:first-child { + flex: 1; + text-align: right; + width: 0; + } .top-row, article { padding-left: 2rem !important; padding-right: 1.5rem !important; } -} +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/NavBar.razor b/SteUp.Shared/Components/Layout/NavBar.razor deleted file mode 100644 index a9c1b7b..0000000 --- a/SteUp.Shared/Components/Layout/NavBar.razor +++ /dev/null @@ -1,40 +0,0 @@ -
- -
- -@code { - -} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/NavBar.razor.css b/SteUp.Shared/Components/Layout/NavBar.razor.css deleted file mode 100644 index 841769e..0000000 --- a/SteUp.Shared/Components/Layout/NavBar.razor.css +++ /dev/null @@ -1,81 +0,0 @@ -a { - text-decoration: none; - color: inherit; -} - -ul { - list-style-type: none; -} - -.container { - max-width: 100%; - margin: 0 auto; - padding: 0; -} - -nav { - position: fixed; - bottom: 0; - width: 100%; - background-color: var(--ligther-color); - margin: 0; - display: flex; - border-radius: 40px 40px 0px 0px; - box-shadow: rgb(50 50 93 / 25%) 0 50px 100px 10px, - rgb(0 0 0 / 30%) 0 30px 60px -30px; -} - -nav ul { - display: inline-flex; - align-items: center; - padding: 0; - flex: 0 0 25%; - justify-content: center; -} - -nav :where(li a) { - position: relative; -} - -nav ul li a { - display: flex; - align-items: center; - justify-content: center; - flex-direction: column-reverse; - padding: 1em; - line-height: 1.4; - -webkit-transition: all .3s ease-out; - transition: all .3s ease-out; -} - -nav ul li a:hover { - color: var(--primary-color); -} - -nav ul li a i { - font-size: 1.5rem; -} - -nav ul li a span { - font-size: 0.9rem; -} - -/* animations */ - -nav li.active a::before, nav li.active a::after { - content: ""; - position: absolute; - background-color: var(--primary-color); - z-index: -1; -} - -nav li.active a::before { - top: 5%; - width: calc(100% - 0px); - height: 100%; - border-radius: 25px; -} - -nav li.active a { - color: var(--ligther-color); -} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/NavMenu.razor b/SteUp.Shared/Components/Layout/NavMenu.razor index ea9c171..5ecebcf 100644 --- a/SteUp.Shared/Components/Layout/NavMenu.razor +++ b/SteUp.Shared/Components/Layout/NavMenu.razor @@ -1,38 +1,72 @@ - + - \ No newline at end of file +@code +{ + private bool IsVisible { get; set; } = true; + private bool PlusVisible { get; set; } = true; + + protected override Task OnInitializedAsync() + { + NavigationManager.LocationChanged += (_, args) => + { + var location = args.Location.Remove(0, NavigationManager.BaseUri.Length); + + var newIsVisible = new List { "Home" } + .Contains(location); + + var newPlusVisible = new List { "Home" } + .Contains(location); + + if (IsVisible == newIsVisible && PlusVisible == newPlusVisible) return; + + IsVisible = newIsVisible; + PlusVisible = newPlusVisible; + StateHasChanged(); + }; + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor b/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor new file mode 100644 index 0000000..89399a9 --- /dev/null +++ b/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor @@ -0,0 +1,8 @@ +
+ +
+ +@code +{ + [Parameter] public bool FullScreen { get; set; } = true; +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor.css b/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor.css new file mode 100644 index 0000000..642f267 --- /dev/null +++ b/SteUp.Shared/Components/Layout/Spinner/SpinnerLayout.razor.css @@ -0,0 +1,43 @@ +.spinner-container { + display: flex; + justify-content: center; + height: calc(100vh - 10.1rem); + align-items: center; + color: var(--mud-palette-primary); +} + +.not-fullScreen { + height: auto !important; + padding: 2rem 0 !important; +} + +.loader { + width: 50px; + aspect-ratio: 1; + border-radius: 50%; + border: 8px solid #0000; + border-right-color: var(--mud-palette-secondary); + position: relative; + animation: l24 1s infinite linear; +} + +.loader:before, +.loader:after { + content: ""; + position: absolute; + inset: -8px; + border-radius: 50%; + border: inherit; + animation: inherit; + animation-duration: 2s; +} + +.loader:after { + animation-duration: 4s; +} + +@keyframes l24 { + 100% { + transform: rotate(1turn) + } +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Counter.razor b/SteUp.Shared/Components/Pages/Counter.razor deleted file mode 100644 index 1d02763..0000000 --- a/SteUp.Shared/Components/Pages/Counter.razor +++ /dev/null @@ -1,16 +0,0 @@ -@page "/counter" - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/SteUp.Shared/Components/Pages/DeviceFormFactor.razor b/SteUp.Shared/Components/Pages/DeviceFormFactor.razor deleted file mode 100644 index 6f421b4..0000000 --- a/SteUp.Shared/Components/Pages/DeviceFormFactor.razor +++ /dev/null @@ -1,23 +0,0 @@ -@page "/device-form-factor" -@using Template.Shared.Interfaces -@inject IFormFactor FormFactor - -Form Factor - -

Device Form Factor

- -

You are running on:

- -
    -
  • Form Factor: @factor
  • -
  • Platform: @platform
  • -
- -

- This component is defined in the Template.Shared library. -

- -@code { - private string factor => FormFactor.GetFormFactor(); - private string platform => FormFactor.GetPlatform(); -} diff --git a/SteUp.Shared/Components/Pages/Home.razor b/SteUp.Shared/Components/Pages/Home.razor index 190c626..724fd98 100644 --- a/SteUp.Shared/Components/Pages/Home.razor +++ b/SteUp.Shared/Components/Pages/Home.razor @@ -1,15 +1,4 @@ -@page "/" +@page "/home" +@attribute [Authorize] -

Hello, world!

- -Welcome to your new app. - - - ... - - - - -@code { - private Modal modal = default!; -} \ No newline at end of file +

Home

\ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Home.razor.css b/SteUp.Shared/Components/Pages/Home.razor.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/SteUp.Shared/Components/Pages/Home.razor.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Impostazioni.razor b/SteUp.Shared/Components/Pages/Impostazioni.razor deleted file mode 100644 index f9a4f56..0000000 --- a/SteUp.Shared/Components/Pages/Impostazioni.razor +++ /dev/null @@ -1,6 +0,0 @@ -@page "/settings" -

Impostazioni

- -@code { - -} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Index.razor b/SteUp.Shared/Components/Pages/Index.razor new file mode 100644 index 0000000..2ab81a2 --- /dev/null +++ b/SteUp.Shared/Components/Pages/Index.razor @@ -0,0 +1,13 @@ +@page "/" +@using SteUp.Shared.Components.Layout.Spinner +@attribute [Authorize] + + + +@code { + protected override void OnInitialized() + { + NavigationManager.NavigateTo("/home"); + } + +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Log Book.razor b/SteUp.Shared/Components/Pages/Log Book.razor deleted file mode 100644 index ecc561d..0000000 --- a/SteUp.Shared/Components/Pages/Log Book.razor +++ /dev/null @@ -1,10 +0,0 @@ -@page "/logbook" -@using Template.Shared.Components.SingleElements -

Log book

- - - -@code { - -} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Login.razor b/SteUp.Shared/Components/Pages/Login.razor new file mode 100644 index 0000000..024bbae --- /dev/null +++ b/SteUp.Shared/Components/Pages/Login.razor @@ -0,0 +1,6 @@ +@page "/login" +

Login

+ +@code { + +} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Login.razor.css b/SteUp.Shared/Components/Pages/Login.razor.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/SteUp.Shared/Components/Pages/Login.razor.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Weather.razor b/SteUp.Shared/Components/Pages/Weather.razor deleted file mode 100644 index 472bb98..0000000 --- a/SteUp.Shared/Components/Pages/Weather.razor +++ /dev/null @@ -1,61 +0,0 @@ -@page "/weather" - -

Weather

- -

This component demonstrates showing data.

- -@if (forecasts == null) -{ -

Loading...

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - // Simulate asynchronous loading to demonstrate a loading indicator - await Task.Delay(500); - - var startDate = DateOnly.FromDateTime(DateTime.Now); - var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; - forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = summaries[Random.Shared.Next(summaries.Length)] - }).ToArray(); - } - - private class WeatherForecast - { - public DateOnly Date { get; set; } - public int TemperatureC { get; set; } - public string? Summary { get; set; } - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } -} diff --git a/SteUp.Shared/Components/Pages/Workout.razor b/SteUp.Shared/Components/Pages/Workout.razor deleted file mode 100644 index ea09c39..0000000 --- a/SteUp.Shared/Components/Pages/Workout.razor +++ /dev/null @@ -1,12 +0,0 @@ -@page "/workout" -@using Template.Shared.Components.SingleElements -

Workout

- - - -@code { - - - -} \ No newline at end of file diff --git a/SteUp.Shared/Components/Pages/Workout.razor.css b/SteUp.Shared/Components/Pages/Workout.razor.css deleted file mode 100644 index e69de29..0000000 diff --git a/SteUp.Shared/Components/Routes.razor b/SteUp.Shared/Components/Routes.razor index 1709cd1..c707971 100644 --- a/SteUp.Shared/Components/Routes.razor +++ b/SteUp.Shared/Components/Routes.razor @@ -1,6 +1,48 @@ - - - - - - +@using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal +@inject NavigationManager NavigationManager + + + + + + + + +

Authorizing page

+
+ + @if (context.User.Identity?.IsAuthenticated != true) + { + NavigationManager.NavigateTo("/login"); + } + else + { +

You are not authorized to access this resource.

+ } +
+
+ +
+ + Not found + +

Sorry, there's nothing at this address.

+
+
+
+
+
+ + + + +
+ +@code { + + private ErrorBoundary? ErrorBoundary { get; set; } + private ExceptionModal ExceptionModal { get; set; } +} \ No newline at end of file diff --git a/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor b/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor new file mode 100644 index 0000000..19fa4f4 --- /dev/null +++ b/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor @@ -0,0 +1,59 @@ +
+
+
+ + Ops +
+
+ @if (Exception != null) + { + @Message + } +
+
+
+ Riprova +
+ +
+ Continua +
+
+
+
+ +@code { + [Parameter] public Exception? Exception { get; set; } + [Parameter] public EventCallback OnRetry { get; set; } + [Parameter] public ErrorBoundary? ErrorBoundary { get; set; } + + private string Message { get; set; } = ""; + + protected override void OnInitialized() + { + if (Exception == null) return; + + if (Exception.Message.Contains("Failed to connect to")) + { + var ipPort = Exception.Message.Split("to /")[1]; + + Message = $"Impossibile collegarsi al server ({ipPort})"; + } + else + { + Message = Exception.Message; + } + StateHasChanged(); + } + + private async Task OnRetryClick() + { + await OnRetry.InvokeAsync(); + } + + private async Task OnContinueClick() + { + NavigationManager.NavigateTo("/"); + await OnRetry.InvokeAsync(); + } +} \ No newline at end of file diff --git a/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor.css b/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor.css new file mode 100644 index 0000000..dbc89fa --- /dev/null +++ b/SteUp.Shared/Components/SingleElements/Modal/ExceptionModal/ExceptionModal.razor.css @@ -0,0 +1,61 @@ +.container-modal { + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; +} + +.c-modal { + border-radius: 16px; + box-shadow: var(--exception-box-shadow); + padding: 16px; +} + +.button-container { + display: flex; + gap: 1rem; + flex-direction: row; + align-items: center; + width: 100%; + justify-content: space-between; + margin: 1.5rem 0 0 0; +} + +.text { + font-size: medium; + font-weight: 500; + display: flex; + text-align: center; +} + +.card-button { + text-align: center; + background-color: transparent; + padding: .3rem 1rem; + font-weight: 700; + color: var(--bs-primary-text-emphasis); +} + +.exception-header { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.exception-header > i { + font-size: 3rem; + line-height: normal; + color: var(--bs-danger); +} + +.exception-header > span { + font-size: x-large; + font-weight: 700; +} + +code { + width: 100%; + height: auto; + color: var(--bs-gray-dark); +} \ No newline at end of file diff --git a/SteUp.Shared/Core/Authorization/Enum/KeyGroupEnum.cs b/SteUp.Shared/Core/Authorization/Enum/KeyGroupEnum.cs new file mode 100644 index 0000000..893cfd2 --- /dev/null +++ b/SteUp.Shared/Core/Authorization/Enum/KeyGroupEnum.cs @@ -0,0 +1,13 @@ +namespace SteUp.Shared.Core.Authorization.Enum; + +public enum KeyGroupEnum +{ + UtenteAziendale = 2, + Cliente = 3, + Agenti = 5, + AmministratoreAziendale = 9, + Tecnico = 22, + ResponsabileDiReparto = 23, + ResponsabileAmministrativo = 29, + Programmatore = 30 +} \ No newline at end of file diff --git a/SteUp.Shared/Interfaces/IFormFactor.cs b/SteUp.Shared/Core/Interface/IFormFactor.cs similarity index 72% rename from SteUp.Shared/Interfaces/IFormFactor.cs rename to SteUp.Shared/Core/Interface/IFormFactor.cs index aa7a4fa..93a63fa 100644 --- a/SteUp.Shared/Interfaces/IFormFactor.cs +++ b/SteUp.Shared/Core/Interface/IFormFactor.cs @@ -1,4 +1,4 @@ -namespace Template.Shared.Interfaces; +namespace SteUp.Shared.Core.Interface; public interface IFormFactor { diff --git a/SteUp.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs b/SteUp.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs new file mode 100644 index 0000000..613fd2a --- /dev/null +++ b/SteUp.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs @@ -0,0 +1,6 @@ +namespace SteUp.Shared.Core.Interface.IntegryApi; + +public interface IIntegryApiService +{ + Task SystemOk(); +} \ No newline at end of file diff --git a/SteUp.Shared/Core/Interface/System/Network/INetworkService.cs b/SteUp.Shared/Core/Interface/System/Network/INetworkService.cs new file mode 100644 index 0000000..10643aa --- /dev/null +++ b/SteUp.Shared/Core/Interface/System/Network/INetworkService.cs @@ -0,0 +1,8 @@ +namespace SteUp.Shared.Core.Interface.System.Network; + +public interface INetworkService +{ + public bool ConnectionAvailable { get; set; } + + public bool IsNetworkAvailable(); +} \ No newline at end of file diff --git a/SteUp.Shared/Core/Services/AppAuthenticationStateProvider.cs b/SteUp.Shared/Core/Services/AppAuthenticationStateProvider.cs new file mode 100644 index 0000000..e6a46c2 --- /dev/null +++ b/SteUp.Shared/Core/Services/AppAuthenticationStateProvider.cs @@ -0,0 +1,56 @@ +using System.Security.Claims; +using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account; +using Microsoft.AspNetCore.Components.Authorization; + +namespace SteUp.Shared.Core.Services; + +public class AppAuthenticationStateProvider : AuthenticationStateProvider +{ + private readonly IUserSession _userSession; + private readonly IUserAccountService _userAccountService; + + + public AppAuthenticationStateProvider(IUserSession userSession, IUserAccountService userAccountService) + { + _userSession = userSession; + _userAccountService = userAccountService; + + userAccountService.ExpiredUserSession += (_, _) => + NotifyAuthenticationStateChanged(LoadAuthenticationState()); + } + + public override async Task GetAuthenticationStateAsync() + { + return await LoadAuthenticationState(); + } + + public async Task SignOut() + { + await _userAccountService.Logout(); + NotifyAuthenticationState(); + } + + public void NotifyAuthenticationState() + { + NotifyAuthenticationStateChanged(LoadAuthenticationState()); + } + + private async Task LoadAuthenticationState() + { + if (!await _userSession.IsLoggedIn() || !await _userSession.IsRefreshTokenValid()) + { + return new AuthenticationState( + new ClaimsPrincipal( + new ClaimsIdentity() + ) + ); + } + + var claimIdentity = new ClaimsIdentity(_userSession.JwtToken!.Claims, "jwt"); + var user = new ClaimsPrincipal(claimIdentity); + + + var authenticationState = new AuthenticationState(user); + return authenticationState; + } +} \ No newline at end of file diff --git a/SteUp.Shared/Core/Services/IntegryApiService.cs b/SteUp.Shared/Core/Services/IntegryApiService.cs new file mode 100644 index 0000000..2d24b81 --- /dev/null +++ b/SteUp.Shared/Core/Services/IntegryApiService.cs @@ -0,0 +1,22 @@ +using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account; +using IntegryApiClient.Core.Domain.RestClient.Contacts; +using SteUp.Shared.Core.Interface.IntegryApi; + +namespace SteUp.Shared.Core.Services; + +public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUserSession userSession) + : IIntegryApiService +{ + public async Task SystemOk() + { + try + { + await integryApiRestClient.Get("system/ok"); + return true; + } + catch (Exception e) + { + return false; + } + } +} \ No newline at end of file diff --git a/SteUp.Shared/InteractiveRenderSettings.cs b/SteUp.Shared/InteractiveRenderSettings.cs index b6aadcf..15d418c 100644 --- a/SteUp.Shared/InteractiveRenderSettings.cs +++ b/SteUp.Shared/InteractiveRenderSettings.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; -namespace Template.Shared; +namespace SteUp.Shared; public static class InteractiveRenderSettings { diff --git a/SteUp.Shared/SteUp.Shared.csproj b/SteUp.Shared/SteUp.Shared.csproj index 96bbb52..fe8d4ee 100644 --- a/SteUp.Shared/SteUp.Shared.csproj +++ b/SteUp.Shared/SteUp.Shared.csproj @@ -1,23 +1,31 @@ - - net8.0 - enable - enable - + + net9.0 + enable + enable + - - - + + + - - - - - + + + + + + + + + - - - + + + + + + + diff --git a/SteUp.Shared/_Imports.razor b/SteUp.Shared/_Imports.razor index 62c3cc9..16c00c2 100644 --- a/SteUp.Shared/_Imports.razor +++ b/SteUp.Shared/_Imports.razor @@ -1,10 +1,19 @@ @using System.Net.Http @using System.Net.Http.Json +@using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account +@using IntegryApiClient.Core.Domain.Abstraction.Contracts.Storage @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop -@using Template.Shared.Components -@using BlazorBootstrap; +@using SteUp.Shared.Components +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using MudBlazor @using static InteractiveRenderSettings + +@inject NavigationManager NavigationManager +@inject IUserSession UserSession +@inject ILocalStorage LocalStorage +@inject ISnackbar Snackbar \ No newline at end of file diff --git a/SteUp.Shared/wwwroot/css/app.css b/SteUp.Shared/wwwroot/css/app.css index 4423743..c5490f8 100644 --- a/SteUp.Shared/wwwroot/css/app.css +++ b/SteUp.Shared/wwwroot/css/app.css @@ -1,46 +1,98 @@ -html, body { - font-family: 'Poppins', 'Helvetica Neue', Helvetica, Arial, sans-serif; +html { overflow: hidden; } + +.page, article, main { height: 100% !important; overflow: hidden; } + +#app { height: 100vh; } + +html, body { + font-family: "Nunito", sans-serif; font-size: 14px; font-weight: 400; line-height: 1.8; color: black; } +* { font-family: "Nunito", sans-serif !important; } + +.mud-button-label { font-weight: 700 !important; } + a, .btn-link { /*color: #006bb7;*/ text-decoration: none; color: inherit; } +article { + display: flex; + flex-direction: column; +} + +/*ServicesIsDown" : "SystemOk" : "NetworkKo*/ + +.Connection { + padding: 0 .75rem; + font-weight: 700; + display: flex; + flex-direction: row; + gap: 1rem; + font-size: larger; + transition: all 0.5s ease; + opacity: 0; + transform: translateY(-35px); + min-height: 35px; + align-items: center; +} + +.Connection.ServicesIsDown, .Connection.NetworkKo { + background-color: var(--mud-palette-error); + color: white; +} + +.Connection.SystemOk { + background-color: var(--mud-palette-success); + color: white; +} + +.Connection.Show { + opacity: 1; + transform: translateY(0); +} + +.Connection.Hide ~ .page { + transition: all 0.5s ease; + transform: translateY(-35px); +} + .btn-primary { color: #fff; background-color: var(--primary-color); border-color: var(--darker-color); } -.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { - box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; -} +.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; } .content { - padding-top: 1.1rem; + padding-top: 1rem; + display: flex; + align-items: center; + flex-direction: column; + height: 90vh; } -h1:focus { - outline: none; +.content::-webkit-scrollbar { width: 3px; } + +.content::-webkit-scrollbar-thumb { + background: #bbb; + border-radius: 2px; } -.valid.modified:not([type=checkbox]) { - outline: 1px solid #26b050; -} +h1:focus { outline: none; } -.invalid { - outline: 1px solid #e50000; -} +.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; } -.validation-message { - color: #e50000; -} +.invalid { outline: 1px solid #e50000; } + +.validation-message { color: #e50000; } #blazor-error-ui { background: lightyellow; @@ -67,18 +119,134 @@ h1:focus { color: white; } -.blazor-error-boundary::after { - content: "An error has occurred." -} +.blazor-error-boundary::after { content: "An error has occurred." } -.status-bar-safe-area { - display: none; -} +.status-bar-safe-area { display: none; } .page-title { - /*text-align: center;*/ font-size: x-large; - color: var(--darker-color); + font-weight: 800; + margin: 0; + line-height: normal; + color: var(--mud-palette-text-primary); +} + +.custom-mudfab { + position: fixed !important; + bottom: 4rem; + margin-bottom: 16px; + right: 16px; +} + +.custom_popover { + border-radius: 5px !important; + background-color: var(--mud-palette-drawer-background) !important; + box-shadow: 4px 4px 20px 0px rgba(0, 0, 0, 0.26), 0px 0px 0px 1px rgb(255 255 255 / 25%) !important; + color: var(--mud-palette-text-primary) !important; +} + +.custom_popover .mud-divider { border-color: var(--mud-palette-text-primary) !important; } + +.custom_popover .mud-list-padding { padding: 3px 0px 3px 0px !important; } + +.custom_popover .mud-list-item { padding: 5px 12px 5px 12px; } + +.custom_popover .mud-menu-item-text { font-weight: 600; } + +.custom_popover .mud-list-item-icon { + min-width: fit-content !important; + padding-right: 12px !important; +} + +.divider { + display: block; + width: 100%; + border: .05rem solid var(--card-border-color); + margin: 1rem 0; +} + +/*Spinner*/ + +.spinner-container { + display: flex; + justify-content: center; + height: 100vh; + align-items: center; + color: var(--mud-palette-primary); +} + +.not-fullScreen { + height: auto !important; + padding: 2rem 0 !important; +} + +.loader { + width: 50px; + aspect-ratio: 1; + border-radius: 50%; + border: 8px solid #0000; + border-right-color: var(--mud-palette-secondary); + position: relative; + animation: l24 1s infinite linear; +} + +.loader:before, +.loader:after { + content: ""; + position: absolute; + inset: -8px; + border-radius: 50%; + border: inherit; + animation: inherit; + animation-duration: 2s; +} + +.loader:after { animation-duration: 4s; } + +@keyframes l24 { + 100% { transform: rotate(1turn) } +} + +/*MudBlazor Personalization*/ + +.mud-button-group-horizontal:not(.mud-button-group-rtl) > .mud-button-root:not(:last-child), .mud-button-group-horizontal:not(.mud-button-group-rtl) > :not(:last-child) .mud-button-root { + border-top-right-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +.mud-button-group-horizontal:not(.mud-button-group-rtl) > .mud-button-root:not(:first-child), .mud-button-group-horizontal:not(.mud-button-group-rtl) > :not(:first-child) .mud-button-root { + border-top-left-radius: 0 !important; + border-bottom-left-radius: 0 !important; +} + +.customDialog-form .mud-dialog-content { + padding: 0 .75rem; + margin: 0; + overflow: hidden; +} + +.custom-item-select { padding: 6px 16px; } + +.custom-item-select .mud-typography-body1 { + font-weight: 600; + font-size: .9rem; +} + +.container { + padding-right: var(--m-page-x) !important; + padding-left: var(--m-page-x) !important; +} + +.lm-container { + padding-right: calc(var(--m-page-x) * 0.5) !important; + padding-left: calc(var(--m-page-x) * 0.5) !important; +} + +.mud-message-box > .mud-dialog-title > h6 { font-weight: 800 !important; } + +.mud-dialog-actions button { + margin-left: .5rem !important; + margin-right: .5rem !important; } @supports (-webkit-touch-callout: none) { @@ -87,18 +255,23 @@ h1:focus { position: fixed; top: 0; height: env(safe-area-inset-top); - background-color: #f7f7f7; width: 100%; z-index: 1; + background-color: var(--mud-palette-surface); } + .modal { padding-top: env(safe-area-inset-top); } + + .safe-area-bottom { margin-bottom: env(safe-area-inset-bottom) !important; } + + .pb-safe-area { padding-bottom: env(safe-area-inset-bottom) !important; } #app { - padding-top: env(safe-area-inset-top); - height: 100vh; + margin-top: env(safe-area-inset-top); + height: calc(100vh - env(safe-area-inset-top)); } - .flex-column, .navbar-brand { - padding-left: env(safe-area-inset-left); - } -} + .flex-column, .navbar-brand { padding-left: env(safe-area-inset-left); } + + .customDialog-form .mud-dialog-content { margin-top: env(safe-area-inset-top); } +} \ No newline at end of file diff --git a/SteUp.Shared/wwwroot/css/default-theme.css b/SteUp.Shared/wwwroot/css/default-theme.css index 2a7bc2f..bb5ba37 100644 --- a/SteUp.Shared/wwwroot/css/default-theme.css +++ b/SteUp.Shared/wwwroot/css/default-theme.css @@ -1,5 +1,5 @@ :root { - --primary-color: #5352ed; + --primary-color: #ec4c41; --ligther-color: #f7f7ff; - --darker-color: hsl(240, 81%, 30%); + --darker-color: #d02315; } \ No newline at end of file diff --git a/SteUp.Web/Components/App.razor b/SteUp.Web/Components/App.razor index a568c09..a2326cf 100644 --- a/SteUp.Web/Components/App.razor +++ b/SteUp.Web/Components/App.razor @@ -10,14 +10,14 @@ - - + + - - - - + + + + @@ -26,13 +26,13 @@ - + - + - + - + diff --git a/SteUp.Web/Components/Pages/Error.razor b/SteUp.Web/Components/Pages/Error.razor index 576cc2d..4f534f3 100644 --- a/SteUp.Web/Components/Pages/Error.razor +++ b/SteUp.Web/Components/Pages/Error.razor @@ -1,5 +1,4 @@ @page "/Error" -@using System.Diagnostics Error @@ -24,13 +23,12 @@ and restarting the app.

-@code{ - [CascadingParameter] - private HttpContext? HttpContext { get; set; } - +@code { private string? RequestId { get; set; } private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - protected override void OnInitialized() => - RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; -} + protected override void OnInitialized() + { + RequestId = Guid.NewGuid().ToString(); + } +} \ No newline at end of file diff --git a/SteUp.Web/Components/_Imports.razor b/SteUp.Web/Components/_Imports.razor index a07e26d..921fcd7 100644 --- a/SteUp.Web/Components/_Imports.razor +++ b/SteUp.Web/Components/_Imports.razor @@ -6,6 +6,6 @@ @using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop -@using Template.Web -@using Template.Shared.Components -@using Template.Shared +@using SteUp.Web +@using SteUp.Shared.Components +@using SteUp.Shared diff --git a/SteUp.Web/Program.cs b/SteUp.Web/Program.cs index 18ab6ae..4f5f807 100644 --- a/SteUp.Web/Program.cs +++ b/SteUp.Web/Program.cs @@ -1,43 +1,30 @@ using IntegryApiClient.Blazor; -using Template.Web.Components; -using Template.Shared.Interfaces; -using Template.Web.Services; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using MudBlazor.Services; +using SteUp.Shared.Components; +using SteUp.Shared.Core.Interface; +using SteUp.Shared.Core.Services; +using SteUp.Web.Services; -#if DEBUG -const string BaseRestServicesEndpoint = "https://devservices.studioml.it/ems-api/"; -//const string BaseRestServicesEndpoint = "http://192.168.2.23:8080/ems-api/"; -#else - const string BaseRestServicesEndpoint = "https://services.studioml.it/ems-api/"; -#endif +var builder = WebAssemblyHostBuilder.CreateDefault(args); -var builder = WebApplication.CreateBuilder(args); +builder.Services.AddMudServices(); +builder.Services.AddAuthorizationCore(); -// Add services to the container. -builder.Services.AddRazorComponents() - .AddInteractiveServerComponents(); - -builder.Services.AddBlazorBootstrap(); -builder.Services.UseIntegry(BaseRestServicesEndpoint); +const string appToken = "4fef1843-793d-499b-a7ed-1edd8cac465c"; +builder.Services.UseIntegry(appToken: appToken, useLoginAzienda: true); builder.Services.AddScoped(); -var app = builder.Build(); +builder.Services.AddScoped(); +builder.Services.AddScoped(provider => provider.GetRequiredService()); -// Configure the HTTP request pipeline. -if (!app.Environment.IsDevelopment()) -{ - app.UseExceptionHandler("/Error", createScopeForErrors: true); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); -} +builder.RootComponents.Add("#app"); +builder.RootComponents.Add("head::after"); -app.UseHttpsRedirection(); +builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); -app.UseStaticFiles(); -app.UseAntiforgery(); - -app.MapRazorComponents() - .AddInteractiveServerRenderMode() - .AddAdditionalAssemblies(typeof(Template.Shared._Imports).Assembly); - -app.Run(); +var host = builder.Build(); +await host.RunAsync(); \ No newline at end of file diff --git a/SteUp.Web/Services/FormFactor.cs b/SteUp.Web/Services/FormFactor.cs index 10c2378..b74cc83 100644 --- a/SteUp.Web/Services/FormFactor.cs +++ b/SteUp.Web/Services/FormFactor.cs @@ -1,6 +1,6 @@ -using Template.Shared.Interfaces; +using SteUp.Shared.Core.Interface; -namespace Template.Web.Services; +namespace SteUp.Web.Services; public class FormFactor : IFormFactor { diff --git a/SteUp.Web/SteUp.Web.csproj b/SteUp.Web/SteUp.Web.csproj index 6549ed2..baf5061 100644 --- a/SteUp.Web/SteUp.Web.csproj +++ b/SteUp.Web/SteUp.Web.csproj @@ -1,17 +1,20 @@ - - net8.0 - enable - enable - + + net9.0 + enable + enable + - - - + + + + + + - - - + + +