Skip to content

Commit

Permalink
Merge pull request #111 from mongodb-developer:main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
ctcac00 authored Mar 18, 2024
2 parents 1699ce0 + 707c3e2 commit 747369d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 82 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Open http://127.0.0.1:8001/ to verify the website is running.

## Contributors

- [Dominic Frei](https://linktr.ee/dominicfrei)
- [Hubert Nguyen](https://)
- [Nic Raboy](https://www.nraboy.com)
- [Sig Narváez](https://www.linkedin.com/in/signarvaez/)
- [Carlos Castro](https://www.linkedin.com/in/carloscastromdb/)
- [Ángel Martínez](https://www.linkedin.com/in/amartinezgonzalez/)
- [Hubert Nguyen](https://www.linkedin.com/in/hubertnguyen/)
- [Nic Raboy](https://www.nraboy.com)
- [Dominic Frei](https://linktr.ee/dominicfrei)
3 changes: 0 additions & 3 deletions payload.json

This file was deleted.

3 changes: 3 additions & 0 deletions rest_service/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,6 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

*env.prod*
*env.stag*
35 changes: 24 additions & 11 deletions website/Pages/EventHome.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,23 @@
</div>
<div class="card bg-white">
<article class="card-body mx-auto" style="max-width: 400px;">
<h2 class="text-center">Event Dashboard</h2>
<table>
<tr>
<td>
<div>
<img src="@GetQRCodeForCurrentUrl()" class="rounded mx-auto d-block" alt="logo">
</div>
</td>
<td>
@if (Event?.Name != null)
{
<h2 class="card-title mt-3 text-center">@Event.Name</h2>
}
</td>
</tr>
</table>
<h4 class="card-title mt-3 text-center">
<b>
@if (Event?.Name != null)
{
<span>@Event.Name</span>
}
else
{
<span>[Unspecified Event]</span>
}
</b>
<h2 class="text-center">Event Dashboard</h2>
</h4>
</article>
</div>
Expand Down Expand Up @@ -101,4 +106,12 @@ else
}
}

// return current url location
private string GetQRCodeForCurrentUrl()
{
string url = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" +
NavigationManager.Uri + "?EventId=" + _eventId;
Console.WriteLine(url);
return url;
}
}
156 changes: 91 additions & 65 deletions website/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
</a>
<div class="card" style="max-width:400px;background:yellow;text-align:center">
<div style="display:inline">
<a href="https://www.mongodb.com/solutions/solutions-library/gaming-player-profiles-solution" target="_blank">Solution</a>
<a href="https://www.mongodb.com/solutions/solutions-library/gaming-player-profiles-solution"
target="_blank">Solution</a>
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
<a href="https://www.mongodb.com/use-cases/gaming" target="_blank">MDB for Gaming</a>
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
Expand All @@ -35,22 +36,36 @@
</div>
<div class="card bg-white">
<article class="card-body mx-auto" style="max-width: 400px;">
<h2 class="text-center">Player Registration & Login</h2>
<h4 class="card-title mt-3 text-center">
<b>
@if ((_event != null))
{
if ((_event.Location != null) && (_event.Name != null))
{
<a target="_blank" href="/eventHome/?location=@_event.Location&EventId=@_event.Id">@_event.Name</a>
}
else
{
@_event.Name
}
}
</b>
</h4>
<table>
<tr>
<td>
<div>
<img src="@GetQRCodeForCurrentUrl()" class="rounded mx-auto d-block" alt="logo">
</div>
</td>
<td>
<h2 class="card-title mt-3 text-center">
<b>
@if ((_event != null))
{
if ((_event.Location != null) && (_event.Name != null))
{
<a target="_blank" href="/eventHome/?location=@_event.Location&EventId=@_event.Id">@_event.Name</a>
}
else
{
@_event.Name
}
}
</b>
</h2>
</td>
</tr>
</table>


<h4 class="text-center">Registration & Login</h4>

<h4 class="card-title mt-3 text-center">
<b class="validation-message">@_errorMessage</b>
</h4>
Expand All @@ -62,30 +77,23 @@
<i class="fa fa-user"></i>
</span>
</div>
<input id="name"
type="text"
class="form-control"
placeholder="Nickname (case sensitive! no spaces!)"
@bind="Player.Name" name=""
@oninput="AutoCompleteName"
required>


<div id="autocomplete" class="autocomplete">
@if (_suggestedNames.Count > 0)
{
<ul class="options">
@foreach (var name in _suggestedNames)
{
<li id="option_@name"
class="option"
@onclick=@(_ => SelectName(name))>
@name <!-- visible suggestion -->
</li>
}
</ul>
}
</div>
<input id="name" type="text" class="form-control" placeholder="Nickname (case sensitive! no spaces!)"
@bind="Player.Name" name="" @oninput="AutoCompleteName" required>


<div id="autocomplete" class="autocomplete">
@if (_suggestedNames.Count > 0)
{
<ul class="options">
@foreach (var name in _suggestedNames)
{
<li id="option_@name" class="option" @onclick=@(_ => SelectName(name))>
@name <!-- visible suggestion -->
</li>
}
</ul>
}
</div>
</div> <!-- form-group// -->

<div class="form-group input-group">
Expand All @@ -94,7 +102,8 @@
<i class="fa fa-users"></i>
</span>
</div>
<input id="teamname" @bind="Player.Team" name="" class="form-control" placeholder="Team Name (optional)" type="text">
<input id="teamname" @bind="Player.Team" name="" class="form-control" placeholder="Team Name (optional)"
type="text">
</div> <!-- form-group// -->

<div class="form-group input-group">
Expand All @@ -103,18 +112,21 @@
<i class="fa fa-comment"></i>
</span>
</div>
<input id="email" @bind="Player.Email"
name=""
class="form-control"
placeholder="E-Mail for prizes (optional)"
type="email">
<input id="email" @bind="Player.Email" name="" class="form-control"
placeholder="E-Mail for prizes (optional)" type="email">
</div> <!-- form-group// -->


<div class="form-group">
<div class="text-center">
<button type="button" class="btn btn-block center" style="background-color:#00ed64" @onclick="CreatePlayer"> Register </button>
<button type="button" class="btn btn-block center" style="background-color:#00ed64" @onclick="LoginPlayer"> Login </button>
<button type="button" class="btn btn-block center" style="background-color:#00ed64"
@onclick="CreatePlayer">
Register
</button>
<button type="button" class="btn btn-block center" style="background-color:#00ed64"
@onclick="LoginPlayer">
Login
</button>
</div>
</div> <!-- form-group// -->
</form>
Expand Down Expand Up @@ -145,8 +157,10 @@
private string _errorMessage = string.Empty;
private readonly RestClient _restClient = RestServiceClient.Create();

protected override async Task OnAfterRenderAsync (bool firstRender){
if (firstRender) {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JS.InvokeAsync<string>("enableListener");
}
}
Expand All @@ -165,13 +179,13 @@
{
var queryParameters = UrlHelper.GetParameters(NavigationManager.Uri);
_eventId = queryParameters.TryGetValue(Constants.QueryParameterEventId, out var eventIdValue) ? eventIdValue :
queryParameters.TryGetValue("event", out var eventValue) ? eventValue :
Constants.DefaultEventId;
queryParameters.TryGetValue("event", out var eventValue) ? eventValue :
Constants.DefaultEventId;

var eventsFilter = new Dictionary<string, string>
{
{ "id", _eventId }
};
{
{ "id", _eventId }
};

string eventsUrlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointEvents, eventsFilter);
var events = await _restClient.GetJsonAsync<List<Event>>(eventsUrlWithQuery);
Expand Down Expand Up @@ -220,9 +234,9 @@
_errorMessage = "";

var args = new Dictionary<string, string>
{
{ "Name", Player.Name }
};
{
{ "Name", Player.Name }
};

string urlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointPlayers, args);

Expand All @@ -245,21 +259,24 @@
{
var input = e.Value!.ToString()!;

if (input.Length >= 3) {
if (input.Length >= 3)
{

var args = new Dictionary<string, string>
{
{ "Name", input }
};
{
{ "Name", input }
};

string urlWithQuery = UrlHelper.BuildUrlWithQuery(Constants.RestServiceEndpointPlayersAutoComplete, args);

var names = await _restClient.GetJsonAsync<List<string>>(urlWithQuery);

_suggestedNames = names;
await JS.InvokeAsync<string>("showAutoComplete");

} else {

}
else
{
_suggestedNames.Clear();
}
}
Expand All @@ -276,4 +293,13 @@
return newDestination;
}

// return current url location
private string GetQRCodeForCurrentUrl()
{
string url = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" +
NavigationManager.Uri + "?EventId=" + _eventId;
Console.WriteLine(url);
return url;
}

}

0 comments on commit 747369d

Please sign in to comment.