Skip to content

Commit

Permalink
Immediate pause/resume button toggling
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcloutier committed Feb 11, 2016
1 parent 6148bf4 commit cd76d6d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use Mix.Config
# watchers to your application. For example, we use it
# with brunch.io to recompile .js and .css sources.
config :ev3, Ev3.Endpoint,
url: [host: "192.168.1.100"],
# url: [host: "192.168.1.100"],
http: [port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
watchers: []
# watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]]
# watchers: []
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]]

# Watch static and templates for browser reloading.
config :ev3, Ev3.Endpoint,
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ defmodule Ev3.Mixfile do
def application do
[mod: {Ev3, []},
applications: [:phoenix, :phoenix_html, :cowboy, :logger],
# env: [{:mock, true}, {:platform, :dev}] # platform in [:brickpi, :ev3, :dev]
env: [{:mock, false}, {:platform, :ev3}] # platform in [:brickpi, :ev3, :dev]
env: [{:mock, true}, {:platform, :dev}] # platform in [:brickpi, :ev3, :dev]
# env: [{:mock, false}, {:platform, :ev3}] # platform in [:brickpi, :ev3, :dev]
# env: [{:mock, false}, {:platform, :brickpi}] # platform in [:brickpi, :ev3, :dev]
]
end
Expand Down
4 changes: 2 additions & 2 deletions web/elm/src/RobotConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module RobotConfig where

hostname: String
hostname =
-- "localhost"
"192.168.1.100"
"localhost"
-- "192.168.1.100"
-- Also update /mix.exs and /config/dev.exs
10 changes: 9 additions & 1 deletion web/elm/src/Status/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Status.Model as Model exposing (Model, RuntimeStats, ActiveState)
type Action =
NoOp (Maybe String)
| SetPaused (Maybe Bool)
| SwitchPaused
| SetActive ActiveState
| TogglePaused
| SetRuntimeStats RuntimeStats
Expand All @@ -28,6 +29,8 @@ update action model =
Maybe.withDefault model.paused maybePaused
in
({model | paused = result}, Effects.none)
SwitchPaused ->
({model | paused = not model.paused}, Effects.none)
SetActive activeState ->
({model | active = activeState.active}, Effects.none)
TogglePaused ->
Expand All @@ -47,7 +50,7 @@ togglePaused =
|> Task.map NoOp
|> Effects.task)
in
Effects.batch [togglePausedEffect, fetchPaused]
Effects.batch [togglePausedEffect, switchPaused]

fetchPaused: Effects Action
fetchPaused =
Expand All @@ -56,6 +59,11 @@ fetchPaused =
|> Task.map SetPaused
|> Effects.task

switchPaused: Effects Action
switchPaused =
Task.succeed SwitchPaused
|> Effects.task

decodePaused: Json.Decoder Bool
decodePaused =
"paused" := Json.bool
Expand Down

0 comments on commit cd76d6d

Please sign in to comment.