Update frontend
This commit is contained in:
parent
6cfbe6e8b4
commit
46c6b3f2f1
|
@ -2,7 +2,7 @@ module Status.Api exposing (getStatus)
|
|||
|
||||
import Utils.Api exposing (send, get)
|
||||
import Utils.Types exposing (ApiData)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, ClusterStatus, ClusterPeer)
|
||||
import Json.Decode exposing (Decoder, map2, string, field, at, list, int, maybe, bool)
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ decodeData =
|
|||
(field "configYAML" string)
|
||||
(field "uptime" string)
|
||||
(field "versionInfo" decodeVersionInfo)
|
||||
(field "meshStatus" (maybe decodeMeshStatus))
|
||||
(field "clusterStatus" (maybe decodeClusterStatus))
|
||||
|
||||
|
||||
decodeVersionInfo : Decoder VersionInfo
|
||||
|
@ -43,27 +43,15 @@ decodeVersionInfo =
|
|||
(field "version" string)
|
||||
|
||||
|
||||
decodeMeshStatus : Decoder MeshStatus
|
||||
decodeMeshStatus =
|
||||
Json.Decode.map4 MeshStatus
|
||||
decodeClusterStatus : Decoder ClusterStatus
|
||||
decodeClusterStatus =
|
||||
Json.Decode.map2 ClusterStatus
|
||||
(field "name" string)
|
||||
(field "nickName" string)
|
||||
(field "peers" (list decodeMeshPeer))
|
||||
(field "connections" (list decodeMeshConnection))
|
||||
(field "peers" (list decodeClusterPeer))
|
||||
|
||||
|
||||
decodeMeshPeer : Decoder MeshPeer
|
||||
decodeMeshPeer =
|
||||
Json.Decode.map3 MeshPeer
|
||||
decodeClusterPeer : Decoder ClusterPeer
|
||||
decodeClusterPeer =
|
||||
Json.Decode.map2 ClusterPeer
|
||||
(field "name" string)
|
||||
(field "nickName" string)
|
||||
(field "uid" int)
|
||||
|
||||
|
||||
decodeMeshConnection : Decoder MeshConnection
|
||||
decodeMeshConnection =
|
||||
Json.Decode.map4 MeshConnection
|
||||
(field "address" string)
|
||||
(field "outbound" bool)
|
||||
(field "state" string)
|
||||
(field "info" string)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
module Status.Types exposing (StatusResponse, VersionInfo, ClusterStatus, ClusterPeer)
|
||||
|
||||
|
||||
type alias StatusResponse =
|
||||
{ config : String
|
||||
, uptime : String
|
||||
, versionInfo : VersionInfo
|
||||
, meshStatus : Maybe MeshStatus
|
||||
, clusterStatus : Maybe ClusterStatus
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,24 +19,13 @@ type alias VersionInfo =
|
|||
}
|
||||
|
||||
|
||||
type alias MeshStatus =
|
||||
type alias ClusterStatus =
|
||||
{ name : String
|
||||
, nickName : String
|
||||
, peers : List MeshPeer
|
||||
, connections : List MeshConnection
|
||||
, peers : List ClusterPeer
|
||||
}
|
||||
|
||||
|
||||
type alias MeshPeer =
|
||||
type alias ClusterPeer =
|
||||
{ name : String
|
||||
, nickName : String
|
||||
, uid : Int
|
||||
}
|
||||
|
||||
|
||||
type alias MeshConnection =
|
||||
{ address : String
|
||||
, outbound : Bool
|
||||
, state : String
|
||||
, info : String
|
||||
, address : String
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ module Views.Status.Views exposing (view)
|
|||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, style)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, ClusterStatus, ClusterPeer)
|
||||
import Types exposing (Msg(MsgForStatus))
|
||||
import Utils.Types exposing (ApiData(Failure, Success, Loading, Initial))
|
||||
import Views.Status.Types exposing (StatusModel)
|
||||
|
@ -33,7 +33,7 @@ viewStatusInfo status =
|
|||
[ b [ class "col-sm-2" ] [ text "Uptime:" ]
|
||||
, div [ class "col-sm-10" ] [ text status.uptime ]
|
||||
]
|
||||
, viewMeshStatus status.meshStatus
|
||||
, viewClusterStatus status.clusterStatus
|
||||
, viewVersionInformation status.versionInfo
|
||||
, viewConfig status.config
|
||||
]
|
||||
|
@ -51,29 +51,20 @@ viewConfig config =
|
|||
]
|
||||
|
||||
|
||||
viewMeshStatus : Maybe MeshStatus -> Html Types.Msg
|
||||
viewMeshStatus meshStatus =
|
||||
case meshStatus of
|
||||
Just meshStatus ->
|
||||
viewClusterStatus : Maybe ClusterStatus -> Html Types.Msg
|
||||
viewClusterStatus clusterStatus =
|
||||
case clusterStatus of
|
||||
Just clusterStatus ->
|
||||
span []
|
||||
[ h2 [] [ text "Mesh Status" ]
|
||||
[ h2 [] [ text "Cluster Status" ]
|
||||
, div [ class "form-group row" ]
|
||||
[ b [ class "col-sm-2" ] [ text "Name:" ]
|
||||
, div [ class "col-sm-10" ] [ text meshStatus.name ]
|
||||
]
|
||||
, div [ class "form-group row" ]
|
||||
[ b [ class "col-sm-2" ] [ text "Nick Name:" ]
|
||||
, div [ class "col-sm-10" ] [ text meshStatus.nickName ]
|
||||
, div [ class "col-sm-10" ] [ text clusterStatus.name ]
|
||||
]
|
||||
, div [ class "form-group row" ]
|
||||
[ b [ class "col-sm-2" ] [ text "Peers:" ]
|
||||
, ul [ class "col-sm-10" ] <|
|
||||
List.map viewMeshPeer meshStatus.peers
|
||||
]
|
||||
, div [ class "form-group row" ]
|
||||
[ b [ class "col-sm-2" ] [ text "Connections:" ]
|
||||
, ul [ class "col-sm-10" ] <|
|
||||
List.map viewMeshConnection meshStatus.connections
|
||||
List.map viewClusterPeer clusterStatus.peers
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -86,38 +77,16 @@ viewMeshStatus meshStatus =
|
|||
]
|
||||
|
||||
|
||||
viewMeshPeer : MeshPeer -> Html Types.Msg
|
||||
viewMeshPeer peer =
|
||||
viewClusterPeer : ClusterPeer -> Html Types.Msg
|
||||
viewClusterPeer peer =
|
||||
li []
|
||||
[ div [ class "" ]
|
||||
[ b [ class "" ] [ text "Name: " ]
|
||||
, text peer.name
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "Nick Name: " ]
|
||||
, text peer.nickName
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "UID: " ]
|
||||
, text <| toString peer.uid
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewMeshConnection : MeshConnection -> Html Types.Msg
|
||||
viewMeshConnection connection =
|
||||
li []
|
||||
[ div [ class "" ]
|
||||
[ b [ class "" ] [ text "Address: " ]
|
||||
, text connection.address
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "Info: " ]
|
||||
, text connection.info
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "State: " ]
|
||||
, text connection.state
|
||||
, text peer.address
|
||||
]
|
||||
]
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue