mirror of
https://github.com/fluencelabs/dashboard
synced 2025-05-28 23:21:30 +00:00
Displaying services in blueprint page
This commit is contained in:
parent
6cbaacfb64
commit
1c2d0859af
@ -1,16 +1,16 @@
|
||||
module Pages.BlueprintPage exposing (Model, fromCache, view)
|
||||
|
||||
import Array exposing (Array)
|
||||
import Cache exposing (BlueprintId)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, a, article, div, img, span, strong, text)
|
||||
import Html.Attributes exposing (attribute)
|
||||
import Html exposing (Html, article, div, span, text)
|
||||
import Html.Events exposing (onClick)
|
||||
import Info exposing (..)
|
||||
import List.Unique exposing (..)
|
||||
import Modules.Model exposing (Module)
|
||||
import Maybe.Extra as Maybe
|
||||
import Msg exposing (Msg(..))
|
||||
import Palette exposing (classes, darkRed, redFont)
|
||||
import Service.Model exposing (Interface)
|
||||
import Services.ServicesTable
|
||||
import Utils.Html exposing (..)
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ type alias Model =
|
||||
|
||||
-- , blueprint : Blueprint
|
||||
, moduleNames : List String
|
||||
, services : Services.ServicesTable.Model
|
||||
, openedModule : Maybe String
|
||||
}
|
||||
|
||||
@ -38,6 +39,26 @@ fromCache cache id =
|
||||
bp =
|
||||
Dict.get id cache.blueprintsById
|
||||
|
||||
services =
|
||||
Dict.get id cache.servicesByBlueprintId
|
||||
|> Maybe.withDefault Array.empty
|
||||
|> Array.toList
|
||||
|> List.map
|
||||
(\mbSrvId ->
|
||||
Dict.get mbSrvId cache.servicesById
|
||||
|> Maybe.map
|
||||
(\srv ->
|
||||
{ -- name = "srv.name"
|
||||
blueprintName = bp |> Maybe.map .name |> Maybe.withDefault ""
|
||||
, blueprintId = id
|
||||
, serviceId = srv.id
|
||||
, peerId = "peerId"
|
||||
, ip = "id"
|
||||
}
|
||||
)
|
||||
)
|
||||
|> Maybe.values
|
||||
|
||||
res =
|
||||
Maybe.map
|
||||
(\x ->
|
||||
@ -50,6 +71,7 @@ fromCache cache id =
|
||||
|
||||
-- , blueprint = "Blueprint"
|
||||
, moduleNames = []
|
||||
, services = services
|
||||
, openedModule = Nothing
|
||||
}
|
||||
)
|
||||
@ -64,6 +86,12 @@ fromCache cache id =
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
let
|
||||
instancesCount =
|
||||
model.services
|
||||
|> List.length
|
||||
|> String.fromInt
|
||||
in
|
||||
div [ classes "fl w-100" ]
|
||||
[ div [ classes "fl w-100 pb4 pt4" ]
|
||||
[ div [ redFont, classes "f1 fw4 pt3 pb2" ] [ text ("Blueprint: " ++ model.name) ]
|
||||
@ -92,13 +120,10 @@ view model =
|
||||
]
|
||||
, div [ classes "pt4 fw5 f3 pb4" ]
|
||||
[ text
|
||||
("Services ("
|
||||
++ -- String.fromInt instanceNum ++
|
||||
")"
|
||||
)
|
||||
("Services (" ++ instancesCount ++ ")")
|
||||
]
|
||||
, div [ classes "fl w-100 mt2 mb4 bg-white br3" ]
|
||||
[--instanceView
|
||||
[ Services.ServicesTable.view model.services
|
||||
]
|
||||
]
|
||||
|
||||
|
33
src/Services/ServiceRow.elm
Normal file
33
src/Services/ServiceRow.elm
Normal file
@ -0,0 +1,33 @@
|
||||
module Services.ServiceRow exposing (Model, view)
|
||||
|
||||
import Cache exposing (BlueprintId)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Palette exposing (classes, shortHashRaw)
|
||||
|
||||
|
||||
|
||||
-- module
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ blueprintName : String
|
||||
, blueprintId : BlueprintId
|
||||
, serviceId : String
|
||||
, peerId : String
|
||||
, ip : String
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- view
|
||||
|
||||
|
||||
view : Model -> Html msg
|
||||
view model =
|
||||
tr [ classes "table-red-row" ]
|
||||
[ td [ classes "ph3" ] [ p [ classes "ws-normal" ] [ a [ attribute "href" ("/blueprint/" ++ model.blueprintId), classes "black" ] [ text model.blueprintName ] ] ]
|
||||
, td [ classes "ph3" ] [ p [ classes "ws-normal" ] [ text model.serviceId ] ]
|
||||
, td [ classes "ph3 dn dtc-ns" ] [ p [ classes "ws-normal" ] [ text (shortHashRaw 8 model.peerId) ] ]
|
||||
, td [ classes "ph3 dn dtc-ns" ] [ p [ classes "ws-normal" ] [ text model.ip ] ]
|
||||
]
|
34
src/Services/ServicesTable.elm
Normal file
34
src/Services/ServicesTable.elm
Normal file
@ -0,0 +1,34 @@
|
||||
module Services.ServicesTable exposing (Model, view)
|
||||
|
||||
import Cache exposing (ServiceId)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Palette exposing (classes)
|
||||
import Services.ServiceRow
|
||||
|
||||
|
||||
|
||||
-- model
|
||||
|
||||
|
||||
type alias Model =
|
||||
List Services.ServiceRow.Model
|
||||
|
||||
|
||||
view : Model -> Html msg
|
||||
view model =
|
||||
div [ classes "pa1 bg-white br3 overflow-auto" ]
|
||||
[ div [ classes "mw8-ns pa2 " ]
|
||||
[ table [ classes "f6 w-100 center ws-normal-ns", attribute "cellspacing" "0" ]
|
||||
[ thead []
|
||||
[ tr [ classes "" ]
|
||||
[ th [ classes "fw5 tl pa3 gray-font" ] [ text "BLUEPRINT" ]
|
||||
, th [ classes "fw5 tl pa3 gray-font" ] [ text "SERVICE ID" ]
|
||||
, th [ classes "fw5 tl pa3 gray-font dn dtc-ns" ] [ text "NODE" ]
|
||||
, th [ classes "fw5 tl pa3 gray-font dn dtc-ns" ] [ text "MULTIADDR" ]
|
||||
]
|
||||
]
|
||||
, tbody [ classes "lucida" ] (model |> List.map Services.ServiceRow.view)
|
||||
]
|
||||
]
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user