linting changes
Some checks failed
Run Tests on Code / test (push) Has been cancelled

This commit is contained in:
Neshura 2024-01-03 20:40:52 +01:00
parent 63197220a6
commit cedf89e106
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
2 changed files with 58 additions and 21 deletions

View file

@ -6,9 +6,13 @@
import { slide } from 'svelte/transition'; import { slide } from 'svelte/transition';
import { IconType, type Service } from '$lib/types/data-types'; import { IconType, type Service } from '$lib/types/data-types';
import { Skeleton } from '$lib/components/ui/skeleton'; import { Skeleton } from '$lib/components/ui/skeleton';
import type {Heartbeat} from "$lib/types/uptime-kuma-types"; import type { Heartbeat } from '$lib/types/uptime-kuma-types';
let { service, icons, monitor } = $props<{ service: Service; icons: Array<string>, monitor: Heartbeat }>(); let { service, icons, monitor } = $props<{
service: Service;
icons: Array<string>;
monitor: Heartbeat;
}>();
let status = $state(4); let status = $state(4);
@ -32,9 +36,9 @@
} }
$effect(() => { $effect(() => {
if (typeof monitor !== "undefined") { if (typeof monitor !== 'undefined') {
if (monitor.monitorID == 9) { if (monitor.monitorID == 9) {
console.log("Vaultwarden: ", monitor.status) console.log('Vaultwarden: ', monitor.status);
} }
status = monitor.status; status = monitor.status;
} }
@ -57,7 +61,15 @@
<div <div
class="flex h-48 w-[28rem] flex-col gap-y-2 rounded-xl border-t-4 class="flex h-48 w-[28rem] flex-col gap-y-2 rounded-xl border-t-4
{status == 0 ? 'border-offline' : status == 1 ? 'border-online' : status == 2 ? 'border-pending' : status == 3 ? 'border-maintenance' : 'border-maintenance'} {status == 0
? 'border-offline'
: status == 1
? 'border-online'
: status == 2
? 'border-pending'
: status == 3
? 'border-maintenance'
: 'border-maintenance'}
bg-black/55 p-4" bg-black/55 p-4"
> >
<div class="flex flex-row justify-between pb-4"> <div class="flex flex-row justify-between pb-4">
@ -96,11 +108,37 @@
{/if} {/if}
</div> </div>
<h1 class="w-16 rounded-md border-b-2 <h1
{status == 0 ? 'border-offline' : status == 1 ? 'border-online' : status == 2 ? 'border-pending' : status == 3 ? 'border-maintenance' : 'border-maintenance'} class="w-16 rounded-md border-b-2
{status == 0
? 'border-offline'
: status == 1
? 'border-online'
: status == 2
? 'border-pending'
: status == 3
? 'border-maintenance'
: 'border-maintenance'}
text-center text-sm text-center text-sm
{status == 0 ? 'text-offline' : status == 1 ? 'text-online' : status == 2 ? 'text-pending' : status == 3 ? 'text-maintenance' : 'text-maintenance'}"> {status == 0
{status == 0 ? 'Offline' : status == 1 ? 'Online' : status == 2 ? 'Pending' : status == 3 ? 'Maint.' : 'Loading'} ? 'text-offline'
: status == 1
? 'text-online'
: status == 2
? 'text-pending'
: status == 3
? 'text-maintenance'
: 'text-maintenance'}"
>
{status == 0
? 'Offline'
: status == 1
? 'Online'
: status == 2
? 'Pending'
: status == 3
? 'Maint.'
: 'Loading'}
</h1> </h1>
</div> </div>
<p class="text-wrap text-center text-sm text-accent">{service.desc}</p> <p class="text-wrap text-center text-sm text-accent">{service.desc}</p>

View file

@ -3,14 +3,14 @@
<script lang="ts"> <script lang="ts">
import ServiceCard from '$lib/components/ServiceCard.svelte'; import ServiceCard from '$lib/components/ServiceCard.svelte';
import type { Service } from '$lib/types/data-types'; import type { Service } from '$lib/types/data-types';
import {io} from "socket.io-client"; import { io } from 'socket.io-client';
import type {Heartbeat} from "$lib/types/uptime-kuma-types"; import type { Heartbeat } from '$lib/types/uptime-kuma-types';
let { data }: { data: { token: string } } = $props(); let { data }: { data: { token: string } } = $props();
$effect(() => { $effect(() => {
console.log("Data:", data.token) console.log('Data:', data.token);
}) });
let services: readonly Service[] = $state.frozen([]); let services: readonly Service[] = $state.frozen([]);
@ -25,10 +25,10 @@
const socket = io('https://status.neshweb.net/'); const socket = io('https://status.neshweb.net/');
socket.on('connect', () => { socket.on('connect', () => {
socket.emit("loginByToken", data.token, (res) => { socket.emit('loginByToken', data.token, (res) => {
console.log(data.token) console.log(data.token);
console.log(res); console.log(res);
}) });
}); });
socket.on('heartbeatList', (idString: string, data) => { socket.on('heartbeatList', (idString: string, data) => {
@ -41,18 +41,17 @@
ping: recent.ping, ping: recent.ping,
important: recent.important, important: recent.important,
duration: recent.duration duration: recent.duration
} };
monitorList.set(monitor.monitorID, monitor); monitorList.set(monitor.monitorID, monitor);
monitorList = new Map(monitorList.entries()); monitorList = new Map(monitorList.entries());
}) });
socket.on('heartbeat', (data) => { socket.on('heartbeat', (data) => {
monitorList.set(data.monitorID, data); monitorList.set(data.monitorID, data);
monitorList = new Map(monitorList.entries()); monitorList = new Map(monitorList.entries());
}) });
} }
}) });
async function get(url: string): Promise<any> { async function get(url: string): Promise<any> {
let res = await fetch(url); let res = await fetch(url);