Skip to content

Commit

Permalink
Cascade from user org name to default org name to "Remotely".
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed May 19, 2021
1 parent 65f9deb commit 17d8717
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
29 changes: 18 additions & 11 deletions Server/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@using Remotely.Server.Services
@using Remotely.Server.Services
@using Remotely.Shared.Models
@inject IApplicationConfig AppConfig
@inject IApplicationConfig AppConfig
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
@inject IDataService DataService
@inject IDataService DataService

@{
var organizationName = "Remotely";
var user = DataService.GetUserByNameWithOrg(User?.Identity?.Name);

if (user is null)
{
var defaultOrg = await DataService.GetDefaultOrganization();
if (!string.IsNullOrWhiteSpace(defaultOrg?.OrganizationName))
{
organizationName = defaultOrg.OrganizationName;
}
}
else if (!string.IsNullOrWhiteSpace(user.Organization?.OrganizationName))
{
organizationName = user.Organization.OrganizationName;
}
}


Expand Down Expand Up @@ -63,14 +77,7 @@
<div class="container">
<a class="navbar-brand text-left" href="~/">
<div>
@if (!string.IsNullOrWhiteSpace(user?.Organization?.OrganizationName))
{
@user.Organization.OrganizationName
}
else
{
@Html.Raw("Remotely")
}
@organizationName
</div>
<div class="logo-subtitle">Support Portal</div>
</a>
Expand Down
15 changes: 13 additions & 2 deletions Server/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div class="pl-4 pb-1 pr-0 pt-0 navbar navbar-dark" style="background-color: rgba(0,0,0,0.3)">
<a class="navbar-brand text-left" href="">
<div class="logo-title">
@if (!string.IsNullOrWhiteSpace(_user?.Organization?.OrganizationName))
@if (!string.IsNullOrWhiteSpace(_organization?.OrganizationName))
{
@_user.Organization.OrganizationName
@_organization.OrganizationName
}
else
{
Expand Down Expand Up @@ -137,11 +137,22 @@
= new() { ["target"] = "blank", ["href"] = "/RemoteControl" };

private RemotelyUser _user;
private Organization _organization;

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();

_user = await AuthService.GetUser();

if (!string.IsNullOrWhiteSpace(_user?.OrganizationID))
{
_organization = DataService.GetOrganizationById(_user.OrganizationID);
}
else
{
_organization = await DataService.GetDefaultOrganization();
}
}

private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
Expand Down

0 comments on commit 17d8717

Please sign in to comment.