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">
<img class="background" src="images/background.jpg" alt="Background" /> <div class="bkg-img">
<img class="profile-img" src="images/kuba.jpg" alt="Profile Picture" /> <img class="background" src="images/background.jpg" alt="Background" />
<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

@ -1,83 +1,85 @@
.page { .page {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
main { main {
flex: 1; flex: 1;
} }
.sidebar { .sidebar {
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;
justify-content: flex-end; justify-content: flex-end;
height: 3.5rem; height: 3.5rem;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
white-space: nowrap; .top-row ::deep .btn-link {
margin-left: 1.5rem; white-space: nowrap;
text-decoration: none; margin-left: 1.5rem;
} text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { .top-row ::deep a:hover,
text-decoration: underline; .top-row ::deep .btn-link:hover {
} text-decoration: underline;
}
.top-row ::deep a:first-child { .top-row ::deep a:first-child {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
@media (max-width: 640.98px) { @media (max-width: 640.98px) {
.top-row:not(.auth) { .top-row:not(.auth) {
display: none; display: none;
} }
.top-row.auth { .top-row.auth {
justify-content: space-between; justify-content: space-between;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
margin-left: 0; .top-row ::deep .btn-link {
} margin-left: 0;
}
} }
@media (min-width: 641px) { @media (min-width: 641px) {
.page { .page {
flex-direction: row; flex-direction: row;
} }
.sidebar { .sidebar {
width: 250px; width: 250px;
height: 100vh; height: 100vh;
position: sticky; position: sticky;
top: 0; top: 0;
} }
.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 {
flex: 1; flex: 1;
text-align: right; text-align: right;
width: 0; width: 0;
} }
.top-row, article { .top-row,
padding-left: 2rem !important; article {
padding-right: 1.5rem !important; padding-left: 2rem !important;
} padding-right: 1.5rem !important;
} }
}

View file

@ -1,86 +1,89 @@
.page { .page {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
main { main {
flex: 1; flex: 1;
} }
.top-row { .top-row {
background-color: #f7f7f7; z-index: 20;
border-bottom: 1px solid #d6d5d5; background-color: #f7f7f7;
justify-content: flex-end; border-bottom: 1px solid #d6d5d5;
height: 3.5rem; justify-content: flex-end;
display: flex; height: 3.5rem;
align-items: center; display: flex;
align-items: center;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
white-space: nowrap; .top-row ::deep .btn-link {
margin-left: 1.5rem; white-space: nowrap;
text-decoration: none; margin-left: 1.5rem;
} text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { .top-row ::deep a:hover,
text-decoration: underline; .top-row ::deep .btn-link:hover {
} text-decoration: underline;
}
.top-row ::deep a:first-child { .top-row ::deep a:first-child {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
@media (max-width: 640.98px) { @media (max-width: 640.98px) {
.top-row:not(.auth) { .top-row:not(.auth) {
display: none; display: none;
} }
.top-row.auth { .top-row.auth {
justify-content: space-between; justify-content: space-between;
} }
.top-row ::deep a, .top-row ::deep .btn-link { .top-row ::deep a,
margin-left: 0; .top-row ::deep .btn-link {
} margin-left: 0;
}
} }
@media (min-width: 641px) { @media (min-width: 641px) {
.page { .page {
flex-direction: row; flex-direction: row;
} }
.sidebar { .sidebar {
width: 250px; width: 250px;
height: 100vh; height: 100vh;
position: sticky; position: sticky;
top: 0; top: 0;
} }
.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 {
flex: 1; flex: 1;
text-align: right; text-align: right;
width: 0; width: 0;
} }
.top-row, article { .top-row,
padding-left: 2rem !important; article {
padding-right: 1.5rem !important; padding-left: 2rem !important;
} padding-right: 1.5rem !important;
}
} }
.form { .form {
min-width: 100%; min-width: 100%;
min-height: 100%; min-height: 100%;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: column; flex-direction: column;
} }

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,30 +12,51 @@
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu"> <div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="flex-column"> <nav class="flex-column">
<div class="nav-item px-3"> @if (user != null)
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> {
<span class="oi oi-home" aria-hidden="true"></span> Your community <div class="nav-item px-3">
</NavLink> <NavLink class="nav-link" href="@($"/profile/{user.Username}")" Match="NavLinkMatch.All">
</div> <span class="oi oi-home" aria-hidden="true"></span> Your profile
</NavLink>
</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> <NavLink class="nav-link" href="/dashboard">
<span class="oi oi-cog" aria-hidden="true"></span> Settings
</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">
<span class="oi oi-info" aria-hidden="true"></span> About <span class="oi oi-info" aria-hidden="true"></span> About
</NavLink> </NavLink>
</div> </div>
</nav> </nav>
</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

@ -1,68 +1,69 @@
.navbar-toggler { .navbar-toggler {
background-color: rgba(255, 255, 255, 0.1); background-color: rgba(255, 255, 255, 0.1);
} }
.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 {
font-size: 1.1rem; font-size: 1.1rem;
} }
.oi { .oi {
width: 2rem; width: 2rem;
font-size: 1.1rem; font-size: 1.1rem;
vertical-align: text-top; vertical-align: text-top;
top: -2px; top: -2px;
} }
.nav-item { .nav-item {
font-size: 0.9rem; font-size: 0.9rem;
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
} }
.nav-item:first-of-type { .nav-item:first-of-type {
padding-top: 1rem; padding-top: 1rem;
} }
.nav-item:last-of-type { .nav-item:last-of-type {
padding-bottom: 1rem; padding-bottom: 1rem;
} }
.nav-item ::deep a { .nav-item ::deep a {
color: #d7d7d7; color: #d7d7d7;
border-radius: 4px; border-radius: 4px;
height: 3rem; height: 3rem;
display: flex; display: flex;
align-items: center; align-items: center;
line-height: 3rem; line-height: 3rem;
} }
.nav-item ::deep a.active { .nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25); background-color: rgba(255, 255, 255, 0.25);
color: white; color: white;
} }
.nav-item ::deep a:hover { .nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1); background-color: rgba(255, 255, 255, 0.1);
color: white; color: white;
} }
@media (min-width: 641px) { @media (min-width: 641px) {
.navbar-toggler { .navbar-toggler {
display: none; display: none;
} }
.collapse { .collapse {
/* Never collapse the sidebar for wide screens */ /* Never collapse the sidebar for wide screens */
display: block; display: block;
} }
.nav-scrollable { .nav-scrollable {
/* Allow sidebar to scroll for tall menus */ /* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem); height: calc(100vh - 3.5rem);
overflow-y: auto; overflow-y: auto;
} }
} }

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,7 +130,17 @@ a,
color: gray; color: gray;
} }
.background-img{ .profile-location-info {
margin-top: 0.3rem;
color: gray;
font-size: 1rem;
}
.bkg-img {
position: relative;
}
.background-img {
min-width: 100%; min-width: 100%;
max-height: 300px; max-height: 300px;
object-fit: cover; object-fit: cover;
@ -136,6 +151,6 @@ a,
max-height: 450px; max-height: 450px;
} }
.aboutme{ .aboutme {
flex-wrap: wrap; flex-wrap: wrap;
} }

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();
} }