|
|
|
@ -4,10 +4,13 @@ import Browser
|
|
|
|
|
import Browser.Navigation as Nav
|
|
|
|
|
import Html exposing (..)
|
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
|
import Html.Events exposing (onClick, onInput)
|
|
|
|
|
import Model exposing (Model)
|
|
|
|
|
import Navigation
|
|
|
|
|
import Random
|
|
|
|
|
import Url
|
|
|
|
|
import Url.Parser
|
|
|
|
|
import WsMessage exposing (createSession)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main =
|
|
|
|
@ -59,6 +62,75 @@ type Msg
|
|
|
|
|
| LinkClicked Browser.UrlRequest
|
|
|
|
|
| WsIn String
|
|
|
|
|
| WsOut String
|
|
|
|
|
| CreateRetro
|
|
|
|
|
| CreatePoker
|
|
|
|
|
| NameChanged String
|
|
|
|
|
| NameGenerated ScrambledName
|
|
|
|
|
| RandomizeName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- BOOT TIME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type alias ScrambledName =
|
|
|
|
|
{ prefix : String
|
|
|
|
|
, suffix : String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
randomUserName : Cmd Msg
|
|
|
|
|
randomUserName =
|
|
|
|
|
let
|
|
|
|
|
prefixes =
|
|
|
|
|
[ "Joyful"
|
|
|
|
|
, "Squiddly"
|
|
|
|
|
, "Fast"
|
|
|
|
|
, "Tinkering"
|
|
|
|
|
, "Freezy"
|
|
|
|
|
, "Warm-To-The-Touch"
|
|
|
|
|
, "Red"
|
|
|
|
|
, "Pale"
|
|
|
|
|
, "Hardy"
|
|
|
|
|
, "Hardened"
|
|
|
|
|
, "Rocky"
|
|
|
|
|
, "Pokey"
|
|
|
|
|
, "Screeching"
|
|
|
|
|
, "Sweet"
|
|
|
|
|
, "Grumpy"
|
|
|
|
|
, "Tempered"
|
|
|
|
|
, "Bendy"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
suffixes =
|
|
|
|
|
[ "Rock"
|
|
|
|
|
, "Impala"
|
|
|
|
|
, "Liliac"
|
|
|
|
|
, "Bike"
|
|
|
|
|
, "Tinker"
|
|
|
|
|
, "Red"
|
|
|
|
|
, "Green"
|
|
|
|
|
, "Squid"
|
|
|
|
|
, "Sponge"
|
|
|
|
|
, "Star"
|
|
|
|
|
, "Fish"
|
|
|
|
|
, "Tandem"
|
|
|
|
|
, "Ground dweller"
|
|
|
|
|
, "Bird"
|
|
|
|
|
, "Ice cream"
|
|
|
|
|
, "Brush"
|
|
|
|
|
, "Highborn"
|
|
|
|
|
]
|
|
|
|
|
in
|
|
|
|
|
Random.generate NameGenerated
|
|
|
|
|
(Random.map2 ScrambledName
|
|
|
|
|
(Random.uniform "Chuck" prefixes)
|
|
|
|
|
(Random.uniform "Norris" suffixes)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- UPDATE PART
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
|
|
@ -77,19 +149,39 @@ update msg model =
|
|
|
|
|
-- TODO error reporting
|
|
|
|
|
( { model | route = Navigation.Home }, Cmd.none )
|
|
|
|
|
|
|
|
|
|
-- WEBSOCKETS
|
|
|
|
|
WsOut wsmsg ->
|
|
|
|
|
( model, wsout wsmsg )
|
|
|
|
|
|
|
|
|
|
WsIn strmsg ->
|
|
|
|
|
( model, Cmd.none )
|
|
|
|
|
|
|
|
|
|
-- INIT
|
|
|
|
|
NameChanged name ->
|
|
|
|
|
( { model | userName = name }, Cmd.none )
|
|
|
|
|
|
|
|
|
|
NameGenerated scrambled ->
|
|
|
|
|
( { model | userName = scrambled.prefix ++ " " ++ scrambled.suffix }, Cmd.none )
|
|
|
|
|
|
|
|
|
|
RandomizeName ->
|
|
|
|
|
( model, randomUserName )
|
|
|
|
|
|
|
|
|
|
-- RETRO
|
|
|
|
|
CreateRetro ->
|
|
|
|
|
Debug.todo "implement create retro"
|
|
|
|
|
|
|
|
|
|
-- POKER
|
|
|
|
|
CreatePoker ->
|
|
|
|
|
Debug.log (createSession model)
|
|
|
|
|
( model, wsout (createSession model) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routeChanged : Navigation.Route -> Model -> ( Model, Cmd Msg )
|
|
|
|
|
routeChanged route model =
|
|
|
|
|
case route of
|
|
|
|
|
Navigation.Home ->
|
|
|
|
|
( { model | route = route }
|
|
|
|
|
, Cmd.none
|
|
|
|
|
, randomUserName
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Navigation.Poker session ->
|
|
|
|
@ -98,6 +190,10 @@ routeChanged route model =
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- HTML STUFF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view : Model -> Browser.Document Msg
|
|
|
|
|
view model =
|
|
|
|
|
{ title = "Open-Retro"
|
|
|
|
@ -106,11 +202,24 @@ view model =
|
|
|
|
|
[ h1 [ class "app-title" ] [ text "Open-Retro" ]
|
|
|
|
|
, ul []
|
|
|
|
|
[ li []
|
|
|
|
|
[ input [ class "board-search-input", placeholder "Session ID..." ] [] ]
|
|
|
|
|
[ input [ onInput NameChanged, value model.userName ]
|
|
|
|
|
[]
|
|
|
|
|
]
|
|
|
|
|
, li []
|
|
|
|
|
[ button
|
|
|
|
|
[ onClick RandomizeName ]
|
|
|
|
|
[ text "🎲" ]
|
|
|
|
|
]
|
|
|
|
|
, li []
|
|
|
|
|
[ text "🂿 New retro" ]
|
|
|
|
|
[ button
|
|
|
|
|
[ onClick CreateRetro ]
|
|
|
|
|
[ text "🂿 New retro" ]
|
|
|
|
|
]
|
|
|
|
|
, li []
|
|
|
|
|
[ text "🃠 New poker" ]
|
|
|
|
|
[ button
|
|
|
|
|
[ onClick CreatePoker ]
|
|
|
|
|
[ text "🃠 New poker" ]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
, main_ [] (appContent model)
|
|
|
|
|