dashboard/src/Port.elm

36 lines
922 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-12-01 14:03:25 +03:00
import Modules.Model exposing (Module)
2020-11-26 21:47:37 +03:00
import Nodes.Model exposing (Identify)
2020-12-01 17:47:52 +03:00
import Service.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-12-01 14:03:25 +03:00
{ name : String, peer : String, peers : Maybe (List String), identify : Maybe Identify, services : Maybe (List Service), modules : Maybe (List Module), 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 }