mirror of
https://github.com/fluencelabs/dashboard
synced 2025-06-30 15:11:39 +00:00
blueprint page, link to blueprint
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="favicon" type="image/ico" href="favicon.ico" />
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
16
src/BlueprintPage/Model.elm
Normal file
16
src/BlueprintPage/Model.elm
Normal file
@ -0,0 +1,16 @@
|
||||
module BlueprintPage.Model exposing (..)
|
||||
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Modules.Model exposing (Module)
|
||||
|
||||
|
||||
type alias BlueprintViewInfo =
|
||||
{ name : String
|
||||
, id : String
|
||||
, author : String
|
||||
, authorPeerId : String
|
||||
, description : String
|
||||
, website : String
|
||||
, blueprint : Blueprint
|
||||
, modules : List Module
|
||||
}
|
73
src/BlueprintPage/View.elm
Normal file
73
src/BlueprintPage/View.elm
Normal file
@ -0,0 +1,73 @@
|
||||
module BlueprintPage.View exposing (..)
|
||||
|
||||
import BlueprintPage.Model exposing (BlueprintViewInfo)
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, article, div, span, text)
|
||||
import Interface.View exposing (instanceView)
|
||||
import Model exposing (Model)
|
||||
import Modules.Model exposing (Module)
|
||||
import Palette exposing (classes)
|
||||
import Service.Model exposing (Interface)
|
||||
|
||||
|
||||
view : Model -> String -> Html msg
|
||||
view model id =
|
||||
let
|
||||
blueprintInfo =
|
||||
blueprintToInfo model id
|
||||
in
|
||||
case blueprintInfo of
|
||||
Just mi ->
|
||||
div [ classes "cf ph2-ns" ]
|
||||
[ span [ classes "fl w-100 f1 lh-title dark-red" ] [ text ("Blueprint: " ++ mi.name) ]
|
||||
, span [ classes "fl w-100 light-red" ] [ text mi.id ]
|
||||
, viewInfo mi
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
div [ classes "cf ph2-ns" ]
|
||||
[ span [ classes "fl w-100 f1 lh-title dark-red" ] [ text "Module not found" ]
|
||||
]
|
||||
|
||||
|
||||
blueprintToInfo : Model -> String -> Maybe BlueprintViewInfo
|
||||
blueprintToInfo model id =
|
||||
case (Dict.get id model.blueprints) of
|
||||
Just bp ->
|
||||
let
|
||||
modules = bp.dependencies |> List.map (\d -> Dict.get d model.modules) |> List.filterMap identity
|
||||
in
|
||||
Just { name = bp.name
|
||||
, id = id
|
||||
, author = "Fluence Labs"
|
||||
, authorPeerId = "fluence_labs_peer_id"
|
||||
, description = "Excelent blueprint"
|
||||
, website = "https://github.com/fluencelabs/"
|
||||
, blueprint = bp
|
||||
, modules = modules
|
||||
}
|
||||
|
||||
Nothing ->
|
||||
Nothing
|
||||
|
||||
|
||||
|
||||
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))
|
||||
]
|
||||
|
||||
viewToggledInterface : Bool -> String -> Interface -> Html msg
|
||||
viewToggledInterface isOpen name interface =
|
||||
div []
|
||||
([ text name
|
||||
] ++
|
||||
instanceView interface)
|
||||
|
@ -6,3 +6,11 @@ type alias Blueprint =
|
||||
, id : String
|
||||
, name : String
|
||||
}
|
||||
|
||||
|
||||
type alias BlueprintInfo =
|
||||
{ name : String
|
||||
, author : String
|
||||
, instanceNumber : Int
|
||||
, id: String
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
module Services.View exposing (..)
|
||||
module Blueprints.View exposing (..)
|
||||
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Blueprints.Model exposing (Blueprint, BlueprintInfo)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, div, text)
|
||||
import Html exposing (Html, a, div, text)
|
||||
import Html.Attributes exposing (attribute)
|
||||
import Model exposing (Model, PeerData)
|
||||
import Palette exposing (classes)
|
||||
import Services.Model exposing (Service, ServiceInfo)
|
||||
import Service.Model exposing (Service)
|
||||
import Utils.Utils exposing (instancesText)
|
||||
|
||||
|
||||
@ -17,7 +17,13 @@ view model =
|
||||
getBlueprintsToServices model.blueprints model.discoveredPeers
|
||||
|
||||
info =
|
||||
Dict.values allBps |> List.map (\( bp, servicesByPeers ) -> { name = bp.name, author = "Fluence Labs", instanceNumber = List.length (servicesByPeers |> List.map (\( _, s ) -> s) |> List.concat) })
|
||||
Dict.values allBps |> List.map (\( bp, servicesByPeers ) ->
|
||||
{ name = bp.name
|
||||
, id = bp.id
|
||||
, author = "Fluence Labs"
|
||||
, instanceNumber = List.length (servicesByPeers |> List.map (\( _, s ) -> s) |> List.concat)
|
||||
}
|
||||
)
|
||||
|
||||
servicesView =
|
||||
List.map viewService info
|
||||
@ -25,13 +31,13 @@ view model =
|
||||
div [ classes "cf ph1-ns" ] servicesView
|
||||
|
||||
|
||||
viewService : ServiceInfo -> Html msg
|
||||
viewService service =
|
||||
viewService : BlueprintInfo -> Html msg
|
||||
viewService blueprint =
|
||||
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" ]
|
||||
[ div [ classes "w-100 mb2 b" ] [ text service.name ]
|
||||
, div [ classes "w-100 mb4" ] [ text ("By " ++ service.author) ]
|
||||
, div [ classes "w-100" ] [ instancesText service.instanceNumber ]
|
||||
[ a [ attribute "href" ("/blueprint/" ++ blueprint.id), classes "fl w-100 link dim black mw5 dt hide-child ba b-black pa4 br2 solid" ]
|
||||
[ div [ classes "w-100 mb2 b" ] [ text blueprint.name ]
|
||||
, div [ classes "w-100 mb4" ] [ text ("By " ++ blueprint.author) ]
|
||||
, div [ classes "w-100" ] [ instancesText blueprint.instanceNumber ]
|
||||
]
|
||||
]
|
||||
|
@ -1,12 +1,12 @@
|
||||
module HubPage.View exposing (..)
|
||||
|
||||
import Blueprints.View
|
||||
import Html exposing (Html, a, div, h1, h3, span, text)
|
||||
import Html.Attributes exposing (attribute)
|
||||
import Instances.View
|
||||
import Model exposing (Model)
|
||||
import Modules.View
|
||||
import Palette exposing (classes, redFont)
|
||||
import Services.View
|
||||
|
||||
|
||||
view : Model -> Html msg
|
||||
@ -14,8 +14,8 @@ view model =
|
||||
div []
|
||||
[ h1 [ redFont ] [ text "Developer Hub" ]
|
||||
, welcomeText
|
||||
, h3 [] [ text "Featured Services" ]
|
||||
, Services.View.view model
|
||||
, h3 [] [ text "Featured Blueprints" ]
|
||||
, Blueprints.View.view model
|
||||
, h3 [] [ text "Featured Modules" ]
|
||||
, Modules.View.view model
|
||||
, h3 [] [ text "Service Instances" ]
|
||||
|
@ -2,13 +2,13 @@ module Instances.View exposing (..)
|
||||
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, a, 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 Instances.Model exposing (Instance)
|
||||
import Model exposing (Model)
|
||||
import Nodes.Model exposing (Identify)
|
||||
import Palette exposing (classes)
|
||||
import Services.Model exposing (Service)
|
||||
import Service.Model exposing (Service)
|
||||
|
||||
|
||||
toInstance : String -> Identify -> Dict String Blueprint -> Service -> Instance
|
||||
@ -41,8 +41,8 @@ view model =
|
||||
viewTable : List Instance -> Html msg
|
||||
viewTable instances =
|
||||
div [ classes "pa1" ]
|
||||
[ div [ classes "" ]
|
||||
[ table [ classes "f6 w-100 mw8 center", attribute "cellspacing" "0" ]
|
||||
[ div [ classes "mw8" ]
|
||||
[ table [ classes "f6 w-100 center", attribute "cellspacing" "0" ]
|
||||
[ thead []
|
||||
[ tr [ classes "stripe-dark" ]
|
||||
[ th [ classes "fw6 tl pa3 bg-white" ] [ text "SERVICE" ]
|
||||
@ -61,7 +61,7 @@ viewInstance : Instance -> Html msg
|
||||
viewInstance instance =
|
||||
tr [ classes "stripe-dark" ]
|
||||
[ td [ classes "pa3" ] [ text instance.name ]
|
||||
, td [] [ a [ attribute "href" ("/service/" ++ instance.instance), classes "pa3 link dim hide-child" ] [ text instance.instance ] ]
|
||||
, td [ classes "pa3" ] [ text instance.instance ]
|
||||
, td [ classes "pa3" ] [ text instance.peerId ]
|
||||
, td [ classes "pa3" ] [ text instance.ip ]
|
||||
]
|
||||
|
51
src/Interface/View.elm
Normal file
51
src/Interface/View.elm
Normal file
@ -0,0 +1,51 @@
|
||||
module Interface.View exposing (..)
|
||||
|
||||
import Html exposing (Html, div, span, text)
|
||||
import Palette exposing (classes)
|
||||
import Service.Model exposing (Interface, Record, Signature)
|
||||
import String.Interpolate exposing (interpolate)
|
||||
|
||||
|
||||
instanceView : Interface -> List (Html msg)
|
||||
instanceView interface =
|
||||
recordsView interface.record_types ++ signaturesView interface.function_signatures
|
||||
|
||||
|
||||
recordsView : List Record -> List (Html msg)
|
||||
recordsView record =
|
||||
record |> List.sortBy .name |> List.map recordView
|
||||
|
||||
|
||||
recordView : Record -> Html msg
|
||||
recordView record =
|
||||
div [ classes "i" ]
|
||||
([ span [ classes "fl w-100 mt2" ] [ text (record.name ++ " {") ] ]
|
||||
++ fieldsView record.fields
|
||||
++ [ span [ classes "fl w-100 mb2" ] [ text "}" ] ]
|
||||
)
|
||||
|
||||
|
||||
fieldsView : List (List String) -> List (Html msg)
|
||||
fieldsView fields =
|
||||
fields |> List.map (\f -> span [ classes "fl w-100 ml2" ] [ text (String.join ": " f) ])
|
||||
|
||||
|
||||
signaturesView : List Signature -> List (Html msg)
|
||||
signaturesView signatures =
|
||||
signatures |> List.sortBy .name |> List.map signatureView
|
||||
|
||||
|
||||
signatureView : Signature -> Html msg
|
||||
signatureView signature =
|
||||
div [ classes "i fl w-100 mv2" ]
|
||||
[ text (interpolate "fn {0}({1}) -> {2}" [ signature.name, argumentsToString signature.arguments, outputToString signature.output_types ]) ]
|
||||
|
||||
|
||||
argumentsToString : List (List String) -> String
|
||||
argumentsToString arguments =
|
||||
String.join ", " (arguments |> List.map (String.join ": "))
|
||||
|
||||
|
||||
outputToString : List String -> String
|
||||
outputToString output =
|
||||
output |> List.head |> Maybe.withDefault "void"
|
@ -26,8 +26,6 @@ import Route
|
||||
import Subscriptions exposing (subscriptions)
|
||||
import Update exposing (update)
|
||||
import Url
|
||||
import Url.Parser
|
||||
import Utils.TaskExtras exposing (run)
|
||||
import View exposing (view)
|
||||
|
||||
|
||||
@ -57,6 +55,7 @@ init flags url key =
|
||||
, discoveredPeers = Dict.empty
|
||||
, modules = Dict.empty
|
||||
, blueprints = Dict.empty
|
||||
, toggledInterface = Nothing
|
||||
}
|
||||
in
|
||||
( emptyModel, Route.routeCommand emptyModel r )
|
||||
|
@ -21,13 +21,13 @@ import Browser.Navigation as Nav
|
||||
import Dict exposing (Dict)
|
||||
import Modules.Model exposing (Module)
|
||||
import Nodes.Model exposing (Identify, emptyIdentify)
|
||||
import Services.Model exposing (Service)
|
||||
import Service.Model exposing (Service)
|
||||
import Url
|
||||
|
||||
|
||||
type Route
|
||||
= Page String
|
||||
| Service String
|
||||
| Blueprint String
|
||||
| Module String
|
||||
| Peer String
|
||||
|
||||
@ -54,4 +54,5 @@ type alias Model =
|
||||
, discoveredPeers : Dict String PeerData
|
||||
, modules : Dict String Module
|
||||
, blueprints : Dict String Blueprint
|
||||
, toggledInterface : Maybe String
|
||||
}
|
||||
|
@ -2,12 +2,11 @@ module ModulePage.View exposing (..)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, article, div, span, text)
|
||||
import Interface.View exposing (instanceView)
|
||||
import Model exposing (Model)
|
||||
import ModulePage.Model exposing (ModuleViewInfo)
|
||||
import Modules.Model exposing (Module)
|
||||
import Palette exposing (classes)
|
||||
import Services.Model exposing (Record, Signature)
|
||||
import String.Interpolate exposing (interpolate)
|
||||
|
||||
|
||||
view : Model -> String -> Html msg
|
||||
@ -64,45 +63,5 @@ viewInfo moduleInfo =
|
||||
, div [ classes "fl w-30 gray mv1" ] [ text "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-70 mv1" ] [ span [ classes "fl w-100 black" ] (recordsView moduleInfo.moduleInfo.interface.record_types ++ signaturesView moduleInfo.moduleInfo.interface.function_signatures) ]
|
||||
, div [ classes "fl w-70 mv1" ] [ span [ classes "fl w-100 black" ] (instanceView moduleInfo.moduleInfo.interface) ]
|
||||
]
|
||||
|
||||
|
||||
recordsView : List Record -> List (Html msg)
|
||||
recordsView record =
|
||||
record |> List.sortBy .name |> List.map recordView
|
||||
|
||||
|
||||
recordView : Record -> Html msg
|
||||
recordView record =
|
||||
div [ classes "i" ]
|
||||
([ span [ classes "fl w-100 mt2" ] [ text (record.name ++ " {") ] ]
|
||||
++ fieldsView record.fields
|
||||
++ [ span [ classes "fl w-100 mb2" ] [ text "}" ] ]
|
||||
)
|
||||
|
||||
|
||||
fieldsView : List (List String) -> List (Html msg)
|
||||
fieldsView fields =
|
||||
fields |> List.map (\f -> span [ classes "fl w-100 ml2" ] [ text (String.join ": " f) ])
|
||||
|
||||
|
||||
signaturesView : List Signature -> List (Html msg)
|
||||
signaturesView signatures =
|
||||
signatures |> List.sortBy .name |> List.map signatureView
|
||||
|
||||
|
||||
signatureView : Signature -> Html msg
|
||||
signatureView signature =
|
||||
div [ classes "i fl w-100 mv2" ]
|
||||
[ text (interpolate "fn {0}({1}) -> {2}" [ signature.name, argumentsToString signature.arguments, outputToString signature.output_types ]) ]
|
||||
|
||||
|
||||
argumentsToString : List (List String) -> String
|
||||
argumentsToString arguments =
|
||||
String.join ", " (arguments |> List.map (String.join ": "))
|
||||
|
||||
|
||||
outputToString : List String -> String
|
||||
outputToString output =
|
||||
output |> List.head |> Maybe.withDefault "void"
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Modules.Model exposing (..)
|
||||
|
||||
import Services.Model exposing (Interface)
|
||||
import Service.Model exposing (Interface)
|
||||
|
||||
|
||||
type alias Module =
|
||||
|
@ -11,4 +11,4 @@ type Msg
|
||||
| LinkClicked UrlRequest
|
||||
| AquamarineEvent Port.ReceiveEvent
|
||||
| RelayChanged String
|
||||
| Click String
|
||||
| ToggleInterface String
|
||||
|
@ -6,7 +6,7 @@ import Dict exposing (Dict)
|
||||
import Json.Encode exposing (Value)
|
||||
import Modules.Model exposing (Module)
|
||||
import Nodes.Model exposing (Identify)
|
||||
import Services.Model exposing (Service)
|
||||
import Service.Model exposing (Service)
|
||||
|
||||
|
||||
type alias SendParticle =
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Route exposing (..)
|
||||
|
||||
import AirScripts.DiscoverPeers as DiscoverPeers
|
||||
import BlueprintPage.View as BlueprintPage
|
||||
import Html exposing (Html, text)
|
||||
import HubPage.View as HubPage
|
||||
import Model exposing (Model, Route(..))
|
||||
@ -14,7 +15,7 @@ routeParser =
|
||||
oneOf
|
||||
[ map Peer (s "peer" </> string)
|
||||
, map Module (s "module" </> string)
|
||||
, map Service (s "service" </> string)
|
||||
, map Blueprint (s "blueprint" </> string)
|
||||
, map Page string
|
||||
]
|
||||
|
||||
@ -44,14 +45,13 @@ routeView model route =
|
||||
Peer peer ->
|
||||
text peer
|
||||
|
||||
Service serviceId ->
|
||||
text serviceId
|
||||
Blueprint id ->
|
||||
BlueprintPage.view model id
|
||||
|
||||
Module moduleName ->
|
||||
ModulePage.view model moduleName
|
||||
|
||||
|
||||
|
||||
routeCommand : Model -> Route -> Cmd msg
|
||||
routeCommand m r =
|
||||
case r of
|
||||
@ -61,7 +61,7 @@ routeCommand m r =
|
||||
Peer _ ->
|
||||
sendAir (DiscoverPeers.air m.peerId m.relayId)
|
||||
|
||||
Service string ->
|
||||
Blueprint string ->
|
||||
sendAir (DiscoverPeers.air m.peerId m.relayId)
|
||||
|
||||
Module string ->
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Services.Air exposing (..)
|
||||
module Service.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
@ -1,4 +1,4 @@
|
||||
module Services.Model exposing (..)
|
||||
module Service.Model exposing (..)
|
||||
|
||||
|
||||
type alias Signature =
|
||||
@ -26,10 +26,3 @@ type alias Service =
|
||||
, blueprint_id : String
|
||||
, interface : Interface
|
||||
}
|
||||
|
||||
|
||||
type alias ServiceInfo =
|
||||
{ name : String
|
||||
, author : String
|
||||
, instanceNumber : Int
|
||||
}
|
@ -28,7 +28,7 @@ import Msg exposing (..)
|
||||
import Nodes.Model exposing (Identify)
|
||||
import Port exposing (sendAir)
|
||||
import Route
|
||||
import Services.Model exposing (Service)
|
||||
import Service.Model exposing (Service)
|
||||
import Url
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ update msg model =
|
||||
cmd =
|
||||
Route.routeCommand model route
|
||||
in
|
||||
( { model | url = url, page = route }, cmd )
|
||||
( { model | url = url, page = route, toggledInterface = Nothing }, cmd )
|
||||
|
||||
LinkClicked urlRequest ->
|
||||
case urlRequest of
|
||||
@ -93,15 +93,8 @@ update msg model =
|
||||
in
|
||||
( model, Cmd.none )
|
||||
|
||||
Click command ->
|
||||
case command of
|
||||
"get_all" ->
|
||||
( model
|
||||
, sendAir (AirScripts.GetAll.air model.peerId model.relayId (Dict.keys model.discoveredPeers))
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model, Cmd.none )
|
||||
ToggleInterface id ->
|
||||
( { model | toggledInterface = Just id }, Cmd.none )
|
||||
|
||||
RelayChanged relayId ->
|
||||
( { model | relayId = relayId }, Cmd.none )
|
||||
|
@ -17,8 +17,8 @@ limitations under the License.
|
||||
-}
|
||||
|
||||
import Browser exposing (Document, UrlRequest(..))
|
||||
import Html exposing (Html, div, header, text)
|
||||
import Html.Events exposing (onClick)
|
||||
import Html exposing (Html, div, header)
|
||||
import Html.Attributes exposing (style)
|
||||
import Model exposing (Model, Route(..))
|
||||
import Msg exposing (..)
|
||||
import Palette exposing (classes)
|
||||
@ -39,15 +39,14 @@ body : Model -> Html Msg
|
||||
body model =
|
||||
layout <|
|
||||
List.concat
|
||||
[ [ header [ classes "w-100 bt bb b--black-10" ] [ routeView model model.page ] ]
|
||||
++ [ header [ classes "w-100 bt bb b--black-10", onClick (Click "get_all") ] [ text "GET ALL" ] ]
|
||||
[ [ header [ classes "w-100" ] [ routeView model model.page ] ]
|
||||
]
|
||||
|
||||
|
||||
layout : List (Html Msg) -> Html Msg
|
||||
layout elms =
|
||||
div [ classes "mw9 center w-70" ]
|
||||
[ div [ classes "fl w-100 pa2" ]
|
||||
[ div [ classes "fl w-100 pa2", style "font-family" "Roboto+Mono" ]
|
||||
([]
|
||||
++ elms
|
||||
)
|
||||
|
@ -8,3 +8,8 @@
|
||||
[data-elm-hot="true"] {
|
||||
height: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 48px;
|
||||
}
|
Reference in New Issue
Block a user