From 7858089cee82542da8d6ff6fff1cdaa58acce4d8 Mon Sep 17 00:00:00 2001 From: Oleksandr Shulgin Date: Wed, 17 Nov 2021 13:54:12 +0100 Subject: [PATCH 1/2] Show partitions count on subscription stats page Sometimes it's helpful to have a quick way to check it. --- client/Pages/SubscriptionDetails/View.elm | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/client/Pages/SubscriptionDetails/View.elm b/client/Pages/SubscriptionDetails/View.elm index 5771485..f49be5d 100644 --- a/client/Pages/SubscriptionDetails/View.elm +++ b/client/Pages/SubscriptionDetails/View.elm @@ -232,12 +232,26 @@ statsPanel model = list = Helpers.Store.items statsStore + eventTypesCount = + List.length list + + partitionsCount = + list + |> List.map countPartitions + |> List.sum + + partitionsStatsString = + String.fromInt partitionsCount ++ " partition(s) / " ++ String.fromInt eventTypesCount ++ " event type(s)" + tableLayout = - grid [ "Partition ID", "State", "Unconsumed", "Stream ID", "Committed Offset", "" ] - (list - |> List.map (renderType model) - |> List.concat - ) + div [] + [ text partitionsStatsString + , grid [ "Partition ID", "State", "Unconsumed", "Stream ID", "Committed Offset", "" ] + (list + |> List.map (renderType model) + |> List.concat + ) + ] in div [ class "dc-card panel--expanded" ] [ refreshButton Refresh @@ -249,6 +263,11 @@ statsPanel model = ] +countPartitions : Stores.SubscriptionStats.SubscriptionStats -> Int +countPartitions stat = + List.length stat.partitions + + renderType : Model -> Stores.SubscriptionStats.SubscriptionStats -> List (Html Msg) renderType model stat = tr [ class "dc-table__tr" ] From 71e75f977eb2d77bf3e13d5a7674f318aa02e968 Mon Sep 17 00:00:00 2001 From: Oleksandr Shulgin Date: Thu, 18 Nov 2021 08:39:34 +0100 Subject: [PATCH 2/2] use pluralCount --- client/Pages/SubscriptionDetails/View.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/Pages/SubscriptionDetails/View.elm b/client/Pages/SubscriptionDetails/View.elm index f49be5d..bf0a299 100644 --- a/client/Pages/SubscriptionDetails/View.elm +++ b/client/Pages/SubscriptionDetails/View.elm @@ -5,7 +5,7 @@ import Constants import Helpers.AccessEditor as AccessEditor import Helpers.Panel exposing (loadingStatus, warningMessage) import Helpers.Store exposing (Id, Status(..), get) -import Helpers.String exposing (formatDateTime, periodToShortString) +import Helpers.String exposing (formatDateTime, periodToShortString, pluralCount) import Helpers.UI exposing ( PopupPosition(..) @@ -241,7 +241,7 @@ statsPanel model = |> List.sum partitionsStatsString = - String.fromInt partitionsCount ++ " partition(s) / " ++ String.fromInt eventTypesCount ++ " event type(s)" + pluralCount partitionsCount "Partition" ++ "/ " ++ pluralCount eventTypesCount "Event type" tableLayout = div []