This commit is contained in:
femsci 2023-10-01 12:00:22 +02:00
parent 291d143328
commit 271b144501
Signed by: femsci
GPG key ID: 08F7911F0E650C67
13 changed files with 246 additions and 200 deletions

View file

@ -66,7 +66,7 @@
} }
usr.SetUser(user); usr.SetUser(user);
this.StateHasChanged(); this.StateHasChanged();
nav.NavigateTo("/"); nav.NavigateTo("/", true);
return; return;
} }

View file

@ -12,6 +12,7 @@
{ {
usr.SetUser(null!); usr.SetUser(null!);
} }
nav.NavigateTo("/login"); this.StateHasChanged();
nav.NavigateTo("/login", true);
} }
} }

View file

@ -56,7 +56,7 @@
{ {
if (await usr.GetUser() != null) if (await usr.GetUser() != null)
{ {
nav.NavigateTo("/"); nav.NavigateTo("/", true);
return; return;
} }
Model ??= new(); Model ??= new();
@ -77,7 +77,7 @@
} }
usr.SetUser(user); usr.SetUser(user);
this.StateHasChanged(); this.StateHasChanged();
nav.NavigateTo("/"); nav.NavigateTo("/", true);
return; return;
} }

View file

@ -17,8 +17,10 @@ else
if (_user != null) if (_user != null)
{ {
<div class="user-profile"> <div class="user-profile">
<div class="bkg-img">
<img class="background" src="images/background.jpg" alt="Background" /> <img class="background" src="images/background.jpg" alt="Background" />
<img class="profile-img" src="images/kuba.jpg" alt="Profile Picture" /> <img class="profile-img" src="images/pfp.jpg" alt="Profile Picture" />
</div>
<div class="profile-names"> <div class="profile-names">
<h1 class="profile-username">@($"@{_user.Username}")</h1> <h1 class="profile-username">@($"@{_user.Username}")</h1>
@if (_user.Name != null) @if (_user.Name != null)
@ -26,6 +28,12 @@ else
<h3 class="profile-fullname">(@_user.Name)</h3> <h3 class="profile-fullname">(@_user.Name)</h3>
} }
</div> </div>
@if (_user.City != null && _user.CountryCode != null)
{
<div class="profile-location-info">
<span class="profile-loc">@($"{_user.City}, {_user.CountryCode}")</span>
</div>
}
<p>@(_user.Bio ?? "~")</p> <p>@(_user.Bio ?? "~")</p>
@if (_user.Interests != null) @if (_user.Interests != null)
{ {

View file

@ -22,6 +22,13 @@ public class UserManager
public async Task InitAsync() public async Task InitAsync()
{ {
await sem.WaitAsync();
if (_init)
{
sem.Release();
return;
}
using var scope = _serv.CreateAsyncScope(); using var scope = _serv.CreateAsyncScope();
var resp = await scope.ServiceProvider.GetRequiredService<HttpClient>().GetAsync("/api/auth/userdata"); var resp = await scope.ServiceProvider.GetRequiredService<HttpClient>().GetAsync("/api/auth/userdata");
if (resp.StatusCode == HttpStatusCode.OK) if (resp.StatusCode == HttpStatusCode.OK)
@ -29,6 +36,10 @@ public class UserManager
this.User = (await resp.Content.ReadFromJsonAsync<UserModel>())!; this.User = (await resp.Content.ReadFromJsonAsync<UserModel>())!;
Console.WriteLine($"User: {User.Id}"); Console.WriteLine($"User: {User.Id}");
} }
_init = true;
sem.Release();
} }
private UserModel User { get; set; } = default!; private UserModel User { get; set; } = default!;
@ -36,12 +47,10 @@ public class UserManager
{ {
if (User == null) if (User == null)
{ {
await sem.WaitAsync();
if (!_init) if (!_init)
{ {
await InitAsync(); await InitAsync();
} }
sem.Release();
} }
return User; return User;

View file

@ -12,8 +12,6 @@ main {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
} }
.top-row { .top-row {
background-color: #f7f7f7; background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5; border-bottom: 1px solid #d6d5d5;
@ -23,13 +21,15 @@ main {
align-items: center; align-items: center;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
.top-row ::deep .btn-link {
white-space: nowrap; white-space: nowrap;
margin-left: 1.5rem; margin-left: 1.5rem;
text-decoration: none; text-decoration: none;
} }
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { .top-row ::deep a:hover,
.top-row ::deep .btn-link:hover {
text-decoration: underline; text-decoration: underline;
} }
@ -47,7 +47,8 @@ main {
justify-content: space-between; justify-content: space-between;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
.top-row ::deep .btn-link {
margin-left: 0; margin-left: 0;
} }
} }
@ -67,7 +68,7 @@ main {
.top-row { .top-row {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 1; z-index: 20;
} }
.top-row.auth ::deep a:first-child { .top-row.auth ::deep a:first-child {
@ -76,7 +77,8 @@ main {
width: 0; width: 0;
} }
.top-row, article { .top-row,
article {
padding-left: 2rem !important; padding-left: 2rem !important;
padding-right: 1.5rem !important; padding-right: 1.5rem !important;
} }

View file

@ -8,9 +8,8 @@ main {
flex: 1; flex: 1;
} }
.top-row { .top-row {
z-index: 20;
background-color: #f7f7f7; background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5; border-bottom: 1px solid #d6d5d5;
justify-content: flex-end; justify-content: flex-end;
@ -19,13 +18,15 @@ main {
align-items: center; align-items: center;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
.top-row ::deep .btn-link {
white-space: nowrap; white-space: nowrap;
margin-left: 1.5rem; margin-left: 1.5rem;
text-decoration: none; text-decoration: none;
} }
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { .top-row ::deep a:hover,
.top-row ::deep .btn-link:hover {
text-decoration: underline; text-decoration: underline;
} }
@ -43,7 +44,8 @@ main {
justify-content: space-between; justify-content: space-between;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
.top-row ::deep .btn-link {
margin-left: 0; margin-left: 0;
} }
} }
@ -63,7 +65,7 @@ main {
.top-row { .top-row {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 1; z-index: 20;
} }
.top-row.auth ::deep a:first-child { .top-row.auth ::deep a:first-child {
@ -72,7 +74,8 @@ main {
width: 0; width: 0;
} }
.top-row, article { .top-row,
article {
padding-left: 2rem !important; padding-left: 2rem !important;
padding-right: 1.5rem !important; padding-right: 1.5rem !important;
} }

View file

@ -1,4 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark"> @inject UserManager usr
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid"> <div class="container-fluid">
<img src="images/InterlinkedLogoWhite.png" style="max-width: 8vw; <img src="images/InterlinkedLogoWhite.png" style="max-width: 8vw;
"> ">
@ -10,20 +12,34 @@
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu"> <div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="flex-column"> <nav class="flex-column">
@if (user != null)
{
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="@($"/profile/{user.Username}")" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Your community <span class="oi oi-home" aria-hidden="true"></span> Your profile
</NavLink> </NavLink>
</div> </div>
}
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="project"> <NavLink class="nav-link" href="project">
<span class="oi oi-plus" aria-hidden="true"></span> Projects <span class="oi oi-plus" aria-hidden="true"></span> Projects
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="/user/This could be you!"> @if (user != null)
<span class="oi oi-list-rich" aria-hidden="true"></span> Your Profile {
<NavLink class="nav-link" href="/dashboard">
<span class="oi oi-cog" aria-hidden="true"></span> Settings
</NavLink> </NavLink>
}
else
{
<NavLink class="nav-link" href="/login">
<span class="oi oi-account-login" aria-hidden="true"></span> Log in
</NavLink>
}
</div> </div>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="about"> <NavLink class="nav-link" href="about">
@ -34,6 +50,13 @@
</div> </div>
@code { @code {
private UserModel? user = null;
protected override async Task OnInitializedAsync()
{
user = await usr.GetUser();
}
private bool collapseNavMenu = true; private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

View file

@ -5,6 +5,7 @@
.top-row { .top-row {
height: 3.5rem; height: 3.5rem;
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
z-index: 20;
} }
.navbar-brand { .navbar-brand {

View file

@ -1,16 +0,0 @@
<div class="alert alert-secondary mt-4">
<span class="oi oi-pencil me-2" aria-hidden="true"></span>
<strong>@Title</strong>
<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold link-dark" href="https://go.microsoft.com/fwlink/?linkid=2186157">brief survey</a>
</span>
and tell us what you think.
</div>
@code {
// Demonstrates how a parent component can supply parameters
[Parameter]
public string? Title { get; set; }
}

View file

@ -97,21 +97,26 @@ a,
} }
} }
.user-profile {
position: relative;
}
.profile-img { .profile-img {
position: absolute; position: absolute;
object-fit: cover; object-fit: cover;
transform: translate(10%, 25%);
z-index: 1; /* Place the profile picture above the background image */ z-index: 1; /* Place the profile picture above the background image */
max-width: 200px; max-width: 200px;
min-width: 200px; min-width: 200px;
max-height: 200px; max-height: 200px;
min-height: 200px; min-height: 200px;
border-radius: 200px; border-radius: 200px;
bottom: -1.5rem;
left: 1rem;
} }
.profile-names { .profile-names {
width: fit-content; width: fit-content;
margin-top: 0.5rem; margin-top: 2.5rem;
} }
.profile-username { .profile-username {
@ -125,6 +130,16 @@ a,
color: gray; color: gray;
} }
.profile-location-info {
margin-top: 0.3rem;
color: gray;
font-size: 1rem;
}
.bkg-img {
position: relative;
}
.background-img { .background-img {
min-width: 100%; min-width: 100%;
max-height: 300px; max-height: 300px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -12,7 +12,7 @@ public class StoreContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder o) protected override void OnConfiguring(DbContextOptionsBuilder o)
{ {
o.UseSqlite("Data Source=./store.db;Cache=Shared"); o.UseSqlite("Data Source=/data/store.db;Cache=Shared");
o.EnableDetailedErrors(); o.EnableDetailedErrors();
} }