updates for production env
This commit is contained in:
24
src/Api.elm
24
src/Api.elm
@@ -113,13 +113,13 @@ fetchLoot toMsg dest =
|
||||
url =
|
||||
case dest of
|
||||
OfPlayer id ->
|
||||
"http://localhost:8088/api/players/" ++ String.fromInt id ++ "/loot"
|
||||
"api/players/" ++ String.fromInt id ++ "/loot"
|
||||
|
||||
OfShop ->
|
||||
"http://localhost:8088/api/shop"
|
||||
"api/shop"
|
||||
|
||||
OfGroup ->
|
||||
"http://localhost:8088/api/players/0/loot"
|
||||
"api/players/0/loot"
|
||||
in
|
||||
Http.get
|
||||
{ url = url
|
||||
@@ -187,7 +187,7 @@ checkList toMsg itemList =
|
||||
toMsg [] <| Just (printError e)
|
||||
in
|
||||
Http.post
|
||||
{ url = "http://localhost:8088/api/items"
|
||||
{ url = "api/items"
|
||||
, body =
|
||||
E.list (\t -> E.string t) itemList
|
||||
|> Http.jsonBody
|
||||
@@ -330,27 +330,27 @@ confirmAction id data =
|
||||
( endpoint, method ) =
|
||||
case data of
|
||||
AddPayload _ _ ->
|
||||
( "http://localhost:8088/api/players/" ++ id ++ "/loot"
|
||||
( "api/players/" ++ id ++ "/loot"
|
||||
, "POST"
|
||||
)
|
||||
|
||||
BuyPayload _ _ _ ->
|
||||
( "http://localhost:8088/api/players/" ++ id ++ "/loot"
|
||||
( "api/players/" ++ id ++ "/loot"
|
||||
, "PUT"
|
||||
)
|
||||
|
||||
SellPayload _ _ _ _ ->
|
||||
( "http://localhost:8088/api/players/" ++ id ++ "/loot"
|
||||
( "api/players/" ++ id ++ "/loot"
|
||||
, "DELETE"
|
||||
)
|
||||
|
||||
GrabPayload _ ->
|
||||
( "http://localhost:8088/api/players/" ++ id ++ "/claims"
|
||||
( "api/players/" ++ id ++ "/claims"
|
||||
, "POST"
|
||||
)
|
||||
|
||||
WealthPayload _ ->
|
||||
( "http://localhost:8088/api/players/" ++ id ++ "/wealth"
|
||||
( "api/players/" ++ id ++ "/wealth"
|
||||
, "PUT"
|
||||
)
|
||||
in
|
||||
@@ -367,7 +367,7 @@ confirmAction id data =
|
||||
|
||||
undoLastAction id =
|
||||
Http.request
|
||||
{ url = "http://localhost:8088/api/players/" ++ String.fromInt id ++ "/events/last"
|
||||
{ url = "api/players/" ++ String.fromInt id ++ "/events/last"
|
||||
, method = "DELETE"
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
@@ -398,7 +398,7 @@ replaceShopItems toMsg loot =
|
||||
toMsg Nothing
|
||||
in
|
||||
Http.request
|
||||
{ url = "http://localhost:8088/api/shop"
|
||||
{ url = "api/shop"
|
||||
, method = "POST"
|
||||
, headers = []
|
||||
, body = Http.jsonBody data
|
||||
@@ -412,7 +412,7 @@ send : { method : String, path : String, decoder : Decoder a } -> Task Http.Erro
|
||||
send { method, path, decoder } =
|
||||
Http.task
|
||||
{ method = method
|
||||
, url = "http://localhost:8088/" ++ path
|
||||
, url = path
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, resolver = Http.stringResolver <| handleJsonResponse decoder
|
||||
|
||||
@@ -49,7 +49,7 @@ blankPlayer =
|
||||
get : (Result Http.Error Player -> msg) -> Int -> Cmd msg
|
||||
get toMsg id =
|
||||
Http.get
|
||||
{ url = "http://localhost:8088/api/players/" ++ String.fromInt id ++ "/"
|
||||
{ url = "api/players/" ++ String.fromInt id ++ "/"
|
||||
, expect = Http.expectJson toMsg (valueDecoder playerDecoder)
|
||||
}
|
||||
|
||||
@@ -64,11 +64,14 @@ list toMsg =
|
||||
toMsg players
|
||||
|
||||
Err e ->
|
||||
Debug.log ("Player's list fetch error : " ++ Debug.toString e) <|
|
||||
let
|
||||
_ =
|
||||
Debug.log "Player's list fetch error" (Debug.toString e)
|
||||
in
|
||||
toMsg []
|
||||
in
|
||||
Http.get
|
||||
{ url = "http://localhost:8088/api/players/"
|
||||
{ url = "api/players/"
|
||||
, expect = Http.expectJson parseResponse (valueDecoder <| D.list playerDecoder)
|
||||
}
|
||||
|
||||
|
||||
10
src/Main.elm
10
src/Main.elm
@@ -60,7 +60,11 @@ setPage page model =
|
||||
|
||||
|
||||
init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||
init _ _ key =
|
||||
init _ url key =
|
||||
let
|
||||
_ =
|
||||
Debug.log "init with url" (Debug.toString url)
|
||||
in
|
||||
( { navbar = initNavbar key
|
||||
, page = Page.Loading
|
||||
}
|
||||
@@ -165,6 +169,10 @@ update msg model =
|
||||
( LinkClicked urlRequest, _ ) ->
|
||||
case urlRequest of
|
||||
Browser.Internal url ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "internal url request" (Debug.toString url)
|
||||
in
|
||||
( model, Nav.pushUrl model.navbar.navKey (Url.toString url) )
|
||||
|
||||
Browser.External href ->
|
||||
|
||||
16
src/Page.elm
16
src/Page.elm
@@ -10,7 +10,7 @@ import Page.Dashboard as Home
|
||||
import Page.GroupChest as GroupChest
|
||||
import Page.Shop as Shop
|
||||
import Process
|
||||
import Route
|
||||
import Route exposing (toHref)
|
||||
import Session exposing (Session)
|
||||
import Task
|
||||
import Wealth
|
||||
@@ -216,19 +216,19 @@ renderLevel left right =
|
||||
|
||||
navLink icon route page =
|
||||
let
|
||||
( link, url ) =
|
||||
linkText =
|
||||
case route of
|
||||
Route.Merchant ->
|
||||
( "Marchand", "/marchand" )
|
||||
"Marchand"
|
||||
|
||||
Route.GroupChest ->
|
||||
( "Coffre de groupe", "/groupe" )
|
||||
"Coffre de groupe"
|
||||
|
||||
Route.Home ->
|
||||
( "Accueil", "/" )
|
||||
"Accueil"
|
||||
|
||||
Route.About ->
|
||||
( "About", "/" )
|
||||
"About"
|
||||
|
||||
isActive =
|
||||
case ( route, page ) of
|
||||
@@ -247,9 +247,9 @@ navLink icon route page =
|
||||
_ ->
|
||||
False
|
||||
in
|
||||
a [ class "navbar-item", classList [ ( "is-active", isActive ) ], href url ]
|
||||
a [ class "navbar-item", classList [ ( "is-active", isActive ) ], href (toHref route) ]
|
||||
[ B.icon { icon = icon, ratio = Just "fa-1x", size = Just "is-medium" }
|
||||
, span [] [ text link ]
|
||||
, span [] [ text linkText ]
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,18 @@ import Url.Parser as P exposing ((</>), Parser, oneOf, s)
|
||||
|
||||
|
||||
|
||||
-- Name of the application, prepended to it's actual root
|
||||
|
||||
|
||||
scriptName =
|
||||
"lootalot"
|
||||
|
||||
|
||||
root =
|
||||
P.s scriptName
|
||||
|
||||
|
||||
|
||||
-- ROUTES
|
||||
|
||||
|
||||
@@ -18,13 +30,32 @@ type Route
|
||||
parser : P.Parser (Route -> a) a
|
||||
parser =
|
||||
oneOf
|
||||
[ P.map Home P.top
|
||||
, P.map GroupChest (P.s "groupe")
|
||||
, P.map Merchant (P.s "marchand")
|
||||
, P.map About (P.s "about")
|
||||
[ P.map Home root
|
||||
, P.map GroupChest (root </> P.s "groupe")
|
||||
, P.map Merchant (root </> P.s "marchand")
|
||||
, P.map About (root </> P.s "about")
|
||||
]
|
||||
|
||||
|
||||
fromUrl : Url.Url -> Maybe Route
|
||||
fromUrl url =
|
||||
P.parse parser url
|
||||
|
||||
|
||||
toHref : Route -> String
|
||||
toHref route =
|
||||
"/"
|
||||
++ scriptName
|
||||
++ (case route of
|
||||
Home ->
|
||||
"/"
|
||||
|
||||
About ->
|
||||
"/"
|
||||
|
||||
Merchant ->
|
||||
"/marchand"
|
||||
|
||||
GroupChest ->
|
||||
"/groupe"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user