Return all users with profiles (#3)
Also fixed server pre-rendering and added log off functionality
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyVersion>0.7.0.0</AssemblyVersion>
|
||||
<FileVersion>0.7.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.Toast" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.1" />
|
||||
|
||||
@@ -44,6 +44,12 @@ else
|
||||
</ErrorList>
|
||||
}
|
||||
<hr>
|
||||
<h4>Phase 3 – What Works <small><em>(<span class="text-uppercase">In Progress</span> ~~ Last Updated January 10<sup>th</sup>, 2021)</em></small></h4>
|
||||
<p>
|
||||
The “View Profiles” link at the side does not have any search capabilities, but it does provide a list of
|
||||
citizens who have filled out profiles, along with a way to view those profiles.
|
||||
</p>
|
||||
<hr>
|
||||
<h4>Phase 2 – What Works <small><em>(Last Updated January 8<sup>th</sup>, 2021)</em></small></h4>
|
||||
<p>
|
||||
If you’ve gotten this far, you’ve already passed
|
||||
|
||||
13
src/JobsJobsJobs/Client/Pages/Citizen/LogOff.razor
Normal file
13
src/JobsJobsJobs/Client/Pages/Citizen/LogOff.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
@page "/citizen/log-off"
|
||||
@inject NavigationManager nav
|
||||
@inject AppState state
|
||||
@inject IToastService toast
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
state.Jwt = "";
|
||||
state.User = null;
|
||||
toast.ShowSuccess("Have a Nice Day!", "Log Off Successful");
|
||||
nav.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
44
src/JobsJobsJobs/Client/Pages/Profile/Search.razor
Normal file
44
src/JobsJobsJobs/Client/Pages/Profile/Search.razor
Normal file
@@ -0,0 +1,44 @@
|
||||
@page "/profile/search"
|
||||
@inject HttpClient http
|
||||
@inject AppState state
|
||||
|
||||
<PageTitle Title="Search Profiles" />
|
||||
<h3>Search Profiles</h3>
|
||||
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Searching)
|
||||
{
|
||||
<p>Searching profiles...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (SearchResults.Any())
|
||||
{
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Profile</th>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col" class="text-center">Seeking?</th>
|
||||
<th scope="col" class="text-center">Remote?</th>
|
||||
<th scope="col" class="text-center">Full-Time?</th>
|
||||
<th scope="col">Last Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var profile in SearchResults)
|
||||
{
|
||||
<tr>
|
||||
<td><a href="/profile/view/@profile.CitizenId">View</a></td>
|
||||
<td class=@IsSeeking(profile)>@profile.DisplayName</td>
|
||||
<td class="text-center">@YesOrNo(profile.SeekingEmployment)</td>
|
||||
<td class="text-center">@YesOrNo(profile.RemoteWork)</td>
|
||||
<td class="text-center">@YesOrNo(profile.FullTime)</td>
|
||||
<td><FullDate TheDate=@profile.LastUpdated /></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
</ErrorList>
|
||||
89
src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs
Normal file
89
src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using JobsJobsJobs.Shared;
|
||||
using JobsJobsJobs.Shared.Api;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JobsJobsJobs.Client.Pages.Profile
|
||||
{
|
||||
public partial class Search : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether a search has been performed
|
||||
/// </summary>
|
||||
private bool Searched { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether a request for matching profiles is in progress
|
||||
/// </summary>
|
||||
private bool Searching { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages encountered while searching for profiles
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// All continents
|
||||
/// </summary>
|
||||
private IEnumerable<Continent> Continents { get; set; } = Enumerable.Empty<Continent>();
|
||||
|
||||
/// <summary>
|
||||
/// The search results
|
||||
/// </summary>
|
||||
private IEnumerable<ProfileSearchResult> SearchResults { get; set; } = Enumerable.Empty<ProfileSearchResult>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ServerApi.SetJwt(http, state);
|
||||
var continentResult = await ServerApi.RetrieveMany<Continent>(http, "continent/all");
|
||||
|
||||
if (continentResult.IsOk)
|
||||
{
|
||||
Continents = continentResult.Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(continentResult.Error);
|
||||
}
|
||||
|
||||
// TODO: remove this call once the filter is ready
|
||||
await RetrieveProfiles();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retreive profiles matching the current search criteria
|
||||
/// </summary>
|
||||
private async Task RetrieveProfiles()
|
||||
{
|
||||
Searching = true;
|
||||
|
||||
// TODO: send a filter with this request
|
||||
var searchResult = await ServerApi.RetrieveMany<ProfileSearchResult>(http, "profile/search");
|
||||
|
||||
if (searchResult.IsOk)
|
||||
{
|
||||
SearchResults = searchResult.Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(searchResult.Error);
|
||||
}
|
||||
|
||||
Searched = true;
|
||||
Searching = false;
|
||||
}
|
||||
|
||||
private static string? IsSeeking(ProfileSearchResult profile) =>
|
||||
profile.SeekingEmployment ? "font-weight-bold" : null;
|
||||
|
||||
/// <summary>
|
||||
/// Return "Yes" for true and "No" for false
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition in question</param>
|
||||
/// <returns>"Yes" for true, "No" for false</returns>
|
||||
private static string YesOrNo(bool condition) => condition ? "Yes" : "No";
|
||||
}
|
||||
}
|
||||
23
src/JobsJobsJobs/Client/Shared/FullDate.razor
Normal file
23
src/JobsJobsJobs/Client/Shared/FullDate.razor
Normal file
@@ -0,0 +1,23 @@
|
||||
@using NodaTime
|
||||
@using NodaTime.Text
|
||||
@using System.Globalization
|
||||
|
||||
@Translated
|
||||
|
||||
@code {
|
||||
/// <summary>
|
||||
/// The pattern with which dates will be formatted
|
||||
/// </summary>
|
||||
private static InstantPattern pattern = InstantPattern.Create("ld<MMMM d, yyyy>", CultureInfo.CurrentCulture);
|
||||
|
||||
/// <summary>
|
||||
/// The date to be formatted
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Instant TheDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The formatted date
|
||||
/// </summary>
|
||||
private string Translated => pattern.Format(TheDate);
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
{
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version!;
|
||||
Version = $"v{version.Major}.{version.Minor}";
|
||||
if (version.Revision > 0) Version += $".{version.Revision}";
|
||||
if (version.Build > 0) Version += $".{version.Build}";
|
||||
base.OnInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,29 +18,34 @@
|
||||
</li>
|
||||
@if (state.User == null)
|
||||
{
|
||||
<li class="nav-item px-3">
|
||||
<a class="nav-link" href="@AuthUrl">
|
||||
<span class="oi oi-account-login" aria-hidden="true"></span> Log On
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<a class="nav-link" href="@AuthUrl">
|
||||
<span class="oi oi-account-login" aria-hidden="true"></span> Log On
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/citizen/dashboard">
|
||||
<span class="oi oi-dashboard" aria-hidden="true"></span> Dashboard
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/citizen/profile">
|
||||
<span class="oi oi-pencil" aria-hidden="true"></span> Edit Profile
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="counter">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Log Off
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/citizen/dashboard">
|
||||
<span class="oi oi-dashboard" aria-hidden="true"></span> Dashboard
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/citizen/profile">
|
||||
<span class="oi oi-pencil" aria-hidden="true"></span> Edit Your Profile
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/profile/search">
|
||||
<span class="oi oi-spreadsheet" aria-hidden="true"></span> View Profiles
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/citizen/log-off">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Log Off
|
||||
</NavLink>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
[Parameter]
|
||||
public string Title { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
await js.InvokeVoidAsync("setPageTitle", $"{Title} ~ Jobs, Jobs, Jobs");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user