modal error

tpBlazor
Nicolas FRANCO 2 years ago
parent 9e0d0dfa4b
commit a7662f699e

@ -4,40 +4,40 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" /> <base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" /> <link href="css/site.css" rel="stylesheet" />
<link href="BlazorTp1.styles.css" rel="stylesheet" /> <link href="BlazorTp1.styles.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> <link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
</head> <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
<body> </head>
@RenderBody() <body>
@RenderBody()
<div id="blazor-error-ui">
<environment include="Staging,Production"> <div id="blazor-error-ui">
An error has occurred. This application may no longer respond until reloaded. <environment include="Staging,Production">
</environment> An error has occurred. This application may no longer respond until reloaded.
<environment include="Development"> </environment>
An unhandled exception has occurred. See browser dev tools for details. <environment include="Development">
</environment> An unhandled exception has occurred. See browser dev tools for details.
<a href="" class="reload">Reload</a> </environment>
<a class="dismiss">🗙</a> <a href="" class="reload">Reload</a>
</div> <a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
<script src="_framework/blazor.server.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" /> <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<script src="_content/Blazored.Modal/blazored.modal.js"></script> <script src="_content/Blazored.Modal/blazored.modal.js"></script>
<script src="Components/Crafting.razor.js"></script> <script src="Components/Crafting.razor.js"></script>
</body> </body>
</html> </html>

@ -1,14 +1,12 @@
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Modal;
using Blazorise; using Blazorise;
using Blazorise.Bootstrap; using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome; using Blazorise.Icons.FontAwesome;
using BlazorTp1.Data; using BlazorTp1.Data;
using Blazored.Modal;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using System.Globalization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Globalization;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -19,6 +17,8 @@ builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddHttpClient(); builder.Services.AddHttpClient();
builder.Services.AddBlazoredModal();
builder.Services builder.Services
.AddBlazorise() .AddBlazorise()
.AddBootstrapProviders() .AddBootstrapProviders()
@ -28,8 +28,6 @@ builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<IDataService, DataLocalService>(); builder.Services.AddScoped<IDataService, DataLocalService>();
builder.Services.AddBlazoredModal();
// Add the controller of the app // Add the controller of the app
builder.Services.AddControllers(); builder.Services.AddControllers();

@ -55,6 +55,16 @@ public class DataLocalService : IDataService
public async Task<int> Count() public async Task<int> Count()
{ {
// Load data from the local storage
var currentData = await _localStorage.GetItemAsync<Item[]>("data");
// Check if data exist in the local storage
if (currentData == null)
{
// this code add in the local storage the fake data
var originalData = await _http.GetFromJsonAsync<Item[]>($"{_navigationManager.BaseUri}fake-data.json");
await _localStorage.SetItemAsync("data", originalData);
}
return (await _localStorage.GetItemAsync<Item[]>("data")).Length; return (await _localStorage.GetItemAsync<Item[]>("data")).Length;
} }

Loading…
Cancel
Save