avansando más
This commit is contained in:
@@ -1,6 +1,103 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import type { GrupoDto } from "../types";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
const token: string = sessionStorage.getItem("token") || "";
|
||||
|
||||
let grupos: GrupoDto[] = $state([]);
|
||||
let modaldat: string = $state("");
|
||||
onMount(() => {
|
||||
ObtenerGrupos();
|
||||
});
|
||||
async function ObtenerGrupos() {
|
||||
try {
|
||||
const ret = await fetch($urlG + "/api/admin/grupos", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Auth: token,
|
||||
},
|
||||
});
|
||||
if (!ret.ok) {
|
||||
modaldat = "Fallo Al intentar hacer la request";
|
||||
return;
|
||||
}
|
||||
grupos = await ret.json();
|
||||
} catch {
|
||||
modaldat = "Fallo Al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable />
|
||||
<div class="container-fluid"></div>
|
||||
<div class="container-fluid">
|
||||
{#if grupos.length == 0}
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
{#each grupos as grupo}
|
||||
<div class="accordion mt-2">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target={`#${grupo.idgrupo}`}
|
||||
aria-expanded="false"
|
||||
aria-controls={grupo.idgrupo}
|
||||
>
|
||||
{grupo.nombre}
|
||||
</button>
|
||||
</h2>
|
||||
<div id={grupo.idgrupo} class="accordion-collapse collapse">
|
||||
<div class="accordion-body">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h5>Grupos Incluidos</h5>
|
||||
<ul class="list-group">
|
||||
{#if grupo.gruposIncluidos.length == 0}
|
||||
<li class="list-group-item">
|
||||
No hay grupos incluidos
|
||||
</li>
|
||||
{:else}
|
||||
{#each grupo.gruposIncluidos as grupoIncluido}
|
||||
<li class="list-group-item">
|
||||
{grupoIncluido}
|
||||
</li>
|
||||
{/each}
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h5>Permisos</h5>
|
||||
<ul class="list-group">
|
||||
{#if grupo.permisos.length == 0}
|
||||
<li class="list-group-item">
|
||||
No hay grupos incluidos
|
||||
</li>
|
||||
{:else}
|
||||
{#each grupo.permisos as permiso}
|
||||
<li class="list-group-item">
|
||||
{permiso.descripcion}
|
||||
</li>
|
||||
{/each}
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-primary">Editar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -9,25 +9,25 @@
|
||||
import PaginacionStepper from "../Componentes/PaginacionStepper.svelte";
|
||||
|
||||
let Logs: LogDto[] = $state([]);
|
||||
let pagina:number = $state(1);
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
let modaldata:string = $state("");
|
||||
let showmodal:boolean =$state(false);
|
||||
let ll:LogDto|any = $state({});
|
||||
let cantpag:number = $state(0);
|
||||
let pagina: number = $state(1);
|
||||
let token: string = sessionStorage.getItem("token") || "";
|
||||
let modaldata: string = $state("");
|
||||
let showmodal: boolean = $state(false);
|
||||
let ll: LogDto | any = $state({});
|
||||
let cantpag: number = $state(0);
|
||||
|
||||
onMount(()=>{
|
||||
onMount(() => {
|
||||
obtenerLogs();
|
||||
obtenerPaginas();
|
||||
});
|
||||
|
||||
async function obtenerPaginas() {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/Logs/cantPag", {
|
||||
try {
|
||||
const r = await fetch($urlG + "/api/Logs/cantPag", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
Auth: token,
|
||||
},
|
||||
});
|
||||
let data = await r.json();
|
||||
if (r.ok) {
|
||||
@@ -41,12 +41,12 @@
|
||||
}
|
||||
|
||||
async function obtenerLogs() {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/Logs?pag="+pagina, {
|
||||
try {
|
||||
const r = await fetch($urlG + "/api/Logs?pag=" + pagina, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
Auth: token,
|
||||
},
|
||||
});
|
||||
let data = await r.json();
|
||||
if (r.ok) {
|
||||
@@ -63,49 +63,65 @@
|
||||
ll = l;
|
||||
showmodal = true;
|
||||
}
|
||||
function queryPag(a:number) {
|
||||
function queryPag(a: number) {
|
||||
pagina = a;
|
||||
obtenerLogs();
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<NavBarAutocompletable />
|
||||
|
||||
{#if modaldata}
|
||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||
<ModalEstatico payload={modaldata} close={() => !!(modaldata = "")} />
|
||||
{/if}
|
||||
|
||||
{#if showmodal}
|
||||
<ModalLogs onClose={()=>!!(showmodal=!showmodal)} log={ll}/>
|
||||
<ModalLogs onClose={() => !!(showmodal = !showmodal)} log={ll} />
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid mt-2">
|
||||
<BarraHorizontalConTexto text={"Logs"}/>
|
||||
<table class="table table-responsive table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha</th>
|
||||
<th>Id Usuario</th>
|
||||
<th>Accion</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each Logs as l}
|
||||
<tr>
|
||||
<td>{l.fecha}</td>
|
||||
<td>{l.dniusuario}</td>
|
||||
<td>{l.accion}</td>
|
||||
<td>
|
||||
<button class="btn btn-primary" onclick={()=>prepararModal(l)}>
|
||||
Ver
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="d-flex justify-content-center">
|
||||
<PaginacionStepper currentPag={pagina} {cantpag} {queryPag} centrado={true}/>
|
||||
<BarraHorizontalConTexto text={"Logs"} />
|
||||
<div
|
||||
class="table-container"
|
||||
style="height: 80vh; overflow-y: auto; margin-bottom: 2.5rem;"
|
||||
>
|
||||
<table class="table table-responsive table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha</th>
|
||||
<th>Id Usuario</th>
|
||||
<th>Accion</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each Logs as l}
|
||||
<tr>
|
||||
<td>{l.fecha}</td>
|
||||
<td>{l.dniusuario}</td>
|
||||
<td>{l.accion}</td>
|
||||
<td>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
onclick={() => prepararModal(l)}
|
||||
>
|
||||
Ver
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
<div
|
||||
class="fixed-bottom w-100 d-flex justify-content-center border-top py-2"
|
||||
style="background-color: rgba(0,0,0,0.5);"
|
||||
>
|
||||
<PaginacionStepper
|
||||
currentPag={pagina}
|
||||
{cantpag}
|
||||
{queryPag}
|
||||
centrado={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user