mirror of
https://github.com/fluencelabs/dashboard
synced 2025-03-28 02:41:04 +00:00
get list of instance info
This commit is contained in:
parent
47a8de2482
commit
a9c739c0b1
@ -1,21 +1,40 @@
|
|||||||
module Instances.View exposing (..)
|
module Instances.View exposing (..)
|
||||||
|
|
||||||
|
import Dict exposing (Dict)
|
||||||
import Html exposing (Html, div, table, tbody, td, text, th, thead, tr)
|
import Html exposing (Html, div, table, tbody, td, text, th, thead, tr)
|
||||||
import Html.Attributes exposing (attribute)
|
import Html.Attributes exposing (attribute)
|
||||||
import Instances.Model exposing (Instance)
|
import Instances.Model exposing (Instance)
|
||||||
import Model exposing (Model)
|
import Model exposing (Model)
|
||||||
|
import Nodes.Model exposing (Identify)
|
||||||
import Palette exposing (classes)
|
import Palette exposing (classes)
|
||||||
|
import Services.Model exposing (Service)
|
||||||
|
|
||||||
|
|
||||||
|
toInstance : String -> Identify -> Dict String String -> Service -> Instance
|
||||||
|
toInstance peerId identify blueprints service =
|
||||||
|
let
|
||||||
|
name =
|
||||||
|
blueprints |> Dict.get service.blueprint_id |> Maybe.withDefault "unknown"
|
||||||
|
ip =
|
||||||
|
List.head identify.external_addresses |> Maybe.withDefault "unknown"
|
||||||
|
in
|
||||||
|
{ name = name, instance = service.service_id, peerId = peerId, ip = ip }
|
||||||
|
|
||||||
|
|
||||||
view : Model -> Html msg
|
view : Model -> Html msg
|
||||||
view model =
|
view model =
|
||||||
let
|
let
|
||||||
|
bps =
|
||||||
|
Dict.values model.discoveredPeers |> List.map (\data -> data.blueprints |> List.map (\b -> ( b.id, b.name )))
|
||||||
|
|
||||||
|
bpsDict =
|
||||||
|
List.concat bps |> Dict.fromList
|
||||||
|
|
||||||
instances =
|
instances =
|
||||||
[ { name = "SQLite", instance = "efrer3434g", peerId = "kljn35kfj4n5kjgn4k5jgn45kj", ip = "123.123.123.123" }
|
Dict.toList model.discoveredPeers
|
||||||
, { name = "SQLite", instance = "efrer3434g", peerId = "kljn35kfj4n5kjgn4k5jgn45kj", ip = "123.123.123.123" }
|
|> List.map (\( peer, data ) -> data.services
|
||||||
, { name = "SQLite", instance = "efrer3434g", peerId = "kljn35kfj4n5kjgn4k5jgn45kj", ip = "123.123.123.123" }
|
|> List.map (toInstance peer data.identify bpsDict))
|
||||||
, { name = "SQLite", instance = "efrer3434g", peerId = "kljn35kfj4n5kjgn4k5jgn45kj", ip = "123.123.123.123" }
|
|> List.concat
|
||||||
]
|
|
||||||
in
|
in
|
||||||
viewTable instances
|
viewTable instances
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user