summaryrefslogtreecommitdiff
path: root/elm3/UVNList/Status.elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-12-30 09:49:13 +0100
committerYorhel <git@yorhel.nl>2019-12-30 09:49:13 +0100
commitd79c982ee876502db2e1a12752667c6a198c2ddc (patch)
treeccd4a4e72e5b0d3dd412bed6aee58044e93893f0 /elm3/UVNList/Status.elm
parente146ed7bda12d369532e485ca0c2e3d823811854 (diff)
Actually, let's get rid of v3 now that it doesn't work anymore anyway
Diffstat (limited to 'elm3/UVNList/Status.elm')
-rw-r--r--elm3/UVNList/Status.elm77
1 files changed, 0 insertions, 77 deletions
diff --git a/elm3/UVNList/Status.elm b/elm3/UVNList/Status.elm
deleted file mode 100644
index 7a2782d2..00000000
--- a/elm3/UVNList/Status.elm
+++ /dev/null
@@ -1,77 +0,0 @@
-module UVNList.Status exposing (main)
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-import Json.Encode as JE
-import Browser
-import Lib.Api as Api
-import Lib.Html exposing (..)
-import Lib.Util exposing (lookup)
-import Lib.Gen as Gen
-
-
-main : Program Flags Model Msg
-main = Browser.element
- { init = \f -> (init f, Cmd.none)
- , subscriptions = always Sub.none
- , view = view
- , update = update
- }
-
-type alias Flags =
- { uid : Int
- , vid : Int
- , status : Int
- }
-
-type alias Model =
- { state : Api.State
- , flags : Flags
- }
-
-init : Flags -> Model
-init f =
- { state = Api.Normal
- , flags = f
- }
-
-
-encodeForm : Model -> JE.Value
-encodeForm o = JE.object
- [ ("uid", JE.int o.flags.uid)
- , ("vid", JE.int o.flags.vid)
- , ("status", JE.int o.flags.status) ]
-
-
-type Msg
- = Input String
- | Saved Api.Response
-
-
-update : Msg -> Model -> (Model, Cmd Msg)
-update msg model =
- case msg of
- Input s ->
- let flags = model.flags
- nflags = { flags | status = Maybe.withDefault 0 <| String.toInt s }
- nmodel = { model | flags = nflags, state = Api.Loading }
- in ( nmodel
- , Api.post "/u/setvnstatus" (encodeForm nmodel) Saved )
-
- Saved Gen.Success -> ({ model | state = Api.Normal }, Cmd.none)
- Saved e -> ({ model | state = Api.Error e }, Cmd.none)
-
-
-view : Model -> Html Msg
-view model =
- -- TODO: Display error somewhere
- if model.state == Api.Loading
- then div [ class "spinner spinner--md" ] []
- else div []
- [ text <| Maybe.withDefault "" <| lookup model.flags.status Gen.vnlistStatus
- , inputSelect
- [ class "form-control--table-edit form-control--table-edit-overlay", onInput Input ]
- (String.fromInt model.flags.status)
- (List.map (\(a,b) -> (String.fromInt a, b)) Gen.vnlistStatus)
- ]