diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index cf359ea..0000000 --- a/.drone.yml +++ /dev/null @@ -1,34 +0,0 @@ -kind: pipeline -type: docker -name: blazor -trigger: - event: - - push - -steps: - - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd myBlazorApp/ - - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore - - - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd myBlazorApp/ - - dotnet restore myBlazorApp.sln - - dotnet test myBlazorApp.sln --no-restore - depends_on: [build] - - - name: docker-build - image: plugins/docker - settings: - dockerfile: myBlazorApp/myBlazorApp/Dockerfile - context: . - registry: hub.codefirst.iut.uca.fr - repo: hub.codefirst.iut.uca.fr/libreton/myBlazorApp - username: - libreton - password: - Li17br51&* \ No newline at end of file diff --git a/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json b/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json index 8851dab..5eb43fe 100644 --- a/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json +++ b/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json @@ -8,30 +8,32 @@ { "itemName": "Grass Block", "position": 2, - "number": 3, + "number": 4, "stackSize": 64 }, { "itemName": "Cobblestone", "position": 3, - "number": 3, + "number": 5, "stackSize": 64 }, { - "itemName": "Sapling", + "itemName": "Dirt", "position": 4, - "number": 1, + "number": 3, "stackSize": 64 }, { - "itemName": "Dirt", + "itemName": "Sapling", "position": 5, - "number": 2, + "number": 1, "stackSize": 64 }, { - "itemName": "null", - "position": 6 + "itemName": "Bedrock", + "position": 6, + "number": 1, + "stackSize": 64 }, { "itemName": "null", diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs index 61f5f9b..62297b0 100644 --- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs +++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs @@ -83,7 +83,18 @@ namespace myBlazorApp.Components } - + /* + * Name: OnReadData + * Function: Set up all the variables depending on what we want. + * totalItem : total number of items in the list + * items: my default list, containing alll the items printed 10 by 10 + * full: another list, loading all the items on one page + * currentPage: current page of the list + * pageSize: numper of items on the page + * choix: list binded on the datagrid that will change when needed + * isSorted: boolean turning true when we click on sort + * searchText: String binded on the search bar input + */ private async Task OnReadData(DataGridReadDataEventArgs e) { @@ -122,16 +133,26 @@ namespace myBlazorApp.Components } } + + /* + * Name: choseList + * Function: change the list choix when we type something in the search bar + */ private List choseList() { + // If the search bar is empty, we don't need to use a special list, we use the default one if (SearchText.IsNullOrEmpty()) { choix = items; totalItem = full.Count(); NavigationManager.NavigateTo("inventory", false); } + + // Else, we change the list choix and we filter the items using the Filtered list else { + // This line allows us to adapt pageSize depending on the number of items on it. + // If there is only 7 items, we don't want to print 10 on our page if (Filtered.Count() < (currentPage - 1) * 10 + pageSize) { pageSize = Filtered.Count() - (currentPage - 1) * 10; @@ -144,13 +165,23 @@ namespace myBlazorApp.Components return choix; } + /* + * Name: inputValue + * Function: When we type on the search bar, this function is called to initialize the Filtered list and call our function + */ private void inputValue() { + // We filter the items with the search bar if their name contain what we are typing Filtered = full.Where( itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList(); choseList(); } + + /* + * Name: OnPress + * Function: This function is binded on the Sort button. It changes our boolean value and call our SortList function + */ private void OnPress() { if (isSorted == true) @@ -161,13 +192,24 @@ namespace myBlazorApp.Components SortList(); } + + /* + * Name: SortList + * Function: When we press the sort button, this function will hange the items in the list choix + */ private List SortList() { + // If our boolean is false, it means that the list was sorted and we pressed the button to unsort it. + // So, it takes the default list for our dataGrid + // The navigateTo allows to be on the first page of the list when we unsort it if (isSorted == false) { choix = items; NavigationManager.NavigateTo("inventory", true); } + + // Else, we put the full list into the Sorted one, and we sort the items by name. + // We check for the number of items in the page and we give the Sorted list to choix with the pageSize we want else { if (Sorted.IsNullOrEmpty()) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile deleted file mode 100644 index 557badb..0000000 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" -COPY . . -WORKDIR "/src/myBlazorApp" -RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file