Commit 4c1429cd authored by Alexandre Delanoë's avatar Alexandre Delanoë
parents 1b26fbba e0df79f2
...@@ -479,7 +479,6 @@ showRow {row : (Corpus c), delete} = ...@@ -479,7 +479,6 @@ showRow {row : (Corpus c), delete} =
loadData :: forall eff. Aff ( console :: CONSOLE, ajax :: AJAX| eff) (Either String (Array Response)) loadData :: forall eff. Aff ( console :: CONSOLE, ajax :: AJAX| eff) (Either String (Array Response))
loadData = do loadData = do
-- liftEff $ log $ "GET /api response: "
affResp <- liftAff $ attempt $ affjax defaultRequest affResp <- liftAff $ attempt $ affjax defaultRequest
{ method = Left GET { method = Left GET
, url = "http://localhost:8009/corpus/1/facet/documents/table" , url = "http://localhost:8009/corpus/1/facet/documents/table"
...@@ -491,13 +490,7 @@ loadData = do ...@@ -491,13 +490,7 @@ loadData = do
} }
case affResp of case affResp of
Left err -> do Left err -> do
--liftEff $ log $ "Error" <> show err
pure $ Left $ show err pure $ Left $ show err
Right a -> do Right a -> do
--liftEff $ log $ "POST method Completed"
--liftEff $ log $ "GET /api response: " <> show a.response
let res = decodeJson a.response let res = decodeJson a.response
pure res pure res
module DocumentView where
import Prelude hiding (div)
import React (ReactElement)
import React.DOM (a, button, div, h4, input, li, nav, option, p, select, span, text, ul)
import React.DOM.Props (_data, _id, _type, aria, className, href, onChange, role, selected, value)
import Thermite (PerformAction, Render, Spec, cotransform, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
type State = String
initialState :: State
initialState = ""
data Action
= NoOp
| ChangeString String
| ChangeAnotherString String
performAction :: PerformAction _ State _ Action
performAction NoOp _ _ = pure unit
performAction (ChangeString ps) _ _ = pure unit
performAction (ChangeAnotherString ps) _ _ = pure unit
docview :: Spec _ State _ Action
docview = simpleSpec performAction render
where
render :: Render State _ Action
render dispatch _ state _ =
[ div [className "container"]
[ div [className "row"]
[ div [className "col-md-4"]
[ div [className "row"]
[ div [className "col-md-12 form-control"] [select [onChange (\e -> dispatch (ChangeString $ (unsafeCoerce e).target.value)) ] $ map optps aryPS ]
, div [className "col-md-12 form-control"] [ select [onChange (\e -> dispatch (ChangeAnotherString $ (unsafeCoerce e).target.value)) ] $ map optps aryPS1 ]
]
, div [className "row"]
[
nav []
[ div [className "nav nav-tabs", _id "nav-tab",role "tablist"]
[ a [className "nav-item nav-link active",_id "nav-home-tab" , _data {toggle : "tab"},href "#nav-home" ,role "tab",aria {controls : "nav-home"} ,aria {selected:true}] [ text "Publications (12)"]
, a [className "nav-item nav-link" ,_id "nav-profile-tab", _data {toggle : "tab"},href "#nav-profile",role "tab",aria {controls : "nav-profile"},aria {selected:true}] [ text "Brevets (2)"]
, a [className "nav-item nav-link" ,_id "nav-contact-tab", _data {toggle : "tab"},href "#nav-contact",role "tab",aria {controls : "nav-contact"},aria {selected:true}] [ text "Projets (5)"]
]
]
, div [className "tab-content" , _id "nav-tabContent"]
[
div [ className "tab-pane fade show active"
, role "tabpanel"
, aria {labelledby : "nav-home-tab"}
, _id "nav-home"
]
[
input [] []
, button [className "btn btn-primary", _type "button"] [text "Create and Add"]
]
, div [ className "tab-pane fade show"
, role "tabpanel"
, aria {labelledby : "nav-profile-tab"}
, _id "nav-profile"
]
[ ]
, div [ className "tab-pane fade show"
, role "tabpanel"
, aria {labelledby : "nav-contact-tab"}
, _id "nav-contact"
]
[ ]
]
]
]
, div [className "col-md-8"]
[ h4 [] [text "Ultrasonic sensors in urban traffic driving-aid systems"]
, ul [className "list-group"]
[ li [className "list-group-item justify-content-between"]
[ span [] [text "Sensors (Basel, switzerland)"]
, span [className "badge badge-default badge-pill"] [text "source"]
]
, li [className "list-group-item justify-content-between"]
[ span [] [text "Luciano Alonso, Vicente Milanes, Carlos Torre-Ferarro, Jorge Godoy, Juan P oria, Teresa de pedro"]
, span [className "badge badge-default badge-pill"] [text "authors"]
]
, li [className "list-group-item justify-content-between"]
[ span [] [text "2011-01-11 0.00"]
, span [className "badge badge-default badge-pill"] [text "date"]
]
]
, span [className "badge badge-default badge-pill"] [text "abstract"]
, p [] [text "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."]
, div [className "jumbotron"]
[ p [] [text "Empty Full Text"]
]
]
]
]
]
aryPS :: Array String
aryPS = ["STOPLIST", "MAINLIST", "MAPLIST"]
aryPS1 :: Array String
aryPS1 = ["Nothing Selected","STOPLIST", "MAINLIST", "MAPLIST"]
optps :: String -> ReactElement
optps val = option [ value val ] [text val]
-- ul [className "nav nav-pills mb-3", _id "pills-tab",role "tablist"]
-- [ li [className "nav-item"]
-- [ a [className "nav-link active", _id "pills-stop", _data {toggle : "pill"}, href "#pills-stop", role "tab", aria {controls :"pills-stop"}, aria {selected : true}] []
-- ]
-- , li [className "nav-item"]
-- [ a [className "nav-link", _id "pills-main", _data {toggle : "pill"}, href "#pills-main", role "tab", aria {controls :"pills-main"}, aria {selected : false}] []
-- ]
-- , li [className "nav-item"]
-- [ a [className "nav-link", _id "pills-map", _data {toggle : "pill"}, href "#pills-map", role "tab", aria {controls :"pills-map"}, aria {selected : false}] []
-- ]
-- ]
-- , div [className "tab-content", _id "pills-tabContent"]
-- [ div [className "tab-pane fade show active", _id "pills-stop", role "tabpanel" ,aria {labelledby : "pills-stop-tab"}] []
-- , div [ className "tab-pane fade", _id "pills-main", role "tabpanel" ,aria {labelledby : "pills-main-tab"}] []
-- , div [ className "tab-pane fade", _id "pills-map", role "tabpanel" ,aria {labelledby : "pills-map-tab"}] []
-- ]
...@@ -19,10 +19,11 @@ import Prelude (class Applicative, class Bind, Unit, bind, id, map, negate, pure ...@@ -19,10 +19,11 @@ import Prelude (class Applicative, class Bind, Unit, bind, id, map, negate, pure
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, img, li, span, text, ul, input, button, footer, p, hr, form) import React.DOM (a, div, img, li, span, text, ul, input, button, footer, p, hr, form)
import React.DOM.Props (_data, _id, _type, aria, className, href, name, placeholder, role, src, style, tabIndex, target, title) import React.DOM.Props (_data, _id, _type, aria, className, href, name, placeholder, role, src, style, tabIndex, target, title)
import React.DOM.Props as RP
import SearchForm as S import SearchForm as S
import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState)
import UserPage as UP import UserPage as UP
import React.DOM.Props as RP import DocumentView as D
type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e) type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e)
...@@ -34,6 +35,7 @@ type AppState = ...@@ -34,6 +35,7 @@ type AppState =
, docViewState :: DV.State , docViewState :: DV.State
, searchState :: S.State , searchState :: S.State
, userPage :: UP.State , userPage :: UP.State
, documentView :: D.State
} }
initAppState :: AppState initAppState :: AppState
...@@ -45,6 +47,7 @@ initAppState = ...@@ -45,6 +47,7 @@ initAppState =
, docViewState : DV.tdata , docViewState : DV.tdata
, searchState : S.initialState , searchState : S.initialState
, userPage : UP.initialState , userPage : UP.initialState
, documentView : D.initialState
} }
data Action data Action
...@@ -56,6 +59,7 @@ data Action ...@@ -56,6 +59,7 @@ data Action
| DocViewA DV.Action | DocViewA DV.Action
| SearchA S.Action | SearchA S.Action
| UserPageA UP.Action | UserPageA UP.Action
| DocumentViewA D.Action
performAction :: forall eff props. PerformAction ( dom :: DOM performAction :: forall eff props. PerformAction ( dom :: DOM
...@@ -135,6 +139,17 @@ _userPageAction = prism UserPageA \action -> ...@@ -135,6 +139,17 @@ _userPageAction = prism UserPageA \action ->
_-> Left action _-> Left action
_documentviewState :: Lens' AppState D.State
_documentviewState = lens (\s -> s.documentView) (\s ss -> s{documentView = ss})
_documentviewAction :: Prism' Action D.Action
_documentviewAction = prism DocumentViewA \action ->
case action of
DocumentViewA caction -> Right caction
_-> Left action
pagesComponent :: forall props eff. AppState -> Spec (E eff) AppState props Action pagesComponent :: forall props eff. AppState -> Spec (E eff) AppState props Action
pagesComponent s = pagesComponent s =
...@@ -154,6 +169,7 @@ pagesComponent s = ...@@ -154,6 +169,7 @@ pagesComponent s =
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser
selectSpec (DocumentView i) = layout0 $ focus _documentviewState _documentviewAction D.docview
-- To be removed -- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
...@@ -421,3 +437,8 @@ dispatchAction dispatcher _ UserPage = do ...@@ -421,3 +437,8 @@ dispatchAction dispatcher _ UserPage = do
_ <- dispatcher $ SetRoute $ UserPage _ <- dispatcher $ SetRoute $ UserPage
_ <- dispatcher $ UserPageA $ UP.NoOp _ <- dispatcher $ UserPageA $ UP.NoOp
pure unit pure unit
dispatchAction dispatcher _ (DocumentView i) = do
_ <- dispatcher $ SetRoute $ DocumentView i
_ <- dispatcher $ UserPageA $ UP.NoOp
pure unit
...@@ -22,6 +22,7 @@ data Routes ...@@ -22,6 +22,7 @@ data Routes
| DocView | DocView
| SearchView | SearchView
| UserPage | UserPage
| DocumentView Int
instance showRoutes :: Show Routes where instance showRoutes :: Show Routes where
...@@ -31,6 +32,7 @@ instance showRoutes :: Show Routes where ...@@ -31,6 +32,7 @@ instance showRoutes :: Show Routes where
show DocView = "DocView" show DocView = "DocView"
show SearchView = "SearchView" show SearchView = "SearchView"
show UserPage = "UserPage" show UserPage = "UserPage"
show (DocumentView i) = "DocumentView"
int :: Match Int int :: Match Int
int = floor <$> num int = floor <$> num
...@@ -39,12 +41,14 @@ int = floor <$> num ...@@ -39,12 +41,14 @@ int = floor <$> num
routing :: Match Routes routing :: Match Routes
routing = routing =
loginRoute loginRoute
<|> documentView
<|> userPageRoute <|> userPageRoute
<|> searchRoute <|> searchRoute
<|> docviewRoute <|> docviewRoute
<|> addcorpusRoute <|> addcorpusRoute
<|> home <|> home
where where
documentView = DocumentView <$> (route "documentView" *> int)
userPageRoute = UserPage <$ route "userPage" userPageRoute = UserPage <$ route "userPage"
searchRoute = SearchView <$ route "search" searchRoute = SearchView <$ route "search"
docviewRoute = DocView <$ route "docView" docviewRoute = DocView <$ route "docView"
......
Markdown is supported
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