mirror of
https://github.com/fluencelabs/dashboard
synced 2025-03-28 02:41:04 +00:00
module page
This commit is contained in:
parent
6dbc8d6ea9
commit
047b66b140
@ -1,14 +1,14 @@
|
|||||||
module ServicePage.Model exposing (..)
|
module ModulePage.Model exposing (..)
|
||||||
|
|
||||||
import Services.Model exposing (Service)
|
import Modules.Model exposing (Module)
|
||||||
|
|
||||||
|
|
||||||
type alias ServiceInfo =
|
type alias ModuleViewInfo =
|
||||||
{ name : String
|
{ name : String
|
||||||
, id : String
|
, id : String
|
||||||
, author : String
|
, author : String
|
||||||
, authorPeerId : String
|
, authorPeerId : String
|
||||||
, description : String
|
, description : String
|
||||||
, website : String
|
, website : String
|
||||||
, service : Service
|
, moduleInfo : Module
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
module ServicePage.View exposing (..)
|
module ModulePage.View exposing (..)
|
||||||
|
|
||||||
import Dict
|
import Dict exposing (Dict)
|
||||||
import Html exposing (Html, article, div, span, text)
|
import Html exposing (Html, article, div, span, text)
|
||||||
import List.Extra
|
|
||||||
import Model exposing (Model)
|
import Model exposing (Model)
|
||||||
|
import ModulePage.Model exposing (ModuleViewInfo)
|
||||||
|
import Modules.Model exposing (Module)
|
||||||
import Palette exposing (classes)
|
import Palette exposing (classes)
|
||||||
import ServicePage.Model exposing (ServiceInfo)
|
|
||||||
import Services.Model exposing (Record, Signature)
|
import Services.Model exposing (Record, Signature)
|
||||||
import String.Interpolate exposing (interpolate)
|
import String.Interpolate exposing (interpolate)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ view : Model -> String -> Html msg
|
|||||||
view model id =
|
view model id =
|
||||||
let
|
let
|
||||||
moduleInfo =
|
moduleInfo =
|
||||||
modelToServiceInfo model id
|
modelToServiceInfo model.modules id
|
||||||
in
|
in
|
||||||
case moduleInfo of
|
case moduleInfo of
|
||||||
Just mi ->
|
Just mi ->
|
||||||
@ -30,53 +30,47 @@ view model id =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
modelToServiceInfo : Model -> String -> Maybe ServiceInfo
|
modelToServiceInfo : Dict String Module -> String -> Maybe ModuleViewInfo
|
||||||
modelToServiceInfo model id =
|
modelToServiceInfo modules id =
|
||||||
let
|
let
|
||||||
datas =
|
moduleInfo =
|
||||||
Dict.toList model.discoveredPeers
|
Dict.get id modules
|
||||||
|
|
||||||
services =
|
|
||||||
datas |> List.map (\( peer, data ) -> data.services |> List.map (\s -> ( peer, s ))) |> List.concat
|
|
||||||
|
|
||||||
service =
|
|
||||||
services |> List.Extra.find (\( _, s ) -> s.service_id == id)
|
|
||||||
|
|
||||||
name =
|
name =
|
||||||
service |> Maybe.andThen (\( _, s ) -> model.blueprints |> Dict.get s.blueprint_id |> Maybe.map .name) |> Maybe.withDefault "unknown"
|
moduleInfo |> Maybe.map .name |> Maybe.withDefault "unknown"
|
||||||
|
|
||||||
info =
|
info =
|
||||||
service
|
moduleInfo
|
||||||
|> Maybe.map
|
|> Maybe.map
|
||||||
(\( p, s ) ->
|
(\m ->
|
||||||
{ name = name
|
{ name = name
|
||||||
, id = id
|
, id = id
|
||||||
, author = "Fluence Labs"
|
, author = "Fluence Labs"
|
||||||
, authorPeerId = p
|
, authorPeerId = "fluence_labs_peer_id"
|
||||||
, description = "Cool service"
|
, description = "Excelent module"
|
||||||
, website = "https://github.com/fluencelabs/chat"
|
, website = "https://github.com/fluencelabs/"
|
||||||
, service = s
|
, moduleInfo = m
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
info
|
info
|
||||||
|
|
||||||
|
|
||||||
viewInfo : ServiceInfo -> Html msg
|
viewInfo : ModuleViewInfo -> Html msg
|
||||||
viewInfo serviceInfo =
|
viewInfo moduleInfo =
|
||||||
article [ classes "cf" ]
|
article [ classes "cf" ]
|
||||||
[ div [ classes "fl w-30 gray mv1" ] [ text "AUTHOR" ]
|
[ div [ classes "fl w-30 gray mv1" ] [ text "AUTHOR" ]
|
||||||
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black b" ] [ text serviceInfo.author ], span [ classes "fl w-100 black" ] [ text serviceInfo.authorPeerId ] ]
|
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black b" ] [ text moduleInfo.author ], span [ classes "fl w-100 black" ] [ text moduleInfo.authorPeerId ] ]
|
||||||
, div [ classes "fl w-30 gray mv1" ] [ text "DESCRIPTION" ]
|
, div [ classes "fl w-30 gray mv1" ] [ text "DESCRIPTION" ]
|
||||||
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] [ text serviceInfo.description ] ]
|
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] [ text moduleInfo.description ] ]
|
||||||
, div [ classes "fl w-30 gray mv1" ] [ text "INTERFACE" ]
|
, div [ classes "fl w-30 gray mv1" ] [ text "INTERFACE" ]
|
||||||
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] (recordsView serviceInfo.service.interface.record_types ++ signaturesView serviceInfo.service.interface.function_signatures) ]
|
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] (recordsView moduleInfo.moduleInfo.interface.record_types ++ signaturesView moduleInfo.moduleInfo.interface.function_signatures) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
recordsView : List Record -> List (Html msg)
|
recordsView : List Record -> List (Html msg)
|
||||||
recordsView record =
|
recordsView record =
|
||||||
List.map recordView record
|
record |> List.sortBy .name |> List.map recordView
|
||||||
|
|
||||||
|
|
||||||
recordView : Record -> Html msg
|
recordView : Record -> Html msg
|
||||||
@ -95,7 +89,7 @@ fieldsView fields =
|
|||||||
|
|
||||||
signaturesView : List Signature -> List (Html msg)
|
signaturesView : List Signature -> List (Html msg)
|
||||||
signaturesView signatures =
|
signaturesView signatures =
|
||||||
List.map signatureView signatures
|
signatures |> List.sortBy .name |> List.map signatureView
|
||||||
|
|
||||||
|
|
||||||
signatureView : Signature -> Html msg
|
signatureView : Signature -> Html msg
|
@ -1,7 +1,7 @@
|
|||||||
module Modules.View exposing (..)
|
module Modules.View exposing (..)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Html exposing (Html, div, p, span, text)
|
import Html exposing (Html, a, div, p, span, text)
|
||||||
import Html.Attributes exposing (attribute)
|
import Html.Attributes exposing (attribute)
|
||||||
import Maybe.Extra
|
import Maybe.Extra
|
||||||
import Model exposing (Model, PeerData)
|
import Model exposing (Model, PeerData)
|
||||||
@ -60,7 +60,7 @@ view modules =
|
|||||||
viewService : ModuleShortInfo -> Html msg
|
viewService : ModuleShortInfo -> Html msg
|
||||||
viewService moduleInfo =
|
viewService moduleInfo =
|
||||||
div [ classes "fl w-third-ns pa2" ]
|
div [ classes "fl w-third-ns pa2" ]
|
||||||
[ div [ attribute "href" "#", classes "fl w-100 link dim black mw5 dt hide-child ba b-black pa4 br2 solid" ]
|
[ a [ attribute "href" ("/module/" ++ moduleInfo.moduleInfo.name), classes "fl w-100 link dim black mw5 dt hide-child ba b-black pa4 br2 solid" ]
|
||||||
[ p [ classes "tl di" ] [ span [ classes "b pl2" ] [ text moduleInfo.moduleInfo.name ], span [ classes "di fr pr2" ] [ instancesText moduleInfo.instanceNumber ] ]
|
[ p [ classes "tl di" ] [ span [ classes "b pl2" ] [ text moduleInfo.moduleInfo.name ], span [ classes "di fr pr2" ] [ instancesText moduleInfo.instanceNumber ] ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -4,8 +4,8 @@ import AirScripts.DiscoverPeers as DiscoverPeers
|
|||||||
import Html exposing (Html, text)
|
import Html exposing (Html, text)
|
||||||
import HubPage.View as HubPage
|
import HubPage.View as HubPage
|
||||||
import Model exposing (Model, Route(..))
|
import Model exposing (Model, Route(..))
|
||||||
|
import ModulePage.View as ModulePage
|
||||||
import Port exposing (sendAir)
|
import Port exposing (sendAir)
|
||||||
import ServicePage.View as ServicePage
|
|
||||||
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
|
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
|
||||||
|
|
||||||
|
|
||||||
@ -45,10 +45,11 @@ routeView model route =
|
|||||||
text peer
|
text peer
|
||||||
|
|
||||||
Service serviceId ->
|
Service serviceId ->
|
||||||
ServicePage.view model serviceId
|
text serviceId
|
||||||
|
|
||||||
Module moduleName ->
|
Module moduleName ->
|
||||||
text moduleName
|
ModulePage.view model moduleName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
routeCommand : Model -> Route -> Cmd msg
|
routeCommand : Model -> Route -> Cmd msg
|
||||||
|
@ -73,9 +73,6 @@ update msg model =
|
|||||||
Dict.toList updatedDict
|
Dict.toList updatedDict
|
||||||
|> List.filter (\( p, data ) -> List.isEmpty data.identify.external_addresses)
|
|> List.filter (\( p, data ) -> List.isEmpty data.identify.external_addresses)
|
||||||
|> List.map Tuple.first
|
|> List.map Tuple.first
|
||||||
|
|
||||||
_ =
|
|
||||||
Debug.log "empty peers" (List.length emptyPeers)
|
|
||||||
in
|
in
|
||||||
( { model | discoveredPeers = updatedDict }, sendAir (AirScripts.GetAll.air model.peerId model.relayId emptyPeers) )
|
( { model | discoveredPeers = updatedDict }, sendAir (AirScripts.GetAll.air model.peerId model.relayId emptyPeers) )
|
||||||
|
|
||||||
@ -120,7 +117,7 @@ updateModel model peer identify services modules blueprints =
|
|||||||
modules |> List.map (\m -> ( m.name, m )) |> Dict.fromList
|
modules |> List.map (\m -> ( m.name, m )) |> Dict.fromList
|
||||||
|
|
||||||
blueprintDict =
|
blueprintDict =
|
||||||
blueprints |> List.map (\b -> ( b.name, b )) |> Dict.fromList
|
blueprints |> List.map (\b -> ( b.id, b )) |> Dict.fromList
|
||||||
|
|
||||||
updatedModules =
|
updatedModules =
|
||||||
Dict.union moduleDict model.modules
|
Dict.union moduleDict model.modules
|
||||||
|
Loading…
x
Reference in New Issue
Block a user