Commit 8c7050a8 authored by André Espaze's avatar André Espaze
Browse files

Use of url prefix from blueprint to Elm

parent 37a37bd277d6
......@@ -26,7 +26,8 @@ import Url.Builder as UB
type alias Model =
{ series : List String
{ urlPrefix : String
, series : List String
, searchString : String
, searchedSeries : List String
, selectedSeries : List String
......@@ -107,7 +108,7 @@ update msg model =
Http.expectJson DeleteDone Decode.string
mkUrl serieName =
UB.crossOrigin "http://tshistory.test.pythonian.fr"
UB.crossOrigin model.urlPrefix
[ "series", "state" ]
[ UB.string "name" serieName ]
in
......@@ -167,17 +168,20 @@ view model =
[ KeywordMultiSelector.view selectorConfig ctx ]
main : Program () Model Msg
main : Program String Model Msg
main =
let
initialGet =
initialGet urlPrefix =
Http.get
{ expect = Http.expectJson CatalogReceived (Decode.dict Decode.string)
, url = "http://tshistory.test.pythonian.fr/series/catalog"
, url =
UB.crossOrigin urlPrefix
[ "series", "catalog" ]
[]
}
init _ =
( Model [] "" [] [] Nothing, initialGet )
init urlPrefix =
( Model urlPrefix [] "" [] [] Nothing, initialGet urlPrefix )
sub model =
Time.every 1000 (always MakeSearch)
......
......@@ -33,7 +33,8 @@ type State
type alias Model =
{ state : State
{ urlPrefix : String
, state : State
, series : List String
, searchString : String
, searchedSeries : List String
......@@ -59,12 +60,12 @@ type Msg
| RenameDone (Result String String)
getCatalog : Cmd Msg
getCatalog =
getCatalog : String -> Cmd Msg
getCatalog urlPrefix =
Http.get
{ expect = Http.expectJson CatalogReceived (Decode.dict Decode.string)
, url =
UB.crossOrigin "http://tshistory.test.pythonian.fr"
UB.crossOrigin urlPrefix
[ "series", "catalog" ]
[]
}
......@@ -149,7 +150,7 @@ update msg model =
Common.expectJsonMessage RenameDone Decode.string
url =
UB.crossOrigin "http://tshistory.test.pythonian.fr"
UB.crossOrigin model.urlPrefix
[ "series", "state" ]
[ UB.string "name" <|
Maybe.withDefault "" model.selectedSerie
......@@ -176,7 +177,7 @@ update msg model =
, renamedSerie = ""
, status = Nothing
}
, getCatalog
, getCatalog model.urlPrefix
)
RenameDone (Err x) ->
......@@ -304,11 +305,13 @@ view model =
article [ classes [ T.center, T.pt4, T.w_90 ] ] [ content ]
main : Program () Model Msg
main : Program String Model Msg
main =
let
init _ =
( Model Select [] "" [] Nothing "" Nothing, getCatalog )
init urlPrefix =
( Model urlPrefix Select [] "" [] Nothing "" Nothing
, getCatalog urlPrefix
)
sub model =
if model.state == Select then
......
......@@ -90,10 +90,12 @@ def tsview(engine, tshclass=timeseries, serie_names=serie_names):
@bp.route('/tsdelete')
def tsdelete():
return render_template('tsedit.html', edit_kind="Delete")
return render_template('tsedit.html',
edit_kind="Delete", urlprefix="api")
@bp.route('/tsrename')
def tsrename():
return render_template('tsedit.html', edit_kind="Rename")
return render_template('tsedit.html',
edit_kind="Rename", urlprefix="api")
return bp
......@@ -9,7 +9,10 @@
<div id="app"></div>
<script src="./tsview_static/{{ edit_kind.lower() }}_elm.js"></script>
<script>
var app = Elm.{{ edit_kind }}.init({node: document.getElementById("app")});
var app = Elm.{{ edit_kind }}.init({
node: document.getElementById("app"),
flags: "{{ urlprefix }}"
});
</script>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment