Commit 76e18024 authored by Abinaya Sudhir's avatar Abinaya Sudhir

pulled code

parents ac67045d dfb784a8
...@@ -30,6 +30,7 @@ import Routing.Hash.Aff (setHash) ...@@ -30,6 +30,7 @@ import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, _render, cotransform, focus, foreach, modifyState, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, cotransform, focus, foreach, modifyState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Landing as L
type State = type State =
...@@ -61,7 +62,10 @@ data Action ...@@ -61,7 +62,10 @@ data Action
| GO | GO
performAction :: forall eff props. PerformAction (console :: CONSOLE, ajax :: AJAX,dom::DOM | eff) State props Action performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff ) State props Action
performAction NoOp _ _ = void do performAction NoOp _ _ = void do
modifyState id modifyState id
...@@ -91,7 +95,8 @@ addcorpusviewSpec = simpleSpec performAction render ...@@ -91,7 +95,8 @@ addcorpusviewSpec = simpleSpec performAction render
render :: Render State props Action render :: Render State props Action
render dispatch _ state _ = render dispatch _ state _ =
[ [
div [className "container"] div [className "container"] [L.jumboTitle false]
, div [className "container"]
[ [
div [className "jumbotron"] div [className "jumbotron"]
[ div [className "row"] [ div [className "row"]
......
...@@ -51,9 +51,9 @@ type EchartsProps eff = ...@@ -51,9 +51,9 @@ type EchartsProps eff =
option :: Option, -- PropTypes.object.isRequired, option :: Option, -- PropTypes.object.isRequired,
initOpts :: String, -- PropTypes.object, initOpts :: String, -- PropTypes.object,
notMerge :: Boolean, notMerge :: Boolean,
lazyUpdate:: Boolean, lazyUpdate :: Boolean,
loading :: Boolean, loading :: Boolean,
optsLoading:: OptsLoading, -- PropTypes.object, optsLoading :: OptsLoading, -- PropTypes.object,
onReady :: String, -- PropTypes.func, onReady :: String, -- PropTypes.func,
resizable :: Boolean, -- PropTypes.bool, resizable :: Boolean, -- PropTypes.bool,
onEvents :: String -- PropTypes.object onEvents :: String -- PropTypes.object
...@@ -63,7 +63,7 @@ type OptsLoading = ...@@ -63,7 +63,7 @@ type OptsLoading =
{ text :: String, { text :: String,
color :: Color, --- color color :: Color, --- color
textColor :: Color, --color textColor :: Color, --color
maskColor:: Color, --color maskColor :: Color, --color
zlevel :: Int zlevel :: Int
} }
...@@ -80,11 +80,11 @@ type Option = ...@@ -80,11 +80,11 @@ type Option =
type DataZoom = type DataZoom =
{"type":: String {"type" :: String
, xAxisIndex:: Int , xAxisIndex :: Int
, filterMode:: String , filterMode :: String
, start:: Int , start :: Int
, end:: Int , end :: Int
} }
type Grid = type Grid =
...@@ -116,7 +116,7 @@ type Legend = ...@@ -116,7 +116,7 @@ type Legend =
} }
type Data = type Data =
{name :: String { name :: String
, icon :: String , icon :: String
, textStyle :: {} , textStyle :: {}
} }
...@@ -173,7 +173,7 @@ type AxisLabel = ...@@ -173,7 +173,7 @@ type AxisLabel =
type Series = type Series =
{name :: String { name :: String
, "type" :: String , "type" :: String
, "data" :: Array Int , "data" :: Array Int
} }
...@@ -373,16 +373,20 @@ yAxisIndex = unsafeMkProps "yAxisIndex" ...@@ -373,16 +373,20 @@ yAxisIndex = unsafeMkProps "yAxisIndex"
-- , p'' -- , p''
-- ] -- ]
ex1 :: ReactElement histogram :: ReactElement
ex1 = echarts histogram = echarts
[ option [ option
[ tooltip [trigger "axis"] [ tooltip [trigger "axis"]
, grid [containLabel true] , grid [containLabel true]
, legend [data' ["Query A", "Query B", "Query C"]] , legend [data' ["Map terms coverage", "Favorites", "All"]]
-- , legend [data' ["Map Terms coverage", "Favorites", "All"]]
, xAxis , xAxis
[ type' "category" [ type' "category"
, axisTick [alignWithLabel true] , axisTick [alignWithLabel true]
, data' ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"] , data' ["Jan" , "Feb", "Mar" , "Apr"
, "May", "Jun", "July", "Aug"
, "Sep", "Oct", "Nov" , "Dec"
]
] ]
, dataZoom [dz1,dz1,dz2,dz2] , dataZoom [dz1,dz1,dz2,dz2]
, yAxis [ya1, ya2] , yAxis [ya1, ya2]
...@@ -408,22 +412,22 @@ dz2 = unsafeFromPropsArray ...@@ -408,22 +412,22 @@ dz2 = unsafeFromPropsArray
ya1 = unsafeFromPropsArray ya1 = unsafeFromPropsArray
[ type' "value" [ type' "value"
, name "Publications (by year)" , name "Score metric"
, min 0 , min 0
, position "left" , position "right"
, axisLabel [formatter "{value}"] , axisLabel [formatter "{value}"]
] ]
ya2 = unsafeFromPropsArray ya2 = unsafeFromPropsArray
[ type' "value" [ type' "value"
, name "Score metric" , name "Publications (by year)"
, min 0 , min 0
, position "right" , position "left"
, axisLabel [formatter "{value}"] , axisLabel [formatter "{value}"]
] ]
sd1 = unsafeFromPropsArray sd1 = unsafeFromPropsArray
[ name "Query A" [ name "Map terms coverage"
, type' "line" , type' "line"
, label [normal[showp true, position "top"]] , label [normal[showp true, position "top"]]
, lineStyle [ normal , lineStyle [ normal
...@@ -432,26 +436,26 @@ sd1 = unsafeFromPropsArray ...@@ -432,26 +436,26 @@ sd1 = unsafeFromPropsArray
, shadowBlur 10 , shadowBlur 10
, shadowOffsetY 10 , shadowOffsetY 10
]] ]]
, data' [1, 13, 37, 35, 15, 13, 25, 21, 6, 45, 32, 2] , data' [95, 80, 75, 35, 30, 50, 70, 80, 95, 95, 95, 99]
] ]
sd2 = unsafeFromPropsArray sd3 = unsafeFromPropsArray
[ name "Query B" [ name "All"
, type' "bar" , type' "bar"
, label [normal[showp true, position "top"]] , label [normal[showp true, position "top"]]
, yAxisIndex 1 , yAxisIndex 1
, data' [22, 22, 23, 77, 24, 55, 55, 89, 98, 164, 106, 224] , data' [201, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 2324]
] ]
sd3 = unsafeFromPropsArray
[ name "Query C" sd2 = unsafeFromPropsArray
[ name "Favorites"
, type' "bar" , type' "bar"
, label [normal[showp true, position "top"]] , label [normal[showp true, position "top"]]
, yAxisIndex 1 , yAxisIndex 1
, data' [201, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 2324] , data' [22, 22, 23, 77, 24, 55, 139, 350, 150, 164, 106, 224]
] ]
p'' :: ReactElement p'' :: ReactElement
p'' = p [] [] p'' = p [] []
This diff is collapsed.
This diff is collapsed.
...@@ -26,6 +26,9 @@ import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) ...@@ -26,6 +26,9 @@ import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
-- TODO: ask for login (modal) or account creation after 15 mn when user is not logged and has made one search at least
newtype State = State newtype State = State
{ username :: String { username :: String
, password :: String , password :: String
...@@ -49,7 +52,11 @@ data Action ...@@ -49,7 +52,11 @@ data Action
| SetPassword String | SetPassword String
performAction :: forall eff props. PerformAction (console :: CONSOLE, ajax :: AJAX,dom::DOM | eff) State props Action performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do performAction NoOp _ _ = void do
modifyState id modifyState id
...@@ -150,16 +157,14 @@ getDeviseID :: forall eff. Eff (dom :: DOM | eff) (Maybe String) ...@@ -150,16 +157,14 @@ getDeviseID :: forall eff. Eff (dom :: DOM | eff) (Maybe String)
getDeviseID = do getDeviseID = do
w <- window w <- window
ls <- localStorage w ls <- localStorage w
i <- getItem "token" ls getItem "token" ls
pure $ i
setToken :: forall e . String -> Eff (dom :: DOM | e) Unit setToken :: forall e . String -> Eff (dom :: DOM | e) Unit
setToken s = do setToken s = do
w <- window w <- window
ls <- localStorage w ls <- localStorage w
liftEff $ setItem "token" s ls setItem "token" s ls
pure unit
......
This diff is collapsed.
...@@ -53,7 +53,17 @@ routing = ...@@ -53,7 +53,17 @@ routing =
home = Home <$ lit "" home = Home <$ lit ""
route str = lit "" *> lit str route str = lit "" *> lit str
routeHandler :: forall e. (Maybe Routes -> Routes -> Eff ( dom :: DOM, console :: CONSOLE | e) Unit) -> Maybe Routes -> Routes -> Eff (dom :: DOM, console :: CONSOLE | e) Unit
routeHandler :: forall e. ( Maybe Routes -> Routes -> Eff
( dom :: DOM
, console :: CONSOLE
| e
) Unit
) -> Maybe Routes -> Routes -> Eff
( dom :: DOM
, console :: CONSOLE
| e
) Unit
routeHandler dispatchAction old new = do routeHandler dispatchAction old new = do
liftEff $ log $ "change route : " <> show new liftEff $ log $ "change route : " <> show new
w <- window w <- window
......
...@@ -6,11 +6,12 @@ import Control.Monad.Cont.Trans (lift) ...@@ -6,11 +6,12 @@ import Control.Monad.Cont.Trans (lift)
import DOM (DOM) import DOM (DOM)
import Network.HTTP.Affjax (AJAX) import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div) import Prelude hiding (div)
import React.DOM (br', button, div, h3, input, text) import React.DOM (br', button, div, h3, input, text, i, span, img)
import React.DOM.Props (_id, _type, className, name, onClick, onInput, placeholder, value) import React.DOM.Props (_id, _type, className, name, onClick, onInput, placeholder, value, aria, src, title)
import Routing.Hash.Aff (setHash) import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Landing as L
type State = type State =
{ {
...@@ -47,43 +48,41 @@ performAction GO _ _ = void do ...@@ -47,43 +48,41 @@ performAction GO _ _ = void do
unsafeEventValue :: forall event. event -> String unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value unsafeEventValue e = (unsafeCoerce e).target.value
-- TODO: case loggedIn of True -> Just Tree ; False -> Nothing
-- TODO: put the search form in the center of the page searchSpec :: forall props eff . Spec ( console :: CONSOLE
searchSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action , ajax :: AJAX
, dom :: DOM
| eff
) State props Action
searchSpec = simpleSpec performAction render searchSpec = simpleSpec performAction render
where where
render :: Render State props Action render :: Render State props Action
render dispatch _ state _ = render dispatch _ state _ =
[ [ div [className "container"] [L.jumboTitle false]
div [className "container"] , div [className "container"]
[ [ div [className "jumbotron" ]
div [className "jumbotron"] [ div [className "row" ]
[ [ div [className "col-md-10" ]
div [className "row"]
[
div [className "col-md-10"]
[ br' [] [ br' []
, br' [] , br' []
, div [className "form-group"] , div [ className "form-group"]
[ [ input [ className "form-control"
input [className "form-control", , _id "id_password"
_id "id_password", , name "query"
name "query", , placeholder "Query, URL or FILE (works best with Firefox or Chromium browsers)"
placeholder "Enter Query", , _type "text"
_type "text", , value state.query
value state.query, , onInput \e -> dispatch (SetQuery (unsafeEventValue e))
onInput \e -> dispatch (SetQuery (unsafeEventValue e))
] [] ] []
, br'[] , br'[]
] ]
] ]
, div [className "col-md-2"] , div [ className "col-md-2"]
[ br' [] [ br' []
, br' [] , br' []
-- TODO put Gargantext logo as search button
, button [onClick \_ -> dispatch GO] [text "GO"] , button [onClick \_ -> dispatch GO] [text "GO"]
] ]
, br' []
] ]
] ]
] ]
......
This diff is collapsed.
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