Commit pour pull ce qu'a fait mathilde

master
Thomas Chazot 2 years ago
parent 763503ab8d
commit f73a3dfcd8

@ -5,7 +5,13 @@ VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorApp", "BlazorApp\BlazorApp.csproj", "{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}"
EndProject
<<<<<<< Updated upstream
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Minecraft.Crafting.Api", "Minecraft.Crafting.Api\Minecraft.Crafting.Api.csproj", "{E1E95C86-6F7D-42A8-983F-C64395DB549C}"
=======
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Minecraft.Crafting.Api", "..\Minecraft.Crafting.Api\Minecraft.Crafting.Api.csproj", "{90D900E1-58D6-48D0-8B7F-B04CF2B32467}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Minecraft.Crafting.Api", "Minecraft.Crafting.Api\Minecraft.Crafting.Api.csproj", "{66D487C8-86D6-4394-BB71-BFA92E57D90E}"
>>>>>>> Stashed changes
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,10 +23,21 @@ Global
{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}.Release|Any CPU.Build.0 = Release|Any CPU
<<<<<<< Updated upstream
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Release|Any CPU.Build.0 = Release|Any CPU
=======
{90D900E1-58D6-48D0-8B7F-B04CF2B32467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90D900E1-58D6-48D0-8B7F-B04CF2B32467}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90D900E1-58D6-48D0-8B7F-B04CF2B32467}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90D900E1-58D6-48D0-8B7F-B04CF2B32467}.Release|Any CPU.Build.0 = Release|Any CPU
{66D487C8-86D6-4394-BB71-BFA92E57D90E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66D487C8-86D6-4394-BB71-BFA92E57D90E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66D487C8-86D6-4394-BB71-BFA92E57D90E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66D487C8-86D6-4394-BB71-BFA92E57D90E}.Release|Any CPU.Build.0 = Release|Any CPU
>>>>>>> Stashed changes
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -7,12 +7,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.3.1" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.3.1" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.3.1" />
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.4.1" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.4.1" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.4.1" />
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazored.Modal" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
@ -25,6 +26,9 @@
<None Remove="Controllers\" />
<None Remove="Resources\" />
<None Remove="Components\" />
<None Remove="Microsoft.Extensions.Logging.Configuration" />
<None Remove="DevExpress.Blazor.ProjectTemplates" />
<None Remove="DevExpress.Data" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />

@ -42,6 +42,7 @@
<div>Available items:</div>
<<<<<<< Updated upstream
<div>
<DataGrid TItem="Item"
@ -68,8 +69,29 @@
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
</DataGrid>
</div>
=======
<div>
<DataGrid TItem="Item"
Data="@Items"
ReadData="@OnReadData"
TotalItems="@totalItem"
PageSize="10"
ShowPager
Sortable="true">
<Button type="submit" @onclick="() => SortByName()">SORT</Button>
>>>>>>> Stashed changes
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)">
<DisplayTemplate>
<InventoryItem Item="@context" NoDrop="true" />
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
</DataGrid>
</div>
</div>

@ -6,12 +6,15 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using BlazorApp.Services;
using Blazorise.DataGrid;
using Microsoft.Extensions.Options;
namespace BlazorApp.Components
{
public partial class InventoryComp
{
public Item CurrentDragItem { get; set; }
public int CurrentDragIndex { get; set; }
@ -24,15 +27,28 @@ namespace BlazorApp.Components
public List<Item> InventoryItems { get; set; }
public ObservableCollection<CraftingAction> Actions { get; set; }
public bool IsSorted { get; set; }
[Inject]
internal IJSRuntime JavaScriptRuntime { get; set; }
private int totalItem;
public InventoryComp()
{
this.InventoryItems = new List<Item> { };
for (int i = 0; i < 18; i++)
{
this.InventoryItems.Append(null);
Actions = new ObservableCollection<CraftingAction>();
Actions.CollectionChanged += OnActionsCollectionChanged;
this.InventoryItems = new List<Item>(new Item[18]);
}
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
}
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
@ -42,16 +58,33 @@ namespace BlazorApp.Components
return;
}
if (!e.CancellationToken.IsCancellationRequested)
if (!e.CancellationToken.IsCancellationRequested && IsSorted==false)
{
Items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count();
}
}
else
{
Items = await DataService.SortedList(e.Page, e.PageSize);
}
}
private async Task SortByName()
private void SortByName()
{
<<<<<<< Updated upstream
Items = await DataService.SortedList();
=======
if (IsSorted)
{
IsSorted = false;
}
else
{
IsSorted = true;
}
StateHasChanged();
>>>>>>> Stashed changes
}
void refresh()

@ -5,10 +5,25 @@
@ondrop="@OnDrop"
@ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave"
@ondragend="@OnDragEnd" >
@ondragend="@OnDragEnd">
@if (Item != null)
{
@Item.DisplayName
}
{
if (NoDrop)
{
@if (!string.IsNullOrWhiteSpace(Item.ImageBase64))
{
<img src="data:image/png;base64, @(Item.ImageBase64)" class="img-thumbnail" title="@Item.DisplayName" alt="@Item.DisplayName" style="min-width: 64px; max-width: 64px " />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@Item.DisplayName" alt="@Item.DisplayName" style="max-width: 64px" />
}
}
else
{
@Item.DisplayName
}
}
</div>

@ -52,6 +52,9 @@ namespace BlazorApp.Components
Parent.CurrentDragItem = tmp;
Parent.CurrentDragIndex = this.Index;
}
Parent.Actions.Add(new CraftingAction { Action = "On Drop", Item = this.Item, Index = this.Index });
}
private void OnDragStart()
@ -70,8 +73,8 @@ namespace BlazorApp.Components
{
Parent.CurrentDragIndex = -1;
}
}
Parent.Actions.Add(new CraftingAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
}
internal void OnDragEnd()
@ -85,6 +88,9 @@ namespace BlazorApp.Components
Parent.InventoryItems[this.Index] = this.Item;
this.Item = Parent.CurrentDragItem;
}
Parent.Actions.Add(new CraftingAction { Action = "Drag End", Item = this.Item, Index = this.Index });
Parent.CurrentDragIndex = -1;
Parent.CurrentDragItem = null;

@ -10,6 +10,8 @@ using Blazored.Modal;
using System.Globalization;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args);
@ -25,6 +27,7 @@ builder.Services
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<IDataService, DataApiService>();
builder.Services.AddBlazoredModal();

@ -57,10 +57,20 @@ namespace BlazorApp.Services
return await _http.GetFromJsonAsync<List<CraftingRecipe>>("https://localhost:7234/api/Crafting/recipe");
}
<<<<<<< Updated upstream
public async Task<List<Item>> SortedList()
{
List<Item> it = await _http.GetFromJsonAsync<List<Item>>($"https://localhost:7234/api/Crafting/all/");
return it.OrderBy(i => i.DisplayName).ToList();
=======
public async Task<List<Item>> SortedList(int currentPage, int pageSize)
{
List<Item> it = await _http.GetFromJsonAsync<List<Item>>($"https://localhost:7234/api/Crafting/all");
it.OrderBy(i => i.DisplayName).ToList();
List<Item> items= it.GetRange((currentPage-1)*10, pageSize);
return items;
>>>>>>> Stashed changes
}

@ -185,7 +185,11 @@ namespace BlazorApp.Services
return Task.FromResult(items);
}
<<<<<<< Updated upstream
public Task<List<Item>> SortedList()
=======
public Task<List<Item>> SortedList(int currentPage, int pageSize)
>>>>>>> Stashed changes
{
throw new NotImplementedException();
}

@ -14,7 +14,11 @@ namespace BlazorApp.Services
Task Update(int id, ItemModel itemModel);
Task Delete(int id);
Task<List<CraftingRecipe>> GetRecipes();
<<<<<<< Updated upstream
Task<List<Item>> SortedList();
=======
Task<List<Item>> SortedList(int currentPage, int pageSize);
>>>>>>> Stashed changes
}
}

@ -1,9 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Default": "Trace",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save