From 4f1c7b782a0f2ed83f711e2983bacb1a31675bc0 Mon Sep 17 00:00:00 2001
From: "Daniel J. Summers"
Date: Thu, 7 Jan 2021 22:49:10 -0500
Subject: [PATCH] Display profile now works
wrapping up #2
---
.../Client/Pages/Citizen/Authorized.razor | 2 +
.../Client/Pages/Citizen/Dashboard.razor | 6 ++-
.../Client/Pages/Citizen/EditProfile.razor | 22 ++++----
.../Client/Pages/Citizen/EditProfile.razor.cs | 18 +++++--
src/JobsJobsJobs/Client/Pages/Index.razor | 8 +--
.../Client/Pages/Profile/View.razor | 41 ++++++++++++++-
.../Client/Pages/Profile/View.razor.cs | 51 +++++++++++++++++--
.../Client/Shared/ErrorList.razor | 2 +-
src/JobsJobsJobs/Client/Shared/NavMenu.razor | 2 +-
.../Client/Shared/PageTitle.razor | 11 ++++
src/JobsJobsJobs/Client/wwwroot/index.html | 8 +++
.../Server/.config/dotnet-tools.json | 12 +++++
src/JobsJobsJobs/Server/Data/Converters.cs | 4 --
src/JobsJobsJobs/Server/Data/JobsDbContext.cs | 2 +
.../Server/JobsJobsJobs.Server.csproj | 1 +
.../Server/JobsJobsJobs.Server.csproj.user | 1 +
.../PublishProfiles/FolderProfile.pubxml | 23 +++++++++
.../PublishProfiles/FolderProfile.pubxml.user | 9 ++++
18 files changed, 192 insertions(+), 31 deletions(-)
create mode 100644 src/JobsJobsJobs/Client/Shared/PageTitle.razor
create mode 100644 src/JobsJobsJobs/Server/.config/dotnet-tools.json
create mode 100644 src/JobsJobsJobs/Server/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 src/JobsJobsJobs/Server/Properties/PublishProfiles/FolderProfile.pubxml.user
diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/Authorized.razor b/src/JobsJobsJobs/Client/Pages/Citizen/Authorized.razor
index ebf5eee..dfec9cb 100644
--- a/src/JobsJobsJobs/Client/Pages/Citizen/Authorized.razor
+++ b/src/JobsJobsJobs/Client/Pages/Citizen/Authorized.razor
@@ -3,4 +3,6 @@
@inject NavigationManager nav
@inject AppState state
+
+
@Message
diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor b/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor
index ecf4dc1..b687348 100644
--- a/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor
+++ b/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor
@@ -2,6 +2,8 @@
@inject HttpClient http
@inject AppState state
+
+
Welcome, @state.User!.Name!
@if (RetrievingData)
@@ -17,17 +19,19 @@ else
Your employment profile was last updated . Your profile currently
lists @Profile.Skills.Length skill@(Profile.Skills.Length != 1 ? "s" : "").
+ View Your Employment Profile
}
else
{
You do not have an employment profile established; click “Profile”* in the menu to get started!
}
+
There @(ProfileCount == 1 ? "is" : "are") @(ProfileCount == 0 ? "no" : ProfileCount) employment
profile@(ProfileCount != 1 ? "s" : "") from citizens of Gitmo Nation.
@if (ProfileCount > 0)
{
- Take a look around and see if you can help them find work!
+ Take a look around and see if you can help them find work! (coming soon)
}
diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor
index e652248..cf938a1 100644
--- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor
+++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor
@@ -1,22 +1,16 @@
@page "/citizen/profile"
@inject HttpClient http
@inject AppState state
+@inject NavigationManager nav
@inject IToastService toast
+
+
Employment Profile
@if (AllLoaded)
{
- @if (ErrorMessages.Count > 0)
- {
- Error
- @foreach (var msg in ErrorMessages)
- {
- @msg
- }
- }
- else
- {
+
@@ -111,7 +105,13 @@
- }
+ @if (!IsNew)
+ {
+
+ View Your User Profile
+
+ }
+
}
else
{
diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs
index 1a3f637..c26f519 100644
--- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs
+++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs
@@ -33,6 +33,11 @@ namespace JobsJobsJobs.Client.Pages.Citizen
///
private IEnumerable Continents { get; set; } = Enumerable.Empty();
+ ///
+ /// Whether this is a new profile or not
+ ///
+ private bool IsNew { get; set; } = false;
+
///
/// Error messages from API access
///
@@ -57,9 +62,15 @@ namespace JobsJobsJobs.Client.Pages.Citizen
if (profileTask.Result.IsOk)
{
- ProfileForm = (profileTask.Result.Ok == null)
- ? new ProfileForm()
- : ProfileForm.FromProfile(profileTask.Result.Ok);
+ if (profileTask.Result.Ok == null)
+ {
+ ProfileForm = new ProfileForm();
+ IsNew = true;
+ }
+ else
+ {
+ ProfileForm = ProfileForm.FromProfile(profileTask.Result.Ok);
+ }
if (ProfileForm.Skills.Count == 0) AddNewSkill();
}
else
@@ -98,6 +109,7 @@ namespace JobsJobsJobs.Client.Pages.Citizen
if (res.IsSuccessStatusCode)
{
toast.ShowSuccess("Profile Saved Successfully");
+ nav.NavigateTo($"/profile/view/{state.User!.Id}");
}
else
{
diff --git a/src/JobsJobsJobs/Client/Pages/Index.razor b/src/JobsJobsJobs/Client/Pages/Index.razor
index d99f9a8..8850a8b 100644
--- a/src/JobsJobsJobs/Client/Pages/Index.razor
+++ b/src/JobsJobsJobs/Client/Pages/Index.razor
@@ -1,6 +1,8 @@
@page "/"
@inject IJSRuntime js
+
+
Future home of No Agenda Jobs, where citizens of Gitmo Nation can assist one another in finding or enhancing their
employment. This will enable them to continue providing value for value to Adam and John, as they continue their work
@@ -10,12 +12,12 @@
Do you not understand the terms in the paragraph above? No worries; just head over to
The Best Podcast in the Universe
- (it’s true!) and find out what you’re missing.
+ (that’s true!) and find out what you’re missing.
-
+
@code {
- async void PlayTrue() => await js.InvokeVoidAsync("Audio.play", "itstrue");
+ async void PlayTrue() => await js.InvokeVoidAsync("Audio.play", "thatstrue");
}
\ No newline at end of file
diff --git a/src/JobsJobsJobs/Client/Pages/Profile/View.razor b/src/JobsJobsJobs/Client/Pages/Profile/View.razor
index 9dbf01f..1909c57 100644
--- a/src/JobsJobsJobs/Client/Pages/Profile/View.razor
+++ b/src/JobsJobsJobs/Client/Pages/Profile/View.razor
@@ -8,8 +8,45 @@
}
else
{
+
- View Profile
+
+ @Profile.Continent!.Name, @Profile.Region
+ @WorkTypes
+
+
+
+ @(new MarkupString(Profile.Biography.ToHtml()))
+
+
+
+ @if (Profile.Skills.Length > 0)
+ {
+
+ Skills
+
+ @foreach (var skill in Profile.Skills)
+ {
+ var notes = skill.Notes == null ? "" : $" ({skill.Notes})";
+ @skill.Description@notes
+ }
+
+ }
+
+ @if (Profile.Experience != null)
+ {
+
+ Experience / Employment History
+
+ @(new MarkupString(Profile.Experience.ToHtml()))
+
+ }
+
+ @if (Id == state.User!.Id.ToString())
+ {
+
+ Edit Your Profile
+ }
-}
\ No newline at end of file
+}
diff --git a/src/JobsJobsJobs/Client/Pages/Profile/View.razor.cs b/src/JobsJobsJobs/Client/Pages/Profile/View.razor.cs
index ecdf7f1..c9691b6 100644
--- a/src/JobsJobsJobs/Client/Pages/Profile/View.razor.cs
+++ b/src/JobsJobsJobs/Client/Pages/Profile/View.razor.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
-using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -9,22 +8,62 @@ namespace JobsJobsJobs.Client.Pages.Profile
{
public partial class View : ComponentBase
{
+ ///
+ /// Whether data for this component is loading
+ ///
private bool IsLoading { get; set; } = true;
- private Domain.Citizen? Citizen { get; set; }
+ ///
+ /// The citizen whose profile is being displayed
+ ///
+ private Domain.Citizen Citizen { get; set; } = default!;
- private Domain.Profile? Profile { get; set; }
+ ///
+ /// The profile to display
+ ///
+ private Domain.Profile Profile { get; set; } = default!;
+ ///
+ /// The work types for the top of the page
+ ///
+ private MarkupString WorkTypes
+ {
+ get
+ {
+ IEnumerable parts()
+ {
+ if (Profile.SeekingEmployment)
+ {
+ yield return "CURRENTLY SEEKING EMPLOYMENT ";
+ }
+ else
+ {
+ yield return "Not actively seeking employment";
+ }
+ yield return $"{(Profile.FullTime ? "I" : "Not i")}nterested in full-time employment";
+ yield return $"{(Profile.RemoteWork ? "I" : "Not i")}nterested in remote opportunities";
+ }
+
+ return new MarkupString(string.Join(" • ", parts()));
+ }
+ }
+
+ ///
+ /// Error messages from data retrieval
+ ///
private IList ErrorMessages { get; } = new List();
+ ///
+ /// The ID of the citizen whose profile should be displayed
+ ///
[Parameter]
public string Id { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
ServerApi.SetJwt(http, state);
- var citizenTask = ServerApi.RetrieveOne(http, $"/api/citizen/{Id}");
- var profileTask = ServerApi.RetrieveOne(http, $"/api/profile/get/{Id}");
+ var citizenTask = ServerApi.RetrieveOne(http, $"citizen/get/{Id}");
+ var profileTask = ServerApi.RetrieveOne(http, $"profile/get/{Id}");
await Task.WhenAll(citizenTask, profileTask);
@@ -53,6 +92,8 @@ namespace JobsJobsJobs.Client.Pages.Profile
{
ErrorMessages.Add(profileTask.Result.Error);
}
+
+ IsLoading = false;
}
}
}
diff --git a/src/JobsJobsJobs/Client/Shared/ErrorList.razor b/src/JobsJobsJobs/Client/Shared/ErrorList.razor
index 0f1599d..8c03d02 100644
--- a/src/JobsJobsJobs/Client/Shared/ErrorList.razor
+++ b/src/JobsJobsJobs/Client/Shared/ErrorList.razor
@@ -8,7 +8,7 @@ else
@foreach (var msg in Errors)
{
- @msg
+ @msg
}
}
diff --git a/src/JobsJobsJobs/Client/Shared/NavMenu.razor b/src/JobsJobsJobs/Client/Shared/NavMenu.razor
index ff92828..4fdf956 100644
--- a/src/JobsJobsJobs/Client/Shared/NavMenu.razor
+++ b/src/JobsJobsJobs/Client/Shared/NavMenu.razor
@@ -33,7 +33,7 @@
- Profile
+ Edit Profile
diff --git a/src/JobsJobsJobs/Client/Shared/PageTitle.razor b/src/JobsJobsJobs/Client/Shared/PageTitle.razor
new file mode 100644
index 0000000..f7f8d08
--- /dev/null
+++ b/src/JobsJobsJobs/Client/Shared/PageTitle.razor
@@ -0,0 +1,11 @@
+@inject IJSRuntime js
+@code {
+ [Parameter]
+ public string Title { get; set; } = default!;
+
+ protected override async Task OnInitializedAsync()
+ {
+ await base.OnInitializedAsync();
+ await js.InvokeVoidAsync("setPageTitle", $"{Title} ~ Jobs, Jobs, Jobs");
+ }
+}
diff --git a/src/JobsJobsJobs/Client/wwwroot/index.html b/src/JobsJobsJobs/Client/wwwroot/index.html
index 0688532..b86b985 100644
--- a/src/JobsJobsJobs/Client/wwwroot/index.html
+++ b/src/JobsJobsJobs/Client/wwwroot/index.html
@@ -35,6 +35,14 @@
document.getElementById(audio).play()
}
}
+ /**
+ * Set the title of the document. (called by PageTitle component)
+ *
+ * @param theTitle The title to be set
+ */
+ function setPageTitle(theTitle) {
+ document.title = theTitle
+ }