diff --git a/webui/src/CsvTsdb/Api.elm b/webui/src/CsvTsdb/Api.elm index cc0e282..2a29784 100644 --- a/webui/src/CsvTsdb/Api.elm +++ b/webui/src/CsvTsdb/Api.elm @@ -18,10 +18,22 @@ decode_error = Decode.decode |> Decode.optional "error" (Decode.string) "" |> Decode.resolve +post_ignore_response : String -> Http.Body -> Http.Request () +post_ignore_response url body = + Http.request + { method = "POST" + , headers = [] + , url = url + , body = body + , expect = Http.expectStringResponse (\response -> Ok ()) + , timeout = Nothing + , withCredentials = False + } + get_records msg = Http.getString track_url |> Http.send (mapError toString >> andThen decode_records >> msg) -send_input : String -> Http.Request String +send_input : String -> Http.Request () send_input input = - Http.post track_url (Http.stringBody "text/plain" input) decode_error + post_ignore_response track_url (Http.stringBody "text/plain" input) diff --git a/webui/src/Model.elm b/webui/src/Model.elm index 91510a4..347240a 100644 --- a/webui/src/Model.elm +++ b/webui/src/Model.elm @@ -21,8 +21,8 @@ type alias Model = type Msg = SelectTab Tab - | NewData (Result String (List CsvTsdb.Record)) - | RequestDone (Result Http.Error String) + | NewData (Result String (List CsvTsdb.Record)) -- TODO change to Http.Error when possible + | RequestDone (Result Http.Error ()) | RefreshWanted | DataInput String | SliderInput Float diff --git a/webui/src/TrackView.elm b/webui/src/TrackView.elm index 7119b2d..9d9f967 100644 --- a/webui/src/TrackView.elm +++ b/webui/src/TrackView.elm @@ -66,7 +66,7 @@ recents : List Record -> Html msg recents records = Table.table [ cs "full-width", Elevation.e2 ] [ Table.tbody [] - (records |> List.map (\record -> + (records |> List.reverse |> List.map (\record -> Table.tr [] [ Table.td [] [ text (view_date record.date) ] , Table.td [] [ text record.label ] diff --git a/webui/src/Update.elm b/webui/src/Update.elm index 4258063..0cdfecf 100644 --- a/webui/src/Update.elm +++ b/webui/src/Update.elm @@ -13,11 +13,11 @@ update msg model = case msg of SelectTab new -> ({model | tab = new}, Cmd.none) NewData r -> check r update_data Cmd.none model - RequestDone r -> check r (\_ -> identity) Cmd.none model + RequestDone r -> check r (\_ -> identity) refresh model DataInput s -> ({model | data_input = s}, Cmd.none) SliderInput x -> ({model | data_input = add_or_replace_value model.data_input x, slider_input = x}, Cmd.none) RefreshWanted -> (model, refresh) - DataSubmit -> ({model | data_input = ""}, send_input model.data_input) + DataSubmit -> ({model | data_input = ""}, send_input model.data_input) -- TODO validation Mdl m -> Material.update Mdl m model -- Mdl action handler update_data new model = {model | data = new, recent_labels = find_labels new}