port forwarding is working
This commit is contained in:
parent
0829e0f03f
commit
7fadc22ce0
|
@ -23,9 +23,14 @@ serve:
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
elm-go src/Main.elm \
|
elm-go src/Main.elm \
|
||||||
--dir=../public \
|
--dir=../public \
|
||||||
--start-page=index.html \
|
--port=8000 \
|
||||||
|
--start-page=../public/index.html \
|
||||||
--host=localhost \
|
--host=localhost \
|
||||||
-- --debug
|
--proxy-prefix=/ \
|
||||||
|
--proxy-host=http://localhost:8080 \
|
||||||
|
-- \
|
||||||
|
--debug \
|
||||||
|
--output=../public/elm.min.js
|
||||||
else ifeq ($(RELEASE),1)
|
else ifeq ($(RELEASE),1)
|
||||||
$(error Cannot use serve target with RELEASE=1)
|
$(error Cannot use serve target with RELEASE=1)
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,28 +1,30 @@
|
||||||
module Page.Landing exposing
|
module Page.Landing exposing
|
||||||
( Model
|
( Model
|
||||||
, Msg
|
, Msg
|
||||||
, view
|
|
||||||
, init
|
, init
|
||||||
, update
|
|
||||||
, subscriptions
|
, subscriptions
|
||||||
|
, update
|
||||||
|
, view
|
||||||
)
|
)
|
||||||
|
|
||||||
import Element exposing (Element)
|
import Element exposing (Element)
|
||||||
import Websockets
|
import Element.Background
|
||||||
import Ports
|
import Element.Input
|
||||||
|
import EncodeDecode
|
||||||
|
import Html.Attributes exposing (placeholder)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode as Encode exposing (Value)
|
import Json.Encode as Encode exposing (Value)
|
||||||
import Html.Attributes exposing (placeholder)
|
import Ports
|
||||||
import Element.Input
|
import Websockets
|
||||||
import Element.Background
|
|
||||||
|
|
||||||
import EncodeDecode
|
|
||||||
|
|
||||||
type alias Model = {
|
type alias Model =
|
||||||
time : String,
|
{ time : String
|
||||||
greetWidgetText : String,
|
, greetWidgetText : String
|
||||||
greeting : String
|
, greeting : String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= DownMsg EncodeDecode.DownMsg
|
= DownMsg EncodeDecode.DownMsg
|
||||||
| UpMsg EncodeDecode.LandingUpMsg
|
| UpMsg EncodeDecode.LandingUpMsg
|
||||||
|
@ -30,15 +32,17 @@ type Msg
|
||||||
| GreetWidgetText String
|
| GreetWidgetText String
|
||||||
| NoOp
|
| NoOp
|
||||||
|
|
||||||
init : () -> (Model, Cmd Msg)
|
|
||||||
init flags = (
|
init : () -> ( Model, Cmd Msg )
|
||||||
{ time = "time not yet set"
|
init flags =
|
||||||
, greetWidgetText = ""
|
( { time = "time not yet set"
|
||||||
, greeting = ""
|
, greetWidgetText = ""
|
||||||
},
|
, greeting = ""
|
||||||
Cmd.none
|
}
|
||||||
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
subscriptions : Model -> Sub Msg
|
subscriptions : Model -> Sub Msg
|
||||||
subscriptions model =
|
subscriptions model =
|
||||||
Ports.socketOnEvent
|
Ports.socketOnEvent
|
||||||
|
@ -48,66 +52,91 @@ subscriptions model =
|
||||||
(\_ -> NoOp)
|
(\_ -> NoOp)
|
||||||
(\message ->
|
(\message ->
|
||||||
case Decode.decodeString EncodeDecode.downMsgDecoder message.data of
|
case Decode.decodeString EncodeDecode.downMsgDecoder message.data of
|
||||||
Ok msg -> DownMsg msg
|
Ok msg ->
|
||||||
Err err -> DecodeError err
|
DownMsg msg
|
||||||
|
|
||||||
|
Err err ->
|
||||||
|
DecodeError err
|
||||||
)
|
)
|
||||||
(\_ -> NoOp)
|
(\_ -> NoOp)
|
||||||
)
|
)
|
||||||
|
|
||||||
update : Msg -> Model -> (Model, Cmd Msg)
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
case msg of
|
||||||
DownMsg (EncodeDecode.LandingDownMsg (EncodeDecode.TimeUpdate time)) ->
|
DownMsg (EncodeDecode.LandingDownMsg (EncodeDecode.TimeUpdate time)) ->
|
||||||
( {model | time = time}, Cmd.none )
|
( { model | time = time }, Cmd.none )
|
||||||
DownMsg (EncodeDecode.LandingDownMsg (EncodeDecode.Greeting greeting)) ->
|
|
||||||
( {model | greeting = greeting}, Cmd.none)
|
DownMsg (EncodeDecode.LandingDownMsg (EncodeDecode.Greeting greeting)) ->
|
||||||
UpMsg upMsg ->
|
( { model | greeting = greeting }, Cmd.none )
|
||||||
let cmd = Ports.socketSend <| EncodeDecode.upMsgEncoder <| EncodeDecode.LandingUpMsg upMsg
|
|
||||||
in
|
UpMsg upMsg ->
|
||||||
(model, cmd)
|
let
|
||||||
|
cmd =
|
||||||
|
Ports.socketSend <| EncodeDecode.upMsgEncoder <| EncodeDecode.LandingUpMsg upMsg
|
||||||
|
in
|
||||||
|
( model, cmd )
|
||||||
|
|
||||||
|
GreetWidgetText text ->
|
||||||
|
( { model | greetWidgetText = text }, Cmd.none )
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
GreetWidgetText text -> ( {model | greetWidgetText = text}, Cmd.none )
|
|
||||||
_ -> (model, Cmd.none)
|
|
||||||
|
|
||||||
greetWidget : Model -> Element Msg
|
greetWidget : Model -> Element Msg
|
||||||
greetWidget model =
|
greetWidget model =
|
||||||
let
|
let
|
||||||
idleBlue = Element.rgb255 18 147 217
|
idleBlue =
|
||||||
focusBlue = Element.rgb255 18 125 184
|
Element.rgb255 18 147 217
|
||||||
|
|
||||||
|
focusBlue =
|
||||||
|
Element.rgb255 18 125 184
|
||||||
|
|
||||||
|
myButton =
|
||||||
|
Element.Input.button
|
||||||
|
[ Element.Background.color idleBlue
|
||||||
|
, Element.mouseOver [ Element.Background.color focusBlue ]
|
||||||
|
, Element.width (Element.fill |> Element.maximum 100)
|
||||||
|
, Element.height (Element.fill |> Element.maximum 50)
|
||||||
|
]
|
||||||
|
{ onPress = Just <| UpMsg <| EncodeDecode.RequestGreet model.greetWidgetText
|
||||||
|
, label = Element.text "Greet"
|
||||||
|
}
|
||||||
|
|
||||||
|
placeholder =
|
||||||
|
case model.greetWidgetText of
|
||||||
|
"" ->
|
||||||
|
Just <| Element.Input.placeholder [] <| Element.text "Type Your Name"
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Just <| Element.Input.placeholder [] <| Element.text ""
|
||||||
|
|
||||||
myButton = Element.Input.button
|
|
||||||
[ Element.Background.color idleBlue
|
|
||||||
, Element.mouseOver [Element.Background.color focusBlue]
|
|
||||||
, Element.width (Element.fill |> Element.maximum 100)
|
|
||||||
, Element.height (Element.fill |> Element.maximum 50)
|
|
||||||
]
|
|
||||||
{ onPress = Just <| UpMsg <| EncodeDecode.RequestGreet model.greetWidgetText
|
|
||||||
, label = Element.text "Greet"
|
|
||||||
}
|
|
||||||
placeholder = case model.greetWidgetText of
|
|
||||||
"" -> Just <| Element.Input.placeholder [] <| Element.text "Type Your Name"
|
|
||||||
_ -> Just <| Element.Input.placeholder [] <| Element.text ""
|
|
||||||
textInput =
|
textInput =
|
||||||
Element.Input.text
|
Element.Input.text
|
||||||
[ Element.width (Element.fill |> Element.maximum 400)
|
[ Element.width (Element.fill |> Element.maximum 400)
|
||||||
, Element.height Element.fill
|
, Element.height Element.fill
|
||||||
]
|
]
|
||||||
{ onChange = GreetWidgetText
|
{ onChange = GreetWidgetText
|
||||||
, text = model.greetWidgetText
|
, text = model.greetWidgetText
|
||||||
, placeholder = placeholder
|
, placeholder = placeholder
|
||||||
, label = Element.Input.labelHidden "Enter your name"
|
, label = Element.Input.labelHidden "Enter your name"
|
||||||
}
|
}
|
||||||
nameInput = Element.row [] [ textInput , myButton]
|
|
||||||
|
nameInput =
|
||||||
|
Element.row [] [ textInput, myButton ]
|
||||||
in
|
in
|
||||||
Element.column []
|
Element.column []
|
||||||
[ nameInput
|
[ nameInput
|
||||||
, Element.text model.greeting
|
, Element.text model.greeting
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
view : Model -> Element Msg
|
view : Model -> Element Msg
|
||||||
view model =
|
view model =
|
||||||
Element.column []
|
Element.column []
|
||||||
[ Element.text "Landing"
|
[ Element.text "Landing..."
|
||||||
, Element.text <| "Current time is : " ++ model.time
|
, Element.text <| "Current time is : " ++ model.time
|
||||||
, greetWidget model
|
, greetWidget model
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue