From 8880e0efec7462f6865e528f01b9973c6e722e8b Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 19 Dec 2020 16:32:14 +0200 Subject: Blazor Template added --- src/DevHive.Blazor/Pages/Counter.razor | 16 +++++++++++ src/DevHive.Blazor/Pages/Error.cshtml | 42 +++++++++++++++++++++++++++++ src/DevHive.Blazor/Pages/Error.cshtml.cs | 32 ++++++++++++++++++++++ src/DevHive.Blazor/Pages/FetchData.razor | 46 ++++++++++++++++++++++++++++++++ src/DevHive.Blazor/Pages/Index.razor | 7 +++++ src/DevHive.Blazor/Pages/_Host.cshtml | 35 ++++++++++++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 src/DevHive.Blazor/Pages/Counter.razor create mode 100644 src/DevHive.Blazor/Pages/Error.cshtml create mode 100644 src/DevHive.Blazor/Pages/Error.cshtml.cs create mode 100644 src/DevHive.Blazor/Pages/FetchData.razor create mode 100644 src/DevHive.Blazor/Pages/Index.razor create mode 100644 src/DevHive.Blazor/Pages/_Host.cshtml (limited to 'src/DevHive.Blazor/Pages') diff --git a/src/DevHive.Blazor/Pages/Counter.razor b/src/DevHive.Blazor/Pages/Counter.razor new file mode 100644 index 0000000..ea07ff3 --- /dev/null +++ b/src/DevHive.Blazor/Pages/Counter.razor @@ -0,0 +1,16 @@ +@page "/counter" + +

Counter

+ +

Current count: @currentCount

+ + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/src/DevHive.Blazor/Pages/Error.cshtml b/src/DevHive.Blazor/Pages/Error.cshtml new file mode 100644 index 0000000..9e1d3fa --- /dev/null +++ b/src/DevHive.Blazor/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model DevHive.Blazor.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

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

+ Request ID: @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. +

+
+
+ + + diff --git a/src/DevHive.Blazor/Pages/Error.cshtml.cs b/src/DevHive.Blazor/Pages/Error.cshtml.cs new file mode 100644 index 0000000..b18c4a6 --- /dev/null +++ b/src/DevHive.Blazor/Pages/Error.cshtml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Logging; + +namespace DevHive.Blazor.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/src/DevHive.Blazor/Pages/FetchData.razor b/src/DevHive.Blazor/Pages/FetchData.razor new file mode 100644 index 0000000..a496d0d --- /dev/null +++ b/src/DevHive.Blazor/Pages/FetchData.razor @@ -0,0 +1,46 @@ +@page "/fetchdata" + +@using DevHive.Blazor.Data +@inject WeatherForecastService ForecastService + +

Weather forecast

+ +

This component demonstrates fetching data from a service.

+ +@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() + { + forecasts = await ForecastService.GetForecastAsync(DateTime.Now); + } +} diff --git a/src/DevHive.Blazor/Pages/Index.razor b/src/DevHive.Blazor/Pages/Index.razor new file mode 100644 index 0000000..a4c47de --- /dev/null +++ b/src/DevHive.Blazor/Pages/Index.razor @@ -0,0 +1,7 @@ +@page "/" + +

Hello, world!

+ +Welcome to your new app. + + diff --git a/src/DevHive.Blazor/Pages/_Host.cshtml b/src/DevHive.Blazor/Pages/_Host.cshtml new file mode 100644 index 0000000..9c03a62 --- /dev/null +++ b/src/DevHive.Blazor/Pages/_Host.cshtml @@ -0,0 +1,35 @@ +@page "/" +@namespace DevHive.Blazor.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@{ + Layout = null; +} + + + + + + + DevHive.Blazor + + + + + + + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + -- cgit v1.2.3