Ajout model Signalement

WORK-KMO
Antoine PINAGOT 1 year ago
parent 2449c27f4e
commit 91a6b54ed3

@ -0,0 +1,14 @@
using Blazorise;
namespace HeartTrack.Models
{
public class Report
{
public int Id { get; set; }
public string Username { get; set; }
public string ReportedUser { get; set; }
public string Raison { get; set; }
public string Description { get; set; }
public Image Image { get; set; }
}
}

@ -0,0 +1,25 @@
using Blazorise;
using System.ComponentModel.DataAnnotations;
namespace HeartTrack.Models
{
public class ReportModel
{
[Required]
[Range(0, 121425711425541)]
public int Id { get; set; }
[Required]
[StringLength(50)]
public string Username { get; set; }
[Required]
[StringLength(50)]
public string ReportedUser { get; set; }
[Required]
[StringLength(150)]
public string Raison { get; set; }
[Required]
[StringLength(500)]
public string Description { get; set; }
public Image Image { get; set; }
}
}

@ -7,7 +7,7 @@
public string Nom { get; set; }
public string Prenom { get; set; }
public string Contexte { get; set; }
public string Description { get; set; }
public string Urgence { get; set; }
public string Description { get; set; }/*
public string Urgence { get; set; }*/
}
}

@ -26,8 +26,7 @@ namespace HeartTrack.Models
[Required]
[StringLength(500, ErrorMessage = "Description must not exceed 500 characters.")]
public string Description { get; set; }
public Boolean Urgence { get; set; }
public Image Image { get; set; }
public string Description { get; set; }/*
public Boolean Urgence { get; set; }*/
}
}

@ -1,16 +1,53 @@
@page "/tickets/add"
<h3>Add Ticket</h3>
<AuthorizeView>
<Authorized>
<h3>Add Ticket</h3>
@*<EditForm Model="@TicketModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<EditForm Model="@ticketModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label>
<InputCheckbox @bind-Value="ticketModel.Urgence" Value="boolean"/>
</label>
</p>
<p>
<label for="username">
Username:
<InputText id="username" @bind-Value="ticketModel.Username" />
</label>
</p>
<p>
<label for="first-name">
First name:
<InputText id="first-name" @bind-Value="ticketModel.Nom" />
</label>
</p>
<p>
<label for="last-name">
Last name:
<InputText id="last-name" @bind-Value="ticketModel.Prenom" />
</label>
</p>
<p>
<label for="oui">
Context:
<InputText id="oui" @bind-Value="ticketModel.Contexte" />
</label>
</p>
<p>
<label for="description">
Description:
<InputText id="description" @bind-Value="ticketModel.Description" />
</label>
</p>
<button type="submit">Submit</button>
</EditForm>*@
@* <p>
<label for="Urgence">
Description:
<InputCheckbox id="Urgence" @bind-Value="ticketModel.Urgence" />
</label>
</p> *@
<button type="submit">Submit</button>
</EditForm>
</Authorized>
</AuthorizeView>

@ -10,6 +10,9 @@ namespace HeartTrack.Pages
[Inject]
public ILocalStorageService LocalStorage { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
@ -18,90 +21,31 @@ namespace HeartTrack.Pages
/// </summary>
private TicketModel ticketModel = new(){};
/*private async void HandleValidSubmit()
{
// Get the current data
var currentData = await LocalStorage.GetItemAsync<List<Ticket>>("data");
// Simulate the Id
ticketModel.Id = currentData.Max(s => s.Id) + 1;
// Add the item to the current data
currentData.Add(new Ticket
{
Id = ticketModel.Id,
Username = ticketModel.Username,
Nom = ticketModel.Nom,
Prenom = ticketModel.Prenom,
Contexte = ticketModel.Contexte,
Description = ticketModel.Description,
Urgence = ticketModel.Urgence
});
// Save the image
var imagePathInfo = new DirectoryInfo($"{WebHostEnvironment.WebRootPath}/images");
// Check if the folder "images" exist
if (!imagePathInfo.Exists)
{
imagePathInfo.Create();
}
// Determine the image name
var fileName = new FileInfo($"{imagePathInfo}/{itemModel.Name}.png");
// Write the file content
await File.WriteAllBytesAsync(fileName.FullName, itemModel.ImageContent);
private async void HandleValidSubmit()
{
// Get the current data
var currentData = await LocalStorage.GetItemAsync<List<Ticket>>("data");
// Save the data
await LocalStorage.SetItemAsync("data", currentData);
}
// Simulate the Id
ticketModel.Id = currentData.Max(s => s.Id) + 1;
private async Task LoadImage(InputFileChangeEventArgs e)
// Add the item to the current data
currentData.Add(new Ticket
{
// Set the content of the image to the model
using (var memoryStream = new MemoryStream())
{
await e.File.OpenReadStream().CopyToAsync(memoryStream);
itemModel.ImageContent = memoryStream.ToArray();
}
}
private void OnEnchantCategoriesChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!itemModel.EnchantCategories.Contains(item))
{
itemModel.EnchantCategories.Add(item);
}
return;
}
if (itemModel.EnchantCategories.Contains(item))
{
itemModel.EnchantCategories.Remove(item);
}
}
private void OnRepairWithChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!itemModel.RepairWith.Contains(item))
{
itemModel.RepairWith.Add(item);
}
return;
}
if (itemModel.RepairWith.Contains(item))
{
itemModel.RepairWith.Remove(item);
}
}*/
Id = ticketModel.Id,
Username = ticketModel.Username,
Nom = ticketModel.Nom,
Prenom = ticketModel.Prenom,
Contexte = ticketModel.Contexte,
Description = ticketModel.Description/*,
Urgence = ticketModel.Urgence*/
});
// Save the data
await LocalStorage.SetItemAsync("data", currentData);
NavigationManager.NavigateTo("list");
}
}
}

@ -24,7 +24,7 @@ namespace HeartTrack.Pages
public ILocalStorageService LocalStorage { get; set; }
[Inject]
public IStringLocalizer<Tokens> Localizer { get; set; }
public IStringLocalizer<BannedUsers> Localizer { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{

@ -6,5 +6,11 @@
This is the ticket list of users.
<div>
<NavLink class="btn btn-primary" href="ticket/add" Match="NavLinkMatch.All">
<i class="fa fa-plus"></i> Ajouter
</NavLink>
</div>
<SurveyPrompt Title="How is Blazor working for you?" />

@ -1,26 +0,0 @@
@page "/tokens"
@using HeartTrack.Models
<PageTitle>Tokens</PageTitle>
<h1>@Localizer["Title"]</h1>
<p>
@Localizer["Description"]
</p>
<DataGrid TItem="User"
Data="@users"
ReadData="@OnReadData"
TotalItems="@totalUser"
PageSize="10"
ShowPager
Responsive>
<DataGridColumn TItem="User" Field="@nameof(User.Id)" Caption="Id" />
<DataGridColumn TItem="User" Field="@nameof(User.Username)" Caption="@Localizer["Username"]" />
<DataGridColumn TItem="User" Field="@nameof(User.Nom)" Caption="@Localizer["FirstN"]" />
<DataGridColumn TItem="User" Field="@nameof(User.Prenom)" Caption="@Localizer["LastN"]" />
<DataGridColumn TItem="User" Field="@nameof(User.Password)" Caption="@Localizer["Password"]" />
</DataGrid>

@ -1,44 +0,0 @@
using Blazorise;
using Blazorise.DataGrid;
using HeartTrack.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System.Collections.Generic;
using static System.Net.WebRequestMethods;
namespace HeartTrack.Pages
{
public partial class Tokens
{
private List<User> users;
private int totalUser;
[Inject]
public HttpClient Http { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
[Inject]
public IStringLocalizer<Tokens> Localizer { get; set; }
private async Task OnReadData(DataGridReadDataEventArgs<User> e)
{
if (e.CancellationToken.IsCancellationRequested)
{
return;
}
// When you use a real API, we use this follow code
//var response = await Http.GetJsonAsync<Item[]>( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" );
var response = (await Http.GetFromJsonAsync<User[]>($"{NavigationManager.BaseUri}fake-data.json")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
if (!e.CancellationToken.IsCancellationRequested)
{
totalUser = (await Http.GetFromJsonAsync<List<User>>($"{NavigationManager.BaseUri}fake-data.json")).Count;
users = new List<User>(response); // an actual data for the current page
}
}
}
}

@ -7,6 +7,6 @@ namespace HeartTrack.Shared
public partial class NavMenu
{
[Inject]
public IStringLocalizer<Tokens> Localizer { get; set; }
public IStringLocalizer<NavMenu> Localizer { get; set; }
}
}

File diff suppressed because one or more lines are too long

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("HeartTrack")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a098e111547c18c55a8705cc7175fee1245ed200")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("HeartTrack")]
[assembly: System.Reflection.AssemblyTitleAttribute("HeartTrack")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
5a687aac22c0782076c5bfe0a6928ecd6e1ff431e08fce9b31ef12d9f3e7872b
cea5cf4b8f540da473991ac2e3822ec5c2239419f8197bfd319d9acd5c853758

@ -62,10 +62,6 @@ build_metadata.AdditionalFiles.CssScope =
build_metadata.AdditionalFiles.TargetPath = UGFnZXNcVGlja2V0cy5yYXpvcg==
build_metadata.AdditionalFiles.CssScope =
[C:/Users/antoi/Documents/Cours/2A/SAE/Admin/Admin/Sources/HeartTrack/Pages/Tokens.razor]
build_metadata.AdditionalFiles.TargetPath = UGFnZXNcVG9rZW5zLnJhem9y
build_metadata.AdditionalFiles.CssScope =
[C:/Users/antoi/Documents/Cours/2A/SAE/Admin/Admin/Sources/HeartTrack/Shared/AuthLayout.razor]
build_metadata.AdditionalFiles.TargetPath = U2hhcmVkXEF1dGhMYXlvdXQucmF6b3I=
build_metadata.AdditionalFiles.CssScope =

@ -1 +1 @@
745ea91892ff6a7a3b964f04dfaa384d73fe1ef6a90b3230451e2306bbffd4b3
e13dc85ac8575b541fad41b72bab609ff265de63b65bc0f33d2a8b0bbf51a86e

@ -1,6 +1,6 @@
{
"Version": 1,
"Hash": "hKkCCyCopeCL2bDCiMqO2ehUbpqNSgrUCESq8+TknS8=",
"Hash": "XrHqO13iBAbq9FrCu+ar89hbnu6/YoLUKGyE0DDd1Z0=",
"Source": "HeartTrack",
"BasePath": "_content/HeartTrack",
"Mode": "Default",
@ -1062,12 +1062,12 @@
"OriginalItemSpec": "wwwroot\\css\\site.css"
},
{
"Identity": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-data.json",
"Identity": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-tickets.json",
"SourceId": "HeartTrack",
"SourceType": "Discovered",
"ContentRoot": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\",
"BasePath": "_content/HeartTrack",
"RelativePath": "fake-data.json",
"RelativePath": "fake-tickets.json",
"AssetKind": "All",
"AssetMode": "All",
"AssetRole": "Primary",
@ -1078,15 +1078,15 @@
"AssetTraitValue": "",
"CopyToOutputDirectory": "Never",
"CopyToPublishDirectory": "PreserveNewest",
"OriginalItemSpec": "wwwroot\\fake-data.json"
"OriginalItemSpec": "wwwroot\\fake-tickets.json"
},
{
"Identity": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-tickets.json",
"Identity": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-users.json",
"SourceId": "HeartTrack",
"SourceType": "Discovered",
"ContentRoot": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\",
"BasePath": "_content/HeartTrack",
"RelativePath": "fake-tickets.json",
"RelativePath": "fake-users.json",
"AssetKind": "All",
"AssetMode": "All",
"AssetRole": "Primary",
@ -1097,7 +1097,7 @@
"AssetTraitValue": "",
"CopyToOutputDirectory": "Never",
"CopyToPublishDirectory": "PreserveNewest",
"OriginalItemSpec": "wwwroot\\fake-tickets.json"
"OriginalItemSpec": "wwwroot\\fake-users.json"
},
{
"Identity": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\favicon.ico",

File diff suppressed because one or more lines are too long

@ -52,14 +52,14 @@
"Id": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\css\\site.css",
"PackagePath": "staticwebassets\\css\\site.css"
},
{
"Id": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-data.json",
"PackagePath": "staticwebassets\\fake-data.json"
},
{
"Id": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-tickets.json",
"PackagePath": "staticwebassets\\fake-tickets.json"
},
{
"Id": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\fake-users.json",
"PackagePath": "staticwebassets\\fake-users.json"
},
{
"Id": "C:\\Users\\antoi\\Documents\\Cours\\2A\\SAE\\Admin\\Admin\\Sources\\HeartTrack\\wwwroot\\favicon.ico",
"PackagePath": "staticwebassets\\favicon.ico"

@ -192,12 +192,12 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\css\site.css))</OriginalItemSpec>
</StaticWebAsset>
<StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-data.json))">
<StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-tickets.json))">
<SourceType>Package</SourceType>
<SourceId>HeartTrack</SourceId>
<ContentRoot>$(MSBuildThisFileDirectory)..\staticwebassets\</ContentRoot>
<BasePath>_content/HeartTrack</BasePath>
<RelativePath>fake-data.json</RelativePath>
<RelativePath>fake-tickets.json</RelativePath>
<AssetKind>All</AssetKind>
<AssetMode>All</AssetMode>
<AssetRole>Primary</AssetRole>
@ -206,14 +206,14 @@
<AssetTraitValue></AssetTraitValue>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-data.json))</OriginalItemSpec>
<OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-tickets.json))</OriginalItemSpec>
</StaticWebAsset>
<StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-tickets.json))">
<StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-users.json))">
<SourceType>Package</SourceType>
<SourceId>HeartTrack</SourceId>
<ContentRoot>$(MSBuildThisFileDirectory)..\staticwebassets\</ContentRoot>
<BasePath>_content/HeartTrack</BasePath>
<RelativePath>fake-tickets.json</RelativePath>
<RelativePath>fake-users.json</RelativePath>
<AssetKind>All</AssetKind>
<AssetMode>All</AssetMode>
<AssetRole>Primary</AssetRole>
@ -222,7 +222,7 @@
<AssetTraitValue></AssetTraitValue>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-tickets.json))</OriginalItemSpec>
<OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\fake-users.json))</OriginalItemSpec>
</StaticWebAsset>
<StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\favicon.ico))">
<SourceType>Package</SourceType>

@ -0,0 +1,178 @@
[
{
"id": 1,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 2,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 3,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 4,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 5,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 6,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 7,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 8,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 9,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 10,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 11,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 12,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 13,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 14,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 15,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 16,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 17,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 18,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 19,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 20,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 21,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
},
{
"id": 22,
"username": "johndoe",
"reported_user": "erickol",
"raison": "Jvais dire wallah",
"description": "Wallah c`est la description",
"image": "oui.png"
}
]
Loading…
Cancel
Save