mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-27 07:34:12 +08:00
feat: show vertical stats on small screen devices
This commit is contained in:
parent
4a39f163fe
commit
841161a0da
@ -10,7 +10,7 @@ import byteSize from 'byte-size'
|
|||||||
import { isIPv6 } from 'is-ip'
|
import { isIPv6 } from 'is-ip'
|
||||||
import { For, createSignal } from 'solid-js'
|
import { For, createSignal } from 'solid-js'
|
||||||
import { secret, wsEndpointURL } from '~/signals'
|
import { secret, wsEndpointURL } from '~/signals'
|
||||||
import type { Connection } from '../types'
|
import type { Connection } from '~/types'
|
||||||
|
|
||||||
export const Connections = () => {
|
export const Connections = () => {
|
||||||
const [search, setSearch] = createSignal('')
|
const [search, setSearch] = createSignal('')
|
||||||
|
@ -3,7 +3,14 @@ import { createReconnectingWS } from '@solid-primitives/websocket'
|
|||||||
import { ApexOptions } from 'apexcharts'
|
import { ApexOptions } from 'apexcharts'
|
||||||
import byteSize from 'byte-size'
|
import byteSize from 'byte-size'
|
||||||
import { SolidApexCharts } from 'solid-apexcharts'
|
import { SolidApexCharts } from 'solid-apexcharts'
|
||||||
import { createEffect, createMemo, createSignal } from 'solid-js'
|
import {
|
||||||
|
JSX,
|
||||||
|
ParentComponent,
|
||||||
|
children,
|
||||||
|
createEffect,
|
||||||
|
createMemo,
|
||||||
|
createSignal,
|
||||||
|
} from 'solid-js'
|
||||||
import { secret, wsEndpointURL } from '~/signals'
|
import { secret, wsEndpointURL } from '~/signals'
|
||||||
import type { Connection } from '~/types'
|
import type { Connection } from '~/types'
|
||||||
|
|
||||||
@ -34,6 +41,15 @@ const defaultChartOptions: ApexOptions = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-title text-secondary-content">{props.label}</div>
|
||||||
|
<div class="stat-value text-primary-content">
|
||||||
|
{children(() => props.children)()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
export const Overview = () => {
|
export const Overview = () => {
|
||||||
const [traffics, setTraffics] = createSignal<{ down: number; up: number }[]>(
|
const [traffics, setTraffics] = createSignal<{ down: number; up: number }[]>(
|
||||||
[],
|
[],
|
||||||
@ -134,45 +150,30 @@ export const Overview = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="stats w-full bg-primary shadow">
|
<div class="stats stats-vertical w-full bg-primary shadow sm:stats-horizontal">
|
||||||
<div class="stat">
|
<TrafficWidget label="Upload">
|
||||||
<div class="stat-title text-secondary-content">Upload</div>
|
{byteSize(traffic()?.up || 0).toString()}/s
|
||||||
<div class="stat-value text-primary-content">
|
</TrafficWidget>
|
||||||
{byteSize(traffic()?.up || 0).toString()}/s
|
|
||||||
</div>
|
<TrafficWidget label="Download">
|
||||||
</div>
|
{byteSize(traffic()?.down || 0).toString()}/s
|
||||||
<div class="stat">
|
</TrafficWidget>
|
||||||
<div class="stat-title text-secondary-content">Download</div>
|
|
||||||
<div class="stat-value text-primary-content">
|
<TrafficWidget label="Upload Total">
|
||||||
{byteSize(traffic()?.down || 0).toString()}/s
|
{byteSize(connection()?.uploadTotal || 0).toString()}
|
||||||
</div>
|
</TrafficWidget>
|
||||||
</div>
|
|
||||||
<div class="stat">
|
<TrafficWidget label="Download Total">
|
||||||
<div class="stat-title text-secondary-content">Upload Total</div>
|
{byteSize(connection()?.downloadTotal || 0).toString()}
|
||||||
<div class="stat-value text-primary-content">
|
</TrafficWidget>
|
||||||
{byteSize(connection()?.uploadTotal || 0).toString()}
|
|
||||||
</div>
|
<TrafficWidget label="Active Connections">
|
||||||
</div>
|
{connection()?.connections.length || 0}
|
||||||
<div class="stat">
|
</TrafficWidget>
|
||||||
<div class="stat-title text-secondary-content">Download Total</div>
|
|
||||||
<div class="stat-value text-primary-content">
|
<TrafficWidget label="Memory Usage">
|
||||||
{byteSize(connection()?.downloadTotal || 0).toString()}
|
{byteSize(memory() || 0).toString()}
|
||||||
</div>
|
</TrafficWidget>
|
||||||
</div>
|
|
||||||
<div class="stat">
|
|
||||||
<div class="stat-title text-secondary-content">
|
|
||||||
Active Connections
|
|
||||||
</div>
|
|
||||||
<div class="stat-value text-primary-content">
|
|
||||||
{connection()?.connections.length || 0}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat">
|
|
||||||
<div class="stat-title text-secondary-content">Memory Usage</div>
|
|
||||||
<div class="stat-value text-primary-content">
|
|
||||||
{byteSize(memory() || 0).toString()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-auto grid w-full max-w-screen-lg grid-cols-1 gap-4">
|
<div class="mx-auto grid w-full max-w-screen-lg grid-cols-1 gap-4">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { For, createSignal, onMount } from 'solid-js'
|
import { For, createSignal, onMount } from 'solid-js'
|
||||||
import { useRequest } from '~/signals'
|
import { useRequest } from '~/signals'
|
||||||
import { Proxy, ProxyProvider } from '~/types'
|
import type { Proxy, ProxyProvider } from '~/types'
|
||||||
|
|
||||||
export const Proxies = () => {
|
export const Proxies = () => {
|
||||||
const request = useRequest()
|
const request = useRequest()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user