149 lines
5.1 KiB
Plaintext
149 lines
5.1 KiB
Plaintext
@inherits LayoutComponentBase
|
|
@implements IDisposable
|
|
@inject GestionaDenunciasAN.Models.UserState userState
|
|
@inject IHttpContextAccessor HttpContextAccessor
|
|
@inject IJSRuntime JSRuntime
|
|
@inject NavigationManager Navigation
|
|
|
|
<div class="app-shell">
|
|
<aside class="app-sidebar">
|
|
<NavMenu />
|
|
</aside>
|
|
|
|
<main class="app-main">
|
|
<header class="app-header">
|
|
<div class="app-header__intro">
|
|
<span class="app-header__eyebrow">Portal interno</span>
|
|
<h1 class="app-header__title">@CurrentPageTitle</h1>
|
|
<p class="app-header__copy mb-0">@CurrentPageDescription</p>
|
|
</div>
|
|
|
|
<div class="app-header__actions">
|
|
<div class="app-session-pill">
|
|
<span class="app-session-pill__dot"></span>
|
|
Sesion interna activa
|
|
</div>
|
|
|
|
<button type="button" class="app-user-chip" @onclick="CerrarSesionAsync">
|
|
<span class="bi bi-person-circle app-user-chip__icon" aria-hidden="true"></span>
|
|
<span class="app-user-chip__text">
|
|
<strong>@DisplayUsername</strong>
|
|
<small>Cerrar sesion</small>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
<article class="app-content">
|
|
@Body
|
|
</article>
|
|
</main>
|
|
</div>
|
|
|
|
<div id="blazor-error-ui">
|
|
An unhandled error has occurred.
|
|
<a href="" class="reload">Reload</a>
|
|
<a class="dismiss">x</a>
|
|
</div>
|
|
|
|
@code {
|
|
private string CurrentPageTitle { get; set; } = "Portal de gestion";
|
|
private string CurrentPageDescription { get; set; } =
|
|
"Entrada, revision y tramitacion coordinada de denuncias y actualizaciones.";
|
|
|
|
private string DisplayUsername =>
|
|
string.IsNullOrWhiteSpace(userState?.NombreUsu)
|
|
? "Usuario"
|
|
: userState.NombreUsu;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Navigation.LocationChanged += HandleLocationChanged;
|
|
RefreshLayoutState();
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
RefreshLayoutState();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Navigation.LocationChanged -= HandleLocationChanged;
|
|
}
|
|
|
|
private void HandleLocationChanged(object? sender, LocationChangedEventArgs args)
|
|
{
|
|
RefreshLayoutState();
|
|
_ = InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private void RefreshLayoutState()
|
|
{
|
|
SincronizarUsuario();
|
|
var pageInfo = ResolvePageInfo();
|
|
CurrentPageTitle = pageInfo.Title;
|
|
CurrentPageDescription = pageInfo.Description;
|
|
}
|
|
|
|
private (string Title, string Description) ResolvePageInfo()
|
|
{
|
|
var relative = Navigation.ToBaseRelativePath(Navigation.Uri);
|
|
var path = string.IsNullOrWhiteSpace(relative)
|
|
? string.Empty
|
|
: relative.Split('?', '#')[0].Trim('/');
|
|
|
|
return path.ToLowerInvariant() switch
|
|
{
|
|
"" or "gestionzip" => (
|
|
"Entrada de denuncias",
|
|
"Importa lo nuevo desde GlobalLeaks, revisa el seguimiento por usuario y decide si habra expediente nuevo o actualizacion."),
|
|
"pendientes" => (
|
|
"Denuncias pendientes",
|
|
"Prepara expedientes nuevos con todos los datos del formulario, documentos y tercero ya resueltos."),
|
|
"actualizaciones" => (
|
|
"Actualizaciones",
|
|
"Gestiona ampliaciones sobre expedientes existentes y sube solo los adjuntos realmente nuevos."),
|
|
"gestiona" => (
|
|
"Expedientes en Gestiona",
|
|
"Consulta el estado de los expedientes ya enviados y continua su seguimiento operativo."),
|
|
"rechazados" => (
|
|
"Denuncias rechazadas",
|
|
"Mantiene trazabilidad de los descartes y de los motivos aplicados en la revision."),
|
|
"buscador" => (
|
|
"Buscador de terceros",
|
|
"Localiza terceros y expedientes relacionados para validar identidades antes de tramitar."),
|
|
"instrucciones" => (
|
|
"Instrucciones",
|
|
"Referencia rapida de uso para el equipo gestor y para las operaciones mas frecuentes."),
|
|
_ => (
|
|
"Portal de gestion",
|
|
"Entrada, revision y tramitacion coordinada de denuncias y actualizaciones.")
|
|
};
|
|
}
|
|
|
|
private void SincronizarUsuario()
|
|
{
|
|
var user = HttpContextAccessor.HttpContext?.User;
|
|
if (user is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var isAuthenticated = user.Identity?.IsAuthenticated == true;
|
|
|
|
userState.Token = isAuthenticated ? "authenticated" : string.Empty;
|
|
userState.NombreUsu = isAuthenticated
|
|
? (user.Identity?.Name ?? string.Empty)
|
|
: string.Empty;
|
|
}
|
|
|
|
private async Task CerrarSesionAsync()
|
|
{
|
|
await JSRuntime.InvokeAsync<object>("appAuthPost", "/api/auth/logout");
|
|
userState.Token = string.Empty;
|
|
userState.NombreUsu = string.Empty;
|
|
Navigation.NavigateTo("/", true);
|
|
}
|
|
}
|