dashboard/src/Port.elm

35 lines
884 B
Elm
Raw Normal View History

2020-11-23 14:27:33 +03:00
port module Port exposing (..)
2020-11-23 15:44:45 +03:00
import Air exposing (Air(..))
2020-11-26 21:47:37 +03:00
import Blueprints.Model exposing (Blueprint)
2020-11-23 14:27:33 +03:00
import Dict exposing (Dict)
import Json.Encode exposing (Value)
2020-11-26 21:47:37 +03:00
import Nodes.Model exposing (Identify)
import Services.Model exposing (Service)
2020-11-23 14:27:33 +03:00
2020-11-23 15:44:45 +03:00
type alias SendParticle =
{ script : String, data : Value }
2020-11-23 14:27:33 +03:00
2020-11-23 15:44:45 +03:00
type alias ReceiveEvent =
2020-11-30 14:31:03 +03:00
{ name : String, peer : String, peers : Maybe (List String), identify : Maybe Identify, services : Maybe (List Service), modules : Maybe (List String), blueprints : Maybe (List Blueprint) }
2020-11-23 14:27:33 +03:00
2020-11-23 15:44:45 +03:00
port sendParticle : SendParticle -> Cmd msg
port eventReceiver : (ReceiveEvent -> msg) -> Sub msg
port relayChanged : (String -> msg) -> Sub msg
sendAir : Air -> Cmd msg
2020-11-23 14:27:33 +03:00
sendAir (Air dataDict script) =
let
2020-11-23 15:44:45 +03:00
data =
Json.Encode.object <| Dict.toList dataDict
2020-11-23 14:27:33 +03:00
in
2020-11-23 15:44:45 +03:00
sendParticle { script = script, data = data }