mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-20 11:41:50 +02:00
refactor (hub): add systemsManager module
- Removed the `updateSystemList` function and replaced it with a more efficient system management approach using `systemsManager`. - Updated the `App` component to initialize and subscribe to system updates through the new `systemsManager`. - Refactored the `SystemsTable` and `SystemDetail` components to utilize the new state management for systems, improving performance and maintainability. - Enhanced the `ActiveAlerts` component to fetch system names directly from the new state structure.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { atom, map } from "nanostores"
|
||||
import { atom, computed, map, ReadableAtom } from "nanostores"
|
||||
import { AlertMap, ChartTimes, SystemRecord, UserSettings } from "@/types"
|
||||
import { Unit } from "./enums"
|
||||
import { pb } from "./api"
|
||||
@@ -6,8 +6,18 @@ import { pb } from "./api"
|
||||
/** Store if user is authenticated */
|
||||
export const $authenticated = atom(pb.authStore.isValid)
|
||||
|
||||
/** List of system records */
|
||||
export const $systems = atom<SystemRecord[]>([])
|
||||
/** Map of system records by name */
|
||||
export const $allSystemsByName = map<Record<string, SystemRecord>>({})
|
||||
/** Map of system records by id */
|
||||
export const $allSystemsById = map<Record<string, SystemRecord>>({})
|
||||
/** Map of up systems by id */
|
||||
export const $upSystems = map<Record<string, SystemRecord>>({})
|
||||
/** Map of down systems by id */
|
||||
export const $downSystems = map<Record<string, SystemRecord>>({})
|
||||
/** Map of paused systems by id */
|
||||
export const $pausedSystems = map<Record<string, SystemRecord>>({})
|
||||
/** List of all system records */
|
||||
export const $systems: ReadableAtom<SystemRecord[]> = computed($allSystemsByName, Object.values)
|
||||
|
||||
/** Map of alert records by system id and alert name */
|
||||
export const $alerts = map<AlertMap>({})
|
||||
|
||||
Reference in New Issue
Block a user