This commit is contained in:
DieMyst 2020-12-01 18:16:56 +03:00
parent 07986e81b5
commit 71cd126b68
4 changed files with 42 additions and 21 deletions

View File

@ -13,4 +13,5 @@ type alias BlueprintViewInfo =
, website : String
, blueprint : Blueprint
, modules : List Module
, openedModule : Maybe String
}

View File

@ -4,14 +4,16 @@ import BlueprintPage.Model exposing (BlueprintViewInfo)
import Blueprints.Model exposing (Blueprint)
import Dict exposing (Dict)
import Html exposing (Html, article, div, span, text)
import Html.Events exposing (onClick)
import Interface.View exposing (instanceView)
import Model exposing (Model)
import Modules.Model exposing (Module)
import Msg exposing (Msg(..))
import Palette exposing (classes)
import Service.Model exposing (Interface)
view : Model -> String -> Html msg
view : Model -> String -> Html Msg
view model id =
let
blueprintInfo =
@ -46,6 +48,7 @@ blueprintToInfo model id =
, website = "https://github.com/fluencelabs/"
, blueprint = bp
, modules = modules
, openedModule = model.toggledInterface
}
Nothing ->
@ -53,21 +56,32 @@ blueprintToInfo model id =
viewInfo : BlueprintViewInfo -> Html msg
viewInfo : BlueprintViewInfo -> Html Msg
viewInfo blueprintInfo =
article [ classes "cf" ]
[ div [ classes "fl w-30 gray mv1" ] [ text "AUTHOR" ]
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black b" ] [ text blueprintInfo.author ], span [ classes "fl w-100 black" ] [ text blueprintInfo.authorPeerId ] ]
, div [ classes "fl w-30 gray mv1" ] [ text "DESCRIPTION" ]
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] [ text blueprintInfo.description ] ]
, div [ classes "fl w-30 gray mv1" ] [ text "INTERFACE" ]
, div [ classes "fl w-70 mv1" ] (blueprintInfo.modules |> List.map (\m -> viewToggledInterface True m.name m.interface))
]
let
checkToggle = (\id -> blueprintInfo.openedModule |> Maybe.map (\om -> om == id) |> Maybe.withDefault False)
in
article [ classes "cf" ]
[ div [ classes "fl w-30 gray mv1" ] [ text "AUTHOR" ]
, div [ classes "fl w-70 mv1" ]
[ span [ classes "fl w-100 black b" ] [ text blueprintInfo.author ]
, span [ classes "fl w-100 black" ] [ text blueprintInfo.authorPeerId ] ]
, div [ classes "fl w-30 gray mv1" ] [ text "DESCRIPTION" ]
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] [ text blueprintInfo.description ] ]
, div [ classes "fl w-30 gray mv1" ] [ text "INTERFACE" ]
, div [ classes "fl w-70 mv1" ]
(blueprintInfo.modules |>
List.map (\m -> viewToggledInterface (checkToggle m.name) m.name m.interface))
]
viewToggledInterface : Bool -> String -> Interface -> Html msg
viewToggledInterface : Bool -> String -> Interface -> Html Msg
viewToggledInterface isOpen name interface =
div []
([ text name
] ++
instanceView interface)
let
interfaceView = if (isOpen) then [(div [classes "fl w-100 ph4"] (instanceView interface))] else []
in
div []
([ div [classes "fl w-100 bg-near-white pa2", onClick (ToggleInterface name)] [text name] ]
++ interfaceView)

View File

@ -6,6 +6,7 @@ import Html exposing (Html, text)
import HubPage.View as HubPage
import Model exposing (Model, Route(..))
import ModulePage.View as ModulePage
import Msg exposing (Msg)
import Port exposing (sendAir)
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
@ -24,7 +25,7 @@ parse url =
Maybe.withDefault (Page "") <| Url.Parser.parse routeParser url
routeView : Model -> Route -> Html msg
routeView : Model -> Route -> Html Msg
routeView model route =
let
_ =
@ -55,14 +56,14 @@ routeView model route =
routeCommand : Model -> Route -> Cmd msg
routeCommand m r =
case r of
Page s ->
Page _ ->
sendAir (DiscoverPeers.air m.peerId m.relayId)
Peer _ ->
sendAir (DiscoverPeers.air m.peerId m.relayId)
Blueprint string ->
Blueprint _ ->
sendAir (DiscoverPeers.air m.peerId m.relayId)
Module string ->
Module _ ->
sendAir (DiscoverPeers.air m.peerId m.relayId)

View File

@ -71,7 +71,7 @@ update msg model =
emptyPeers =
Dict.toList updatedDict
|> List.filter (\( p, data ) -> List.isEmpty data.identify.external_addresses)
|> List.filter (\( _, data ) -> List.isEmpty data.identify.external_addresses)
|> List.map Tuple.first
in
( { model | discoveredPeers = updatedDict }, sendAir (AirScripts.GetAll.air model.peerId model.relayId emptyPeers) )
@ -94,7 +94,12 @@ update msg model =
( model, Cmd.none )
ToggleInterface id ->
( { model | toggledInterface = Just id }, Cmd.none )
case model.toggledInterface of
Just ti ->
( { model | toggledInterface = if (id == ti) then Nothing else Just id }, Cmd.none )
Nothing ->
( { model | toggledInterface = Just id }, Cmd.none )
RelayChanged relayId ->
( { model | relayId = relayId }, Cmd.none )