diff --git a/src/Config/Graph.elm b/src/Config/Graph.elm index f56df0ff..52c4d5a8 100644 --- a/src/Config/Graph.elm +++ b/src/Config/Graph.elm @@ -123,6 +123,7 @@ minGapBetweenLayers = type AddressLabelType = ID | Balance + | TotalReceived | Tag @@ -131,6 +132,41 @@ type TxLabelType | Value +addressLabelToString : AddressLabelType -> String +addressLabelToString c = + case c of + ID -> + "id" + + Balance -> + "balance" + + TotalReceived -> + "total received" + + Tag -> + "tag" + + +stringToAddressLabel : String -> Maybe AddressLabelType +stringToAddressLabel s = + case s of + "id" -> + Just ID + + "balance" -> + Just Balance + + "tag" -> + Just Tag + + "total received" -> + Just TotalReceived + + _ -> + Nothing + + type alias Config = { addressLabelType : AddressLabelType , txLabelType : TxLabelType diff --git a/src/Config/UserSettings.elm b/src/Config/UserSettings.elm index 7c05f273..e84f5742 100644 --- a/src/Config/UserSettings.elm +++ b/src/Config/UserSettings.elm @@ -1,6 +1,6 @@ module Config.UserSettings exposing (..) -import Config.Graph exposing (AddressLabelType(..), TxLabelType(..)) +import Config.Graph exposing (AddressLabelType(..), TxLabelType(..), addressLabelToString, stringToAddressLabel) import Json.Decode as Decode exposing (Decoder, bool, nullable, string) import Json.Decode.Extra import Json.Decode.Pipeline exposing (optional, required) @@ -66,35 +66,6 @@ stringToCurrency s = Fiat x -addressLabelToString : AddressLabelType -> String -addressLabelToString c = - case c of - ID -> - "id" - - Balance -> - "balance" - - Tag -> - "tag" - - -stringToAddressLabel : String -> AddressLabelType -stringToAddressLabel s = - case s of - "id" -> - ID - - "balance" -> - Balance - - "tag" -> - Tag - - _ -> - ID - - edgeLabelToString : TxLabelType -> String edgeLabelToString c = case c of @@ -135,7 +106,7 @@ decoder = |> optional "lightMode" (nullable bool |> fromString) Nothing |> optional "valueDetail" (Decode.string |> Decode.map stringToValueDetail |> nullable) Nothing |> optional "valueDenomination" (Decode.string |> Decode.map stringToCurrency |> nullable) Nothing - |> optional "addressLabel" (Decode.string |> Decode.map stringToAddressLabel |> nullable) Nothing + |> optional "addressLabel" (Decode.string |> Decode.map stringToAddressLabel) Nothing |> optional "edgeLabel" (Decode.string |> Decode.map stringToEdgeLabel |> nullable) Nothing |> optional "showAddressShadowLinks" (nullable bool |> fromString) Nothing |> optional "showClusterShadowLinks" (nullable bool |> fromString) Nothing diff --git a/src/Update/Graph.elm b/src/Update/Graph.elm index c43488c2..f97ef319 100644 --- a/src/Update/Graph.elm +++ b/src/Update/Graph.elm @@ -1687,18 +1687,8 @@ updateByMsg plugins uc msg model = | config = model.config |> s_addressLabelType - (case at of - "id" -> - Config.Graph.ID - - "balance" -> - Config.Graph.Balance - - "tag" -> - Config.Graph.Tag - - _ -> - model.config.addressLabelType + (Config.Graph.stringToAddressLabel at + |> Maybe.withDefault model.config.addressLabelType ) } |> n diff --git a/src/View/Graph/Address.elm b/src/View/Graph/Address.elm index 7f0e2080..8f803e3a 100644 --- a/src/View/Graph/Address.elm +++ b/src/View/Graph/Address.elm @@ -165,6 +165,12 @@ getLabel vc gc addr = Label.normalizeValues gc (Id.currency addr.id) addr.address.balance addr.address.tokenBalances |> Locale.currency vc.locale + TotalReceived -> + Label.normalizeValues gc (Id.currency addr.id) addr.address.totalReceived addr.address.totalTokensReceived + |> Debug.log "values" + |> Locale.currency vc.locale + |> Debug.log "curr" + Tag -> addr.userTag |> Maybe.map .label diff --git a/src/View/Graph/Configuration.elm b/src/View/Graph/Configuration.elm index f678d5a6..dd309f98 100644 --- a/src/View/Graph/Configuration.elm +++ b/src/View/Graph/Configuration.elm @@ -66,6 +66,13 @@ configuration vc config = [ Locale.string vc.locale "Balance" |> text ] + , option + [ value "total received" + , config.addressLabelType == Graph.TotalReceived |> selected + ] + [ Locale.string vc.locale "Total received" + |> text + ] , option [ value "tag" , config.addressLabelType == Graph.Tag |> selected