diff --git a/.travis.yml b/.travis.yml index 22c26b7..8d95b23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: - "$TRAVIS_BUILD_DIR/ci-scripts/install_coder.sh" - "$TRAVIS_BUILD_DIR/ci-scripts/install_server.sh" - "$TRAVIS_BUILD_DIR/ci-scripts/install_shell.sh" -- "$TRAVIS_BUILD_DIR/ci-scripts/install_elm_format.sh" +- "$TRAVIS_BUILD_DIR/ci-scripts/install_elm_analyse.sh" before_script: - "$TRAVIS_BUILD_DIR/ci-scripts/prepare_client.sh" script: @@ -33,7 +33,7 @@ script: - "$TRAVIS_BUILD_DIR/ci-scripts/test_coder.sh" - "$TRAVIS_BUILD_DIR/ci-scripts/test_server.sh" - "$TRAVIS_BUILD_DIR/ci-scripts/test_shell.sh" -- "$TRAVIS_BUILD_DIR/ci-scripts/test_elm_format.sh" +- "$TRAVIS_BUILD_DIR/ci-scripts/test_elm_analyse.sh" cache: directories: - client/elm-stuff/packages diff --git a/ci-scripts/install_client.sh b/ci-scripts/install_client.sh index a6c592d..16cd82f 100755 --- a/ci-scripts/install_client.sh +++ b/ci-scripts/install_client.sh @@ -8,7 +8,7 @@ set -e # ---------------------------------------------------------------------------- # # Check the current build. -if [ -z "${BUILD_CLIENT+x}" ] || [ "$BUILD_CLIENT" -ne 1 ]; then +if ([ -z "${BUILD_CLIENT+x}" ] || [ "$BUILD_CLIENT" -ne 1 ]) && ([ -z "${ELM_REVIEW+x}" ] || [ "$ELM_REVIEW" -ne 1 ]); then exit 0; fi diff --git a/ci-scripts/install_elm_format.sh b/ci-scripts/install_elm_analyse.sh similarity index 85% rename from ci-scripts/install_elm_format.sh rename to ci-scripts/install_elm_analyse.sh index 4787841..4173b44 100755 --- a/ci-scripts/install_elm_format.sh +++ b/ci-scripts/install_elm_analyse.sh @@ -3,7 +3,7 @@ set -e # ---------------------------------------------------------------------------- # # -# Install Elm Format. +# Install elm-analyse. # # ---------------------------------------------------------------------------- # @@ -13,3 +13,4 @@ if [ -z "${ELM_REVIEW+x}" ] || [ "$ELM_REVIEW" -ne 1 ]; then fi npm install -g elm-format@0.6.1-alpha +npm install -g elm-analyse@0.11.0 diff --git a/ci-scripts/test_elm_format.sh b/ci-scripts/test_elm_analyse.sh similarity index 50% rename from ci-scripts/test_elm_format.sh rename to ci-scripts/test_elm_analyse.sh index 1379ef8..49a7341 100755 --- a/ci-scripts/test_elm_format.sh +++ b/ci-scripts/test_elm_analyse.sh @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------------- # # -# Run the Elm Format reviews. +# Run the elm-analyse reviews. # # ---------------------------------------------------------------------------- # @@ -11,16 +11,5 @@ if [ -z "${ELM_REVIEW+x}" ] || [ "$ELM_REVIEW" -ne 1 ]; then exit 0; fi -source "$TRAVIS_BUILD_DIR"/server/travis.config.sh - -HAS_ERRORS=0 - -SCRIPTS=$(find client/src -name '*.elm') -for FILE in $SCRIPTS; do - echo "Validating $FILE" - if ! elm-format --validate "$FILE"; then - HAS_ERRORS=1 - fi -done - -exit $HAS_ERRORS +cd client +elm-analyse diff --git a/client/README.md b/client/README.md index 7c74272..fe2fb2c 100644 --- a/client/README.md +++ b/client/README.md @@ -6,6 +6,7 @@ Make sure the following are installed: * Elm (e.g. `npm install -g elm@~0.18.0`) * Compass (for SASS) (`gem update --system && gem install compass`) * Elm Format (`npm install -g elm-format@0.6.1-alpha`), not strictly required for the development, but the standard must be followed, as Travis checks that. Therefore it's highly suggested to run Elm Format upon save at your IDE (https://github.com/avh4/elm-format#editor-integration). +* Elm Analyse (`npm install -g elm-analyse@0.11.0`), not strictly required for the development, but the standard must be followed, as Travis checks that. Configure inspection / linting in your IDE if possible. ## Installation diff --git a/client/elm-analyse.json b/client/elm-analyse.json new file mode 100644 index 0000000..f624302 --- /dev/null +++ b/client/elm-analyse.json @@ -0,0 +1,4 @@ +{ + "checks" : { + } +} diff --git a/client/src/elm/App/Model.elm b/client/src/elm/App/Model.elm index 5c6b827..43e3b80 100644 --- a/client/src/elm/App/Model.elm +++ b/client/src/elm/App/Model.elm @@ -2,20 +2,31 @@ module App.Model exposing ( emptyModel , Flags - , Msg(..) + , Msg + ( HandleOfflineEvent + , Logout + , MsgItemManager + , MsgPusher + , NoOp + , PageLogin + , SetActivePage + , SetCurrentDate + , Tick + , ToggleSideBar + ) , Model - , Sidebar(..) + , Sidebar(Left, Top) ) -import App.PageType exposing (Page(..)) +import App.PageType exposing (Page(Login)) import Config.Model import Date exposing (Date) -import Pages.Login.Model exposing (emptyModel, Model) +import Pages.Login.Model exposing (Model) import Pusher.Model -import RemoteData exposing (RemoteData(..), WebData) -import ItemManager.Model exposing (emptyModel, Model) +import RemoteData exposing (RemoteData(NotAsked), WebData) +import ItemManager.Model exposing (Model) import Time exposing (Time) -import User.Model exposing (..) +import User.Model exposing (User) type Msg diff --git a/client/src/elm/App/PageType.elm b/client/src/elm/App/PageType.elm index b0cc704..8387503 100644 --- a/client/src/elm/App/PageType.elm +++ b/client/src/elm/App/PageType.elm @@ -1,4 +1,14 @@ -module App.PageType exposing (Page(..)) +module App.PageType + exposing + ( Page + ( AccessDenied + , Dashboard + , Item + , Login + , MyAccount + , PageNotFound + ) + ) {-| Prevent circular dependency. -} diff --git a/client/src/elm/App/Router.elm b/client/src/elm/App/Router.elm index 7fa8824..fa158f3 100644 --- a/client/src/elm/App/Router.elm +++ b/client/src/elm/App/Router.elm @@ -1,10 +1,10 @@ module App.Router exposing (delta2url, location2messages) -import App.Model exposing (..) -import App.PageType exposing (..) +import App.Model exposing (Model, Msg(SetActivePage)) +import App.PageType exposing (Page(AccessDenied, Dashboard, Item, Login, MyAccount, PageNotFound)) import Navigation exposing (Location) -import RouteUrl exposing (HistoryEntry(..), UrlChange) -import UrlParser exposing (Parser, map, parseHash, s, oneOf, (), int, string) +import RouteUrl exposing (HistoryEntry(ModifyEntry, NewEntry), UrlChange) +import UrlParser exposing (Parser, map, s, oneOf, (), int) delta2url : Model -> Model -> Maybe UrlChange @@ -13,18 +13,6 @@ delta2url previous current = AccessDenied -> Nothing - Login -> - Just <| UrlChange NewEntry "#/login" - - MyAccount -> - Just <| UrlChange NewEntry "#/my-account" - - PageNotFound -> - Just <| UrlChange NewEntry "#/404" - - Item id -> - Just <| UrlChange NewEntry ("#/item/" ++ id) - Dashboard -> Just <| -- We treat this as the default URL, so you can get here from @@ -39,6 +27,18 @@ delta2url previous current = _ -> UrlChange NewEntry "#/" + Item id -> + Just <| UrlChange NewEntry ("#/item/" ++ id) + + Login -> + Just <| UrlChange NewEntry "#/login" + + MyAccount -> + Just <| UrlChange NewEntry "#/my-account" + + PageNotFound -> + Just <| UrlChange NewEntry "#/404" + location2messages : Location -> List Msg location2messages location = diff --git a/client/src/elm/App/Test.elm b/client/src/elm/App/Test.elm index 2b8d720..5dc04ac 100644 --- a/client/src/elm/App/Test.elm +++ b/client/src/elm/App/Test.elm @@ -1,15 +1,15 @@ module App.Test exposing (all) -import App.Model exposing (..) -import App.PageType exposing (Page(..)) -import App.Update exposing (..) +import App.Model exposing (emptyModel, Msg(SetActivePage)) +import App.PageType exposing (Page(AccessDenied, Login, MyAccount, PageNotFound)) +import App.Update exposing (update) import App.View exposing (view) import Expect import Http import Test exposing (describe, test, Test) import Test.Html.Query as Query -import Test.Html.Selector exposing (text, tag) -import RemoteData exposing (RemoteData(..)) +import Test.Html.Selector exposing (text) +import RemoteData exposing (RemoteData(Failure, Success)) setActivePageTest : Test diff --git a/client/src/elm/App/Update.elm b/client/src/elm/App/Update.elm index c67e88f..16bb120 100644 --- a/client/src/elm/App/Update.elm +++ b/client/src/elm/App/Update.elm @@ -1,7 +1,24 @@ port module App.Update exposing (init, update, subscriptions) -import App.Model exposing (..) -import App.PageType exposing (Page(..)) +import App.Model + exposing + ( emptyModel + , Flags + , Model + , Msg + ( HandleOfflineEvent + , Logout + , MsgItemManager + , MsgPusher + , NoOp + , PageLogin + , SetActivePage + , SetCurrentDate + , Tick + , ToggleSideBar + ) + ) +import App.PageType exposing (Page(AccessDenied, Dashboard, Item, Login, PageNotFound)) import Config import Date import Dict @@ -12,10 +29,10 @@ import Json.Encode exposing (Value) import Pages.Login.Update import Pusher.Model import Pusher.Update -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (RemoteData(Failure, NotAsked, Success), WebData) import Task import Time exposing (minute) -import User.Model exposing (..) +import User.Model exposing (User) init : Flags -> ( Model, Cmd Msg ) @@ -25,24 +42,24 @@ init flags = NotAsked ( config, cmds, activePage ) = - case (Dict.get flags.hostname Config.configs) of - Just config -> + case Dict.get flags.hostname Config.configs of + Just config_ -> let defaultCmds = [ Task.perform SetCurrentDate Date.now ] - ( cmds, activePage_ ) = - if (String.isEmpty flags.accessToken) then + ( cmds_, activePage_ ) = + if String.isEmpty flags.accessToken then -- Check if we have already an access token. ( defaultCmds, Login ) else - ( [ Cmd.map PageLogin <| Pages.Login.Update.fetchUserFromBackend config.backendUrl flags.accessToken ] ++ defaultCmds + ( (Cmd.map PageLogin <| Pages.Login.Update.fetchUserFromBackend config_.backendUrl flags.accessToken) :: defaultCmds , emptyModel.activePage ) in - ( Success config - , cmds + ( Success config_ + , cmds_ , activePage_ ) @@ -63,7 +80,7 @@ init flags = update : Msg -> Model -> ( Model, Cmd Msg ) -update msg model = +update updateMsg model = let backendUrl = case model.config of @@ -73,11 +90,11 @@ update msg model = _ -> "" in - case msg of + case updateMsg of HandleOfflineEvent (Ok offline) -> { model | offline = offline } ! [] - HandleOfflineEvent (Err err) -> + HandleOfflineEvent (Err _) -> model ! [] Logout -> @@ -99,10 +116,10 @@ update msg model = MsgItemManager subMsg -> case model.user of - Success user -> + Success _ -> let ( val, cmds, redirectPage ) = - ItemManager.Update.update model.currentDate backendUrl model.accessToken user subMsg model.pageItem + ItemManager.Update.update backendUrl model.accessToken subMsg model.pageItem modelUpdated = { model | pageItem = val } diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index 63ef921..2314ba6 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -1,24 +1,24 @@ -module App.View exposing (..) +module App.View exposing (view) -import App.Model exposing (..) -import App.PageType exposing (Page(..)) +import App.Model exposing (Model, Msg(Logout, PageLogin, MsgItemManager, SetActivePage, ToggleSideBar), Sidebar(Left, Top)) +import App.PageType exposing (Page(AccessDenied, Dashboard, Item, Login, MyAccount, PageNotFound)) import Config.View -import Html exposing (..) -import Html.Attributes exposing (alt, class, classList, href, src, style, target) +import Html exposing (a, div, i, img, Html, h4, span, text) +import Html.Attributes exposing (alt, class, classList, src) import Html.Events exposing (onClick) -import User.Model exposing (..) -import Pages.Login.View exposing (..) -import Pages.MyAccount.View exposing (..) -import Pages.PageNotFound.View exposing (..) -import ItemManager.View exposing (..) -import RemoteData exposing (RemoteData(..), WebData) +import User.Model exposing (User) +import Pages.Login.View +import Pages.MyAccount.View +import Pages.PageNotFound.View +import ItemManager.View +import RemoteData exposing (RemoteData(Failure, NotAsked, Success)) import Utils.Html exposing (emptyNode) view : Model -> Html Msg view model = case model.config of - Failure err -> + Failure _ -> Config.View.view _ -> @@ -138,15 +138,6 @@ viewSidebar model sidebar = emptyNode -viewPageNotFoundItem : Page -> Html Msg -viewPageNotFoundItem activePage = - a - [ classByPage PageNotFound activePage - , onClick <| SetActivePage PageNotFound - ] - [ text "404 page" ] - - viewAvatar : User -> Html Msg viewAvatar user = img @@ -181,9 +172,9 @@ viewMainContent model = -- at this higher level that we could present a UI related to loading -- the user information. case model.user of - Success user -> + Success _ -> Html.map MsgItemManager <| - ItemManager.View.viewItems model.currentDate user model.pageItem + ItemManager.View.viewItems model.pageItem _ -> div [] @@ -195,9 +186,9 @@ viewMainContent model = -- at this higher level that we could present a UI related to loading -- the user information. case model.user of - Success user -> + Success _ -> Html.map MsgItemManager <| - ItemManager.View.viewPageItem model.currentDate id user model.pageItem + ItemManager.View.viewPageItem id model.pageItem _ -> div [] @@ -216,14 +207,3 @@ viewMainContent model = _ -> viewContent - - -{-| Get menu items classes. This function gets the active page and checks if -it is indeed the page used. --} -classByPage : Page -> Page -> Attribute a -classByPage page activePage = - classList - [ ( "item", True ) - , ( "active", page == activePage ) - ] diff --git a/client/src/elm/Config.elm b/client/src/elm/Config.elm index 8ca86cf..12a821e 100644 --- a/client/src/elm/Config.elm +++ b/client/src/elm/Config.elm @@ -1,9 +1,9 @@ module Config exposing (configs) -import Config.Model as Config exposing (Model) -import Dict exposing (..) +import Config.Model exposing (Model) +import Dict exposing (Dict) import LocalConfig exposing (localConfigs) -import Pusher.Model exposing (Cluster(..), PusherAppKey) +import Pusher.Model exposing (Cluster(UsEast1), PusherAppKey) devPantheon : Model diff --git a/client/src/elm/Config/Model.elm b/client/src/elm/Config/Model.elm index bf32c4e..8626957 100644 --- a/client/src/elm/Config/Model.elm +++ b/client/src/elm/Config/Model.elm @@ -1,4 +1,4 @@ -module Config.Model exposing (..) +module Config.Model exposing (BackendUrl, Model) import Pusher.Model exposing (PusherAppKey) diff --git a/client/src/elm/Config/View.elm b/client/src/elm/Config/View.elm index 85f6f43..e3ddf1a 100644 --- a/client/src/elm/Config/View.elm +++ b/client/src/elm/Config/View.elm @@ -1,4 +1,4 @@ -module Config.View exposing (..) +module Config.View exposing (view) import Html exposing (div, h2, text, Html) import Html.Attributes exposing (class) diff --git a/client/src/elm/Item/Decoder.elm b/client/src/elm/Item/Decoder.elm index 1442b1b..8af4e4f 100644 --- a/client/src/elm/Item/Decoder.elm +++ b/client/src/elm/Item/Decoder.elm @@ -1,12 +1,8 @@ -module Item.Decoder - exposing - ( decodeItem - , decodeItemsDict - ) +module Item.Decoder exposing (decodeItem, decodeItemsDict) -import Json.Decode exposing (Decoder, andThen, dict, fail, field, int, list, map, map2, nullable, string, succeed) -import Json.Decode.Pipeline exposing (custom, decode, optional, optionalAt, required) -import Item.Model exposing (..) +import Json.Decode exposing (Decoder, nullable, string) +import Json.Decode.Pipeline exposing (decode, optional, optionalAt, required) +import Item.Model exposing (Item, ItemsDict) import Utils.Json exposing (decodeListAsDict) diff --git a/client/src/elm/ItemManager/Model.elm b/client/src/elm/ItemManager/Model.elm index d26244d..9af5c68 100644 --- a/client/src/elm/ItemManager/Model.elm +++ b/client/src/elm/ItemManager/Model.elm @@ -1,11 +1,25 @@ -module ItemManager.Model exposing (..) +module ItemManager.Model + exposing + ( emptyModel + , Model + , Msg + ( FetchAll + , HandleFetchedItem + , HandleFetchedItems + , HandlePusherEvent + , MsgPagesItem + , MsgPagesItems + , Subscribe + , Unsubscribe + ) + ) import Dict exposing (Dict) import Http import Pages.Item.Model import Pages.Items.Model import Pusher.Model exposing (PusherEvent) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Item.Model exposing (Item, ItemId, ItemsDict) diff --git a/client/src/elm/ItemManager/Update.elm b/client/src/elm/ItemManager/Update.elm index 77e3837..7b6964a 100644 --- a/client/src/elm/ItemManager/Update.elm +++ b/client/src/elm/ItemManager/Update.elm @@ -1,27 +1,38 @@ port module ItemManager.Update exposing (update, subscriptions) -import App.PageType exposing (Page(..)) +import App.PageType exposing (Page) import Config.Model exposing (BackendUrl) -import Date exposing (Date) -import Dict exposing (Dict) -import Item.Model exposing (Item, ItemId) +import Dict +import Item.Model exposing (ItemId) import ItemManager.Decoder exposing (decodeItemFromResponse, decodeItemsFromResponse) -import ItemManager.Model exposing (..) -import ItemManager.Utils exposing (..) +import ItemManager.Model + exposing + ( Model + , Msg + ( FetchAll + , HandleFetchedItem + , HandleFetchedItems + , HandlePusherEvent + , MsgPagesItem + , MsgPagesItems + , Subscribe + , Unsubscribe + ) + ) +import ItemManager.Utils exposing (getItem, wrapItemsDict) import Json.Decode exposing (decodeValue) import Json.Encode exposing (Value) -import HttpBuilder exposing (get, withQueryParams) +import HttpBuilder exposing (withQueryParams) import Pages.Item.Update import Pages.Items.Update import Pusher.Decoder exposing (decodePusherEvent) -import Pusher.Model exposing (PusherEventData(..)) -import RemoteData exposing (RemoteData(..)) -import User.Model exposing (User) +import Pusher.Model exposing (PusherEventData(ItemUpdate)) +import RemoteData exposing (RemoteData(Failure, Loading, NotAsked, Success)) import Utils.WebData exposing (sendWithHandler) -update : Date -> BackendUrl -> String -> User -> Msg -> Model -> ( Model, Cmd Msg, Maybe Page ) -update currentDate backendUrl accessToken user msg model = +update : BackendUrl -> String -> Msg -> Model -> ( Model, Cmd Msg, Maybe Page ) +update backendUrl accessToken msg model = case msg of Subscribe id -> -- Note that we're waiting to get the response from the server @@ -71,7 +82,7 @@ update currentDate backendUrl accessToken user msg model = Success item -> let ( subModel, subCmd, redirectPage ) = - Pages.Item.Update.update backendUrl accessToken user subMsg item + Pages.Item.Update.update subMsg item in ( { model | items = Dict.insert id (Success subModel) model.items } , Cmd.map (MsgPagesItem id) subCmd @@ -92,7 +103,7 @@ update currentDate backendUrl accessToken user msg model = MsgPagesItems subMsg -> let ( subModel, subCmd, redirectPage ) = - Pages.Items.Update.update backendUrl accessToken user subMsg (unwrapItemsDict model.items) model.itemsPage + Pages.Items.Update.update subMsg model.itemsPage in ( { model | itemsPage = subModel } , Cmd.map MsgPagesItems subCmd @@ -105,18 +116,12 @@ update currentDate backendUrl accessToken user msg model = , Nothing ) - HandleFetchedItems (Err err) -> - let - _ = - Debug.log "HandleFetchedItems" err - in - ( model, Cmd.none, Nothing ) + HandleFetchedItems (Err _) -> + ( model, Cmd.none, Nothing ) HandleFetchedItem itemId (Ok item) -> let -- Let Item settings fetch own data. - -- @todo: Pass the activePage here, so we can fetch - -- data only when really needed. updatedModel = { model | items = Dict.insert itemId (Success item) model.items } in @@ -143,13 +148,9 @@ update currentDate backendUrl accessToken user msg model = , Nothing ) - Err err -> - let - _ = - Debug.log "Pusher decode Err" err - in - -- We'll log the error decoding the pusher event - ( model, Cmd.none, Nothing ) + Err _ -> + -- We'll log the error decoding the pusher event + ( model, Cmd.none, Nothing ) {-| A single port for all messages coming in from pusher for a `Item` ... they @@ -186,5 +187,5 @@ fetchAllItemsFromBackend backendUrl accessToken model = subscriptions : Model -> Page -> Sub Msg -subscriptions model activePage = +subscriptions _ _ = pusherItemMessages (decodeValue decodePusherEvent >> HandlePusherEvent) diff --git a/client/src/elm/ItemManager/Utils.elm b/client/src/elm/ItemManager/Utils.elm index b0e6121..685063a 100644 --- a/client/src/elm/ItemManager/Utils.elm +++ b/client/src/elm/ItemManager/Utils.elm @@ -8,7 +8,7 @@ module ItemManager.Utils import Dict exposing (Dict) import Item.Model exposing (Item, ItemId, ItemsDict) import ItemManager.Model as ItemManager -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (RemoteData(NotAsked, Success), WebData) getItem : ItemId -> ItemManager.Model -> WebData Item diff --git a/client/src/elm/ItemManager/View.elm b/client/src/elm/ItemManager/View.elm index 20839c7..54428d7 100644 --- a/client/src/elm/ItemManager/View.elm +++ b/client/src/elm/ItemManager/View.elm @@ -4,36 +4,34 @@ module ItemManager.View , viewItems ) -import Date exposing (Date) import Pages.Item.View -import Html exposing (..) +import Html exposing (div, Html, text) import Html.Attributes exposing (class) import Html.Events exposing (onClick) import Pages.Items.View -import Item.Model exposing (ItemId, ItemsDict) -import ItemManager.Model exposing (..) +import Item.Model exposing (ItemId) +import ItemManager.Model exposing (Model, Msg(MsgPagesItem, MsgPagesItems, Subscribe)) import ItemManager.Utils exposing (getItem, unwrapItemsDict) -import RemoteData exposing (RemoteData(..)) -import User.Model exposing (User) +import RemoteData exposing (RemoteData(Failure, Loading, NotAsked, Success)) import Utils.Html exposing (emptyNode) import Utils.WebData exposing (viewError) {-| Show all Items page. -} -viewItems : Date -> User -> Model -> Html Msg -viewItems currentDate user model = +viewItems : Model -> Html Msg +viewItems model = let items = unwrapItemsDict model.items in - Html.map MsgPagesItems <| Pages.Items.View.view currentDate user items model.itemsPage + Html.map MsgPagesItems <| Pages.Items.View.view items model.itemsPage {-| Show the Item page. -} -viewPageItem : Date -> ItemId -> User -> Model -> Html Msg -viewPageItem currentDate id user model = +viewPageItem : ItemId -> Model -> Html Msg +viewPageItem id model = case getItem id model of NotAsked -> -- This shouldn't happen, but if it does, we provide @@ -59,4 +57,4 @@ viewPageItem currentDate id user model = Success item -> div [] - [ Html.map (MsgPagesItem id) <| Pages.Item.View.view currentDate user id item ] + [ Html.map (MsgPagesItem id) <| Pages.Item.View.view item ] diff --git a/client/src/elm/LocalConfig.Example.elm b/client/src/elm/LocalConfig.Example.elm index ab82dd4..dd25e74 100644 --- a/client/src/elm/LocalConfig.Example.elm +++ b/client/src/elm/LocalConfig.Example.elm @@ -1,8 +1,8 @@ module LocalConfig exposing (localConfigs) -import Config.Model as Config exposing (Model) -import Dict exposing (..) -import Pusher.Model exposing (Cluster(..), PusherAppKey) +import Config.Model exposing (Model) +import Dict exposing (Dict) +import Pusher.Model exposing (Cluster(UsEast1), PusherAppKey) local : Model diff --git a/client/src/elm/Main.elm b/client/src/elm/Main.elm index c44c436..6c62c29 100644 --- a/client/src/elm/Main.elm +++ b/client/src/elm/Main.elm @@ -1,8 +1,8 @@ -module Main exposing (..) +module Main exposing (main) import App.Model exposing (Flags, Model, Msg) import App.Update exposing (init, update, subscriptions) -import App.Router exposing (..) +import App.Router exposing (delta2url, location2messages) import App.View exposing (view) import RouteUrl @@ -12,8 +12,8 @@ main = RouteUrl.programWithFlags { delta2url = delta2url , location2messages = location2messages - , init = App.Update.init - , update = App.Update.update - , view = App.View.view - , subscriptions = App.Update.subscriptions + , init = init + , update = update + , view = view + , subscriptions = subscriptions } diff --git a/client/src/elm/Pages/Dashboard/View.elm b/client/src/elm/Pages/Dashboard/View.elm deleted file mode 100644 index e390c6a..0000000 --- a/client/src/elm/Pages/Dashboard/View.elm +++ /dev/null @@ -1,38 +0,0 @@ -module Pages.Dashboard.View exposing (view) - -import Html exposing (..) -import Html.Attributes exposing (..) -import Html.Events exposing (onClick) -import Item.Model exposing (Item, ItemId) -import User.Model exposing (User) - - -view : User -> ItemsDict -> Html Msg -view currentUser items = - div [] - [ h1 [ class "ui header" ] [ text "Dashboard" ] - , div [ class "ui divider" ] [] - , viewActiveIncidents items - ] - - -viewActiveIncidents : ItemsDict -> Html Msg -viewActiveIncidents items = - let - orderedIncidentes = - getOrderedIncidents items - in - -- @todo: Filter out - if (List.isEmpty orderedIncidentes) then - div [ style [ ( "font-size", "300%" ) ] ] - [ i [ class "ui icon check circle teal huge" ] [] - , text "No active incidents!" - ] - else - div [ class "ui cards" ] - (List.map - (\{ itemId, item, incidentId, incident } -> - Html.map (MsgIncident itemId incidentId) (Incident.View.view ( itemId, item ) ( incidentId, incident ) IncidentViewFull) - ) - orderedIncidentes - ) diff --git a/client/src/elm/Pages/Item/Model.elm b/client/src/elm/Pages/Item/Model.elm index 4f240dc..6d18537 100644 --- a/client/src/elm/Pages/Item/Model.elm +++ b/client/src/elm/Pages/Item/Model.elm @@ -1,9 +1,6 @@ -module Pages.Item.Model - exposing - ( Msg(..) - ) +module Pages.Item.Model exposing (Msg(HandlePusherEventData, SetRedirectPage)) -import App.PageType exposing (Page(..)) +import App.PageType exposing (Page) import Pusher.Model exposing (PusherEventData) diff --git a/client/src/elm/Pages/Item/Update.elm b/client/src/elm/Pages/Item/Update.elm index a7d6f86..0d5cea9 100644 --- a/client/src/elm/Pages/Item/Update.elm +++ b/client/src/elm/Pages/Item/Update.elm @@ -1,15 +1,13 @@ module Pages.Item.Update exposing (update) -import App.PageType exposing (Page(..)) -import Config.Model exposing (BackendUrl) -import User.Model exposing (..) -import Pages.Item.Model exposing (Msg(..)) -import Pusher.Model exposing (PusherEventData(..)) +import App.PageType exposing (Page) +import Pages.Item.Model exposing (Msg(HandlePusherEventData, SetRedirectPage)) +import Pusher.Model exposing (PusherEventData(ItemUpdate)) import Item.Model exposing (Item) -update : BackendUrl -> String -> User -> Msg -> Item -> ( Item, Cmd Msg, Maybe Page ) -update backendUrl accessToken user msg item = +update : Msg -> Item -> ( Item, Cmd Msg, Maybe Page ) +update msg item = case msg of HandlePusherEventData event -> case event of diff --git a/client/src/elm/Pages/Item/View.elm b/client/src/elm/Pages/Item/View.elm index 80b74a0..f0e41a2 100644 --- a/client/src/elm/Pages/Item/View.elm +++ b/client/src/elm/Pages/Item/View.elm @@ -1,16 +1,14 @@ module Pages.Item.View exposing (view) -import Date exposing (Date) -import Html exposing (..) -import Html.Attributes exposing (..) -import Pages.Item.Model exposing (Msg(..)) -import Item.Model exposing (ItemId, Item) -import User.Model exposing (User) +import Html exposing (a, div, Html, h2, img, text) +import Html.Attributes exposing (alt, class, src) +import Pages.Item.Model exposing (Msg) +import Item.Model exposing (Item) import Utils.Html exposing (divider, showMaybe) -view : Date -> User -> ItemId -> Item -> Html Msg -view currentDate currentUser itemId item = +view : Item -> Html Msg +view item = let privateNote = showMaybe <| diff --git a/client/src/elm/Pages/Items/Model.elm b/client/src/elm/Pages/Items/Model.elm index d4ca091..ff3c144 100644 --- a/client/src/elm/Pages/Items/Model.elm +++ b/client/src/elm/Pages/Items/Model.elm @@ -1,6 +1,6 @@ -module Pages.Items.Model exposing (..) +module Pages.Items.Model exposing (emptyModel, Model, Msg(SetRedirectPage, SetTableState, SetQuery)) -import App.PageType exposing (Page(..)) +import App.PageType exposing (Page) import Table diff --git a/client/src/elm/Pages/Items/Update.elm b/client/src/elm/Pages/Items/Update.elm index ea2803d..b404699 100644 --- a/client/src/elm/Pages/Items/Update.elm +++ b/client/src/elm/Pages/Items/Update.elm @@ -1,24 +1,21 @@ module Pages.Items.Update exposing (update) -import App.PageType exposing (Page(..)) -import Config.Model exposing (BackendUrl) -import User.Model exposing (..) -import Pages.Items.Model exposing (Model, Msg(..)) -import Item.Model exposing (ItemsDict) +import App.PageType exposing (Page) +import Pages.Items.Model exposing (Model, Msg(SetQuery, SetRedirectPage, SetTableState)) -update : BackendUrl -> String -> User -> Msg -> ItemsDict -> Model -> ( Model, Cmd Msg, Maybe Page ) -update backendUrl accessToken user msg items model = +update : Msg -> Model -> ( Model, Cmd Msg, Maybe Page ) +update msg model = case msg of - SetRedirectPage page -> - ( model, Cmd.none, Just page ) - SetQuery newQuery -> ( { model | query = newQuery } , Cmd.none , Nothing ) + SetRedirectPage page -> + ( model, Cmd.none, Just page ) + SetTableState newState -> ( { model | tableState = newState } , Cmd.none diff --git a/client/src/elm/Pages/Items/View.elm b/client/src/elm/Pages/Items/View.elm index d931003..31e235b 100644 --- a/client/src/elm/Pages/Items/View.elm +++ b/client/src/elm/Pages/Items/View.elm @@ -1,28 +1,26 @@ module Pages.Items.View exposing (view) -import App.PageType exposing (Page(..)) -import Date exposing (Date) +import App.PageType import Dict -import Html exposing (..) -import Html.Attributes exposing (..) +import Html exposing (a, div, Html, h2, input, text) +import Html.Attributes exposing (class, placeholder, style) import Html.Attributes.Aria exposing (ariaLabel) -import Html.Events exposing (on, onClick, onInput, onWithOptions) -import Pages.Items.Model exposing (Model, Msg(..)) +import Html.Events exposing (onClick, onInput) +import Pages.Items.Model exposing (Model, Msg(SetQuery, SetRedirectPage, SetTableState)) import Item.Model exposing (Item, ItemId, ItemsDict) -import Table exposing (..) -import User.Model exposing (User) +import Table exposing (defaultCustomizations) import Utils.Html exposing (emptyNode) -view : Date -> User -> ItemsDict -> Model -> Html Msg -view currentDate currentUser items model = +view : ItemsDict -> Model -> Html Msg +view items model = let lowerQuery = String.toLower model.query acceptableItems = Dict.filter - (\itemId item -> + (\_ item -> (String.contains lowerQuery << String.toLower << .name) item ) items diff --git a/client/src/elm/Pages/Login/Decoder.elm b/client/src/elm/Pages/Login/Decoder.elm index bb45840..c089a7d 100644 --- a/client/src/elm/Pages/Login/Decoder.elm +++ b/client/src/elm/Pages/Login/Decoder.elm @@ -1,6 +1,6 @@ -module Pages.Login.Decoder exposing (..) +module Pages.Login.Decoder exposing (decodeAccessToken, encodeCredentials) -import Base64 exposing (encode) +import Base64 import Json.Decode as Decode import Pages.Login.Model exposing (AccessToken) @@ -10,11 +10,6 @@ decodeAccessToken = Decode.at [ "access_token" ] <| Decode.string -decodeError : Decode.Decoder String -decodeError = - Decode.at [ "data", "error" ] <| Decode.string - - encodeCredentials : ( String, String ) -> String encodeCredentials ( name, pass ) = let @@ -25,5 +20,5 @@ encodeCredentials ( name, pass ) = Ok result -> result - Err err -> + Err _ -> "" diff --git a/client/src/elm/Pages/Login/Model.elm b/client/src/elm/Pages/Login/Model.elm index aec8d54..facd5a0 100644 --- a/client/src/elm/Pages/Login/Model.elm +++ b/client/src/elm/Pages/Login/Model.elm @@ -1,4 +1,10 @@ -module Pages.Login.Model exposing (..) +module Pages.Login.Model + exposing + ( AccessToken + , emptyModel + , Model + , Msg(HandleFetchedAccessToken, HandleFetchedUser, SetName, SetPassword, TryLogin) + ) import Http import User.Model exposing (User) @@ -14,14 +20,8 @@ type alias LoginForm = } -type UserMessage - = None - | Error String - - type alias Model = - { loginForm : LoginForm - } + LoginForm type Msg @@ -34,5 +34,4 @@ type Msg emptyModel : Model emptyModel = - { loginForm = LoginForm "admin" "admin" - } + LoginForm "admin" "admin" diff --git a/client/src/elm/Pages/Login/Test.elm b/client/src/elm/Pages/Login/Test.elm index 4c6ecb4..4f3a57f 100644 --- a/client/src/elm/Pages/Login/Test.elm +++ b/client/src/elm/Pages/Login/Test.elm @@ -35,11 +35,16 @@ fetchUnauthorized = } """ , status = { code = 401, message = "Authorization Required" } - , headers = Dict.fromList [ ( "Cache-Control", "no-cache, must-revalidate" ), ( "Content-Type", "application/problem+json; charset=utf-8" ), ( "Expires", "Sun, 19 Nov 1978 05:00:00 GMT" ) ] + , headers = + Dict.fromList + [ ( "Cache-Control", "no-cache, must-revalidate" ) + , ( "Content-Type", "application/problem+json; charset=utf-8" ) + , ( "Expires", "Sun, 19 Nov 1978 05:00:00 GMT" ) + ] , url = "http://localhost/server/www/api/me?access_token=some-wrong-token" } - ( updatedModel, cmds, ( webdata, accessToken ) ) = + ( _, _, ( webdata, accessToken ) ) = update url (HandleFetchedAccessToken (Err badRequest)) emptyModel in describe "Unauthorized tests" @@ -69,14 +74,19 @@ fetchUserUnauthorized = } """ , status = { code = 401, message = "Authorization Required" } - , headers = Dict.fromList [ ( "Cache-Control", "no-cache, must-revalidate" ), ( "Content-Type", "application/problem+json; charset=utf-8" ), ( "Expires", "Sun, 19 Nov 1978 05:00:00 GMT" ) ] + , headers = + Dict.fromList + [ ( "Cache-Control", "no-cache, must-revalidate" ) + , ( "Content-Type", "application/problem+json; charset=utf-8" ) + , ( "Expires", "Sun, 19 Nov 1978 05:00:00 GMT" ) + ] , url = "http://localhost/server/www/api/me?access_token=some-wrong-token" } invalidToken = "some-wrong-token" - ( updatedModel, cmds, ( webdata, accessToken ) ) = + ( _, _, ( webdata, accessToken ) ) = update url (HandleFetchedUser invalidToken (Err badRequest)) emptyModel in describe "Invalid Token tests" diff --git a/client/src/elm/Pages/Login/Update.elm b/client/src/elm/Pages/Login/Update.elm index 8e694a5..fd6404a 100644 --- a/client/src/elm/Pages/Login/Update.elm +++ b/client/src/elm/Pages/Login/Update.elm @@ -2,11 +2,11 @@ module Pages.Login.Update exposing (fetchUserFromBackend, update) import Config.Model exposing (BackendUrl) import Http exposing (Error(BadStatus)) -import HttpBuilder exposing (..) -import User.Model exposing (..) -import Pages.Login.Model as Login exposing (..) -import Pages.Login.Decoder exposing (..) -import RemoteData exposing (RemoteData(..), WebData) +import HttpBuilder exposing (withHeader, withQueryParams) +import User.Model exposing (User) +import Pages.Login.Model exposing (AccessToken, Model, Msg(HandleFetchedAccessToken, HandleFetchedUser, SetName, SetPassword, TryLogin)) +import Pages.Login.Decoder exposing (decodeAccessToken, encodeCredentials) +import RemoteData exposing (RemoteData(Failure, Loading, NotAsked, Success), WebData) import User.Decoder exposing (decodeUser) import Utils.WebData exposing (sendWithHandler) @@ -32,12 +32,12 @@ update backendUrl msg model = , ( Success user, accessToken ) ) - HandleFetchedUser accessToken (Err err) -> + HandleFetchedUser _ (Err err) -> let -- If Access token in local storage is invalid, make sure we don't show a "bad credentials" error. webdata = case err of - BadStatus e -> + BadStatus _ -> NotAsked _ -> @@ -49,45 +49,31 @@ update backendUrl msg model = ) SetName name -> - let - loginForm = - model.loginForm - - loginForm_ = - { loginForm | name = name } - in - ( { model | loginForm = loginForm_ } - , Cmd.none - , ( NotAsked, "" ) - ) + ( { model | name = name } + , Cmd.none + , ( NotAsked, "" ) + ) SetPassword pass -> - let - loginForm = - model.loginForm - - loginForm_ = - { loginForm | pass = pass } - in - ( { model | loginForm = loginForm_ } - , Cmd.none - , ( NotAsked, "" ) - ) + ( { model | pass = pass } + , Cmd.none + , ( NotAsked, "" ) + ) TryLogin -> ( model - , fetchAccessTokenFromBackend backendUrl model.loginForm + , fetchAccessTokenFromBackend backendUrl model , ( Loading, "" ) ) {-| Get access token from backend. -} -fetchAccessTokenFromBackend : BackendUrl -> LoginForm -> Cmd Msg -fetchAccessTokenFromBackend backendUrl loginForm = +fetchAccessTokenFromBackend : BackendUrl -> Model -> Cmd Msg +fetchAccessTokenFromBackend backendUrl model = let credentials = - encodeCredentials ( loginForm.name, loginForm.pass ) + encodeCredentials ( model.name, model.pass ) in HttpBuilder.get (backendUrl ++ "/api/login-token") |> withHeader "Authorization" ("Basic " ++ credentials) diff --git a/client/src/elm/Pages/Login/View.elm b/client/src/elm/Pages/Login/View.elm index 426b5e1..fe0ded4 100644 --- a/client/src/elm/Pages/Login/View.elm +++ b/client/src/elm/Pages/Login/View.elm @@ -1,12 +1,12 @@ module Pages.Login.View exposing (view) -import Html exposing (..) -import Html.Attributes exposing (..) +import Html exposing (button, div, Html, i, input, span, text) +import Html.Attributes exposing (action, class, disabled, hidden, name, placeholder, type_, value) import Html.Attributes.Aria exposing (ariaLabel) -import Html.Events exposing (onClick, onInput, onSubmit) -import Pages.Login.Model exposing (..) -import RemoteData exposing (RemoteData(..), WebData) -import User.Model exposing (..) +import Html.Events exposing (onInput, onSubmit) +import Pages.Login.Model exposing (Model, Msg(SetName, SetPassword, TryLogin)) +import RemoteData exposing (RemoteData(Failure, Loading), WebData) +import User.Model exposing (User) import Utils.Html exposing (emptyNode) import Utils.WebData exposing (viewError) @@ -28,7 +28,7 @@ viewForm user model = spinner = i [ class "notched circle loading icon" ] [] - ( isLoading, isError ) = + ( isLoading, _ ) = case user of Loading -> ( True, False ) @@ -59,7 +59,7 @@ viewForm user model = , name "username" , placeholder "Username" , onInput SetName - , value model.loginForm.name + , value model.name , ariaLabel "Enter your username" ] [] @@ -70,7 +70,7 @@ viewForm user model = , placeholder "Password" , name "password" , onInput SetPassword - , value model.loginForm.pass + , value model.pass , ariaLabel "Enter your password" ] [] diff --git a/client/src/elm/Pages/MyAccount/View.elm b/client/src/elm/Pages/MyAccount/View.elm index 9a36cb8..f543a67 100644 --- a/client/src/elm/Pages/MyAccount/View.elm +++ b/client/src/elm/Pages/MyAccount/View.elm @@ -1,9 +1,9 @@ module Pages.MyAccount.View exposing (view) -import Html exposing (a, div, h2, i, p, text, img, Html) -import Html.Attributes exposing (class, href, src) -import RemoteData exposing (RemoteData(..), WebData) -import User.Model exposing (..) +import Html exposing (div, text, img, Html) +import Html.Attributes exposing (class, src) +import RemoteData exposing (RemoteData(Success), WebData) +import User.Model exposing (User) import Utils.Html exposing (emptyNode) diff --git a/client/src/elm/Pages/PageNotFound/View.elm b/client/src/elm/Pages/PageNotFound/View.elm index 19fd127..a775d43 100644 --- a/client/src/elm/Pages/PageNotFound/View.elm +++ b/client/src/elm/Pages/PageNotFound/View.elm @@ -1,7 +1,7 @@ module Pages.PageNotFound.View exposing (view) -import Html exposing (a, div, h2, text, Html) -import Html.Attributes exposing (class, href) +import Html exposing (div, h2, text, Html) +import Html.Attributes exposing (class) -- VIEW diff --git a/client/src/elm/Pusher/Decoder.elm b/client/src/elm/Pusher/Decoder.elm index a54371b..dcb7503 100644 --- a/client/src/elm/Pusher/Decoder.elm +++ b/client/src/elm/Pusher/Decoder.elm @@ -1,8 +1,8 @@ module Pusher.Decoder exposing (decodePusherEvent) -import Json.Decode as Json exposing (Decoder, andThen, at, fail, field, map, map2, string) -import Json.Decode.Pipeline exposing (custom, decode, optional, required, requiredAt) -import Pusher.Model exposing (..) +import Json.Decode exposing (Decoder, andThen, fail, field, map, string) +import Json.Decode.Pipeline exposing (custom, decode, requiredAt) +import Pusher.Model exposing (PusherEvent, PusherEventData(ItemUpdate)) import Item.Decoder exposing (decodeItem) import Item.Model exposing (Item) diff --git a/client/src/elm/Pusher/Model.elm b/client/src/elm/Pusher/Model.elm index a7e69c7..c604ed7 100644 --- a/client/src/elm/Pusher/Model.elm +++ b/client/src/elm/Pusher/Model.elm @@ -1,4 +1,18 @@ -module Pusher.Model exposing (..) +module Pusher.Model + exposing + ( AccessToken(AccessToken) + , ConnectionStatus(Connected, Connecting, Disconnected, Failed, Initialized, Other, Unavailable) + , Cluster(ApSouthEast1, EuWest1, UsEast1) + , emptyModel + , eventNames + , Model + , Msg(HandleError, HandleStateChange, Login, Logout) + , PusherAppKey + , PusherConfig + , PusherError + , PusherEvent + , PusherEventData(ItemUpdate) + ) import Item.Model exposing (Item, ItemId) diff --git a/client/src/elm/Pusher/Test.elm b/client/src/elm/Pusher/Test.elm index fa9b295..f5a0ba3 100644 --- a/client/src/elm/Pusher/Test.elm +++ b/client/src/elm/Pusher/Test.elm @@ -1,11 +1,9 @@ module Pusher.Test exposing (all) -import Date -import Dict import Expect import Json.Decode exposing (decodeString) -import Pusher.Decoder exposing (..) -import Pusher.Model exposing (..) +import Pusher.Decoder exposing (decodePusherEvent) +import Pusher.Model exposing (PusherEventData(ItemUpdate)) import Test exposing (Test, describe, test) diff --git a/client/src/elm/Pusher/Update.elm b/client/src/elm/Pusher/Update.elm index a31b417..9477de3 100644 --- a/client/src/elm/Pusher/Update.elm +++ b/client/src/elm/Pusher/Update.elm @@ -1,7 +1,15 @@ port module Pusher.Update exposing (update, subscription) import Config.Model exposing (BackendUrl) -import Pusher.Model exposing (..) +import Pusher.Model + exposing + ( AccessToken(AccessToken) + , ConnectionStatus(Connected, Connecting, Disconnected, Failed, Initialized, Other, Unavailable) + , Model + , Msg(HandleError, HandleStateChange, Login, Logout) + , PusherConfig + , PusherError + ) import Pusher.Utils exposing (getClusterName) diff --git a/client/src/elm/Pusher/Utils.elm b/client/src/elm/Pusher/Utils.elm index a4332d8..714c80c 100644 --- a/client/src/elm/Pusher/Utils.elm +++ b/client/src/elm/Pusher/Utils.elm @@ -3,7 +3,7 @@ module Pusher.Utils ( getClusterName ) -import Pusher.Model exposing (Cluster(..)) +import Pusher.Model exposing (Cluster(ApSouthEast1, EuWest1, UsEast1)) getClusterName : Cluster -> String diff --git a/client/src/elm/TestRunner.elm b/client/src/elm/TestRunner.elm index d2ee3fc..cfa02c9 100644 --- a/client/src/elm/TestRunner.elm +++ b/client/src/elm/TestRunner.elm @@ -1,9 +1,9 @@ -port module Main exposing (..) +port module Main exposing (main) -import App.Test exposing (all) +import App.Test import Json.Encode exposing (Value) import Pages.Login.Test -import Pusher.Test exposing (all) +import Pusher.Test import Test exposing (Test, describe) import Test.Runner.Node exposing (TestProgram, run) diff --git a/client/src/elm/User/Decoder.elm b/client/src/elm/User/Decoder.elm index 04c504f..295707b 100644 --- a/client/src/elm/User/Decoder.elm +++ b/client/src/elm/User/Decoder.elm @@ -1,8 +1,8 @@ module User.Decoder exposing (decodeUser) -import Json.Decode exposing (nullable, string, Decoder) +import Json.Decode exposing (string, Decoder) import Json.Decode.Pipeline exposing (decode, optional, required) -import User.Model exposing (..) +import User.Model exposing (User) import Utils.Json exposing (decodeInt) diff --git a/client/src/elm/User/Model.elm b/client/src/elm/User/Model.elm index dd0fd3a..d9e9bd1 100644 --- a/client/src/elm/User/Model.elm +++ b/client/src/elm/User/Model.elm @@ -1,8 +1,4 @@ -module User.Model exposing (..) - - -type alias UserId = - String +module User.Model exposing (User) type alias User = diff --git a/client/src/elm/Utils/Html.elm b/client/src/elm/Utils/Html.elm index f7db558..f774717 100644 --- a/client/src/elm/Utils/Html.elm +++ b/client/src/elm/Utils/Html.elm @@ -1,6 +1,6 @@ module Utils.Html exposing (divider, emptyNode, showMaybe) -import Html exposing (..) +import Html exposing (div, Html, text) import Html.Attributes exposing (class) diff --git a/client/src/elm/Utils/Json.elm b/client/src/elm/Utils/Json.elm index e00b737..9ff4f60 100644 --- a/client/src/elm/Utils/Json.elm +++ b/client/src/elm/Utils/Json.elm @@ -11,7 +11,7 @@ module Utils.Json import Date exposing (Date) import Dict exposing (Dict) -import Json.Decode exposing (Decoder, andThen, dict, fail, field, float, int, list, map, map2, nullable, oneOf, string, succeed, value) +import Json.Decode exposing (Decoder, andThen, fail, field, float, int, list, map2, oneOf, string, succeed, value) import Json.Decode.Extra exposing (date) import String @@ -19,17 +19,17 @@ import String decodeDate : Decoder Date decodeDate = string - |> andThen (\val -> date) + |> andThen (\_ -> date) decodeEmptyArrayAsEmptyDict : Decoder (Dict.Dict k v) decodeEmptyArrayAsEmptyDict = list value |> andThen - (\list -> + (\list_ -> let length = - List.length list + List.length list_ in if length == 0 then succeed Dict.empty @@ -51,8 +51,8 @@ decodeFloat = |> andThen (\val -> case String.toFloat val of - Ok int -> - succeed int + Ok int_ -> + succeed int_ Err _ -> fail "Cannot convert string to float" @@ -70,8 +70,8 @@ decodeInt = |> andThen (\val -> case String.toInt val of - Ok int -> - succeed int + Ok int_ -> + succeed int_ Err _ -> fail "Cannot convert string to integer" @@ -89,7 +89,7 @@ decodeListAsDictByProperty property keyDecoder valDecoder stringFunc = list (map2 (,) (field property keyDecoder) valDecoder) |> andThen (\valList -> - List.map (\( id, value ) -> ( stringFunc id, value )) valList + List.map (\( id, value_ ) -> ( stringFunc id, value_ )) valList |> Dict.fromList |> succeed ) diff --git a/client/src/elm/Utils/WebData.elm b/client/src/elm/Utils/WebData.elm index 993f904..aba389d 100644 --- a/client/src/elm/Utils/WebData.elm +++ b/client/src/elm/Utils/WebData.elm @@ -1,9 +1,9 @@ module Utils.WebData exposing (sendWithHandler, viewError) import Json.Decode exposing (Decoder) -import Html exposing (..) +import Html exposing (div, Html, p, text) import Http -import HttpBuilder exposing (..) +import HttpBuilder exposing (RequestBuilder, send, withExpect) {-| Provide some `Html` to view an error message. @@ -11,7 +11,7 @@ import HttpBuilder exposing (..) viewError : Http.Error -> Html any viewError error = case error of - Http.BadUrl message -> + Http.BadUrl _ -> div [] [ text "URL is not valid." ] Http.BadPayload message _ ->