This commit is contained in:
DieMyst 2020-12-09 10:20:08 +03:00
parent 7c7768cbee
commit aca851004a
11 changed files with 85 additions and 56 deletions

View File

@ -3,12 +3,13 @@ module AirScripts.GetAll exposing (..)
import Air exposing (Air, callBI, fold, next, par, relayEvent, seq, set) import Air exposing (Air, callBI, fold, next, par, relayEvent, seq, set)
import Json.Encode exposing (list, string) import Json.Encode exposing (list, string)
askRelaySchema : Air askRelaySchema : Air
askRelaySchema = askRelaySchema =
(seq seq
(callBI "relayId" ( "op", "identity" ) [] Nothing) (callBI "relayId" ( "op", "identity" ) [] Nothing)
(askAllAndSend "relayId") (askAllAndSend "relayId")
)
askRelayScript : String -> String -> Air askRelayScript : String -> String -> Air
askRelayScript peerId relayId = askRelayScript peerId relayId =
@ -19,18 +20,19 @@ askRelayScript peerId relayId =
relayIdSet = relayIdSet =
set "relayId" <| string relayId set "relayId" <| string relayId
in in
clientIdSet <| relayIdSet <| askRelaySchema clientIdSet <| relayIdSet <| askRelaySchema
askPeersSchema : Air askPeersSchema : Air
askPeersSchema = askPeersSchema =
(fold "knownPeers" "p" <| fold "knownPeers" "p" <|
par par
(seq (seq
(callBI "p" ( "op", "identity" ) [] Nothing) (callBI "p" ( "op", "identity" ) [] Nothing)
(askAllAndSend "p") (askAllAndSend "p")
) )
(next "p") (next "p")
)
askPeersScript : String -> String -> List String -> Air askPeersScript : String -> String -> List String -> Air
askPeersScript peerId relayId peers = askPeersScript peerId relayId peers =
@ -44,7 +46,8 @@ askPeersScript peerId relayId peers =
peersSet = peersSet =
set "knownPeers" <| list string peers set "knownPeers" <| list string peers
in in
clientIdSet <| relayIdSet <| peersSet <| askPeersSchema clientIdSet <| relayIdSet <| peersSet <| askPeersSchema
findAndAskNeighboursSchema : Air findAndAskNeighboursSchema : Air
findAndAskNeighboursSchema = findAndAskNeighboursSchema =
@ -63,9 +66,11 @@ findAndAskNeighboursSchema =
) )
) )
(next "n") (next "n")
)) )
)
findAndAskNeighboursScript : String -> String ->Air
findAndAskNeighboursScript : String -> String -> Air
findAndAskNeighboursScript peerId relayId = findAndAskNeighboursScript peerId relayId =
let let
clientIdSet = clientIdSet =
@ -74,7 +79,8 @@ findAndAskNeighboursScript peerId relayId =
relayIdSet = relayIdSet =
set "relayId" <| string relayId set "relayId" <| string relayId
in in
clientIdSet <| relayIdSet <| findAndAskNeighboursSchema clientIdSet <| relayIdSet <| findAndAskNeighboursSchema
air : String -> String -> List String -> Air air : String -> String -> List String -> Air
air peerId relayId peers = air peerId relayId peers =
@ -88,23 +94,24 @@ air peerId relayId peers =
peersSet = peersSet =
set "knownPeers" <| list string peers set "knownPeers" <| list string peers
askRelay = (\innerAir -> askRelay =
\innerAir ->
par par
askRelaySchema askRelaySchema
innerAir innerAir
)
askPeers = (\innerAir -> askPeers =
\innerAir ->
par par
askPeersSchema askPeersSchema
innerAir innerAir
)
in in
clientIdSet <| relayIdSet <| peersSet <| (askRelay <| askPeers <| findAndAskNeighboursSchema) clientIdSet <| relayIdSet <| peersSet <| (askRelay <| askPeers <| findAndAskNeighboursSchema)
askAllAndSend : String -> Air askAllAndSend : String -> Air
askAllAndSend var = askAllAndSend var =
(seq seq
(callBI var ( "op", "identify" ) [] (Just "ident")) (callBI var ( "op", "identify" ) [] (Just "ident"))
(seq (seq
(callBI var ( "dist", "get_blueprints" ) [] (Just "blueprints")) (callBI var ( "dist", "get_blueprints" ) [] (Just "blueprints"))
@ -116,4 +123,3 @@ askAllAndSend var =
) )
) )
) )
)

View File

@ -39,8 +39,7 @@ view model id =
Nothing -> Nothing ->
div [ classes "cf ph2-ns" ] div [ classes "cf ph2-ns" ]
[ []
]
blueprintToInfo : Model -> String -> Maybe BlueprintViewInfo blueprintToInfo : Model -> String -> Maybe BlueprintViewInfo

View File

@ -36,11 +36,12 @@ view model =
viewService : BlueprintInfo -> Html msg viewService : BlueprintInfo -> Html msg
viewService blueprint = viewService blueprint =
div [ classes "fl w-100 w-third-ns pr3 lucida" ] div [ classes "fl w-100 w-third-ns pr3 lucida" ]
[ a [ attribute "href" ("/blueprint/" ++ blueprint.id) [ a
[ attribute "href" ("/blueprint/" ++ blueprint.id)
, classes "fl w-100 bg-white black mw6 mr3 mb3 hide-child pv3 pl4 br3 element-box ba b--white no-underline" , classes "fl w-100 bg-white black mw6 mr3 mb3 hide-child pv3 pl4 br3 element-box ba b--white no-underline"
] ]
[ div [ classes "w-100 mb3 pt1 b f3 overflow-hidden" ] [ text blueprint.name ] [ div [ classes "w-100 mb3 pt1 b f3 overflow-hidden" ] [ text blueprint.name ]
, div [ classes "w-100 mb4 fw4 gray-font" ] [ text "By ", span [classes "lucida-in normal"] [text blueprint.author] ] , div [ classes "w-100 mb4 fw4 gray-font" ] [ text "By ", span [ classes "lucida-in normal" ] [ text blueprint.author ] ]
, div [ classes "w-100 mt1 lucida gray-font" ] [ instancesText blueprint.instanceNumber ] , div [ classes "w-100 mt1 lucida gray-font" ] [ instancesText blueprint.instanceNumber ]
] ]
] ]

View File

@ -29,6 +29,7 @@ welcomeText =
[ span [] [ span []
[ text "Welcome to the Fluence Developer Hub! Start building with composing existing services or explore featured modules to create your custom services. Learn more about how to build applications in " [ text "Welcome to the Fluence Developer Hub! Start building with composing existing services or explore featured modules to create your custom services. Learn more about how to build applications in "
, a [ attribute "href" "https://fluence-labs.readme.io/docs" ] [ text "Documentation" ] , a [ attribute "href" "https://fluence-labs.readme.io/docs" ] [ text "Documentation" ]
--, text " and " --, text " and "
--, a [ attribute "href" "/" ] [ text "Tutorials" ] --, a [ attribute "href" "/" ] [ text "Tutorials" ]
, text "." , text "."

View File

@ -1,30 +1,32 @@
module Info exposing (..) module Info exposing (..)
import Dict exposing (Dict) import Dict exposing (Dict)
type alias ModuleDescription = type alias ModuleDescription =
{ site: String { site : String
, description: String , description : String
} }
getSite : String -> String getSite : String -> String
getSite name = getSite name =
modulesDescription |> Dict.get name |> Maybe.map .site |> Maybe.withDefault "" modulesDescription |> Dict.get name |> Maybe.map .site |> Maybe.withDefault ""
getDescription : String -> String getDescription : String -> String
getDescription name = getDescription name =
modulesDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault "Awesome module without description" modulesDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault "Awesome module without description"
modulesDescription : Dict String ModuleDescription modulesDescription : Dict String ModuleDescription
modulesDescription = modulesDescription =
Dict.fromList Dict.fromList
[ ("sqlite3", { site = "https://github.com/fluencelabs/sqlite", description = "A database that ported on Wasm"}) [ ( "sqlite3", { site = "https://github.com/fluencelabs/sqlite", description = "A database that ported on Wasm" } )
, ("history", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/history", description = "Middleware that stores history (i.e. chat messages) in sqlite"}) , ( "history", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/history", description = "Middleware that stores history (i.e. chat messages) in sqlite" } )
, ("user-list", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/user-list", description = "Middleware that stores users with their auth (i.e. chat members) in sqlite"}) , ( "user-list", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/user-list", description = "Middleware that stores users with their auth (i.e. chat members) in sqlite" } )
, ("redis", { site = "https://github.com/fluencelabs/redis", description = "A database that ported on Wasm"}) , ( "redis", { site = "https://github.com/fluencelabs/redis", description = "A database that ported on Wasm" } )
, ("curl", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/curl", description = "Module that call 'curl' command"}) , ( "curl", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/curl", description = "Module that call 'curl' command" } )
, ("facade", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "An API facade for Url-Downloader app"}) , ( "facade", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "An API facade for Url-Downloader app" } )
, ("local_storage", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/local_storage", description = "Could be used to store data"}) , ( "local_storage", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/local_storage", description = "Could be used to store data" } )
] ]

View File

@ -17,9 +17,11 @@ toInstance peerId identify blueprints service =
bp = bp =
blueprints |> Dict.get service.blueprint_id blueprints |> Dict.get service.blueprint_id
name = bp |> Maybe.map .name |> Maybe.withDefault "unknown" name =
bp |> Maybe.map .name |> Maybe.withDefault "unknown"
blueprintId = bp |> Maybe.map .id |> Maybe.withDefault "#" blueprintId =
bp |> Maybe.map .id |> Maybe.withDefault "#"
ip = ip =
List.head identify.external_addresses List.head identify.external_addresses
@ -69,8 +71,8 @@ viewTable instances =
viewInstance : Instance -> Html msg viewInstance : Instance -> Html msg
viewInstance instance = viewInstance instance =
tr [ classes "table-red-row" ] tr [ classes "table-red-row" ]
[ td [ classes "ph3" ] [ p [classes "ws-normal"] [ a [ attribute "href" ("/blueprint/" ++ instance.blueprintId), classes "black" ] [text instance.name ]]] [ td [ classes "ph3" ] [ p [ classes "ws-normal" ] [ a [ attribute "href" ("/blueprint/" ++ instance.blueprintId), classes "black" ] [ text instance.name ] ] ]
, td [ classes "ph3" ] [ p [classes "ws-normal"] [text instance.instance ]] , td [ classes "ph3" ] [ p [ classes "ws-normal" ] [ text instance.instance ] ]
, td [ classes "ph3 dn dtc-ns" ] [ p [classes "ws-normal"] [text (shortHashRaw 8 instance.peerId) ]] , td [ classes "ph3 dn dtc-ns" ] [ p [ classes "ws-normal" ] [ text (shortHashRaw 8 instance.peerId) ] ]
, td [ classes "ph3 dn dtc-ns" ] [ p [classes "ws-normal"] [text instance.ip ]] , td [ classes "ph3 dn dtc-ns" ] [ p [ classes "ws-normal" ] [ text instance.ip ] ]
] ]

View File

@ -39,8 +39,9 @@ signatureView : Signature -> Html msg
signatureView signature = signatureView signature =
div [ classes "i f6 fl w-100 mv2" ] div [ classes "i f6 fl w-100 mv2" ]
[ text "fn " [ text "fn "
, span [classes "fw5"] [text signature.name] , span [ classes "fw5" ] [ text signature.name ]
, text (interpolate "({0}) -> {1}" [ argumentsToString signature.arguments, outputToString signature.output_types ]) ] , text (interpolate "({0}) -> {1}" [ argumentsToString signature.arguments, outputToString signature.output_types ])
]
argumentsToString : List (List String) -> String argumentsToString : List (List String) -> String

View File

@ -42,8 +42,7 @@ view model id =
Nothing -> Nothing ->
div [ classes "cf ph2-ns" ] div [ classes "cf ph2-ns" ]
[ []
]
moduleToInfo : Dict String Module -> String -> Maybe ModuleViewInfo moduleToInfo : Dict String Module -> String -> Maybe ModuleViewInfo
@ -71,9 +70,14 @@ moduleToInfo modules id =
in in
info info
resString = String.fromChar (Char.fromCode 160)
empty = span [ ] [ text resString ] resString =
String.fromChar (Char.fromCode 160)
empty =
span [] [ text resString ]
viewInfo : ModuleViewInfo -> Html msg viewInfo : ModuleViewInfo -> Html msg
viewInfo moduleInfo = viewInfo moduleInfo =
@ -83,7 +87,12 @@ viewInfo moduleInfo =
[ span [ classes "fl w-100 black b lucida" ] [ text moduleInfo.author ] ] [ span [ classes "fl w-100 black b lucida" ] [ text moduleInfo.author ] ]
, div [ classes "fl w-100 w-20-ns gray mv3" ] [ text "WEBSITE" ] , div [ classes "fl w-100 w-20-ns gray mv3" ] [ text "WEBSITE" ]
, div [ classes "fl w-100 w-80-ns mv3 lucida" ] , div [ classes "fl w-100 w-80-ns mv3 lucida" ]
[ if moduleInfo.website == "" then empty else a [ attribute "href" moduleInfo.website, classes "fl w-100 fluence-red" ] [ text moduleInfo.website ] ] [ if moduleInfo.website == "" then
empty
else
a [ attribute "href" moduleInfo.website, classes "fl w-100 fluence-red" ] [ text moduleInfo.website ]
]
, div [ classes "fl w-100 w-20-ns gray mv3" ] [ text "DESCRIPTION" ] , div [ classes "fl w-100 w-20-ns gray mv3" ] [ text "DESCRIPTION" ]
, div [ classes "fl w-100 w-80-ns mv3 lucida" ] , div [ classes "fl w-100 w-80-ns mv3 lucida" ]
[ span [ classes "fl w-100 black", property "innerHTML" (string "&nbsp;123") ] [ text moduleInfo.description ] ] [ span [ classes "fl w-100 black", property "innerHTML" (string "&nbsp;123") ] [ text moduleInfo.description ] ]

View File

@ -12,9 +12,9 @@ import Utils.Utils exposing (instancesText)
getModuleShortInfo : Model -> List ModuleShortInfo getModuleShortInfo : Model -> List ModuleShortInfo
getModuleShortInfo model = getModuleShortInfo model =
getAllModules model.modules model.discoveredPeers |> getAllModules model.modules model.discoveredPeers
Dict.toList |> |> Dict.toList
List.map (\( _, ( moduleInfo, peers ) ) -> { moduleInfo = moduleInfo, instanceNumber = List.length peers }) |> List.map (\( _, ( moduleInfo, peers ) ) -> { moduleInfo = moduleInfo, instanceNumber = List.length peers })
getAllModules : Dict String Module -> Dict String PeerData -> Dict String ( Module, List String ) getAllModules : Dict String Module -> Dict String PeerData -> Dict String ( Module, List String )
@ -62,12 +62,14 @@ view modules =
viewService : ModuleShortInfo -> Html msg viewService : ModuleShortInfo -> Html msg
viewService moduleInfo = viewService moduleInfo =
div [ classes "fl w-100 w-third-ns pr3" ] div [ classes "fl w-100 w-third-ns pr3" ]
[ a [ attribute "href" ("/module/" ++ moduleInfo.moduleInfo.name), [ a
classes "fl w-100 bg-white black mw6 mr2 mb3 hide-child pa2 element-box ba b--white pl3" ] [ attribute "href" ("/module/" ++ moduleInfo.moduleInfo.name)
, classes "fl w-100 bg-white black mw6 mr2 mb3 hide-child pa2 element-box ba b--white pl3"
]
[ p [ classes "tl di" ] [ p [ classes "tl di" ]
[ div [ classes "fl b w-100 mb1 fw5 overflow-hidden" ] [ div [ classes "fl b w-100 mb1 fw5 overflow-hidden" ]
[ text moduleInfo.moduleInfo.name ] [ text moduleInfo.moduleInfo.name ]
, div [ classes "fl w-100 mt1 lucida gray-font2" ] [ instancesText moduleInfo.instanceNumber ] , div [ classes "fl w-100 mt1 lucida gray-font2" ] [ instancesText moduleInfo.instanceNumber ]
] ]
] ]
] ]

View File

@ -48,6 +48,7 @@ routeView model route =
Module moduleName -> Module moduleName ->
ModulePage.view model moduleName ModulePage.view model moduleName
getAllCmd : String -> String -> List String -> Cmd msg getAllCmd : String -> String -> List String -> Cmd msg
getAllCmd peerId relayId knownPeers = getAllCmd peerId relayId knownPeers =
Cmd.batch Cmd.batch
@ -56,6 +57,7 @@ getAllCmd peerId relayId knownPeers =
, sendAir (GetAll.findAndAskNeighboursScript peerId relayId) , sendAir (GetAll.findAndAskNeighboursScript peerId relayId)
] ]
routeCommand : Model -> Route -> Cmd msg routeCommand : Model -> Route -> Cmd msg
routeCommand m r = routeCommand m r =
case r of case r of

View File

@ -41,16 +41,20 @@ body model =
List.concat List.concat
[ [ header [ classes "w-100" ] [ [ header [ classes "w-100" ]
[ div [ classes "w-100 fl pv2 bg-white one-edge-shadow" ] [ div [ classes "w-100 fl pv2 bg-white one-edge-shadow" ]
[ div [ classes "mw8-ns center ph3"] [ div [ classes "mw8-ns center ph3" ]
[ div [ classes "fl mv1 pl3" ] [ div [ classes "fl mv1 pl3" ]
[ a [ attribute "href" "/" ] [ a [ attribute "href" "/" ]
[ img [ classes "mw-100", style "height" "30px" [ img
, attribute "src" "/images/logo_new.svg" [ classes "mw-100"
, style "position" "relative" , style "height" "30px"
, style "top" "0.16rem" ] [] , attribute "src" "/images/logo_new.svg"
, style "position" "relative"
, style "top" "0.16rem"
]
[]
] ]
] ]
, div [ classes "fl pl5 h-auto" ] [ p [ classes "h-100 m-auto fw4" ] [ text "Developer Hub" ] ] , div [ classes "fl pl5 h-auto" ] [ p [ classes "h-100 m-auto fw4" ] [ a [ attribute "href" "/", classes "link black" ] [ text "Developer Hub" ] ] ]
] ]
] ]
] ]