From 9600e3243b124fd63abb84a00b30134329544a99 Mon Sep 17 00:00:00 2001 From: Kentin BRONGNIART Date: Wed, 18 Dec 2024 17:21:58 +0100 Subject: [PATCH] base site --- WF-WebAdmin/WF-WebAdmin.sln | 2 +- WF-WebAdmin/WF-WebAdmin/Model/Quote.cs | 14 ++++++ WF-WebAdmin/WF-WebAdmin/Pages/Accueil.cs | 22 +++++++++ WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor | 38 +++++++++++++++ WF-WebAdmin/WF-WebAdmin/Pages/Counter.razor | 18 ------- WF-WebAdmin/WF-WebAdmin/Pages/FetchData.razor | 48 ------------------- WF-WebAdmin/WF-WebAdmin/Pages/Index.razor | 9 ---- WF-WebAdmin/WF-WebAdmin/Pages/Quiz.razor | 4 ++ .../WF-WebAdmin/Pages/ValidQuote.razor | 5 ++ WF-WebAdmin/WF-WebAdmin/Program.cs | 2 + WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor | 10 ++-- .../WF-WebAdmin/Shared/SurveyPrompt.razor | 16 ------- .../WF-WebAdmin/wwwroot/fake-data.json | 22 +++++++++ 13 files changed, 113 insertions(+), 97 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Model/Quote.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Accueil.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor delete mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Counter.razor delete mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/FetchData.razor delete mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Index.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Quiz.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor delete mode 100644 WF-WebAdmin/WF-WebAdmin/Shared/SurveyPrompt.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/wwwroot/fake-data.json diff --git a/WF-WebAdmin/WF-WebAdmin.sln b/WF-WebAdmin/WF-WebAdmin.sln index f987bb2..f97bd2a 100644 --- a/WF-WebAdmin/WF-WebAdmin.sln +++ b/WF-WebAdmin/WF-WebAdmin.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34723.18 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WF-WebAdmin", "WF-WebAdmin\WF-WebAdmin.csproj", "{0E8D1007-ADDC-4103-847D-8EE48ACCDC62}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WF-WebAdmin", "WF-WebAdmin\WF-WebAdmin.csproj", "{0E8D1007-ADDC-4103-847D-8EE48ACCDC62}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs new file mode 100644 index 0000000..7ef671e --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs @@ -0,0 +1,14 @@ +namespace WF_WebAdmin.Model +{ + public class Quote + { + public int Id { get; set; } + public string Content { get; set; } + public string Charac { get; set; } + public string ImgPath { get; set; } + public string TitleSrc { get; set; } + public DateTime DateSrc { get; set; } + public int Like { get; set; } + public string Langue { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.cs new file mode 100644 index 0000000..4858265 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Components; +using WF_WebAdmin.Model; + + +namespace WF_WebAdmin.Pages +{ + public partial class Accueil + { + private Quote[] quotes; + + [Inject] + public HttpClient Http { get; set; } + + [Inject] + public NavigationManager NavigationManager { get; set; } + + protected override async Task OnInitializedAsync() + { + quotes = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-data.json"); + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor new file mode 100644 index 0000000..ba4614e --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor @@ -0,0 +1,38 @@ +@page "/" + + +Accueil + +

Accueil

+ + +@if (quotes != null) +{ + + + + + + + + + + + + + + @foreach (var quote in quotes) + { + + + + + + + + + + } + +
IdContentCharactéreTitle SourceLikeLangueDate Source
@quote.Id@quote.Content@quote.Charac@quote.TitleSrc@quote.Like@quote.Langue@quote.DateSrc.ToShortDateString()
+} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Counter.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Counter.razor deleted file mode 100644 index b21f052..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Counter.razor +++ /dev/null @@ -1,18 +0,0 @@ -@page "/counter" - -Counter - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/FetchData.razor b/WF-WebAdmin/WF-WebAdmin/Pages/FetchData.razor deleted file mode 100644 index b9a2aca..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Pages/FetchData.razor +++ /dev/null @@ -1,48 +0,0 @@ -@page "/fetchdata" - -Weather forecast - -@using WF_WebAdmin.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/WF-WebAdmin/WF-WebAdmin/Pages/Index.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Index.razor deleted file mode 100644 index b1a9fbd..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Index.razor +++ /dev/null @@ -1,9 +0,0 @@ -@page "/" - -Index - -

Hello, world!

- -Welcome to your new app. - - diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Quiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Quiz.razor new file mode 100644 index 0000000..4a38264 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Quiz.razor @@ -0,0 +1,4 @@ +@page "/Quiz" + + +

Quiz

diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor new file mode 100644 index 0000000..ba82a6e --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor @@ -0,0 +1,5 @@ +@page "/ValidQuote" + + +

ValidQuote

+ diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index 59daffc..cdcdbeb 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -9,6 +9,8 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); +builder.Services.AddHttpClient(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor index 226024f..86a21aa 100644 --- a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor +++ b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor @@ -11,17 +11,17 @@ diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/SurveyPrompt.razor b/WF-WebAdmin/WF-WebAdmin/Shared/SurveyPrompt.razor deleted file mode 100644 index 799bb62..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Shared/SurveyPrompt.razor +++ /dev/null @@ -1,16 +0,0 @@ -
- - @Title - - - Please take our - brief survey - - and tell us what you think. -
- -@code { - // Demonstrates how a parent component can supply parameters - [Parameter] - public string? Title { get; set; } -} diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-data.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-data.json new file mode 100644 index 0000000..f38cd34 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-data.json @@ -0,0 +1,22 @@ +[ + { + "Id": 1, + "Content": "coucou", + "Charac": "moi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2001-01-01", + "Like": 20, + "Langue": "fr" + }, + { + "Id": 2, + "Content": "boujour", + "Charac": "toi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2002-02-02", + "Like": 0, + "Langue": "fr" + } +] \ No newline at end of file