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 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorApp", "BlazorApp\BlazorApp.csproj", "{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorApp", "BlazorApp\BlazorApp.csproj", "{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}"
EndProject 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("{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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.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.ActiveCfg = Release|Any CPU
{1E9341D6-EB75-4CD3-8144-A24BE53DB7E1}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{E1E95C86-6F7D-42A8-983F-C64395DB549C}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

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

@ -42,6 +42,7 @@
<div>Available items:</div> <div>Available items:</div>
<<<<<<< Updated upstream
<div> <div>
<DataGrid TItem="Item" <DataGrid TItem="Item"
@ -68,7 +69,28 @@
</DataGridColumn> </DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" /> <DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
</DataGrid> </DataGrid>
=======
<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 System.Collections.Specialized;
using BlazorApp.Services; using BlazorApp.Services;
using Blazorise.DataGrid; using Blazorise.DataGrid;
using Microsoft.Extensions.Options;
namespace BlazorApp.Components namespace BlazorApp.Components
{ {
public partial class InventoryComp public partial class InventoryComp
{ {
public Item CurrentDragItem { get; set; } public Item CurrentDragItem { get; set; }
public int CurrentDragIndex { get; set; } public int CurrentDragIndex { get; set; }
@ -24,15 +27,28 @@ namespace BlazorApp.Components
public List<Item> InventoryItems { get; set; } 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; private int totalItem;
public InventoryComp() public InventoryComp()
{ {
this.InventoryItems = new List<Item> { }; Actions = new ObservableCollection<CraftingAction>();
for (int i = 0; i < 18; i++) Actions.CollectionChanged += OnActionsCollectionChanged;
{
this.InventoryItems.Append(null); 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) private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
@ -42,16 +58,33 @@ namespace BlazorApp.Components
return; return;
} }
if (!e.CancellationToken.IsCancellationRequested) if (!e.CancellationToken.IsCancellationRequested && IsSorted==false)
{ {
Items = await DataService.List(e.Page, e.PageSize); Items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count(); 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(); Items = await DataService.SortedList();
=======
if (IsSorted)
{
IsSorted = false;
}
else
{
IsSorted = true;
}
StateHasChanged();
>>>>>>> Stashed changes
} }
void refresh() void refresh()

@ -8,7 +8,22 @@
@ondragend="@OnDragEnd"> @ondragend="@OnDragEnd">
@if (Item != null) @if (Item != null)
{
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 @Item.DisplayName
} }
}
</div> </div>

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

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

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

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

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

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

Loading…
Cancel
Save