diff --git a/rest_service/Controllers/RecordingsController.cs b/rest_service/Controllers/RecordingsController.cs index 5753283..fba4fdd 100644 --- a/rest_service/Controllers/RecordingsController.cs +++ b/rest_service/Controllers/RecordingsController.cs @@ -110,6 +110,17 @@ public async Task PostRecording([FromBody] RecordingRequest recor return Ok(new { Message = "Recording created successfully." }); } + [HttpGet(Name = "GetRecording")] + public async Task GetRecording([FromQuery] string id) + { + Recording recording = _recordingsCollection + .Find(r => r.Id.ToString() == id) + .Limit(1).ToList().First(); + + return recording.ToJson(); + } + + private async Task AddLocation(Recording recording) { var eventId = recording.Event.Id; diff --git a/website/Pages/PlayerSimilar.razor b/website/Pages/PlayerSimilar.razor index 8e069c6..e1a0d02 100644 --- a/website/Pages/PlayerSimilar.razor +++ b/website/Pages/PlayerSimilar.razor @@ -102,54 +102,61 @@ else {

Similar Players

- foreach (SimilarRecording rec in Similar) - { - string chartUrl = ChartsUrl.CreateSimilarUrl(_atlasChartIdSimilar, rec.Id); -
-
@rec.Name
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Score@rec.SessionStatisticsPlain.Score
DamageDone@rec.SessionStatisticsPlain.DamageDone
BulletsFired@rec.SessionStatisticsPlain.BulletsFired
PelletsDestroyedLarge@rec.SessionStatisticsPlain.PelletsDestroyedLarge
PelletsDestroyedMedium@rec.SessionStatisticsPlain.PelletsDestroyedMedium
PelletsDestroyedSmall@rec.SessionStatisticsPlain.PelletsDestroyedSmall
PowerUpBulletDamageCollected@rec.SessionStatisticsPlain.PowerUpBulletDamageCollected
PowerUpBulletSpeedCollected@rec.SessionStatisticsPlain.PowerUpBulletSpeedCollected
PowerUpPlayerSpeedCollected@rec.SessionStatisticsPlain.PowerUpPlayerSpeedCollected
- -
- } - } + foreach (SimilarRecording rec in Similar) + { + string chartUrl = ChartsUrl.CreateSimilarUrl(_atlasChartIdSimilar, rec.Id); +
+
@rec.Name
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Score@rec.SessionStatisticsPlain.Score
DamageDone@rec.SessionStatisticsPlain.DamageDone
BulletsFired@rec.SessionStatisticsPlain.BulletsFired
PelletsDestroyedLarge@rec.SessionStatisticsPlain.PelletsDestroyedLarge
PelletsDestroyedMedium@rec.SessionStatisticsPlain.PelletsDestroyedMedium
PelletsDestroyedSmall@rec.SessionStatisticsPlain.PelletsDestroyedSmall
PowerUpBulletDamageCollected@rec.SessionStatisticsPlain.PowerUpBulletDamageCollected
PowerUpBulletSpeedCollected@rec.SessionStatisticsPlain.PowerUpBulletSpeedCollected
PowerUpPlayerSpeedCollected@rec.SessionStatisticsPlain.PowerUpPlayerSpeedCollected
+ +
+
+     + View JSON data +     +
+
+
} + } + } @@ -187,10 +194,10 @@ var players = await _restClient.GetJsonAsync>(playersUrlWithQuery); Player = players.First(); - //string similarBySpeedUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointSimilarBySpeed, playerFilter); + //string similarBySpeedUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointRecordingsSimilarBySpeed, playerFilter); //SimilarBySpeed = await _restClient.GetJsonAsync>(similarBySpeedUrlWithQuery); - string similarUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointSimilar, playerFilter); + string similarUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointRecordingsSimilar, playerFilter); Similar = await _restClient.GetJsonAsync>(similarUrlWithQuery); //TO-DO: Revisit acceleration diff --git a/website/Pages/PlayerSimilar_json.razor b/website/Pages/PlayerSimilar_json.razor new file mode 100644 index 0000000..9b8c66b --- /dev/null +++ b/website/Pages/PlayerSimilar_json.razor @@ -0,0 +1,97 @@ +@page "/playerSimilar_json" +@using RestSharp +@using website.Utils +@using dotenv.net + +@inject NavigationManager NavigationManager +@inject Blazored.LocalStorage.ILocalStorageService localStore +@inject IJSRuntime JSRuntime + + + + + + logo + + +
+
+ Solution +    |    + MDB for Gaming +    |    + GitHub +
+
+ +
+ @if (recordingAsString == string.Empty) + if (_errorMessage != string.Empty) + { +

@_errorMessage

+ } + else + { +

Loading... [@_recordingId]

+ } + else + { + @recordingAsString + } +
+ + +@code { + + private string _eventId = string.Empty; + private string _recordingId = string.Empty; + + private string recordingAsString = string.Empty; + private string _errorMessage = string.Empty; + private readonly RestClient _restClient = RestServiceClient.Create(); + + private string chartFilter = string.Empty; + + protected override async Task OnInitializedAsync() + { + try + { + var queryParameters = UrlHelper.GetParameters(NavigationManager.Uri); + + _eventId = queryParameters[Constants.QueryParameterEventId]; + _recordingId = queryParameters[Constants.QueryParameterRecordingId].ToString(); + + var recordingFilter = new Dictionary + { + { "id", _recordingId } + }; + + string recordingUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointRecordings, recordingFilter); + recordingAsString = await _restClient.GetJsonAsync(recordingUrlWithQuery); + + DotEnv.Load(); + var envVars = DotEnv.Read(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + _errorMessage = "EXCEPTION: " + e.Message + e.StackTrace; + } + } +} diff --git a/website/Utils/Constants.cs b/website/Utils/Constants.cs index e3f2e89..1669d40 100644 --- a/website/Utils/Constants.cs +++ b/website/Utils/Constants.cs @@ -8,10 +8,12 @@ public static class Constants public const string RestServiceEndpointPlayers = "players"; public const string RestServiceEndpointPlayersAutoComplete = "players/autocomplete"; public const string RestServiceEndpointPlayersSearch = "players/search"; - public const string RestServiceEndpointSimilar = "recordings/similar"; - public const string RestServiceEndpointSimilarBySpeed = "recordings/similarBySpeed"; - public const string RestServiceEndpointSimilarByAccel = "recordings/similarByAcceleration"; - public const string RestServiceEndpointSimilarByStats = "recordings/similarByStats"; + public const string RestServiceEndpointRecordings = "recordings"; + public const string RestServiceEndpointRecordingsSimilar = "recordings/similar"; + public const string RestServiceEndpointRecordingsSimilarBySpeed = "recordings/similarBySpeed"; + public const string RestServiceEndpointRecordingsSimilarByAccel = "recordings/similarByAcceleration"; + public const string RestServiceEndpointRecordingsSimilarByStats = "recordings/similarByStats"; public const string QueryParameterEventId = "EventId"; public const string QueryParameterName = "Name"; + public const string QueryParameterRecordingId = "recordingId"; } \ No newline at end of file