{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Cardano.RTView.GUI.Updater
( updateGUI
) where
import Cardano.Prelude hiding ((%))
import qualified Data.List as L
import Data.Map.Strict ((!))
import Data.Text (unpack)
import Data.Time.Calendar (Day (..), diffDays)
import Data.Time.Clock (NominalDiffTime, UTCTime (..), addUTCTime)
import Data.Time.Format (defaultTimeLocale, formatTime)
import Formatting (fixed, sformat, (%))
import GHC.Clock (getMonotonicTimeNSec)
import qualified Graphics.UI.Threepenny as UI
import Graphics.UI.Threepenny.Core (Element, UI, children, element, set, style, text,
( # ), ( #+ ), ( #. ))
import Prelude (String)
import Cardano.RTView.CLI (RTViewParams (..))
import qualified Cardano.RTView.GUI.Charts as Chart
import Cardano.RTView.GUI.Elements (ElementName (..), ElementValue (..),
HTMLClass (..), HTMLId (..),
HTMLW3Class (..), NodeStateElements,
NodesStateElements,
PeerInfoElements (..), PeerInfoItem (..),
(<+>))
import Cardano.RTView.NodeState.Types (NodeError (..), NodeInfo (..),
NodeMetrics (..), NodeState (..),
NodesState, PeerInfo (..))
import Cardano.BM.Data.Configuration (RemoteAddr (..), RemoteAddrNamed (..))
import Cardano.BM.Data.Severity (Severity (..))
updateGUI
:: UI.Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> (NodesStateElements, NodesStateElements)
-> UI ()
updateGUI :: Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> (NodesStateElements, NodesStateElements)
-> UI ()
updateGUI Window
window NodesState
nodesState RTViewParams
params [RemoteAddrNamed]
acceptors (NodesStateElements
nodesStateElems, NodesStateElements
gridNodesStateElems) = do
Window -> String -> UI (Maybe Element)
UI.getElementById Window
window (HTMLId -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
ViewModeButton) UI (Maybe Element) -> (Maybe Element -> UI ()) -> UI ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Just Element
btn -> ReadWriteAttr Element String String -> Element -> UI String
forall x i o. ReadWriteAttr x i o -> x -> UI o
UI.get ReadWriteAttr Element String String
UI.value Element
btn UI String -> (String -> UI ()) -> UI ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
String
"paneMode" -> Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updatePaneGUI Window
window NodesState
nodesState RTViewParams
params [RemoteAddrNamed]
acceptors NodesStateElements
nodesStateElems
String
_ -> Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updateGridGUI Window
window NodesState
nodesState RTViewParams
params [RemoteAddrNamed]
acceptors NodesStateElements
gridNodesStateElems
Maybe Element
Nothing -> () -> UI ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
updatePaneGUI
:: UI.Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updatePaneGUI :: Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updatePaneGUI Window
window NodesState
nodesState RTViewParams
params [RemoteAddrNamed]
acceptors NodesStateElements
nodesStateElems = do
NodesStateElements
-> ((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ NodesStateElements
nodesStateElems (((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ())
-> ((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \(Text
nameOfNode, NodeStateElements
elements, [PeerInfoItem]
peerInfoItems) -> do
let nodeState :: NodeState
nodeState = NodesState
nodesState NodesState -> Text -> NodeState
forall k a. Ord k => Map k a -> k -> a
! Text
nameOfNode
acceptorEndpoint :: String
acceptorEndpoint = Text -> [RemoteAddrNamed] -> String
mkTraceAcceptorEndpoint Text
nameOfNode [RemoteAddrNamed]
acceptors
let ni :: NodeInfo
ni = NodeState -> NodeInfo
nsInfo NodeState
nodeState
nm :: NodeMetrics
nm = NodeState -> NodeMetrics
nsMetrics NodeState
nodeState
activeNodeMark :: String
activeNodeMark = Text -> String
unpack Text
nameOfNode
Window -> Text -> NodeInfo -> NodeMetrics -> UI ()
updateCharts Window
window Text
nameOfNode NodeInfo
ni NodeMetrics
nm
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Element -> UI Element
updateEndpoint String
acceptorEndpoint (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElTraceAcceptorEndpoint
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodeProtocol NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeProtocol
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodeVersion NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeVersion
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodePlatform NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodePlatform
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> String -> Element -> UI Element
updateNodeCommit (NodeInfo -> String
niNodeCommit NodeInfo
ni) (NodeInfo -> String
niNodeShortCommit NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCommitHref
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString String
activeNodeMark) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElActiveNode
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Word64 -> Element -> UI Element
updateNodeUpTime (NodeInfo -> Word64
niUpTime NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElUptime
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niEpoch NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElEpoch
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niSlot NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlot
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niBlocksNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niBlocksForgedNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksForgedNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niNodeCannotForge NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCannotForge
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Double
niChainDensity NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElChainDensity
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niNodeIsLeaderNum NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeIsLeaderNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niSlotsMissedNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlotsMissedNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niTxsProcessed NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElTxsProcessed
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ [NodeError] -> Element -> UI Element
updateErrorsList (NodeInfo -> [NodeError]
niNodeErrors NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeErrors
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ [NodeError] -> Element -> UI Element
updateErrorsTab (NodeInfo -> [NodeError]
niNodeErrors NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeErrorsTab
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Word64 -> ElementValue
ElementWord64 (Word64 -> ElementValue) -> Word64 -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Word64
nmMempoolTxsNumber NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolTxsNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMempoolTxsPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolTxsPercent
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Word64 -> ElementValue
ElementWord64 (Word64 -> ElementValue) -> Word64 -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Word64
nmMempoolBytes NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolBytes
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMempoolBytesPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolBytesPercent
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmMempoolMaxTxs NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolMaxTxs
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmMempoolMaxBytes NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolMaxBytes
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMemory NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMemory
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMemoryMax NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMemoryMax
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMemoryMaxTotal NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMemoryMaxTotal
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmMemoryPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMemoryPercent
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmCPUPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElCPUPercent
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmDiskUsageR NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElDiskUsageR
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmDiskUsageRMaxTotal NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElDiskUsageRMaxTotal
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmDiskUsageW NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElDiskUsageW
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmDiskUsageWMaxTotal NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElDiskUsageWMaxTotal
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmNetworkUsageIn NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNetworkUsageIn
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmNetworkUsageInMaxTotal NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNetworkUsageInMaxTotal
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmNetworkUsageOut NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNetworkUsageOut
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmNetworkUsageOutMaxTotal NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNetworkUsageOutMaxTotal
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSMemoryAllocated NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSMemoryAllocated
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSMemoryUsed NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSMemoryUsed
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSMemoryUsedPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSMemoryUsedPercent
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSGcCpu NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcCpu
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSGcElapsed NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcElapsed
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmRTSGcNum NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcNum
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmRTSGcMajorNum NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcMajorNum
[(Integer, Element)] -> UI ()
updateKESInfo [ (NodeInfo -> Integer
niOpCertStartKESPeriod NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElOpCertStartKESPeriod)
, (NodeInfo -> Integer
niCurrentKESPeriod NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElCurrentKESPeriod)
, (NodeInfo -> Integer
niRemainingKESPeriods NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRemainingKESPeriods)
]
[PeerInfo] -> [PeerInfoItem] -> UI ()
updatePeersList (NodeInfo -> [PeerInfo]
niPeersInfo NodeInfo
ni) [PeerInfoItem]
peerInfoItems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Double -> Element -> UI Element
updateProgressBar (NodeMetrics -> Double
nmMempoolBytesPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolBytesProgress
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Double -> Element -> UI Element
updateProgressBar (NodeMetrics -> Double
nmMempoolTxsPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolTxsProgress
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Double -> Element -> UI Element
updateProgressBar (NodeMetrics -> Double
nmRTSMemoryUsedPercent NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSMemoryProgress
RTViewParams
-> NodeInfo -> NodeMetrics -> NodeStateElements -> UI ()
markOutdatedElements RTViewParams
params NodeInfo
ni NodeMetrics
nm NodeStateElements
elements
updateGridGUI
:: UI.Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updateGridGUI :: Window
-> NodesState
-> RTViewParams
-> [RemoteAddrNamed]
-> NodesStateElements
-> UI ()
updateGridGUI Window
window NodesState
nodesState RTViewParams
_params [RemoteAddrNamed]
acceptors NodesStateElements
gridNodesStateElems =
NodesStateElements
-> ((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ NodesStateElements
gridNodesStateElems (((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ())
-> ((Text, NodeStateElements, [PeerInfoItem]) -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \(Text
nameOfNode, NodeStateElements
elements, [PeerInfoItem]
_) -> do
let nodeState :: NodeState
nodeState = NodesState
nodesState NodesState -> Text -> NodeState
forall k a. Ord k => Map k a -> k -> a
! Text
nameOfNode
acceptorEndpoint :: String
acceptorEndpoint = Text -> [RemoteAddrNamed] -> String
mkTraceAcceptorEndpoint Text
nameOfNode [RemoteAddrNamed]
acceptors
let ni :: NodeInfo
ni = NodeState -> NodeInfo
nsInfo NodeState
nodeState
nm :: NodeMetrics
nm = NodeState -> NodeMetrics
nsMetrics NodeState
nodeState
Window -> Text -> NodeInfo -> NodeMetrics -> UI ()
updateCharts Window
window Text
nameOfNode NodeInfo
ni NodeMetrics
nm
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Element -> UI Element
updateEndpoint String
acceptorEndpoint (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElTraceAcceptorEndpoint
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodeProtocol NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeProtocol
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodeVersion NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeVersion
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (String -> ElementValue) -> String -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> String
niNodePlatform NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodePlatform
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> String -> Element -> UI Element
updateNodeCommit (NodeInfo -> String
niNodeCommit NodeInfo
ni) (NodeInfo -> String
niNodeShortCommit NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCommitHref
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Int -> ElementValue
ElementInt (Int -> ElementValue) -> Int -> ElementValue
forall a b. (a -> b) -> a -> b
$ [PeerInfo] -> Int
forall a. HasLength a => a -> Int
length (NodeInfo -> [PeerInfo]
niPeersInfo NodeInfo
ni)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElPeersNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Word64 -> Element -> UI Element
updateNodeUpTime (NodeInfo -> Word64
niUpTime NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElUptime
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niEpoch NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElEpoch
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niSlot NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlot
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niBlocksNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niBlocksForgedNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksForgedNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niNodeCannotForge NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCannotForge
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Double
niChainDensity NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElChainDensity
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niNodeIsLeaderNum NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeIsLeaderNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niSlotsMissedNumber NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlotsMissedNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeInfo -> Integer
niTxsProcessed NodeInfo
ni) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElTxsProcessed
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Word64 -> ElementValue
ElementWord64 (Word64 -> ElementValue) -> Word64 -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Word64
nmMempoolTxsNumber NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolTxsNumber
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Word64 -> ElementValue
ElementWord64 (Word64 -> ElementValue) -> Word64 -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Word64
nmMempoolBytes NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElMempoolBytes
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSGcCpu NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcCpu
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Double -> ElementValue
ElementDouble (Double -> ElementValue) -> Double -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Double
nmRTSGcElapsed NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcElapsed
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmRTSGcNum NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcNum
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger (Integer -> ElementValue) -> Integer -> ElementValue
forall a b. (a -> b) -> a -> b
$ NodeMetrics -> Integer
nmRTSGcMajorNum NodeMetrics
nm) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcMajorNum
[(Integer, Element)] -> UI ()
updateKESInfo [ (NodeInfo -> Integer
niOpCertStartKESPeriod NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElOpCertStartKESPeriod)
, (NodeInfo -> Integer
niCurrentKESPeriod NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElCurrentKESPeriod)
, (NodeInfo -> Integer
niRemainingKESPeriods NodeInfo
ni, NodeStateElements
elements NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRemainingKESPeriods)
]
updateElementValue
:: ElementValue
-> Element
-> UI Element
updateElementValue :: ElementValue -> Element -> UI Element
updateElementValue (ElementInt Int
i) Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text (Int -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Int
i)
updateElementValue (ElementInteger Integer
i) Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text (Integer -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Integer
i)
updateElementValue (ElementWord64 Word64
w) Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text (Word64 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Word64
w)
updateElementValue (ElementDouble Double
d) Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text (Double -> String
showWith1DecPlace Double
d)
updateElementValue (ElementString String
s) Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text String
s
updateProgressBar
:: Double
-> Element
-> UI Element
updateProgressBar :: Double -> Element -> UI Element
updateProgressBar Double
percents Element
bar = do
Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
bar UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element [(String, String)] ()
-> [(String, String)] -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element [(String, String)] ()
style [(String
"width", Double -> String
showWith1DecPlace Double
preparedPercents String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"%")]
where
preparedPercents :: Double
preparedPercents = if Double
percents Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
> Double
100.0 then Double
100.0 else Double
percents
showWith1DecPlace :: Double -> String
showWith1DecPlace :: Double -> String
showWith1DecPlace = Text -> String
unpack (Text -> String) -> (Double -> Text) -> Double -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format Text (Double -> Text) -> Double -> Text
forall a. Format Text a -> a
sformat (Format (Double -> Text) (Double -> Text)
"" Format (Double -> Text) (Double -> Text)
-> Format Text (Double -> Text) -> Format Text (Double -> Text)
forall r a r'. Format r a -> Format r' r -> Format r' a
% Int -> Format Text (Double -> Text)
forall a r. Real a => Int -> Format r (a -> r)
fixed Int
1)
updateNodeCommit
:: String
-> String
-> Element
-> UI Element
updateNodeCommit :: String -> String -> Element -> UI Element
updateNodeCommit String
commit String
shortCommit Element
commitHref = do
Element
sComm <- String -> UI Element
UI.string String
shortCommit
Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
commitHref UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.href (String
"https://github.com/input-output-hk/cardano-node/commit/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
commit)
# set children [sComm]
updateEndpoint
:: String
-> Element
-> UI Element
updateEndpoint :: String -> Element -> UI Element
updateEndpoint String
endpoint Element
endpointLabel =
Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
endpointLabel UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text String
shortened
# set UI.title__ fullEndpointTitle
where
len :: Int
len = String -> Int
forall a. HasLength a => a -> Int
length String
endpoint
shortened :: String
shortened = if Int
len Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
20
then Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
10 String
endpoint String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"..." String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String -> String
forall a. Int -> [a] -> [a]
drop (Int
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
10) String
endpoint
else String
endpoint
fullEndpointTitle :: String
fullEndpointTitle = if String
shortened String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
endpoint then String
"" else String
endpoint
updateNodeUpTime
:: Word64
-> Element
-> UI Element
updateNodeUpTime :: Word64 -> Element -> UI Element
updateNodeUpTime Word64
upTimeInNs Element
upTimeLabel =
Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
upTimeLabel UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
text String
upTimeWithDays
where
upTimeInSec :: Double
upTimeInSec :: Double
upTimeInSec = Word64 -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
upTimeInNs Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
1000000000
upTimeDiff :: NominalDiffTime
upTimeDiff :: NominalDiffTime
upTimeDiff = Integer -> NominalDiffTime
forall a. Num a => Integer -> a
fromInteger (Integer -> NominalDiffTime) -> Integer -> NominalDiffTime
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round Double
upTimeInSec
nullDay :: UTCTime
nullDay = Day -> DiffTime -> UTCTime
UTCTime (Integer -> Day
ModifiedJulianDay Integer
0) DiffTime
0
upTime :: UTCTime
upTime = NominalDiffTime
upTimeDiff NominalDiffTime -> UTCTime -> UTCTime
`addUTCTime` UTCTime
nullDay
upTimeFormatted :: String
upTimeFormatted = TimeLocale -> String -> UTCTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%X" UTCTime
upTime
daysNum :: Integer
daysNum = UTCTime -> Day
utctDay UTCTime
upTime Day -> Day -> Integer
`diffDays` UTCTime -> Day
utctDay UTCTime
nullDay
upTimeWithDays :: String
upTimeWithDays = if Integer
daysNum Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0
then Integer -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Integer
daysNum String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"d " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
upTimeFormatted
else String
upTimeFormatted
updatePeersList
:: [PeerInfo]
-> [PeerInfoItem]
-> UI ()
updatePeersList :: [PeerInfo] -> [PeerInfoItem] -> UI ()
updatePeersList [PeerInfo]
peersInfo' [PeerInfoItem]
peersInfoItems = do
(PeerInfoItem -> UI Element) -> [PeerInfoItem] -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Element -> UI Element
hideElement (Element -> UI Element)
-> (PeerInfoItem -> Element) -> PeerInfoItem -> UI Element
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. PeerInfoItem -> Element
piItem) [PeerInfoItem]
peersInfoItems
let peersInfo :: [PeerInfo]
peersInfo =
if [PeerInfo] -> Int
forall a. HasLength a => a -> Int
length [PeerInfo]
peersInfo' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> [PeerInfoItem] -> Int
forall a. HasLength a => a -> Int
length [PeerInfoItem]
peersInfoItems
then
Int -> [PeerInfo] -> [PeerInfo]
forall a. Int -> [a] -> [a]
take ([PeerInfoItem] -> Int
forall a. HasLength a => a -> Int
length [PeerInfoItem]
peersInfoItems) [PeerInfo]
peersInfo'
else
[PeerInfo]
peersInfo'
let peersInfoWithIndices :: [(PeerInfo, Int)]
peersInfoWithIndices = [PeerInfo] -> [Int] -> [(PeerInfo, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip [PeerInfo]
peersInfo [Int
0 .. [PeerInfo] -> Int
forall a. HasLength a => a -> Int
length [PeerInfo]
peersInfo Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
[(PeerInfo, Int)] -> ((PeerInfo, Int) -> UI Element) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(PeerInfo, Int)]
peersInfoWithIndices (((PeerInfo, Int) -> UI Element) -> UI ())
-> ((PeerInfo, Int) -> UI Element) -> UI ()
forall a b. (a -> b) -> a -> b
$ \(PeerInfo
pI, Int
i) -> do
let item :: PeerInfoItem
item = [PeerInfoItem]
peersInfoItems [PeerInfoItem] -> Int -> PeerInfoItem
forall a. [a] -> Int -> a
L.!! Int
i
internalElems :: PeerInfoElements
internalElems = PeerInfoItem -> PeerInfoElements
piItemElems PeerInfoItem
item
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piEndpoint PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieEndpoint PeerInfoElements
internalElems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piBytesInF PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieBytesInF PeerInfoElements
internalElems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piReqsInF PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieReqsInF PeerInfoElements
internalElems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piBlocksInF PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieBlocksInF PeerInfoElements
internalElems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piSlotNumber PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieSlotNumber PeerInfoElements
internalElems
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString (PeerInfo -> String
piStatus PeerInfo
pI)) (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoElements -> Element
pieStatus PeerInfoElements
internalElems
Element -> UI Element
showElement (Element -> UI Element) -> Element -> UI Element
forall a b. (a -> b) -> a -> b
$ PeerInfoItem -> Element
piItem PeerInfoItem
item
updateKESInfo :: [(Integer, Element)] -> UI ()
updateKESInfo :: [(Integer, Element)] -> UI ()
updateKESInfo [(Integer, Element)]
valuesWithElems =
[(Integer, Element)] -> ((Integer, Element) -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(Integer, Element)]
valuesWithElems (((Integer, Element) -> UI ()) -> UI ())
-> ((Integer, Element) -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \(Integer
value, Element
kesElem) ->
if Integer
value Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
9999999999
then UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (String -> ElementValue
ElementString String
"—") Element
kesElem
else UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ ElementValue -> Element -> UI Element
updateElementValue (Integer -> ElementValue
ElementInteger Integer
value) Element
kesElem
updateErrorsList
:: [NodeError]
-> Element
-> UI Element
updateErrorsList :: [NodeError] -> Element -> UI Element
updateErrorsList [NodeError]
nodeErrors Element
errorsList = do
[Element]
errors <- [NodeError] -> (NodeError -> UI Element) -> UI [Element]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [NodeError]
nodeErrors ((NodeError -> UI Element) -> UI [Element])
-> (NodeError -> UI Element) -> UI [Element]
forall a b. (a -> b) -> a -> b
$ \(NodeError UTCTime
utcTimeStamp Severity
sev String
msg) -> do
let className :: String
className :: String
className = case Severity
sev of
Severity
Warning -> HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
WarningMessage
Severity
Error -> HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ErrorMessage
Severity
Critical -> HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
CriticalMessage
Severity
Alert -> HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
AlertMessage
Severity
Emergency -> HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
EmergencyMessage
Severity
_ -> String
""
let timeStamp :: String
timeStamp = TimeLocale -> String -> UTCTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%F %T" UTCTime
utcTimeStamp
UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Row UI Element -> [UI Element] -> UI Element
#+
[ UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Third, HTMLW3Class
W3Theme] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+ [UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
UI.string String
timeStamp]]
, UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3TwoThird, HTMLW3Class
W3Theme] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+ [UI Element
UI.div UI Element -> String -> UI Element
#. String
className UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
UI.string String
msg]]
]
Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
errorsList UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element [Element] ()
-> [Element] -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element [Element] ()
children [Element]
errors
updateErrorsTab
:: [NodeError]
-> Element
-> UI Element
updateErrorsTab :: [NodeError] -> Element -> UI Element
updateErrorsTab [NodeError]
nodeErrors Element
errorsTab =
if [NodeError] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [NodeError]
nodeErrors
then UI Element
disableErrorsTab
else UI Element
enableErrorsTab
where
disableErrorsTab :: UI Element
disableErrorsTab = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
errorsTab UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element Bool Bool -> Bool -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element Bool Bool
UI.enabled Bool
False
# set UI.title__ "Good news: there are no errors!"
enableErrorsTab :: UI Element
enableErrorsTab = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
errorsTab UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element Bool Bool -> Bool -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element Bool Bool
UI.enabled Bool
True
# set UI.title__ "Errors"
mkTraceAcceptorEndpoint
:: Text
-> [RemoteAddrNamed]
-> String
mkTraceAcceptorEndpoint :: Text -> [RemoteAddrNamed] -> String
mkTraceAcceptorEndpoint Text
nameOfNode [RemoteAddrNamed]
acceptors =
case Maybe RemoteAddrNamed
maybeActiveNode of
Just (RemoteAddrNamed Text
_ (RemoteSocket String
host String
port)) -> String
host String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
":" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
port
Just (RemoteAddrNamed Text
_ (RemotePipe String
pipePath)) -> String
pipePath
Maybe RemoteAddrNamed
Nothing -> String
"-"
where
maybeActiveNode :: Maybe RemoteAddrNamed
maybeActiveNode = ((RemoteAddrNamed -> Bool)
-> [RemoteAddrNamed] -> Maybe RemoteAddrNamed)
-> [RemoteAddrNamed]
-> (RemoteAddrNamed -> Bool)
-> Maybe RemoteAddrNamed
forall a b c. (a -> b -> c) -> b -> a -> c
flip (RemoteAddrNamed -> Bool)
-> [RemoteAddrNamed] -> Maybe RemoteAddrNamed
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
L.find [RemoteAddrNamed]
acceptors ((RemoteAddrNamed -> Bool) -> Maybe RemoteAddrNamed)
-> (RemoteAddrNamed -> Bool) -> Maybe RemoteAddrNamed
forall a b. (a -> b) -> a -> b
$ \(RemoteAddrNamed Text
name RemoteAddr
_) -> Text
name Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
nameOfNode
markOutdatedElements
:: RTViewParams
-> NodeInfo
-> NodeMetrics
-> NodeStateElements
-> UI ()
markOutdatedElements :: RTViewParams
-> NodeInfo -> NodeMetrics -> NodeStateElements -> UI ()
markOutdatedElements RTViewParams
params NodeInfo
ni NodeMetrics
nm NodeStateElements
els = do
Word64
now <- IO Word64 -> UI Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Word64
getMonotonicTimeNSec
let niLife :: Word64
niLife = RTViewParams -> Word64
rtvNodeInfoLife RTViewParams
params
bcLife :: Word64
bcLife = RTViewParams -> Word64
rtvBlockchainInfoLife RTViewParams
params
rtsLife :: Word64
rtsLife = RTViewParams -> Word64
rtvRTSInfoLife RTViewParams
params
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niUpTimeLastUpdate NodeInfo
ni) Word64
niLife [ NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElUptime
, NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeProtocol
, NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeVersion
, NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodePlatform
, NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCommitHref
]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niEpochLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElEpoch]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niOpCertStartKESPeriodLastUpdate NodeInfo
ni) Word64
niLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElOpCertStartKESPeriod]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niCurrentKESPeriodLastUpdate NodeInfo
ni) Word64
niLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElCurrentKESPeriod]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niRemainingKESPeriodsLastUpdate NodeInfo
ni) Word64
niLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRemainingKESPeriods]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niSlotLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlot]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niBlocksNumberLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksNumber]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niBlocksForgedNumberLastUpdate NodeInfo
ni) Word64
bcLife [ NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElBlocksForgedNumber
, NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeCannotForge
]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niChainDensityLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElChainDensity]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niSlotsMissedNumberLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElSlotsMissedNumber]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeInfo -> Word64
niNodeIsLeaderNumLastUpdate NodeInfo
ni) Word64
bcLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElNodeIsLeaderNumber]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeMetrics -> Word64
nmRTSGcCpuLastUpdate NodeMetrics
nm) Word64
rtsLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcCpu]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeMetrics -> Word64
nmRTSGcElapsedLastUpdate NodeMetrics
nm) Word64
rtsLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcElapsed]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeMetrics -> Word64
nmRTSGcNumLastUpdate NodeMetrics
nm) Word64
rtsLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcNum]
Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now (NodeMetrics -> Word64
nmRTSGcMajorNumLastUpdate NodeMetrics
nm) Word64
rtsLife [NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
ElRTSGcMajorNum]
Word64
-> Word64
-> Word64
-> NodeStateElements
-> (ElementName, ElementName)
-> [ElementName]
-> UI ()
markProgressBar Word64
now (NodeMetrics -> Word64
nmRTSMemoryLastUpdate NodeMetrics
nm) Word64
rtsLife NodeStateElements
els ( ElementName
ElRTSMemoryProgress
, ElementName
ElRTSMemoryProgressBox
)
[ ElementName
ElRTSMemoryAllocated
, ElementName
ElRTSMemoryUsed
, ElementName
ElRTSMemoryUsedPercent
]
markValues
:: Word64
-> Word64
-> Word64
-> [Element]
-> UI ()
markValues :: Word64 -> Word64 -> Word64 -> [Element] -> UI ()
markValues Word64
now Word64
lastUpdate Word64
lifetime [Element]
els =
if Word64
now Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
- Word64
lastUpdate Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
> Word64
lifetime
then (Element -> UI ()) -> [Element] -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ())
-> (Element -> UI Element) -> Element -> UI ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Element -> UI Element
markAsOutdated) [Element]
els
else (Element -> UI ()) -> [Element] -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ())
-> (Element -> UI Element) -> Element -> UI ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Element -> UI Element
markAsUpToDate) [Element]
els
showElement, hideElement :: Element -> UI Element
showElement :: Element -> UI Element
showElement Element
w = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
w UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element [(String, String)] ()
-> [(String, String)] -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element [(String, String)] ()
UI.style [(String
"display", String
"inline")]
hideElement :: Element -> UI Element
hideElement Element
w = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
w UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element [(String, String)] ()
-> [(String, String)] -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element [(String, String)] ()
UI.style [(String
"display", String
"none")]
markAsOutdated, markAsUpToDate :: Element -> UI Element
markAsOutdated :: Element -> UI Element
markAsOutdated Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ (HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
OutdatedValue)
markAsUpToDate :: Element -> UI Element
markAsUpToDate Element
el = Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
el UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ String
""
markProgressBar
:: Word64
-> Word64
-> Word64
-> NodeStateElements
-> (ElementName, ElementName)
-> [ElementName]
-> UI ()
markProgressBar :: Word64
-> Word64
-> Word64
-> NodeStateElements
-> (ElementName, ElementName)
-> [ElementName]
-> UI ()
markProgressBar Word64
now Word64
lastUpdate Word64
lifetime NodeStateElements
els (ElementName
barName, ElementName
barBoxName) [ElementName]
labelsNames =
if Word64
now Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
- Word64
lastUpdate Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
> Word64
lifetime
then UI ()
markBarAsOutdated
else UI ()
markBarAsUpToDate
where
bar :: Element
bar = NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
barName
barBox :: Element
barBox = NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
barBoxName
markBarAsOutdated :: UI ()
markBarAsOutdated = do
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
bar UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ (HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarOutdated)
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
barBox UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ (HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarBoxOutdated)
# set UI.title__ "The progress values are outdated"
[ElementName] -> (ElementName -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [ElementName]
labelsNames ((ElementName -> UI ()) -> UI ())
-> (ElementName -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \ElementName
name -> UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ())
-> (Element -> UI Element) -> Element -> UI ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Element -> UI Element
markAsOutdated (Element -> UI ()) -> Element -> UI ()
forall a b. (a -> b) -> a -> b
$ NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
name
markBarAsUpToDate :: UI ()
markBarAsUpToDate = do
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
bar UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ (HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBar)
UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ()) -> UI Element -> UI ()
forall a b. (a -> b) -> a -> b
$ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
barBox UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# ReadWriteAttr Element String ()
-> String -> UI Element -> UI Element
forall x i o. ReadWriteAttr x i o -> i -> UI x -> UI x
set ReadWriteAttr Element String ()
UI.class_ (HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarBox)
# set UI.title__ ""
[ElementName] -> (ElementName -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [ElementName]
labelsNames ((ElementName -> UI ()) -> UI ())
-> (ElementName -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \ElementName
name -> UI Element -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI Element -> UI ())
-> (Element -> UI Element) -> Element -> UI ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Element -> UI Element
markAsUpToDate (Element -> UI ()) -> Element -> UI ()
forall a b. (a -> b) -> a -> b
$ NodeStateElements
els NodeStateElements -> ElementName -> Element
forall k a. Ord k => Map k a -> k -> a
! ElementName
name
updateCharts
:: UI.Window
-> Text
-> NodeInfo
-> NodeMetrics
-> UI ()
updateCharts :: Window -> Text -> NodeInfo -> NodeMetrics -> UI ()
updateCharts Window
window Text
nameOfNode NodeInfo
ni NodeMetrics
nm = do
Text
mcId <- UI Bool -> UI Text -> UI Text -> UI Text
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Text -> UI Bool
elementExists Text
mN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
mN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
mGN)
Text
ccId <- UI Bool -> UI Text -> UI Text -> UI Text
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Text -> UI Bool
elementExists Text
cN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
cN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
cGN)
Text
dcId <- UI Bool -> UI Text -> UI Text -> UI Text
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Text -> UI Bool
elementExists Text
dN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
dN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
dGN)
Text
ncId <- UI Bool -> UI Text -> UI Text -> UI Text
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Text -> UI Bool
elementExists Text
nN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
nN) (Text -> UI Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
nGN)
JSFunction () -> UI ()
UI.runFunction (JSFunction () -> UI ()) -> JSFunction () -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> Double -> JSFunction ()
forall a. FFI a => String -> a
UI.ffi String
Chart.updateMemoryUsageChartJS Text
mcId String
ts (NodeMetrics -> Double
nmMemory NodeMetrics
nm)
JSFunction () -> UI ()
UI.runFunction (JSFunction () -> UI ()) -> JSFunction () -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> Double -> JSFunction ()
forall a. FFI a => String -> a
UI.ffi String
Chart.updateCPUUsageChartJS Text
ccId String
ts (NodeMetrics -> Double
nmCPUPercent NodeMetrics
nm)
JSFunction () -> UI ()
UI.runFunction (JSFunction () -> UI ()) -> JSFunction () -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> Double -> Double -> JSFunction ()
forall a. FFI a => String -> a
UI.ffi String
Chart.updateDiskUsageChartJS Text
dcId String
ts (NodeMetrics -> Double
nmDiskUsageR NodeMetrics
nm) (NodeMetrics -> Double
nmDiskUsageW NodeMetrics
nm)
JSFunction () -> UI ()
UI.runFunction (JSFunction () -> UI ()) -> JSFunction () -> UI ()
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> Double -> Double -> JSFunction ()
forall a. FFI a => String -> a
UI.ffi String
Chart.updateNetworkUsageChartJS Text
ncId String
ts (NodeMetrics -> Double
nmNetworkUsageIn NodeMetrics
nm) (NodeMetrics -> Double
nmNetworkUsageOut NodeMetrics
nm)
where
ts :: String
ts :: String
ts = TimeLocale -> String -> UTCTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%M:%S" UTCTime
time
time :: UTCTime
time = NominalDiffTime -> UTCTime -> UTCTime
addUTCTime NominalDiffTime
timeDiff (Day -> DiffTime -> UTCTime
UTCTime (Integer -> Day
ModifiedJulianDay Integer
0) DiffTime
0)
timeDiff :: NominalDiffTime
timeDiff :: NominalDiffTime
timeDiff = Integer -> NominalDiffTime
forall a. Num a => Integer -> a
fromInteger (Integer -> NominalDiffTime) -> Integer -> NominalDiffTime
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round Double
timeInSec
timeInSec :: Double
timeInSec :: Double
timeInSec = Word64 -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (NodeInfo -> Word64
niUpTime NodeInfo
ni) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
1000000000
mN :: Text
mN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
MemoryUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
cN :: Text
cN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
CPUUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
dN :: Text
dN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
DiskUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
nN :: Text
nN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
NetworkUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
mGN :: Text
mGN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
GridMemoryUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
cGN :: Text
cGN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
GridCPUUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
dGN :: Text
dGN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
GridDiskUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
nGN :: Text
nGN = HTMLId -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
GridNetworkUsageChartId Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameOfNode
elementExists :: Text -> UI Bool
elementExists Text
anId = Maybe Element -> Bool
forall a. Maybe a -> Bool
isJust (Maybe Element -> Bool) -> UI (Maybe Element) -> UI Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Window -> String -> UI (Maybe Element)
UI.getElementById Window
window (Text -> String
unpack Text
anId)