mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
Bandwidth alert max value increased to 1 Gigabit (closes #222)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { pb } from "@/lib/stores"
|
import { pb } from "@/lib/stores"
|
||||||
import { alertInfo, cn } from "@/lib/utils"
|
import { alertInfo, cn } from "@/lib/utils"
|
||||||
import { Switch } from "@/components/ui/switch"
|
import { Switch } from "@/components/ui/switch"
|
||||||
import { AlertRecord, SystemRecord } from "@/types"
|
import { AlertInfo, AlertRecord, SystemRecord } from "@/types"
|
||||||
import { lazy, Suspense, useRef, useState } from "react"
|
import { lazy, Suspense, useRef, useState } from "react"
|
||||||
import { toast } from "../ui/use-toast"
|
import { toast } from "../ui/use-toast"
|
||||||
import { RecordOptions } from "pocketbase"
|
import { RecordOptions } from "pocketbase"
|
||||||
@@ -14,7 +14,7 @@ interface AlertData {
|
|||||||
min?: number
|
min?: number
|
||||||
updateAlert?: (checked: boolean, value: number, min: number) => void
|
updateAlert?: (checked: boolean, value: number, min: number) => void
|
||||||
key: keyof typeof alertInfo
|
key: keyof typeof alertInfo
|
||||||
alert: (typeof alertInfo)[keyof typeof alertInfo]
|
alert: AlertInfo
|
||||||
system: SystemRecord
|
system: SystemRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ function AlertContent({ data }: { data: AlertData }) {
|
|||||||
onValueCommit={(val) => (newValue.current = val[0]) && updateAlert()}
|
onValueCommit={(val) => (newValue.current = val[0]) && updateAlert()}
|
||||||
onValueChange={(val) => setValue(val[0])}
|
onValueChange={(val) => setValue(val[0])}
|
||||||
min={1}
|
min={1}
|
||||||
max={99}
|
max={alertInfo[key].max ?? 99}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -2,7 +2,7 @@ import { toast } from "@/components/ui/use-toast"
|
|||||||
import { type ClassValue, clsx } from "clsx"
|
import { type ClassValue, clsx } from "clsx"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
import { $alerts, $copyContent, $systems, $userSettings, pb } from "./stores"
|
import { $alerts, $copyContent, $systems, $userSettings, pb } from "./stores"
|
||||||
import { AlertRecord, ChartTimeData, ChartTimes, SystemRecord } from "@/types"
|
import { AlertInfo, AlertRecord, ChartTimeData, ChartTimes, SystemRecord } from "@/types"
|
||||||
import { RecordModel, RecordSubscription } from "pocketbase"
|
import { RecordModel, RecordSubscription } from "pocketbase"
|
||||||
import { WritableAtom } from "nanostores"
|
import { WritableAtom } from "nanostores"
|
||||||
import { timeDay, timeHour } from "d3-time"
|
import { timeDay, timeHour } from "d3-time"
|
||||||
@@ -229,7 +229,7 @@ function getStorageValue(key: string, defaultValue: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Hook to sync value in local storage */
|
/** Hook to sync value in local storage */
|
||||||
export const useLocalStorage = (key: string, defaultValue: any) => {
|
export function useLocalStorage<T>(key: string, defaultValue: T) {
|
||||||
key = `besz-${key}`
|
key = `besz-${key}`
|
||||||
const [value, setValue] = useState(() => {
|
const [value, setValue] = useState(() => {
|
||||||
return getStorageValue(key, defaultValue)
|
return getStorageValue(key, defaultValue)
|
||||||
@@ -277,7 +277,7 @@ export const getSizeAndUnit = (n: number, isGigabytes = true) => {
|
|||||||
|
|
||||||
export const chartMargin = { top: 12 }
|
export const chartMargin = { top: 12 }
|
||||||
|
|
||||||
export const alertInfo = {
|
export const alertInfo: Record<string, AlertInfo> = {
|
||||||
Status: {
|
Status: {
|
||||||
name: () => t`Status`,
|
name: () => t`Status`,
|
||||||
unit: "",
|
unit: "",
|
||||||
@@ -308,6 +308,7 @@ export const alertInfo = {
|
|||||||
unit: " MB/s",
|
unit: " MB/s",
|
||||||
icon: EthernetIcon,
|
icon: EthernetIcon,
|
||||||
desc: () => t`Triggers when combined up/down exceeds a threshold`,
|
desc: () => t`Triggers when combined up/down exceeds a threshold`,
|
||||||
|
max: 125,
|
||||||
},
|
},
|
||||||
Temperature: {
|
Temperature: {
|
||||||
name: () => t`Temperature`,
|
name: () => t`Temperature`,
|
||||||
|
9
beszel/site/src/types.d.ts
vendored
9
beszel/site/src/types.d.ts
vendored
@@ -166,3 +166,12 @@ export interface ChartData {
|
|||||||
domain: number[]
|
domain: number[]
|
||||||
chartTime: ChartTimes
|
chartTime: ChartTimes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AlertInfo {
|
||||||
|
name: () => string
|
||||||
|
unit: string
|
||||||
|
icon: any
|
||||||
|
desc: () => string
|
||||||
|
single?: boolean
|
||||||
|
max?: number
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user