Fix : Finishing the WIP

Multiplayer_Php
Yvan CALATAYUD 1 year ago
commit e2a4f487dd

3
.gitignore vendored

@ -819,8 +819,9 @@ replay_pid*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# config ignore to not stock password on the git (:
# config ignore to not stock password on the git (: neither the Token of the API
/Website/usages/Config_DB.php
/Blazor/Blazor/Pages/Token.cs
### DotnetCore ###
# .NET Core build folders

@ -0,0 +1,7 @@
namespace Blazor.Pages;
public static class API
{
public static string TOKEN = "[INSERT THE TOKEN ID HERE]"; //ASK IF YOU WANT THOSE ACCESS
public static string API_URL = "[INSERT THE API URL HERE]"; //ASK IF YOU WANT THOSE ACCESS
}

@ -20,7 +20,7 @@ namespace Blazor.Pages.Admins
public ILogger<AddAdministrator> Logger { get; set; }
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
administratorModel.HashPassword(administratorModel.HashedPassword);
@ -32,7 +32,7 @@ namespace Blazor.Pages.Admins
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/administrator/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/administrator"+"/"+API.TOKEN;
using (var httpClient = new HttpClient())
{

@ -45,7 +45,7 @@ public partial class Administrators
// When you use a real API, we use this follow code
//var response = await Http.GetFromJsonAsync<ChaptersModel[]>( $"https://trusting-panini.87-106-126-109.plesk.page/api/administrators?page={e.Page}&pageSize={e.PageSize}" );
var response = Http.GetFromJsonAsync<Administrator[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var response = Http.GetFromJsonAsync<Administrator[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators"+"/"+API.TOKEN).Result;
if (!e.CancellationToken.IsCancellationRequested)
{
@ -54,7 +54,7 @@ public partial class Administrators
var currentData = await LocalStorage.GetItemAsync<Administrator[]>("data");
if (currentData == null || currentData.Length != administrators.Count)
{
var originalData = Http.GetFromJsonAsync<Administrator[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var originalData = Http.GetFromJsonAsync<Administrator[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators"+"/"+API.TOKEN).Result;
await LocalStorage.SetItemAsync("data", originalData);
}
}
@ -92,7 +92,7 @@ public partial class Administrators
return;
}
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/administrator/" + id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/administrator/" + id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{

@ -40,7 +40,7 @@ namespace Blazor.Pages.Admins
};
}
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
administratorModel.HashPassword(administratorModel.HashedPassword);
@ -51,7 +51,7 @@ namespace Blazor.Pages.Admins
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/administrator/" + administratorModel.Id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/administrator/" + administratorModel.Id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{

@ -19,7 +19,7 @@ public partial class AddChapter
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
//await DataService.Add(chapterModel);
@ -29,7 +29,7 @@ public partial class AddChapter
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/chapter/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/chapter"+"/"+API.TOKEN;
using (var httpClient = new HttpClient())
{

@ -53,7 +53,7 @@ public partial class Chapters
return;
}
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/chapter/" + id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/chapter/" + id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{
@ -92,7 +92,7 @@ public partial class Chapters
return;
}
var response = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var response = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
if (!e.CancellationToken.IsCancellationRequested)
{
@ -101,7 +101,7 @@ public partial class Chapters
var currentData = await LocalStorage.GetItemAsync<Chapter[]>("data");
if (currentData == null || currentData.Length != chapters.Count)
{
var originalData = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var originalData = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
await LocalStorage.SetItemAsync("data", originalData);
}
}

@ -38,7 +38,7 @@ public partial class EditChapter
};
}
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
//await DataService.Update(Id, chapterModel);
@ -48,7 +48,7 @@ public partial class EditChapter
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/chapter/" + chapterModel.Id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/chapter/" + chapterModel.Id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{

@ -2,26 +2,19 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace Blazor.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
namespace Blazor.Pages;
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
private readonly ILogger<ErrorModel> _logger;
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

@ -15,7 +15,7 @@ namespace Blazor.Pages.Players
public NavigationManager NavigationManager { get; set; }
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
playerModel.HashPassword(playerModel.HashedPassword);
@ -27,7 +27,7 @@ namespace Blazor.Pages.Players
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/player/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/player"+"/"+API.TOKEN;
using (var httpClient = new HttpClient())
{

@ -36,7 +36,7 @@ namespace Blazor.Pages.Players
};
}
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
playerModel.HashPassword(playerModel.HashedPassword);
@ -48,7 +48,7 @@ namespace Blazor.Pages.Players
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/player/" + playerModel.Id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/player/" + playerModel.Id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{

@ -2,16 +2,11 @@
using Blazor.Services;
using Blazored.Modal.Services;
using Blazor.ViewClasses;
using System.Text;
using Microsoft.JSInterop;
using Microsoft.AspNetCore.Components;
using Blazorise.DataGrid;
using ChoETL;
using Microsoft.AspNetCore.Components.Forms;
using Blazor.Modals;
using Blazored.Modal;
using Blazor.Pages.Admins;
using Blazor.Pages.Chapters;
namespace Blazor.Pages.Players;
@ -53,7 +48,7 @@ public partial class Players
return;
}
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/player/" + id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/player/" + id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{
@ -92,7 +87,7 @@ public partial class Players
return;
}
var response = Http.GetFromJsonAsync<Player[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/players/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var response = Http.GetFromJsonAsync<Player[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/players"+"/"+API.TOKEN).Result;
if (!e.CancellationToken.IsCancellationRequested)
{
@ -101,7 +96,7 @@ public partial class Players
var currentData = await LocalStorage.GetItemAsync<Player[]>("data");
if (currentData == null || currentData.Length != players.Count)
{
var originalData = Http.GetFromJsonAsync<Player[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/players/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var originalData = Http.GetFromJsonAsync<Player[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/players"+"/"+API.TOKEN).Result;
await LocalStorage.SetItemAsync("data", originalData);
}
}

@ -21,7 +21,7 @@ namespace Blazor.Pages.Questions
public ILogger<AddAdministrator> Logger { get; set; }
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
await DataService.Add(questionModel);
@ -31,7 +31,7 @@ namespace Blazor.Pages.Questions
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/administrator/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/administrator"+"/"+API.TOKEN;
using (var httpClient = new HttpClient())
{

@ -26,7 +26,7 @@ namespace Blazor.Pages.Questions
public ILogger<EditQuestion> Logger { get; set; }
private async void HandleValidSubmit()
private async Task HandleValidSubmit()
{
await DataService.Update(Id, questionModel);
@ -35,7 +35,7 @@ namespace Blazor.Pages.Questions
var formContent = new FormUrlEncodedContent(formData);
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/questions/" + questionModel.Id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/update/questions/" + questionModel.Id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{

@ -53,7 +53,7 @@ public partial class Questions
return;
}
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/question/" + id + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/delete/question/" + id + "/" + API.TOKEN;;
using (var httpClient = new HttpClient())
{
@ -105,16 +105,16 @@ public partial class Questions
if (currentData == null || currentData.Length != questions.Count)
{
// this code add in the local storage the fake data (we load the data sync for initialize the data before load the OnReadData method)
var originalData = Http.GetFromJsonAsync<Question[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var originalData = Http.GetFromJsonAsync<Question[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
await LocalStorage.SetItemAsync("data", originalData);
}
}
}
private async void Export()
private async Task Export()
{
StringBuilder sb = new StringBuilder();
HttpResponseMessage response = await Http.GetAsync("https://trusting-panini.87-106-126-109.plesk.page/api/questionsExport/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO");
HttpResponseMessage response = await Http.GetAsync("https://trusting-panini.87-106-126-109.plesk.page/api/questionsExport"+"/"+API.TOKEN);
var json = await response.Content.ReadAsStringAsync();
using (var jsonFile = ChoJSONReader.LoadText(json))
{
@ -155,7 +155,7 @@ public partial class Questions
formData.Add(new KeyValuePair<string, string>("answerContent4", field[5]));
formData.Add(new KeyValuePair<string, string>("idanswergood", field[6]));
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/chapters/name/"+field[1] + "/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
string apiUri = API.API_URL+"chapters/name/"+field[1] + "/" + API.TOKEN;;
var response = await Http.GetAsync(apiUri);
@ -174,7 +174,7 @@ public partial class Questions
}
var formContent = new FormUrlEncodedContent(formData);
apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO";
apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/questions"+"/"+API.TOKEN;
response = await Http.PostAsync(apiUri, formContent);

@ -6,6 +6,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Host</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />

@ -1,5 +1,9 @@
<html>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Layout</title>
</head>
<body>
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />

@ -4,10 +4,8 @@ using Blazored.LocalStorage;
using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Blazored.Modal;
using Microsoft.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args);
@ -56,3 +54,4 @@ app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();

@ -1,4 +1,5 @@
using Blazor.Models;
using Blazor.Pages;
using Blazor.ViewClasses;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
@ -12,24 +13,21 @@ namespace Blazor.Services
private readonly HttpClient _http;
private readonly ILocalStorageService _localStorage;
private readonly NavigationManager _navigationManager;
private readonly IWebHostEnvironment _webHostEnvironment;
public DataLocalService(
ILocalStorageService localStorage,
HttpClient http,
IWebHostEnvironment webHostEnvironment,
NavigationManager navigationManager)
{
_localStorage = localStorage;
_http = http;
_webHostEnvironment = webHostEnvironment;
_navigationManager = navigationManager;
}
public async Task<Chapter> GetById(int id)
{
// Get the current data
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
// Get the chapter int the list
var chapter = currentData.FirstOrDefault(w => w.Id == id);
@ -89,7 +87,7 @@ namespace Blazor.Services
{
// Get the current data
//var currentData = await _localStorage.GetItemAsync<List<Chapter>>("data");
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
// Get the chapter int the list
var chapter = currentData.FirstOrDefault(w => w.Id == id);
@ -136,7 +134,7 @@ namespace Blazor.Services
public async Task<Administrator> GetAdminById(int id)
{
// Get the current data
var currentData = _http.GetFromJsonAsync<List<Administrator>>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var currentData = _http.GetFromJsonAsync<List<Administrator>>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators"+"/"+API.TOKEN).Result;
// Get the admin int the list
var admin = currentData.FirstOrDefault(w => w.Id == id);
@ -229,7 +227,7 @@ namespace Blazor.Services
public async Task<Question> GetQuestionById(int id)
{
// Get the current data
var currentData = _http.GetFromJsonAsync<List<Question>>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var currentData = _http.GetFromJsonAsync<List<Question>>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions"+"/"+API.TOKEN).Result;
// Get the question int the list
var question = currentData.FirstOrDefault(w => w.Q_id == id);
@ -321,7 +319,7 @@ namespace Blazor.Services
public async Task<Player> GetPlayerById(int id)
{
// Get the current data
var currentData = _http.GetFromJsonAsync<List<Player>>($"https://trusting-panini.87-106-126-109.plesk.page/api/players/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
var currentData = _http.GetFromJsonAsync<List<Player>>($"https://trusting-panini.87-106-126-109.plesk.page/api/players"+"/"+API.TOKEN).Result;
// Get the player in the list
var player = currentData.FirstOrDefault(w => w.Id == id);

Loading…
Cancel
Save