Private
Public Access
añadidas imagenes a los grupos y pérmisos
This commit is contained in:
1 parent
00f140480d
commit
cec07f51f9
4 files changed
+191
-64
No files matched your search
@@ -4,7 +4,17 @@
|
||||
import { ObtenerGruposDeUsuario } from '$lib/hooks/ObtenerGruposDeUsuario';
|
||||
import CardError from '$lib/components/CardError.svelte';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import { Accordion, ContainedList, ContainedListItem } from 'carbon-components-svelte';
|
||||
import IconPreview from '$lib/components/IconPreview.svelte';
|
||||
import {
|
||||
ClickableTile,
|
||||
Column,
|
||||
Grid,
|
||||
Row,
|
||||
SkeletonPlaceholder,
|
||||
SkeletonText,
|
||||
Text,
|
||||
Tile
|
||||
} from 'carbon-components-svelte';
|
||||
import { BpmnLinkOutline } from 'carbon-icons-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
@@ -15,37 +25,110 @@
|
||||
});
|
||||
|
||||
let grupos = usuario ? ObtenerGruposDeUsuario(usuario) : undefined;
|
||||
|
||||
function hrefPermiso(alias: string): string {
|
||||
return alias.startsWith('/') ? alias : `/${alias}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Header {usuario} {grupos} />
|
||||
|
||||
<main>
|
||||
<section class="dashboard-section">
|
||||
<div class="dashboard-header">
|
||||
<h2 class="section-title">Tu panel de control</h2>
|
||||
<p class="section-subtitle">Accede a los módulos de tu cuenta</p>
|
||||
<section class="mx-auto! max-w-[1000px] px-4! py-20!">
|
||||
<div class="mb-8">
|
||||
<Text tag="h2" type="productive-heading-05" weight="semibold" class="mb-3! text-center">
|
||||
Tu panel de control
|
||||
</Text>
|
||||
<Text
|
||||
tag="p"
|
||||
type="body-long-01"
|
||||
color="secondary"
|
||||
class="mx-auto! mb-12! max-w-[520px] text-center"
|
||||
>
|
||||
Accede a los módulos de tu cuenta
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{#await grupos}
|
||||
<Accordion skeleton />
|
||||
<Grid fullWidth>
|
||||
<Row>
|
||||
{#each Array(8) as _, i (i)}
|
||||
<Column sm={4} md={4} lg={4}>
|
||||
<Tile
|
||||
class="pointer-events-none flex! aspect-square min-h-[9rem]! animate-pulse cursor-default flex-col items-center justify-center gap-3"
|
||||
>
|
||||
<SkeletonPlaceholder size={32} />
|
||||
<SkeletonText lines={2} width="80%" />
|
||||
</Tile>
|
||||
</Column>
|
||||
{/each}
|
||||
</Row>
|
||||
</Grid>
|
||||
{:then gg}
|
||||
{#if gg == undefined}
|
||||
<p class="py-8 text-center text-neutral-500">No tienes grupos asignados</p>
|
||||
{#if !gg || gg.groups.length === 0}
|
||||
<Text tag="p" type="body-long-01" color="secondary" class="py-8! text-center">
|
||||
No tienes grupos asignados
|
||||
</Text>
|
||||
{:else}
|
||||
{#each gg.groups as g}
|
||||
<p class="text-2xl!">{g.nombre}</p>
|
||||
{#if g.permisos?.length == 0}
|
||||
<p class="text-neutral-500">No hay permisos en este grupo</p>
|
||||
{:else}
|
||||
<ContainedList>
|
||||
{#each g.permisos?.sort((a, b) => (a.alias > b.alias ? 0 : -1)) as p}
|
||||
<div class="w-full cursor-pointer hover:bg-white/5">
|
||||
<ContainedListItem icon={BpmnLinkOutline} on:click={() => goto(p.alias)}>
|
||||
<span>{p.nombre}</span>
|
||||
</ContainedListItem>
|
||||
</div>
|
||||
{/each}
|
||||
</ContainedList>
|
||||
{/if}
|
||||
{#each gg.groups as g (g.id)}
|
||||
<section class="mb-12! last:mb-0!">
|
||||
<div class="mb-2 flex items-center gap-3">
|
||||
<span
|
||||
class="inline-flex items-center justify-center text-[var(--cds-icon-primary,#f4f4f4)]"
|
||||
>
|
||||
{#if g.imagen}
|
||||
<IconPreview nombre={g.imagen} size={28} />
|
||||
{:else}
|
||||
<BpmnLinkOutline size={28} />
|
||||
{/if}
|
||||
</span>
|
||||
<Text tag="h3" type="productive-heading-03" weight="semibold">
|
||||
{g.nombre}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{#if g.descripcion}
|
||||
<Text tag="p" type="body-long-01" color="secondary" class="mb-4!">
|
||||
{g.descripcion}
|
||||
</Text>
|
||||
{/if}
|
||||
|
||||
{#if g.permisos && g.permisos.length > 0}
|
||||
<Grid fullWidth class="mt-4">
|
||||
<Row>
|
||||
{#each [...g.permisos].sort( (a, b) => a.nombre.localeCompare(b.nombre) ) as p (p.nombre)}
|
||||
<Column sm={4} md={4} lg={4}>
|
||||
<ClickableTile
|
||||
href={hrefPermiso(p.alias)}
|
||||
title={p.nombre}
|
||||
class="flex! aspect-square min-h-[9rem]! mb-2! flex-col items-center justify-center text-center whitespace-normal! no-underline! hover:-translate-y-0.5"
|
||||
>
|
||||
<span class="inline-flex items-center justify-center">
|
||||
{#if p.imagen}
|
||||
<IconPreview nombre={p.imagen} size={32} />
|
||||
{:else}
|
||||
<BpmnLinkOutline size={32} />
|
||||
{/if}
|
||||
</span>
|
||||
<Text
|
||||
tag="span"
|
||||
type="body-short-01"
|
||||
weight="semibold"
|
||||
class="line-clamp-2 max-w-full wrap-anywhere"
|
||||
>
|
||||
{p.nombre}
|
||||
</Text>
|
||||
</ClickableTile>
|
||||
</Column>
|
||||
{/each}
|
||||
</Row>
|
||||
</Grid>
|
||||
{:else}
|
||||
<Text tag="p" type="body-long-01" color="secondary" class="py-8! text-center">
|
||||
No hay permisos en este grupo
|
||||
</Text>
|
||||
{/if}
|
||||
</section>
|
||||
{/each}
|
||||
{/if}
|
||||
{:catch err}
|
||||
@@ -53,34 +136,3 @@
|
||||
{/await}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
.section-title {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
font-size: 1.05rem;
|
||||
color: var(--cds-text-secondary, #c6c6c6);
|
||||
text-align: center;
|
||||
max-width: 520px;
|
||||
margin: 0 auto 3rem;
|
||||
}
|
||||
|
||||
.dashboard-section {
|
||||
padding: 5rem 1rem;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.dashboard-header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.dashboard-section :global(.bx--accordion) {
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user