{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.RTView.GUI.Pane
    ( mkNodePane
    ) where

import           Cardano.Prelude
import qualified Data.Map.Strict as Map
import qualified Data.Text as T
import           Prelude (String)

import qualified Graphics.UI.Threepenny as UI
import           Graphics.UI.Threepenny.Core (Element, UI, element, set, string, ( # ), ( #+ ),
                                              ( #. ))

import           Cardano.RTView.GUI.Elements (ElementName (..), HTMLClass (..),
                                              HTMLId (..), HTMLW3Class (..),
                                              NodeStateElements, PeerInfoElements (..),
                                              PeerInfoItem (..), hideIt, showIt,
                                              ( ## ), (<+>))

mkNodePane
  :: Text
  -> UI (Element, NodeStateElements, [PeerInfoItem])
mkNodePane :: Text -> UI (Element, NodeStateElements, [PeerInfoItem])
mkNodePane Text
nameOfNode = do
  -- Create |Element|s containing node state (info, metrics).
  -- These elements will be part of the complete page,
  -- later they will be updated by acceptor thread.
  Element
elNodeProtocol            <- String -> UI Element
string String
""
  Element
elNodeVersion             <- String -> UI Element
string String
""
  Element
elNodePlatform            <- String -> UI Element
string String
""
  Element
elActiveNode              <- String -> UI Element
string String
"-"
  Element
elUptime                  <- String -> UI Element
string String
"00:00:00"
  Element
elEpoch                   <- String -> UI Element
string String
"0"
  Element
elSlot                    <- String -> UI Element
string String
"0"
  Element
elBlocksNumber            <- String -> UI Element
string String
"0"
  Element
elBlocksForgedNumber      <- String -> UI Element
string String
"0"
  Element
elNodeCannotForge         <- String -> UI Element
string String
"0"
  Element
elChainDensity            <- String -> UI Element
string String
"0"
  Element
elNodeIsLeaderNumber      <- String -> UI Element
string String
"0"
  Element
elSlotsMissedNumber       <- String -> UI Element
string String
"0"
  Element
elTxsProcessed            <- String -> UI Element
string String
"0"
  Element
elTraceAcceptorEndpoint   <- String -> UI Element
string String
"0"
  Element
elOpCertStartKESPeriod    <- String -> UI Element
string String
"0"
  Element
elCurrentKESPeriod        <- String -> UI Element
string String
"0"
  Element
elRemainingKESPeriods     <- String -> UI Element
string String
"0"
  Element
elMempoolTxsNumber        <- String -> UI Element
string String
"0"
  Element
elMempoolTxsPercent       <- String -> UI Element
string String
"0"
  Element
elMempoolBytes            <- String -> UI Element
string String
"0"
  Element
elMempoolBytesPercent     <- String -> UI Element
string String
"0"
  Element
elMempoolMaxTxs           <- String -> UI Element
string String
"0"
  Element
elMempoolMaxBytes         <- String -> UI Element
string String
"0"
  Element
elMemory                  <- String -> UI Element
string String
"0"
  Element
elMemoryMax               <- String -> UI Element
string String
"0"
  Element
elMemoryMaxTotal          <- String -> UI Element
string String
"0"
  Element
elMemoryPercent           <- String -> UI Element
string String
"0"
  Element
elCPUPercent              <- String -> UI Element
string String
"0"
  Element
elDiskUsageR              <- String -> UI Element
string String
"0"
  Element
elDiskUsageRMaxTotal      <- String -> UI Element
string String
"0"
  Element
elDiskUsageW              <- String -> UI Element
string String
"0"
  Element
elDiskUsageWMaxTotal      <- String -> UI Element
string String
"0"
  Element
elNetworkUsageIn          <- String -> UI Element
string String
"0"
  Element
elNetworkUsageInMaxTotal  <- String -> UI Element
string String
"0"
  Element
elNetworkUsageOut         <- String -> UI Element
string String
"0"
  Element
elNetworkUsageOutMaxTotal <- String -> UI Element
string String
"0"
  Element
elRTSMemoryAllocated      <- String -> UI Element
string String
"0"
  Element
elRTSMemoryUsed           <- String -> UI Element
string String
"0"
  Element
elRTSMemoryUsedPercent    <- String -> UI Element
string String
"0"
  Element
elRTSGcCpu                <- String -> UI Element
string String
"0"
  Element
elRTSGcElapsed            <- String -> UI Element
string String
"0"
  Element
elRTSGcNum                <- String -> UI Element
string String
"0"
  Element
elRTSGcMajorNum           <- String -> UI Element
string String
"0"

  -- Progress bars.
  Element
elMempoolBytesProgress    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBar UI Element -> [UI Element] -> UI Element
#+
                                 [ UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
HSpacer UI Element -> [UI Element] -> UI Element
#+ []
                                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolBytes
                                 , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
PercentsSlashHSpacer UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"/"]
                                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolBytesPercent
                                 , String -> UI Element
string String
"%"
                                 ]
  Element
elMempoolBytesProgressBox <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarBox UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolBytesProgress]

  Element
elMempoolTxsProgress      <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBar UI Element -> [UI Element] -> UI Element
#+
                                 [ UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
HSpacer UI Element -> [UI Element] -> UI Element
#+ []
                                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolTxsNumber
                                 , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
PercentsSlashHSpacer UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"/"]
                                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolTxsPercent
                                 , String -> UI Element
string String
"%"
                                 ]
  Element
elMempoolTxsProgressBox   <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarBox UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolTxsProgress]

  Element
elRTSMemoryProgress       <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBar UI Element -> [UI Element] -> UI Element
#+
                                 [ UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
HSpacer UI Element -> [UI Element] -> UI Element
#+ []
                                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSMemoryUsed
                                 , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
BarValueUnit UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"MB"]
                                 ]
  Element
elRTSMemoryProgressBox    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ProgressBarBox UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSMemoryProgress]

  Element
elNodeCommitHref <- UI Element
UI.anchor 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
""
                                # set UI.target "_blank"
                                # set UI.title__ "Browse cardano-node repository on this commit"
                                #+ [string ""]

  -- Create content area for each tab.
  Element
nodeTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
showIt UI Element -> [UI Element] -> UI Element
#+
         [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node protocol" 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.title__ String
"Node's protocol"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node version"  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.title__ String
"Version of the node"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node platform" 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.title__ String
"Platform the node is working on"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node commit"   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.title__ String
"Git commit the node was built from"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node uptime"   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.title__ String
"How long the node is working"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Node endpoint" 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.title__ String
"Socket/pipe used to connect the node with RTView"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeInfoValues UI Element -> [UI Element] -> UI Element
#+
                     [ UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ReleaseName UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeProtocol]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeVersion]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodePlatform]
                     , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
CommitLink UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeCommitHref]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elUptime]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elTraceAcceptorEndpoint]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     ]
                 ]
             ]
         ]

  Element
kesTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Start KES period" 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.title__ String
"Certificate KES start period"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"KES period"       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.title__ String
"Current KES period"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"KES remaining"    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.title__ String
"KES periods until expiry"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeInfoValues UI Element -> [UI Element] -> UI Element
#+
                     [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elOpCertStartKESPeriod]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elCurrentKESPeriod]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRemainingKESPeriods]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     ]
                 ]
             ]
         ]

  -- List of items corresponding to each peer. To avoid dynamic changes of DOM
  -- (unfortunately, it can be a reason of space leak), we create 20 (hidden) rows
  -- corresponding to 20 connected peers. Theoretically, the number of connected
  -- peers can be bigger, but the policy of ouroboros-network is about 20 hot peers
  -- (or less).
  let supportedPeersNum :: Int
supportedPeersNum = Int
20 :: Int -- TODO: Probably cardano-node cab trace this number?
  [(UI Element, PeerInfoItem)]
peersList :: [(UI Element, PeerInfoItem)]
    <- [Int]
-> (Int -> UI (UI Element, PeerInfoItem))
-> UI [(UI Element, PeerInfoItem)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Int
1..Int
supportedPeersNum] ((Int -> UI (UI Element, PeerInfoItem))
 -> UI [(UI Element, PeerInfoItem)])
-> (Int -> UI (UI Element, PeerInfoItem))
-> UI [(UI Element, PeerInfoItem)]
forall a b. (a -> b) -> a -> b
$ UI (UI Element, PeerInfoItem)
-> Int -> UI (UI Element, PeerInfoItem)
forall a b. a -> b -> a
const (UI (UI Element, PeerInfoItem)
 -> Int -> UI (UI Element, PeerInfoItem))
-> UI (UI Element, PeerInfoItem)
-> Int
-> UI (UI Element, PeerInfoItem)
forall a b. (a -> b) -> a -> b
$ do
         Element
endpoint   <- String -> UI Element
string String
""
         Element
slotNumber <- String -> UI Element
string String
""
         Element
bytesInF   <- String -> UI Element
string String
""
         Element
reqsInF    <- String -> UI Element
string String
""
         Element
blocksInF  <- String -> UI Element
string String
""
         Element
status     <- String -> UI Element
string String
""

         Element
peerItem <- 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
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")] UI Element -> [UI Element] -> UI Element
#+
                       [ UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeMetricsValues] UI Element -> [UI Element] -> UI Element
#+
                           [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
endpoint]
                       , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeMetricsValues] UI Element -> [UI Element] -> UI Element
#+
                           [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
slotNumber]
                       , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeMetricsValues] UI Element -> [UI Element] -> UI Element
#+
                           [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
bytesInF 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.title__ String
"Sum of the byte count of blocks expected from all in-flight fetch requests"
                           , String -> UI Element
string String
" / "
                           , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
reqsInF 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.title__ String
"Number of blocks fetch requests that are currently in-flight"
                           , String -> UI Element
string String
" / "
                           , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
blocksInF 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.title__ String
"Blocks that are currently in-flight"
                           ]
                       , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeMetricsValues] UI Element -> [UI Element] -> UI Element
#+
                           [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
status]
                       ]
         (UI Element, PeerInfoItem) -> UI (UI Element, PeerInfoItem)
forall (m :: * -> *) a. Monad m => a -> m a
return ( Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
peerItem
                , Element -> PeerInfoElements -> PeerInfoItem
PeerInfoItem
                    Element
peerItem
                    (Element
-> Element
-> Element
-> Element
-> Element
-> Element
-> PeerInfoElements
PeerInfoElements Element
endpoint Element
bytesInF Element
reqsInF Element
blocksInF Element
slotNumber Element
status)
                )
  let ([UI Element]
elPeersList, [PeerInfoItem]
peerInfoItems) = [(UI Element, PeerInfoItem)] -> ([UI Element], [PeerInfoItem])
forall a b. [(a, b)] -> ([a], [b])
unzip [(UI Element, PeerInfoItem)]
peersList

  Element
peersTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Quarter UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"Endpoint" 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.title__ String
"How the peer connected to this node"
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"Slot No." 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.title__ String
"Total number of peers reported by peer"
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"In Flight: b/r/bl" 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.title__ String
"In Flight: bytes/requests/blocks"
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Quarter, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"Status" 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.title__ String
"Peer's status"
                 ]
             ]
         , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [UI Element]
elPeersList
         ]

  Element
blockchainTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Epoch / Slot in epoch" 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.title__ String
"Number of current epoch / number of the current slot in this epoch"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Blocks number" 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.title__ String
"Total number of blocks in this blockchain"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Forged blocks number" 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.title__ String
"Number of blocks forged by this node"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Chain density" 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.title__ String
"Chain density, in percents"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Slot leader, number" 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.title__ String
"Number of slots when this node was a leader"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Cannot forge, number" 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.title__ String
"Number of slots when this node was a leader but because of misconfiguration, it's impossible to forge a new block"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Missed slots number" 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.title__ String
"Number of slots when this node was a leader but didn't forge a new block"]
                 , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeInfoValues UI Element -> [UI Element] -> UI Element
#+
                     [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elEpoch
                         , String -> UI Element
string String
" / "
                         , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elSlot
                         ]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elBlocksNumber]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elBlocksForgedNumber]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elChainDensity
                         , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
DensityPercent UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"%"]
                         ]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeIsLeaderNumber]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeCannotForge]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elSlotsMissedNumber]
                     , HTMLClass -> UI Element
vSpacer HTMLClass
NodeInfoVSpacer
                     ]
                 ]
             ]
         ]

  Element
mempoolTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Mempool | bytes" 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.title__ String
"Size of all transactions in the mempool, in bytes"]
                 , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Half, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                     [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolMaxBytes
                     , String -> UI Element
infoMark String
"Maximum in bytes"
                     ]
                 ]
                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolBytesProgressBox
             ]
         , HTMLClass -> UI Element
vSpacer HTMLClass
NodeMetricsVSpacer
         , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Mempool | TXs" 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.title__ String
"Number of transactions in the mempool"]
                 , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Half, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                     [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolMaxTxs
                     , String -> UI Element
infoMark String
"Maximum in txs"
                     ]
                 ]
                 , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elMempoolTxsProgressBox
             ]
         , HTMLClass -> UI Element
vSpacer HTMLClass
NodeMetricsVSpacer
         , 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Theme UI Element -> [UI Element] -> UI Element
#+
                  [ String -> UI Element
string String
"TXs processed" 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.title__ String
"Number of processed transactions in this blockchain (these transactions are already removed from the mempool)"
                  , UI Element
nbsp
                  , UI Element
nbsp
                  , UI Element
nbsp
                  , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeInfoValues UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elTxsProcessed]
                  ]
              ]
         , HTMLClass -> UI Element
vSpacer HTMLClass
NodeMetricsVSpacer
         ]

  Element
resourcesTabMemoryContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ UI Element
UI.canvas UI Element -> String -> UI Element
## (HTMLId -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
MemoryUsageChartId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
nameOfNode)
                         #. show MemoryUsageChart
                         #+ []
             ]
         ]

  Element
resourcesTabCPUContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ UI Element
UI.canvas UI Element -> String -> UI Element
## (HTMLId -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
CPUUsageChartId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
nameOfNode)
                         #. show CPUUsageChart
                         #+ []
             ]
         ]

  Element
resourcesTabDiskContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ UI Element
UI.canvas UI Element -> String -> UI Element
## (HTMLId -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
DiskUsageChartId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
nameOfNode)
                         #. show DiskUsageChart
                         #+ []
             ]
         ]

  Element
resourcesTabNetworkContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ UI Element
UI.canvas UI Element -> String -> UI Element
## (HTMLId -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLId
NetworkUsageChartId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
nameOfNode)
                         #. show NetworkUsageChart
                         #+ []
             ]
         ]

  Element
ghcRTSTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
TabContainer UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Container UI Element -> [UI Element] -> UI Element
#+
             [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"RTS live memory" 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.title__ String
"Total amount of live data in the heap, in MB (updated after every GC)"]
                 , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Half, HTMLW3Class
W3RightAlign] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                     [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSMemoryAllocated
                     , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ValueUnit UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"MB"]
                     ]
                 ]
             , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSMemoryProgressBox
             ]
         , HTMLClass -> UI Element
vSpacer HTMLClass
NodeMetricsVSpacer
         , 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"GC CPU time"       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.title__ String
"Total CPU time used by the GC, in seconds"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"GC time elapsed"   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.title__ String
"Total elapsed time used by the GC, in seconds"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Number of GC runs" 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.title__ String
"Total number of GCs"]
                 , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"Major GC runs"     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.title__ String
"Total number of major (oldest generation) GCs"]
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Half UI Element -> [UI Element] -> UI Element
#+
                 [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeInfoValues UI Element -> [UI Element] -> UI Element
#+
                     [ UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSGcCpu
                         , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ValueUnit UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"s"]
                         ]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+
                         [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSGcElapsed
                         , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
ValueUnit UI Element -> [UI Element] -> UI Element
#+ [String -> UI Element
string String
"s"]
                         ]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSGcNum]
                     , UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ [Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elRTSGcMajorNum]
                     ]
                 ]
             ]
         , HTMLClass -> UI Element
vSpacer HTMLClass
NodeMetricsVSpacer
         ]

  -- List of node errors, it will be changed dynamically!
  Element
elNodeErrorsList <- UI Element
UI.div UI Element -> [UI Element] -> UI Element
#+ []

  Element
errorsTabContent
    <- UI Element
UI.div UI Element -> String -> UI Element
#. [] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
TabContainer, HTMLClass
ErrorsTabContainer] UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt UI Element -> [UI Element] -> UI Element
#+
         [ 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 -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Third UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"Timestamp"
                 , String -> UI Element
infoMark String
"Time in UTC"
                 ]
             , UI Element
UI.div UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3TwoThird UI Element -> [UI Element] -> UI Element
#+
                 [ String -> UI Element
string String
"Error message"
                 ]
             ]
         , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elNodeErrorsList
         ]

  -- Tabs for corresponding sections.
  let tabButton :: String -> String -> UI Element
tabButton String
title String
iconName =
        UI Element
UI.button UI Element -> String -> UI Element
#. [HTMLW3Class
W3BarItem, HTMLW3Class
W3Button, HTMLW3Class
W3Mobile] [HTMLW3Class] -> [HTMLClass] -> String
<+> []
                  # set UI.title__ title
                  #+ [UI.img #. show NodeMenuIcon
                             # set UI.src ("/static/images/" <> iconName)]
      anchorButton :: String -> String -> UI Element
anchorButton String
title String
iconName =
        UI Element
UI.anchor UI Element -> String -> UI Element
#. [HTMLW3Class
W3BarItem, HTMLW3Class
W3Button, HTMLW3Class
W3Mobile] [HTMLW3Class] -> [HTMLClass] -> String
<+> []
                  # set UI.href "#"
                  #+ [ UI.img #. show ResourcesIcon
                              # set UI.src ("/static/images/" <> iconName)
                     , string title
                     ]

  Element
nodeTab       <- String -> String -> UI Element
tabButton String
"Node info" String
"info.svg" UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
makeItActive
  Element
kesTab        <- String -> String -> UI Element
tabButton String
"Key Evolving Signature" String
"key.svg"
  Element
peersTab      <- String -> String -> UI Element
tabButton String
"Peers" String
"peers.svg"
  Element
blockchainTab <- String -> String -> UI Element
tabButton String
"Blockchain" String
"blockchain.svg"
  Element
mempoolTab    <- String -> String -> UI Element
tabButton String
"Mempool" String
"mempool.svg"
  Element
ghcRTSTab     <- String -> String -> UI Element
tabButton String
"RTS GC" String
"rts.svg"
  Element
errorsTab     <- String -> String -> UI Element
tabButton String
"Errors" String
"bugs.svg"

  Element
resourcesTabMemory  <- String -> String -> UI Element
anchorButton String
"Memory" String
"memory.svg"
  Element
resourcesTabCPU     <- String -> String -> UI Element
anchorButton String
"CPU" String
"cpu.svg"
  Element
resourcesTabDisk    <- String -> String -> UI Element
anchorButton String
"Disk" String
"disk.svg"
  Element
resourcesTabNetwork <- String -> String -> UI Element
anchorButton String
"Network" String
"network.svg"

  Element
resourcesTab  <- UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3DropdownHover, HTMLW3Class
W3Mobile] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                     [ UI Element
UI.button UI Element -> String -> UI Element
#. HTMLW3Class -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLW3Class
W3Button
                                 # set UI.title__ "Resources"
                                 #+
                         [ UI Element
UI.img UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeMenuIcon 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.src String
"/static/images/resources.svg"
                         , String -> UI Element
string String
" ▾"
                         ]
                     , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3DropdownContent, HTMLW3Class
W3BarBlock, HTMLW3Class
W3Card4] [HTMLW3Class] -> [HTMLClass] -> String
<+> [] UI Element -> [UI Element] -> UI Element
#+
                         [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabMemory
                         , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabCPU
                         , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabDisk
                         , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabNetwork
                         ]
                     ]

  let tabs :: [((Element, Element), Int)]
      tabs :: [((Element, Element), Int)]
tabs =
        let allTabs :: [(Element, Element)]
allTabs = [ (Element
nodeTab,             Element
nodeTabContent)
                      , (Element
kesTab,              Element
kesTabContent)
                      , (Element
peersTab,            Element
peersTabContent)
                      , (Element
blockchainTab,       Element
blockchainTabContent)
                      , (Element
mempoolTab,          Element
mempoolTabContent)
                      , (Element
resourcesTabMemory,  Element
resourcesTabMemoryContent)
                      , (Element
resourcesTabCPU,     Element
resourcesTabCPUContent)
                      , (Element
resourcesTabDisk,    Element
resourcesTabDiskContent)
                      , (Element
resourcesTabNetwork, Element
resourcesTabNetworkContent)
                      , (Element
errorsTab,           Element
errorsTabContent)
                      , (Element
ghcRTSTab,           Element
ghcRTSTabContent)
                      ]
        in [(Element, Element)] -> [Int] -> [((Element, Element), Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip [(Element, Element)]
allTabs [Int
1..[(Element, Element)] -> Int
forall a. HasLength a => a -> Int
length [(Element, Element)]
allTabs]

  [((Element, Element), Int)] -> UI ()
registerClicksOnTabs [((Element, Element), Int)]
tabs

  -- Make a widget for one node.
  Element
nodeWidget <-
    UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Container, HTMLW3Class
W3Margin, HTMLW3Class
W3Border] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeContainer] UI Element -> [UI Element] -> UI Element
#+
      [ UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeNameArea UI Element -> [UI Element] -> UI Element
#+
          [ String -> UI Element
string String
"Name: "
          , UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
NodeName UI Element -> [UI Element] -> UI Element
#+ [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
elActiveNode ]
          ]
      , UI Element
UI.div UI Element -> String -> UI Element
#. [HTMLW3Class
W3Bar] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
NodeBar] UI Element -> [UI Element] -> UI Element
#+
          [ Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
nodeTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
kesTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
peersTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
blockchainTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
mempoolTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
errorsTab
          , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
ghcRTSTab
          ]
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
nodeTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
kesTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
peersTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
blockchainTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
mempoolTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabMemoryContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabCPUContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabDiskContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
resourcesTabNetworkContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
errorsTabContent
      , Element -> UI Element
forall (m :: * -> *) w. (MonadIO m, Widget w) => w -> m Element
element Element
ghcRTSTabContent
      ]

  -- Return these elements, they will be updated by another thread later.
  let nodeStateElems :: NodeStateElements
nodeStateElems =
        [(ElementName, Element)] -> NodeStateElements
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
          [ (ElementName
ElNodeProtocol,            Element
elNodeProtocol)
          , (ElementName
ElNodeVersion,             Element
elNodeVersion)
          , (ElementName
ElNodePlatform,            Element
elNodePlatform)
          , (ElementName
ElNodeCommitHref,          Element
elNodeCommitHref)
          , (ElementName
ElActiveNode,              Element
elActiveNode)
          , (ElementName
ElUptime,                  Element
elUptime)
          , (ElementName
ElEpoch,                   Element
elEpoch)
          , (ElementName
ElSlot,                    Element
elSlot)
          , (ElementName
ElBlocksNumber,            Element
elBlocksNumber)
          , (ElementName
ElBlocksForgedNumber,      Element
elBlocksForgedNumber)
          , (ElementName
ElNodeCannotForge,         Element
elNodeCannotForge)
          , (ElementName
ElChainDensity,            Element
elChainDensity)
          , (ElementName
ElNodeIsLeaderNumber,      Element
elNodeIsLeaderNumber)
          , (ElementName
ElSlotsMissedNumber,       Element
elSlotsMissedNumber)
          , (ElementName
ElTxsProcessed,            Element
elTxsProcessed)
          , (ElementName
ElTraceAcceptorEndpoint,   Element
elTraceAcceptorEndpoint)
          , (ElementName
ElOpCertStartKESPeriod,    Element
elOpCertStartKESPeriod)
          , (ElementName
ElCurrentKESPeriod,        Element
elCurrentKESPeriod)
          , (ElementName
ElRemainingKESPeriods,     Element
elRemainingKESPeriods)
          , (ElementName
ElNodeErrors,              Element
elNodeErrorsList)
          , (ElementName
ElNodeErrorsTab,           Element
errorsTab)
          , (ElementName
ElMempoolTxsNumber,        Element
elMempoolTxsNumber)
          , (ElementName
ElMempoolTxsPercent,       Element
elMempoolTxsPercent)
          , (ElementName
ElMempoolBytes,            Element
elMempoolBytes)
          , (ElementName
ElMempoolBytesPercent,     Element
elMempoolBytesPercent)
          , (ElementName
ElMempoolMaxTxs,           Element
elMempoolMaxTxs)
          , (ElementName
ElMempoolMaxBytes,         Element
elMempoolMaxBytes)
          , (ElementName
ElMemory,                  Element
elMemory)
          , (ElementName
ElMemoryMax,               Element
elMemoryMax)
          , (ElementName
ElMemoryMaxTotal,          Element
elMemoryMaxTotal)
          , (ElementName
ElMemoryPercent,           Element
elMemoryPercent)
          , (ElementName
ElCPUPercent,              Element
elCPUPercent)
          , (ElementName
ElDiskUsageR,              Element
elDiskUsageR)
          , (ElementName
ElDiskUsageRMaxTotal,      Element
elDiskUsageRMaxTotal)
          , (ElementName
ElDiskUsageW,              Element
elDiskUsageW)
          , (ElementName
ElDiskUsageWMaxTotal,      Element
elDiskUsageWMaxTotal)
          , (ElementName
ElNetworkUsageIn,          Element
elNetworkUsageIn)
          , (ElementName
ElNetworkUsageInMaxTotal,  Element
elNetworkUsageInMaxTotal)
          , (ElementName
ElNetworkUsageOut,         Element
elNetworkUsageOut)
          , (ElementName
ElNetworkUsageOutMaxTotal, Element
elNetworkUsageOutMaxTotal)
          , (ElementName
ElRTSMemoryAllocated,      Element
elRTSMemoryAllocated)
          , (ElementName
ElRTSMemoryUsed,           Element
elRTSMemoryUsed)
          , (ElementName
ElRTSMemoryUsedPercent,    Element
elRTSMemoryUsedPercent)
          , (ElementName
ElRTSGcCpu,                Element
elRTSGcCpu)
          , (ElementName
ElRTSGcElapsed,            Element
elRTSGcElapsed)
          , (ElementName
ElRTSGcNum,                Element
elRTSGcNum)
          , (ElementName
ElRTSGcMajorNum,           Element
elRTSGcMajorNum)
          -- Progress bars
          , (ElementName
ElMempoolBytesProgress,    Element
elMempoolBytesProgress)
          , (ElementName
ElMempoolBytesProgressBox, Element
elMempoolBytesProgressBox)
          , (ElementName
ElMempoolTxsProgress,      Element
elMempoolTxsProgress)
          , (ElementName
ElMempoolTxsProgressBox,   Element
elMempoolTxsProgressBox)
          , (ElementName
ElRTSMemoryProgress,       Element
elRTSMemoryProgress)
          , (ElementName
ElRTSMemoryProgressBox,    Element
elRTSMemoryProgressBox)
          ]

  (Element, NodeStateElements, [PeerInfoItem])
-> UI (Element, NodeStateElements, [PeerInfoItem])
forall (m :: * -> *) a. Monad m => a -> m a
return (Element
nodeWidget, NodeStateElements
nodeStateElems, [PeerInfoItem]
peerInfoItems)

---

vSpacer :: HTMLClass -> UI Element
vSpacer :: HTMLClass -> UI Element
vSpacer HTMLClass
className = UI Element
UI.div UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
className UI Element -> [UI Element] -> UI Element
#+ []

-- | Since information and metrics are splitted to tabs,
--   we have to make them clickable and show which one is active.
registerClicksOnTabs
  :: [((Element, Element), Int)]
  -> UI ()
registerClicksOnTabs :: [((Element, Element), Int)] -> UI ()
registerClicksOnTabs [((Element, Element), Int)]
tabs =
  [((Element, Element), Int)]
-> (((Element, Element), Int) -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [((Element, Element), Int)]
tabs ((((Element, Element), Int) -> UI ()) -> UI ())
-> (((Element, Element), Int) -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \((Element
tab, Element
_), Int
tabNum) ->
    UI (UI ()) -> UI ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (UI (UI ()) -> UI ()) -> UI (UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ Event () -> (() -> UI ()) -> UI (UI ())
forall a void. Event a -> (a -> UI void) -> UI (UI ())
UI.onEvent (Element -> Event ()
UI.click Element
tab) ((() -> UI ()) -> UI (UI ())) -> (() -> UI ()) -> UI (UI ())
forall a b. (a -> b) -> a -> b
$ \()
_ -> Int -> UI ()
showTabAndMakeItActive Int
tabNum
 where
  showTabAndMakeItActive :: Int -> UI ()
showTabAndMakeItActive Int
num =
    [((Element, Element), Int)]
-> (((Element, Element), Int) -> UI ()) -> UI ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [((Element, Element), Int)]
tabs ((((Element, Element), Int) -> UI ()) -> UI ())
-> (((Element, Element), Int) -> UI ()) -> UI ()
forall a b. (a -> b) -> a -> b
$ \((Element
tab', Element
tabContent), Int
tabNum') ->
      if Int
num Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
tabNum'
        then 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
tabContent UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
showIt
          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
tab' UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
makeItActive
        else 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
tabContent UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
hideIt
          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
tab' UI Element -> (UI Element -> UI Element) -> UI Element
forall a b. a -> (a -> b) -> b
# UI Element -> UI Element
makeItInactive

makeItActive, makeItInactive :: UI Element -> UI Element
makeItActive :: UI Element -> UI Element
makeItActive   = 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_ ([HTMLW3Class
W3BarItem, HTMLW3Class
W3Button, HTMLW3Class
W3Mobile] [HTMLW3Class] -> [HTMLClass] -> String
<+> [HTMLClass
ActiveTab])
makeItInactive :: UI Element -> UI Element
makeItInactive = 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_ ([HTMLW3Class
W3BarItem, HTMLW3Class
W3Button, HTMLW3Class
W3Mobile] [HTMLW3Class] -> [HTMLClass] -> String
<+> [])

infoMark :: String -> UI Element
infoMark :: String -> UI Element
infoMark String
aTitle =
  UI Element
UI.span UI Element -> String -> UI Element
#. HTMLClass -> String
forall a b. (Show a, ConvertText String b) => a -> b
show HTMLClass
InfoMark
          #  set UI.title__ aTitle
          #+ [ UI.img #. show InfoMarkImg
                      # set UI.src "/static/images/question.svg" #+ []
             ]

nbsp :: UI Element
nbsp :: UI Element
nbsp = UI Element
UI.span 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.html String
"&nbsp;" UI Element -> [UI Element] -> UI Element
#+ []