comment the list functions

master
Lilian BRETON 2 years ago
parent e63e285156
commit 6d18ec1dd7

@ -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&*

@ -8,30 +8,32 @@
{ {
"itemName": "Grass Block", "itemName": "Grass Block",
"position": 2, "position": 2,
"number": 3, "number": 4,
"stackSize": 64 "stackSize": 64
}, },
{ {
"itemName": "Cobblestone", "itemName": "Cobblestone",
"position": 3, "position": 3,
"number": 3, "number": 5,
"stackSize": 64 "stackSize": 64
}, },
{ {
"itemName": "Sapling", "itemName": "Dirt",
"position": 4, "position": 4,
"number": 1, "number": 3,
"stackSize": 64 "stackSize": 64
}, },
{ {
"itemName": "Dirt", "itemName": "Sapling",
"position": 5, "position": 5,
"number": 2, "number": 1,
"stackSize": 64 "stackSize": 64
}, },
{ {
"itemName": "null", "itemName": "Bedrock",
"position": 6 "position": 6,
"number": 1,
"stackSize": 64
}, },
{ {
"itemName": "null", "itemName": "null",

@ -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<Item> e) private async Task OnReadData(DataGridReadDataEventArgs<Item> 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<Item> choseList() private List<Item> choseList()
{ {
// If the search bar is empty, we don't need to use a special list, we use the default one
if (SearchText.IsNullOrEmpty()) if (SearchText.IsNullOrEmpty())
{ {
choix = items; choix = items;
totalItem = full.Count(); totalItem = full.Count();
NavigationManager.NavigateTo("inventory", false); NavigationManager.NavigateTo("inventory", false);
} }
// Else, we change the list choix and we filter the items using the Filtered list
else 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) if (Filtered.Count() < (currentPage - 1) * 10 + pageSize)
{ {
pageSize = Filtered.Count() - (currentPage - 1) * 10; pageSize = Filtered.Count() - (currentPage - 1) * 10;
@ -144,13 +165,23 @@ namespace myBlazorApp.Components
return choix; 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() private void inputValue()
{ {
// We filter the items with the search bar if their name contain what we are typing
Filtered = full.Where( Filtered = full.Where(
itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList(); itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList();
choseList(); 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() private void OnPress()
{ {
if (isSorted == true) if (isSorted == true)
@ -161,13 +192,24 @@ namespace myBlazorApp.Components
SortList(); SortList();
} }
/*
* Name: SortList
* Function: When we press the sort button, this function will hange the items in the list choix
*/
private List<Item> SortList() private List<Item> 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) if (isSorted == false)
{ {
choix = items; choix = items;
NavigationManager.NavigateTo("inventory", true); 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 else
{ {
if (Sorted.IsNullOrEmpty()) if (Sorted.IsNullOrEmpty())

@ -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"]
Loading…
Cancel
Save