Basic ui for addons

This commit is contained in:
eikek
2022-05-08 14:01:41 +02:00
parent 7fdd78ad06
commit 73747c4ea3
33 changed files with 2881 additions and 13 deletions

View File

@ -5,15 +5,34 @@
-}
module Data.ServerEvent exposing (ServerEvent(..), decode)
module Data.ServerEvent exposing (AddonInfo, ServerEvent(..), decode)
import Json.Decode as D
import Json.Decode.Pipeline as P
type ServerEvent
= JobSubmitted String
| JobDone String
| JobsWaiting Int
| AddonInstalled AddonInfo
type alias AddonInfo =
{ success : Bool
, addonId : Maybe String
, addonUrl : Maybe String
, message : String
}
addonInfoDecoder : D.Decoder AddonInfo
addonInfoDecoder =
D.succeed AddonInfo
|> P.required "success" D.bool
|> P.optional "addonId" (D.maybe D.string) Nothing
|> P.optional "addonUrl" (D.maybe D.string) Nothing
|> P.required "message" D.string
decoder : D.Decoder ServerEvent
@ -43,5 +62,9 @@ decodeTag tag =
D.field "content" D.int
|> D.map JobsWaiting
"addon-installed" ->
D.field "content" addonInfoDecoder
|> D.map AddonInstalled
_ ->
D.fail ("Unknown tag: " ++ tag)