Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pkg/webui/console/containers/gateway-status-panel/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Copyright © 2024 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React, { useMemo } from 'react'
import { useSelector } from 'react-redux'
import React, { useMemo, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { defineMessages } from 'react-intl'
import { useParams } from 'react-router-dom'

import Panel from '@ttn-lw/components/panel'
import Icon, { IconGateway, IconInfoCircle, IconBolt, IconRouterOff } from '@ttn-lw/components/icon'
Expand All @@ -30,6 +31,8 @@
import sharedMessages from '@ttn-lw/lib/shared-messages'
import { getBackendErrorName, isBackend } from '@ttn-lw/lib/errors/utils'

import { startGatewayStatistics, stopGatewayStatistics } from '@console/store/actions/gateways'

import {
selectGatewayStatistics,
selectGatewayStatisticsError,
Expand Down Expand Up @@ -104,9 +107,20 @@
}

const GatewayStatusPanel = () => {
const { gtwId } = useParams()
const dispatch = useDispatch()
const gatewayStats = useSelector(selectGatewayStatistics)
const error = useSelector(selectGatewayStatisticsError)
const fetching = useSelector(selectGatewayStatisticsIsFetching)

// Start statistics fetching when component mounts
useEffect(() => {
Comment thread
ryaplots marked this conversation as resolved.
Outdated
dispatch(startGatewayStatistics(gtwId))
return () => {
dispatch(stopGatewayStatistics())
}
}, [dispatch, gtwId])

const isDisconnected = Boolean(gatewayStats?.disconnected_at)
const isConnected = Boolean(gatewayStats?.connected_at) && !isDisconnected
const isFetching = !Boolean(gatewayStats) && fetching
Expand Down
Loading