fix: el checkbox no guardaba estado
This commit is contained in:
@@ -4,39 +4,52 @@
|
|||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import FChart from "../Componentes/Estadisticas/fChart.svelte";
|
import FChart from "../Componentes/Estadisticas/fChart.svelte";
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import {urlG} from "../stores/urlStore";
|
import { urlG } from "../stores/urlStore";
|
||||||
import type { ChartData } from "../types";
|
import type { ChartData } from "../types";
|
||||||
|
|
||||||
let token = sessionStorage.getItem("token")||"";
|
let token = sessionStorage.getItem("token") || "";
|
||||||
let y = $state(2025);
|
let y = $state(2025);
|
||||||
|
|
||||||
let cdata:ChartData|any = $state();
|
let cdata: ChartData | any = $state();
|
||||||
let aldata:{id:number, ubicacion:string, divisa:string}[]= $state([]);
|
let aldata: { id: number; ubicacion: string; divisa: string }[] = $state(
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
let chartMesesDuracion:ChartData|any = $state();
|
let chartMesesDuracion: ChartData | any = $state();
|
||||||
let tablaMesesDuracion:{meses:number, repes:number, semaforizacion:string}[] = $state([]);
|
let tablaMesesDuracion: {
|
||||||
|
meses: number;
|
||||||
|
repes: number;
|
||||||
|
semaforizacion: string;
|
||||||
|
}[] = $state([]);
|
||||||
|
|
||||||
let modaldata:string = $state("");
|
let showModoDaltonico: boolean = $state(false);
|
||||||
|
let modaldata: string = $state("");
|
||||||
|
|
||||||
onMount(async() => {
|
onMount(async () => {
|
||||||
await dataAlquileresporAño();
|
await dataAlquileresporAño();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function dataAlquileresporAño(year = 2025) {
|
async function dataAlquileresporAño(year = 2025) {
|
||||||
try{
|
try {
|
||||||
const rep = fetch($urlG+"/api/stats/alquileresIniciados?year="+year, {
|
const rep = fetch(
|
||||||
method : "GET",
|
$urlG + "/api/stats/alquileresIniciados?year=" + year,
|
||||||
headers: {
|
{
|
||||||
"Auth": token,
|
method: "GET",
|
||||||
}
|
headers: {
|
||||||
});
|
Auth: token,
|
||||||
const pre = fetch($urlG+"/api/tabla/alquileresIniciados?year="+year, {
|
},
|
||||||
method : "GET",
|
},
|
||||||
headers: {
|
);
|
||||||
"Auth": token,
|
const pre = fetch(
|
||||||
}
|
$urlG + "/api/tabla/alquileresIniciados?year=" + year,
|
||||||
});
|
{
|
||||||
let [r,p] = await Promise.all([rep, pre]);
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Auth: token,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let [r, p] = await Promise.all([rep, pre]);
|
||||||
|
|
||||||
let data = await r.json();
|
let data = await r.json();
|
||||||
let data2 = await p.json();
|
let data2 = await p.json();
|
||||||
@@ -44,76 +57,93 @@
|
|||||||
cdata = data;
|
cdata = data;
|
||||||
aldata = data2;
|
aldata = data2;
|
||||||
return;
|
return;
|
||||||
}catch{
|
} catch {
|
||||||
modaldata="Fallo al intentar alcanzar el servidor";
|
modaldata = "Fallo al intentar alcanzar el servidor";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let visibleMesesDuracion:boolean = $state(false);
|
let visibleMesesDuracion: boolean = $state(false);
|
||||||
async function dataMesesDuracion() {
|
async function dataMesesDuracion() {
|
||||||
try{
|
try {
|
||||||
const p1 = fetch($urlG+"/api/stats/duracionContrato", {
|
const p1 = fetch($urlG + "/api/stats/duracionContrato", {
|
||||||
method : "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Auth": token,
|
Auth: token,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const p2 = fetch($urlG+"/api/tabla/duracionContrato", {
|
const p2 = fetch($urlG + "/api/tabla/duracionContrato", {
|
||||||
method : "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Auth": token,
|
Auth: token,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
let [r1, r2] = await Promise.all([p1,p2]);
|
let [r1, r2] = await Promise.all([p1, p2]);
|
||||||
let [d1,d2] = await Promise.all([r1.json(), r2.json()])
|
let [d1, d2] = await Promise.all([r1.json(), r2.json()]);
|
||||||
chartMesesDuracion = d1;
|
chartMesesDuracion = d1;
|
||||||
tablaMesesDuracion = d2;
|
tablaMesesDuracion = d2;
|
||||||
}catch {
|
} catch {
|
||||||
modaldata="Fallo al intentar alcanzar el servidor";
|
modaldata = "Fallo al intentar alcanzar el servidor";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleModoDaltonico() {
|
function toggleModoDaltonico() {
|
||||||
if (tablaMesesDuracion== null) return;
|
if (tablaMesesDuracion == null) return;
|
||||||
|
|
||||||
tablaMesesDuracion.forEach(item => {
|
tablaMesesDuracion.forEach((item) => {
|
||||||
if (item.semaforizacion === '🟢') {
|
if (item.semaforizacion === "🟢") {
|
||||||
item.semaforizacion = '🔵';
|
item.semaforizacion = "🔵";
|
||||||
} else if (item.semaforizacion === '🔵') {
|
} else if (item.semaforizacion === "🔵") {
|
||||||
item.semaforizacion = '🟢';
|
item.semaforizacion = "🟢";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if modaldata}
|
{#if modaldata}
|
||||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")} />
|
<ModalEstatico payload={modaldata} close={() => !!(modaldata = "")} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable />
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row mt-4" >
|
<div class="row mt-4">
|
||||||
<BarraHorizontalConTexto text="Estadisticas"/>
|
<BarraHorizontalConTexto text="Estadisticas" />
|
||||||
<div class="accordion" id="accordionExample">
|
<div class="accordion" id="accordionExample">
|
||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<h2 class="accordion-header" id="hea1">
|
<h2 class="accordion-header" id="hea1">
|
||||||
<button class="accordion-button"
|
<button
|
||||||
type="button"
|
class="accordion-button"
|
||||||
data-bs-toggle="collapse"
|
type="button"
|
||||||
data-bs-target="#c1"
|
data-bs-toggle="collapse"
|
||||||
aria-expanded="true"
|
data-bs-target="#c1"
|
||||||
aria-controls="c1">
|
aria-expanded="true"
|
||||||
|
aria-controls="c1"
|
||||||
|
>
|
||||||
Alquileres en el ultimo año
|
Alquileres en el ultimo año
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="accordion-collapse collapse show" id="c1" data-bs-parent="#accordionExample">
|
<div
|
||||||
|
class="accordion-collapse collapse show"
|
||||||
|
id="c1"
|
||||||
|
data-bs-parent="#accordionExample"
|
||||||
|
>
|
||||||
<div class="accordion-body row">
|
<div class="accordion-body row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="d-flex input-group">
|
<div class="d-flex input-group">
|
||||||
<input class="form-control" type="number" bind:value={y}>
|
<input
|
||||||
<button class="btn btn-primary" onclick={()=>dataAlquileresporAño(y)}><img src="/zoom.svg" alt="lupa" aria-label="Lupa">Buscar</button>
|
class="form-control"
|
||||||
|
type="number"
|
||||||
|
bind:value={y}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
onclick={() => dataAlquileresporAño(y)}
|
||||||
|
><img
|
||||||
|
src="/zoom.svg"
|
||||||
|
alt="lupa"
|
||||||
|
aria-label="Lupa"
|
||||||
|
/>Buscar</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -125,18 +155,18 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each aldata as al}
|
{#each aldata as al}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{al.id}</td>
|
<td>{al.id}</td>
|
||||||
<td>{al.ubicacion}</td>
|
<td>{al.ubicacion}</td>
|
||||||
<td>{al.divisa}</td>
|
<td>{al.divisa}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{#if cdata}
|
{#if cdata}
|
||||||
<FChart chartData={cdata}/>
|
<FChart chartData={cdata} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -144,30 +174,51 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<h2 class="accordion-header" id="hea2">
|
<h2 class="accordion-header" id="hea2">
|
||||||
<button class="accordion-button collapsed"
|
<button
|
||||||
type="button"
|
class="accordion-button collapsed"
|
||||||
data-bs-toggle="collapse"
|
type="button"
|
||||||
data-bs-target="#c2"
|
data-bs-toggle="collapse"
|
||||||
aria-expanded="false"
|
data-bs-target="#c2"
|
||||||
aria-controls="c2"
|
aria-expanded="false"
|
||||||
onclick={()=>{
|
aria-controls="c2"
|
||||||
if(visibleMesesDuracion === true){
|
onclick={() => {
|
||||||
visibleMesesDuracion=false;
|
if (visibleMesesDuracion === true) {
|
||||||
return;
|
visibleMesesDuracion = false;
|
||||||
} else if (visibleMesesDuracion== false){
|
return;
|
||||||
dataMesesDuracion();
|
} else if (visibleMesesDuracion === false) {
|
||||||
|
visibleMesesDuracion = true;
|
||||||
}
|
showModoDaltonico = false;
|
||||||
}}
|
dataMesesDuracion();
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Meses De Duracion
|
Meses De Duracion
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="accordion-collapse collapse" id="c2" data-bs-parent="#accordionExample">
|
<div
|
||||||
|
class="accordion-collapse collapse"
|
||||||
|
id="c2"
|
||||||
|
data-bs-parent="#accordionExample"
|
||||||
|
>
|
||||||
<div class="accordion-body row">
|
<div class="accordion-body row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p class="text-muted">Objetivo: <i>Mide la longitud de los contratos en meses y cuantos hay por cada longitud. por lo menos 2.</i></p>
|
<p class="text-muted">
|
||||||
<input class="form-check-input" type="checkbox" onclick={toggleModoDaltonico}> Activar Modo Daltónico
|
Objetivo: <i
|
||||||
|
>Mide la longitud de los contratos en meses
|
||||||
|
y cuantos hay por cada longitud. por lo
|
||||||
|
menos 2.</i
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
onclick={() => {
|
||||||
|
showModoDaltonico = !showModoDaltonico;
|
||||||
|
toggleModoDaltonico();
|
||||||
|
}}
|
||||||
|
checked={showModoDaltonico}
|
||||||
|
/>
|
||||||
|
Activar Modo Daltónico
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -189,7 +240,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{#if chartMesesDuracion}
|
{#if chartMesesDuracion}
|
||||||
<FChart chartData={chartMesesDuracion} typec="pie"/>
|
<FChart
|
||||||
|
chartData={chartMesesDuracion}
|
||||||
|
typec="pie"
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user