mirror of
https://github.com/fluencelabs/dashboard
synced 2025-04-03 05:11:07 +00:00
module page wip
This commit is contained in:
parent
ea2fcf9971
commit
370cd20a31
@ -3,7 +3,7 @@ module HubPage.View exposing (..)
|
|||||||
import Html exposing (Html)
|
import Html exposing (Html)
|
||||||
import HubPage.Model exposing (Model)
|
import HubPage.Model exposing (Model)
|
||||||
import HubPage.Msg exposing (Msg)
|
import HubPage.Msg exposing (Msg)
|
||||||
import Modules.Model exposing (ModuleInfo)
|
import Modules.Model exposing (ModuleShortInfo)
|
||||||
import Modules.View
|
import Modules.View
|
||||||
import Services.Model exposing (ServiceInfo)
|
import Services.Model exposing (ServiceInfo)
|
||||||
import Services.View
|
import Services.View
|
||||||
@ -18,7 +18,7 @@ servicesExample =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
modulesExample : List ModuleInfo
|
modulesExample : List ModuleShortInfo
|
||||||
modulesExample =
|
modulesExample =
|
||||||
[ { name = "sqlite3", instanceNumber = 2 }
|
[ { name = "sqlite3", instanceNumber = 2 }
|
||||||
, { name = "ipfs_adapter", instanceNumber = 3 }
|
, { name = "ipfs_adapter", instanceNumber = 3 }
|
||||||
|
@ -1 +1,13 @@
|
|||||||
module ModulePage.Model exposing (..)
|
module ModulePage.Model exposing (..)
|
||||||
|
|
||||||
|
import Services.Model exposing (Service)
|
||||||
|
|
||||||
|
type alias ModuleInfo =
|
||||||
|
{ name: String
|
||||||
|
, id: String
|
||||||
|
, author: String
|
||||||
|
, authorPeerId: String
|
||||||
|
, description: String
|
||||||
|
, website: String
|
||||||
|
, service: Service
|
||||||
|
}
|
||||||
|
@ -1 +1,22 @@
|
|||||||
module ModulePage.View exposing (..)
|
module ModulePage.View exposing (..)
|
||||||
|
|
||||||
|
import Html exposing (Html)
|
||||||
|
import ModulePage.Model exposing (ModuleInfo)
|
||||||
|
import Palette exposing (classes)
|
||||||
|
|
||||||
|
view : ModuleInfo -> Html msg
|
||||||
|
view moduleInfo =
|
||||||
|
Html.div [classes "cf ph2-ns"]
|
||||||
|
[ Html.span [classes "fl w-100 f1 lh-title dark-red"] [Html.text ("Module: " ++ moduleInfo.name)]
|
||||||
|
, Html.span [classes "fl w-100 light-red"] [Html.text (moduleInfo.id)]
|
||||||
|
, viewInfo moduleInfo
|
||||||
|
]
|
||||||
|
|
||||||
|
viewInfo : ModuleInfo -> Html msg
|
||||||
|
viewInfo moduleInfo =
|
||||||
|
Html.article [classes "cf"]
|
||||||
|
[ Html.div [classes "fl w-30 gray"] [Html.text "AUTHOR"]
|
||||||
|
, Html.div [classes "fl w-70"] [ Html.span [classes "fl w-100 black b"] [Html.text moduleInfo.author], Html.span [classes "fl w-100 black"] [Html.text moduleInfo.authorPeerId]]
|
||||||
|
, Html.div [classes "fl w-30 gray"] [Html.text "DESCRIPTION"]
|
||||||
|
, Html.div [classes "fl w-70"] [ Html.span [classes "fl w-100 black b"] [Html.text moduleInfo.author]]
|
||||||
|
]
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
module Modules.Model exposing (..)
|
module Modules.Model exposing (..)
|
||||||
|
|
||||||
|
|
||||||
type alias ModuleInfo =
|
type alias ModuleShortInfo =
|
||||||
{ name : String
|
{ name : String
|
||||||
, instanceNumber : Int
|
, instanceNumber : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ modules : List ModuleInfo
|
{ modules : List ModuleShortInfo
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module Modules.View exposing (..)
|
module Modules.View exposing (..)
|
||||||
|
|
||||||
import Html exposing (Html)
|
import Html exposing (Html)
|
||||||
import Modules.Model exposing (Model, ModuleInfo)
|
import Modules.Model exposing (Model, ModuleShortInfo)
|
||||||
import Palette exposing (classes)
|
import Palette exposing (classes)
|
||||||
import Utils.Utils exposing (instancesText)
|
import Utils.Utils exposing (instancesText)
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ view model =
|
|||||||
Html.div [ classes "cf ph2-ns" ] modulesView
|
Html.div [ classes "cf ph2-ns" ] modulesView
|
||||||
|
|
||||||
|
|
||||||
viewService : ModuleInfo -> Html msg
|
viewService : ModuleShortInfo -> Html msg
|
||||||
viewService service =
|
viewService service =
|
||||||
Html.div [ classes "fl w-third-ns pa2" ]
|
Html.div [ classes "fl w-third-ns pa2" ]
|
||||||
[ Html.div [ classes "fl w-100 br2 ba solid pa2 mh2" ]
|
[ Html.div [ classes "fl w-100 br2 ba solid pa2 mh2" ]
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
module Route exposing (..)
|
module Route exposing (..)
|
||||||
|
|
||||||
import Air exposing (callBI, fold, next, par, relayEvent, seq, set)
|
import Air exposing (callBI, fold, next, par, relayEvent, seq, set)
|
||||||
|
import Dict
|
||||||
import Html exposing (Html)
|
import Html exposing (Html)
|
||||||
import HubPage.View as HubPage
|
import HubPage.View as HubPage
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Model exposing (Model, Route(..))
|
import Model exposing (Model, Route(..))
|
||||||
|
import ModulePage.View as ModulePage
|
||||||
import Port exposing (sendAir)
|
import Port exposing (sendAir)
|
||||||
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
|
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
|
||||||
|
|
||||||
@ -21,14 +23,41 @@ parse url =
|
|||||||
Maybe.withDefault (Page "") <| Url.Parser.parse routeParser url
|
Maybe.withDefault (Page "") <| Url.Parser.parse routeParser url
|
||||||
|
|
||||||
|
|
||||||
routeView : Route -> Html msg
|
routeView : Model -> Route -> Html msg
|
||||||
routeView route =
|
routeView model route =
|
||||||
case route of
|
case route of
|
||||||
Page page ->
|
Page page ->
|
||||||
case page of
|
case page of
|
||||||
"hub" ->
|
"hub" ->
|
||||||
HubPage.view {}
|
HubPage.view {}
|
||||||
|
|
||||||
|
"module" ->
|
||||||
|
let
|
||||||
|
up = (\(pid, p) -> Maybe.map (\a -> Tuple.pair pid a) (List.head (List.drop 0 p.services)))
|
||||||
|
el = (List.head (List.drop 3 (Dict.toList model.discoveredPeers)))
|
||||||
|
_ = Debug.log "el" el
|
||||||
|
in
|
||||||
|
case Maybe.andThen up el of
|
||||||
|
Just (peerId, service) ->
|
||||||
|
let
|
||||||
|
example =
|
||||||
|
{ name = "Chat"
|
||||||
|
, id = service.service_id
|
||||||
|
, author = "Fluence Labs"
|
||||||
|
, authorPeerId = peerId
|
||||||
|
, description = "Cool service"
|
||||||
|
, website = "https://github.com/fluencelabs/chat"
|
||||||
|
, service = service
|
||||||
|
}
|
||||||
|
in
|
||||||
|
ModulePage.view example
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
Html.text "alala"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Html.text ("undefined page: " ++ page)
|
Html.text ("undefined page: " ++ page)
|
||||||
|
|
||||||
|
@ -130,8 +130,6 @@ update msg model =
|
|||||||
updatedDict =
|
updatedDict =
|
||||||
Dict.update peer up model.discoveredPeers
|
Dict.update peer up model.discoveredPeers
|
||||||
|
|
||||||
_ =
|
|
||||||
Debug.log "discovered" updatedDict
|
|
||||||
in
|
in
|
||||||
( { model | discoveredPeers = updatedDict }, Cmd.none )
|
( { model | discoveredPeers = updatedDict }, Cmd.none )
|
||||||
|
|
||||||
@ -149,8 +147,6 @@ update msg model =
|
|||||||
updatedDict =
|
updatedDict =
|
||||||
Dict.update peer up model.discoveredPeers
|
Dict.update peer up model.discoveredPeers
|
||||||
|
|
||||||
_ =
|
|
||||||
Debug.log "discovered" updatedDict
|
|
||||||
in
|
in
|
||||||
( { model | discoveredPeers = updatedDict }, Cmd.none )
|
( { model | discoveredPeers = updatedDict }, Cmd.none )
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ body model =
|
|||||||
in
|
in
|
||||||
layout <|
|
layout <|
|
||||||
List.concat
|
List.concat
|
||||||
[ [ header [ classes "w-100 bt bb b--black-10" ] [ routeView (Page "hub") ] ]
|
[ [ header [ classes "w-100 bt bb b--black-10" ] [ routeView model (Page "hub") ] ]
|
||||||
|
++ [ header [ classes "w-100 bt bb b--black-10" ] [ routeView model (Page "module") ] ]
|
||||||
++ [ header [ classes "w-100 bt bb b--black-10", onClick Click ] [ text "GET SERVICES" ] ]
|
++ [ header [ classes "w-100 bt bb b--black-10", onClick Click ] [ text "GET SERVICES" ] ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user