diff --git a/blazor_lab/Models/Item.cs b/blazor_lab/Models/Item.cs new file mode 100644 index 0000000..c77fbe9 --- /dev/null +++ b/blazor_lab/Models/Item.cs @@ -0,0 +1,15 @@ +namespace blazor_lab.Models +{ + public class Item + { + public int Id { get; set; } + public string DisplayName { get; set; } + public string Name { get; set; } + public int StackSize { get; set; } + public int MaxDurability { get; set; } + public List EnchantCategories { get; set; } + public List RepairWith { get; set; } + public DateTime CreatedDate { get; set; } + public DateTime? UpdatedDate { get; set; } + } +} diff --git a/blazor_lab/Pages/Admin/Index.razor b/blazor_lab/Pages/Admin/Index.razor new file mode 100644 index 0000000..bf98b1c --- /dev/null +++ b/blazor_lab/Pages/Admin/Index.razor @@ -0,0 +1,3 @@ +@page "/admin" + +

Index

diff --git a/blazor_lab/Pages/Admin/Users.razor b/blazor_lab/Pages/Admin/Users.razor new file mode 100644 index 0000000..560b324 --- /dev/null +++ b/blazor_lab/Pages/Admin/Users.razor @@ -0,0 +1,2 @@ +@page "/admin/users" +

Users

diff --git a/blazor_lab/Pages/Admin/_Imports.razor b/blazor_lab/Pages/Admin/_Imports.razor new file mode 100644 index 0000000..f6c6b4b --- /dev/null +++ b/blazor_lab/Pages/Admin/_Imports.razor @@ -0,0 +1 @@ +@layout AdminLayout \ No newline at end of file diff --git a/blazor_lab/Pages/List.razor b/blazor_lab/Pages/List.razor new file mode 100644 index 0000000..4ddb9d3 --- /dev/null +++ b/blazor_lab/Pages/List.razor @@ -0,0 +1,41 @@ +@page "/list" +@using Models + +

List

+ +@if (items != null) +{ + + + + + + + + + + + + @(string.Join(", ", ((Item)context).EnchantCategories)) + + + + + @(string.Join(", ", ((Item)context).RepairWith)) + + + + + +} + diff --git a/blazor_lab/Pages/List.razor.cs b/blazor_lab/Pages/List.razor.cs new file mode 100644 index 0000000..d76f8ba --- /dev/null +++ b/blazor_lab/Pages/List.razor.cs @@ -0,0 +1,57 @@ +using blazor_lab.Models; +using Blazorise.DataGrid; +using Microsoft.AspNetCore.Components; + +namespace blazor_lab.Pages +{ + public partial class List + { + private List items; + + private int totalItems; + + [Inject] + public HttpClient HttpClient { get; set; } + + [Inject] + public NavigationManager NavigationManager { get; set; } + + private async Task OnReadData(DataGridReadDataEventArgs e) + { + if (e.CancellationToken.IsCancellationRequested) + { + return; + } + + //real API => + //var response = await Http.GetJsonAsync( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" ); + var response = + ( + await HttpClient.GetFromJsonAsync( + $"{NavigationManager.BaseUri}fake-data.json" + ) + ) + .Skip((e.Page - 1) * e.PageSize) + .Take(e.PageSize) + .ToList(); + + if (!e.CancellationToken.IsCancellationRequested) + { + totalItems = + ( + await HttpClient.GetFromJsonAsync>( + $"{NavigationManager.BaseUri}fake-data.json" + ) + ) + .Count; + + items = new List(response); + } + } + + protected override async Task OnInitializedAsync() + { + items = await HttpClient.GetFromJsonAsync>($"{NavigationManager.BaseUri}fake-data.json"); + } + } +} diff --git a/blazor_lab/Pages/_Layout.cshtml b/blazor_lab/Pages/_Layout.cshtml index 5a2af19..e4979ec 100644 --- a/blazor_lab/Pages/_Layout.cshtml +++ b/blazor_lab/Pages/_Layout.cshtml @@ -28,5 +28,7 @@ - + + + diff --git a/blazor_lab/Program.cs b/blazor_lab/Program.cs index f0d0562..6be187b 100644 --- a/blazor_lab/Program.cs +++ b/blazor_lab/Program.cs @@ -1,6 +1,8 @@ using blazor_lab.Data; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Web; +using Blazorise; +using Blazorise.Bootstrap; +using Blazorise.Icons.FontAwesome; +using Blazored.LocalStorage; var builder = WebApplication.CreateBuilder(args); @@ -9,6 +11,15 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); +builder.Services.AddHttpClient(); + +builder.Services + .AddBlazorise()/*( options => { options.Immediate = true; } ) */ + .AddBootstrapProviders() + .AddFontAwesomeIcons(); + +builder.Services.AddBlazoredLocalStorage(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/blazor_lab/Shared/AdminLayout.razor b/blazor_lab/Shared/AdminLayout.razor new file mode 100644 index 0000000..77e107a --- /dev/null +++ b/blazor_lab/Shared/AdminLayout.razor @@ -0,0 +1,15 @@ +@inherits LayoutComponentBase + + +

Welcome to admin

+ + + +
+
+ @Body +
+
diff --git a/blazor_lab/Shared/MainLayout.razor b/blazor_lab/Shared/MainLayout.razor index 9231489..b91da66 100644 --- a/blazor_lab/Shared/MainLayout.razor +++ b/blazor_lab/Shared/MainLayout.razor @@ -1,19 +1,15 @@ @inherits LayoutComponentBase -blazor_lab +

blabla topic stuff

-
- - -
-
- About -
+ -
- @Body -
+
+
+ @Body
+ +
blabla trademark stuff
\ No newline at end of file diff --git a/blazor_lab/Shared/MainLayout.razor.css b/blazor_lab/Shared/MainLayout.razor.css deleted file mode 100644 index 699f17c..0000000 --- a/blazor_lab/Shared/MainLayout.razor.css +++ /dev/null @@ -1,70 +0,0 @@ -.page { - position: relative; - display: flex; - flex-direction: column; -} - -main { - flex: 1; -} - -.sidebar { - background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); -} - -.top-row { - background-color: #f7f7f7; - border-bottom: 1px solid #d6d5d5; - justify-content: flex-end; - height: 3.5rem; - display: flex; - align-items: center; -} - - .top-row ::deep a, .top-row .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - } - - .top-row a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } - -@media (max-width: 640.98px) { - .top-row:not(.auth) { - display: none; - } - - .top-row.auth { - justify-content: space-between; - } - - .top-row a, .top-row .btn-link { - margin-left: 0; - } -} - -@media (min-width: 641px) { - .page { - flex-direction: row; - } - - .sidebar { - width: 250px; - height: 100vh; - position: sticky; - top: 0; - } - - .top-row { - position: sticky; - top: 0; - z-index: 1; - } - - .top-row, article { - padding-left: 2rem !important; - padding-right: 1.5rem !important; - } -} diff --git a/blazor_lab/Shared/NavMenu.razor b/blazor_lab/Shared/NavMenu.razor index 4b9f81b..e9baf2f 100644 --- a/blazor_lab/Shared/NavMenu.razor +++ b/blazor_lab/Shared/NavMenu.razor @@ -9,6 +9,12 @@
diff --git a/blazor_lab/_Imports.razor b/blazor_lab/_Imports.razor index 419cf21..e00a243 100644 --- a/blazor_lab/_Imports.razor +++ b/blazor_lab/_Imports.razor @@ -8,3 +8,4 @@ @using Microsoft.JSInterop @using blazor_lab @using blazor_lab.Shared +@using Blazorise.DataGrid diff --git a/blazor_lab/blazor_lab.csproj b/blazor_lab/blazor_lab.csproj index b775b09..011212e 100644 --- a/blazor_lab/blazor_lab.csproj +++ b/blazor_lab/blazor_lab.csproj @@ -6,4 +6,11 @@ enable + + + + + + + diff --git a/blazor_lab/wwwroot/fake-data.json b/blazor_lab/wwwroot/fake-data.json new file mode 100644 index 0000000..a1bfd34 --- /dev/null +++ b/blazor_lab/wwwroot/fake-data.json @@ -0,0 +1,217 @@ +[ + { + "id": 1, + "displayname": "Rodemco", + "name": "rodemco", + "stacksize": 22, + "maxdurability": 69, + "enchantcategories": [ + "armor_chest", + "vanishable", + "weapon" + ], + "repairwith": [], + "createddate": "2016-03-23", + "updateddate": "2014-06-06" + }, + { + "id": 2, + "displayname": "Candecor", + "name": "candecor", + "stacksize": 63, + "maxdurability": 109, + "enchantcategories": [ + "digger" + ], + "repairwith": [ + "oak_planks" + ], + "createddate": "2018-07-06", + "updateddate": null + }, + { + "id": 3, + "displayname": "Cuizine", + "name": "cuizine", + "stacksize": 1, + "maxdurability": 23, + "enchantcategories": [ + "weapon" + ], + "repairwith": [], + "createddate": "2020-01-13", + "updateddate": "2016-01-20" + }, + { + "id": 4, + "displayname": "Bluplanet", + "name": "bluplanet", + "stacksize": 13, + "maxdurability": 95, + "enchantcategories": [], + "repairwith": [ + "dark_oak_planks", + "warped_planks" + ], + "createddate": "2020-11-24", + "updateddate": null + }, + { + "id": 5, + "displayname": "Neurocell", + "name": "neurocell", + "stacksize": 34, + "maxdurability": 35, + "enchantcategories": [ + "armor_head", + "digger", + "breakable" + ], + "repairwith": [ + "crimson_planks", + "oak_planks" + ], + "createddate": "2019-12-10", + "updateddate": "2017-05-09" + }, + { + "id": 6, + "displayname": "Adornica", + "name": "adornica", + "stacksize": 7, + "maxdurability": 75, + "enchantcategories": [ + "weapon" + ], + "repairwith": [ + "oak_planks" + ], + "createddate": "2015-11-20", + "updateddate": "2022-01-16" + }, + { + "id": 7, + "displayname": "Magnina", + "name": "magnina", + "stacksize": 63, + "maxdurability": 117, + "enchantcategories": [], + "repairwith": [], + "createddate": "2014-08-27", + "updateddate": null + }, + { + "id": 8, + "displayname": "Entroflex", + "name": "entroflex", + "stacksize": 38, + "maxdurability": 50, + "enchantcategories": [ + "armor", + "digger", + "armor_head" + ], + "repairwith": [ + "crimson_planks", + "oak_planks" + ], + "createddate": "2021-11-20", + "updateddate": "2017-06-29" + }, + { + "id": 9, + "displayname": "Comcur", + "name": "comcur", + "stacksize": 20, + "maxdurability": 13, + "enchantcategories": [], + "repairwith": [ + "jungle_planks", + "birch_planks" + ], + "createddate": "2014-06-24", + "updateddate": null + }, + { + "id": 10, + "displayname": "Quarx", + "name": "quarx", + "stacksize": 64, + "maxdurability": 79, + "enchantcategories": [], + "repairwith": [ + "jungle_planks", + "spruce_planks" + ], + "createddate": "2019-07-03", + "updateddate": "2018-09-30" + }, + { + "id": 11, + "displayname": "Parcoe", + "name": "parcoe", + "stacksize": 26, + "maxdurability": 97, + "enchantcategories": [ + "breakable", + "armor" + ], + "repairwith": [ + "crimson_planks" + ], + "createddate": "2018-03-25", + "updateddate": null + }, + { + "id": 12, + "displayname": "Dogspa", + "name": "dogspa", + "stacksize": 45, + "maxdurability": 95, + "enchantcategories": [ + "vanishable" + ], + "repairwith": [], + "createddate": "2014-07-03", + "updateddate": "2021-12-29" + }, + { + "id": 13, + "displayname": "Buzzmaker", + "name": "buzzmaker", + "stacksize": 55, + "maxdurability": 85, + "enchantcategories": [], + "repairwith": [ + "crimson_planks" + ], + "createddate": "2015-06-23", + "updateddate": null + }, + { + "id": 14, + "displayname": "Realysis", + "name": "realysis", + "stacksize": 52, + "maxdurability": 72, + "enchantcategories": [ + "weapon" + ], + "repairwith": [ + "oak_planks" + ], + "createddate": "2019-12-26", + "updateddate": null + }, + { + "id": 15, + "displayname": "Decratex", + "name": "decratex", + "stacksize": 15, + "maxdurability": 101, + "enchantcategories": [], + "repairwith": [], + "createddate": "2017-06-20", + "updateddate": "2016-09-04" + } +] \ No newline at end of file