Dashboard Hooks
Dashboard data fetching and state management hooks
Hooks for dashboard data and state management.
From @tetherto/mdk-react-adapter
useActiveIncidents
TanStack Query hook returning the list of currently-firing alerts, shaped for <ActiveIncidentsCard items={...} />.
(options: UseActiveIncidentsOptions = {}) => UseQueryResult<IncidentRow[], Error>useCancelAction
Cancels pending actions via DELETE /auth/actions/:type/cancel?ids=…. Invalidates the pool/miner/actions caches on success. Gated by actions:w.
() => UseCancelActionResultuseConsumptionChartData
TanStack Query hook returning raw consumption tail-log samples. Most dashboards should consume the higher-level useSiteConsumptionChartData, which wraps this hook with the site powermeter defaults and returns a <LineChartCard>-ready `C…
(params: UseConsumptionChartDataParams) => UseQueryResult<TailLogEntry[], Error>useContainerPoolStats
Fetches per-container pool override counts from GET /auth/pools/stats/containers. Feeds the Sites Overview cards.
(options: UseContainerPoolStatsOptions = {}) => UseContainerPoolStatsResultuseContainerUnits
Fetches the site's container things from GET /auth/list-things (tag t-container). Returns the raw rows the Sites Overview merge needs — id, type, info.container, info.poolConfig, and the container status under `last.snap.stats.…
(options: UseContainerUnitsOptions = {}) => UseContainerUnitsResultuseDashboardDateRange
Owns the single source of truth for the dashboard's date-range picker. Pass start / end from the return value into every data hook on the page (useHashrateChartData, useConsumptionChartData, the export, etc.) so they refetch in loc…
(options: UseDashboardDateRangeOptions = {}) => UseDashboardDateRangeReturnuseDashboardExport
Builds CSV / JSON downloads from the dashboard's already-cached TanStack Query data. Does NOT trigger refetches — the export is exactly what the user is looking at when they click the button.
(options: UseDashboardExportOptions) => UseDashboardExportReturnuseDashboardTimeRange
Tiny piece of shared state for the dashboard's timeline selector. Owns the current timeline value plus the canonical option list. The chart hooks (useHashrateChartData, etc.) consume timeline as a prop.
(opts: UseDashboardTimeRangeOptions = {}) => DashboardTimeRangeuseDeviceAction
Entry point for wiring device-control UI (reboot, power mode, LED, socket switches, ...) into the voting/approval workflow: components build a typed submission with the foundation's device-action builders and queue it here. Submission and…
() => UseDeviceActionResultuseGetAvailableDevices
Pure projector turning a flat device list (or the /auth/list-things nested shape) into the two type-buckets the device-explorer toolbar needs.
({ data, }: UseGetAvailableDevicesOptions) => AvailableDevicesuseHashrateChartData
Multi-series hashrate chart data — Mining OS (miner tail-log) plus an Aggr Pool rollup and one line per individual pool (drawn from the paginated type=minerpool, key=stats-history ext-data feed).
(params: UseHashrateChartDataParams) => HashrateChartResultuseLiveActions
Polls GET /auth/actions every 5 s (voting, ready, executing, done). Partitions results into the current user's actions vs others', and gates othersVoting behind the actions:w permission.
() => LiveActionsDatauseMinerDevices
Fetches miner devices from GET /auth/list-things (tag t-miner) in the nested shape the devkit Miner Explorer expects. Prefer this over useMiners when feeding the devkit — only the nested info.poolConfig id can resolve pool na…
(options: UseMinerDevicesOptions = {}) => UseMinerDevicesResultuseMiners
Fetches miners with their assigned poolConfig from GET /auth/miners. Unwraps the paginated response envelope and returns the page rows for the Miner Explorer table plus the site-wide totalCount; row shaping (status mapping, pool labe…
(options: UseMinersOptions = {}) => UseMinersResultusePendingActions
Fetches submitted actions from GET /auth/actions — the server-side voting/approval queue (distinct from the local actionsStore staging buffer). Vote/cancel mutations invalidate this query's key.
(options: UsePendingActionsOptions = {}) => UsePendingActionsResultusePoolBalanceHistory
Fetches per-pool revenue/hashrate history from GET /auth/pools/:pool/balance-history. The query is disabled until a non-empty pool is supplied.
(pool: string, options: UsePoolBalanceHistoryOptions = {}) => UsePoolBalanceHistoryResultusePoolConfigsData
Fetches raw pool configurations from GET /auth/configs/pool. Returns the untransformed rows in the { data, isLoading, error } shape the devkit usePoolConfigs transform consumes — keeping tag/endpoint parsing in the component layer pe…
(options: UsePoolConfigsDataOptions = {}) => UsePoolConfigsDataResultusePoolManagerDashboard
Composes the Pool Manager dashboard view-model:
(options: UsePoolManagerDashboardOptions = {}) => UsePoolManagerDashboardResultusePoolRows
Returns one row per configured mining pool, ready for the <MiningPoolsPanel /> table. Reuses the same TanStack queryKey as usePoolStats so subscribing here doesn't trigger an extra fetch — both hooks share the cache entry.
(options: UsePoolRowsOptions = {}) => UsePoolRowsResultusePools
Fetches aggregated pools from GET /auth/pools (hashrate / workers / balance / revenue / summary). Feeds the Dashboard pool panel — distinct from usePoolConfigsData (/auth/configs/pool), which drives the editable Pools list.
(options: UsePoolsOptions = {}) => UsePoolsResultusePoolStats
Aggregates per-pool worker counts and hashrate from GET /auth/ext-data?type=minerpool&query={"key":"stats"}. Returns the total, online, and mismatch triplets and the summed hashratePhs shaped for `<HeaderMinersBox poolTotal/poolO…
(options: UsePoolStatsOptions = {}) => PoolStatsusePowerModeTimelineData
TanStack Query hook returning power-mode/status samples shaped for <PowerModeTimelineChart data={...} />.
(params: UsePowerModeTimelineDataParams) => UseQueryResult<PowerModeTimelineEntry[], Error>useSiteConsumption
Projects the freshest consumption sample out of the dashboard's existing tail-log query for the header stats strip (<HeaderConsumptionBox />).
(params: UseConsumptionChartDataParams) => SiteConsumptionuseSiteConsumptionChartData
Site-level power consumption time-series, shaped for <LineChartCard />. Reads site_power_w from the t-powermeter-tagged tail-log (same source the header's useSitePowerMeter snapshot uses), converts W → MW, and emits `highlightedVal…
(params: UseSiteConsumptionChartDataParams) => SiteConsumptionChartResultuseSiteContainerCapacity
Reads the aggregated nominal miner capacity across the site's containers — i.e. the maximum number of miners the facility was designed to host. Used as the "denominator" of the <HeaderMinersBox /> row: e.g. the 2,188 in 158 / 2,188.
(options: UseSiteContainerCapacityOptions = {}) => SiteContainerCapacityuseSiteDetailMiners
Resolves the container that backs selectedUnitId, then returns the subset of miner devices assigned to that container. Both underlying queries are already issued by the PoolManager page, so React Query deduplicates them — no extra networ…
(selectedUnitId: string | null) => UseSiteDetailMinersResultuseSiteEfficiency
Derives W/TH/s from the latest consumption + hashrate samples. Reuses both existing tail-log queries (no extra fetch) so the header efficiency box stays in step with the corresponding chart cards. Pass powerW to swap the numerator in (e.…
(params: UseSiteEfficiencyParams) => SiteEfficiencyuseSiteHashrate
Projects the freshest hashrate sample from the dashboard's tail-log query. Shares the TanStack queryKey with useHashrateChartData, so subscribing here does NOT trigger an extra fetch — both hooks read the same cache entry.
(params: UseSiteHashrateParams) => SiteHashrateuseSiteMinerCounts
Counts active miners by status for the header <HeaderMinersBox />. Hits /auth/list-things?status=1 with a tight projection (id, type, last.status only) so the response stays small even on big sites.
(options: UseSiteMinerCountsOptions = {}) => UseQueryResult<SiteMinerCounts, Error>useSiteMinerStats
Live miner-status breakdown for the header <HeaderMinersBox /> strip. Reads the realtime tail-log (key=stat-rtd, type=miner, tag=t-miner) and projects four aggregate counts. Values reflect what is reporting right now, not the full inve…
(options: UseSiteMinerStatsOptions = {}) => SiteMinerStatsuseSitePowerMeter
Site-level power reading for the header's <HeaderConsumptionBox />. Reads the freshest snapshot from a t-powermeter-tagged thing at info.pos = 'site'; falls back to a t-container-tagged thing if no powermeter is configured (matches…
(options: UseSitePowerMeterOptions = {}) => SitePowerMeteruseSitesOverview
Composes the Sites Overview dataset from three sources:
(options: UseSitesOverviewOptions = {}) => UseSitesOverviewResultuseSitesOverviewData
Projects raw site-overview rows into a <PoolManagerSitesOverview />- ready shape: each container gets its per-container hashrate (in MH/s), an attached pool-stats row keyed by container id, and a mining / offline status derived from…
({ units: rawUnits, poolStats, isLoading, tailLogItem, }: UseSitesOverviewDataOptions) => UseSitesOverviewDataResultuseSiteStatusLive
Polls GET /auth/site/status/live?overwriteCache=true every 5s for the composite site snapshot (hashrate, power, efficiency, miner / alert / pool counts). Returns the raw typed payload for a hook or component to shape into dashboard cards.
(options: UseSiteStatusLiveOptions = {}) => UseSiteStatusLiveResultuseSubmitPendingActions
Submits the locally-staged actionsStore queue to the voting/approval workflow. This is the network half of the write flow: the devkit modals only enqueue (setAddPendingSubmissionAction); nothing posted to /auth/actions until this h…
() => UseSubmitPendingActionsResultuseSubmitSingleAction
Submits a single action from the staged queue by its local id. Inspects the 200 response body for embedded errors before treating the call as successful. Removes the action from the queue only on genuine success.
() => UseSubmitSingleActionResultuseVoteOnAction
Casts an approve/reject vote on a pending action via PUT /auth/actions/voting/:id/vote. Invalidates the pool/miner/actions caches on success so the review tray and dashboard reflect the new state. Gated by actions:w.
() => UseVoteOnActionResultFrom @tetherto/mdk-react-devkit
useContainerWidgetsData
Site Overview data hook: composes the container inventory + realtime miner aggregate (useContainerWidgets) with the per-model thresholds (useContainerSettings) and shapes them into th…
(options?: UseContainerWidgetsOptions) => UseContainerWidgetsDataResultusePoolConfigs
Transforms raw pool-configuration rows from the host's API into PoolSummary objects for Pool Manager components.
({ data, isLoading, error, }: Partial<UsePoolConfigsOptions>) => UsePoolConfigsResultuseSiteOverviewDetailsData
Composes the per-site overview view-model: pools, performance series, and recent activity.
(unit?: UnitData | undefined, options?: SiteOverviewDetailsDataOptions) => UseSiteOverviewDetailsDataResult