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 =
...@@ -47,7 +48,7 @@ newtype Response = Response ...@@ -47,7 +48,7 @@ newtype Response = Response
initialState :: State initialState :: State
initialState = initialState =
{ {
select_database : true select_database : true
, unselect_database : true , unselect_database : true
, response : [] , response : []
} }
...@@ -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"]
...@@ -180,7 +185,7 @@ getDatabaseDetails reqBody = do ...@@ -180,7 +185,7 @@ getDatabaseDetails reqBody = do
instance decodeJsonresponse :: DecodeJson Response where instance decodeJsonresponse :: DecodeJson Response where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
count <- obj .? "count" count <- obj .? "count"
name <- obj .? "name" name <- obj .? "name"
pure $ Response {count,name } pure $ Response {count,name }
...@@ -44,47 +44,47 @@ group = unsafeMkProps "group" ...@@ -44,47 +44,47 @@ group = unsafeMkProps "group"
-- onEvents :: String -- PropTypes.object -- onEvents :: String -- PropTypes.object
type EchartsProps eff = type EchartsProps eff =
{ className :: String, { className :: String,
style :: String, -- object, style :: String, -- object,
theme :: String, theme :: String,
group :: String, group :: String,
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
} }
type OptsLoading = 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
} }
type Option = type Option =
{ title :: Title { title :: Title
, legend :: Legend , legend :: Legend
, tooltip :: Tooltip , tooltip :: Tooltip
, grid :: Grid , grid :: Grid
, xAxis :: Array XAxis , xAxis :: Array XAxis
, yAxis :: Array YAxis , yAxis :: Array YAxis
, series :: Array Series , series :: Array Series
, dataZoom :: Array DataZoom , dataZoom :: Array DataZoom
} }
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 =
...@@ -92,66 +92,66 @@ type Grid = ...@@ -92,66 +92,66 @@ type Grid =
} }
type Legend = type Legend =
{"type" :: String {"type" :: String
, show :: Boolean , show :: Boolean
, zlevel :: Number , zlevel :: Number
, z :: Number , z :: Number
, left :: Number , left :: Number
, top :: Number , top :: Number
, right :: Number , right :: Number
, bottom :: Number , bottom :: Number
, width :: Number , width :: Number
, height :: Number , height :: Number
, orient :: String , orient :: String
, align :: String , align :: String
, padding :: Number , padding :: Number
, itemGap :: Number , itemGap :: Number
, itemWidth :: Number , itemWidth :: Number
, itemHeight :: Number , itemHeight :: Number
, formatter :: String , formatter :: String
, selectedMode :: Boolean , selectedMode :: Boolean
, inactiveColor :: Color , inactiveColor :: Color
, selected :: String -- object , selected :: String -- object
, "data" :: Array Data , "data" :: Array Data
} }
type Data = type Data =
{name :: String { name :: String
, icon :: String , icon :: String
, textStyle :: {} , textStyle :: {}
} }
type SubtextStyle = type SubtextStyle =
{ color :: Color { color :: Color
, fontStyle :: String , fontStyle :: String
, fontWeight :: String , fontWeight :: String
, fontFamily :: String , fontFamily :: String
, fontSize :: Int , fontSize :: Int
, align :: String , align :: String
, verticalAlign :: String , verticalAlign :: String
, lineHeight :: Number , lineHeight :: Number
, width :: Number , width :: Number
, height :: Number , height :: Number
, textBorderColor :: String , textBorderColor :: String
, textBorderWidth :: Number , textBorderWidth :: Number
, textShadowColor :: String , textShadowColor :: String
, textShadowBlur :: Number , textShadowBlur :: Number
, textShadowOffsetX :: Number , textShadowOffsetX :: Number
, textShadowOffsetY :: Number , textShadowOffsetY :: Number
, rich :: Rich , rich :: Rich
} }
type Tooltip = type Tooltip =
{ trigger :: String { trigger :: String
, formatter :: String -- TODO function , formatter :: String -- TODO function
} }
type XAxis = type XAxis =
{ "data" :: Array String { "data" :: Array String
, "type" :: String , "type" :: String
, axisTick :: AxisTick , axisTick :: AxisTick
} }
type AxisTick = type AxisTick =
...@@ -160,10 +160,10 @@ type AxisTick = ...@@ -160,10 +160,10 @@ type AxisTick =
} }
type YAxis = type YAxis =
{ "type" :: String { "type" :: String
, name :: String , name :: String
, min :: Int , min :: Int
, position :: String , position :: String
, axisLabel :: AxisLabel , axisLabel :: AxisLabel
} }
...@@ -173,37 +173,37 @@ type AxisLabel = ...@@ -173,37 +173,37 @@ type AxisLabel =
type Series = type Series =
{name :: String { name :: String
, "type" :: String , "type" :: String
, "data" :: Array Int , "data" :: Array Int
} }
type Title = type Title =
{ text :: String { text :: String
, show :: Boolean , show :: Boolean
, link :: String , link :: String
, target :: String , target :: String
, textStyle :: TextStyle , textStyle :: TextStyle
, subtext :: String , subtext :: String
, sublink :: String , sublink :: String
, subtarget :: String , subtarget :: String
, subtextStyle :: SubtextStyle , subtextStyle :: SubtextStyle
, padding :: Number , padding :: Number
, itemGap :: Number , itemGap :: Number
, zlevel :: Number , zlevel :: Number
, z :: Number , z :: Number
, left :: Number , left :: Number
, top :: Number , top :: Number
, right :: Number , right :: Number
, bottom :: Number , bottom :: Number
, backgroundColor :: Color , backgroundColor :: Color
, borderColor :: Color , borderColor :: Color
, borderWidth :: Number , borderWidth :: Number
, borderRadius :: Number -- NumberOrArray , borderRadius :: Number -- NumberOrArray
, shadowBlur :: Number , shadowBlur :: Number
, shadowColor :: Color , shadowColor :: Color
, shadowOffsetX :: Number , shadowOffsetX :: Number
, shadowOffsetY :: Number , shadowOffsetY :: Number
} }
-- data NumberOrArray = Number | Array Number -- data NumberOrArray = Number | Array Number
...@@ -224,23 +224,23 @@ loading :: Boolean -> Props ...@@ -224,23 +224,23 @@ loading :: Boolean -> Props
loading = unsafeMkProps "loading" loading = unsafeMkProps "loading"
type TextStyle = type TextStyle =
{ color :: Color { color :: Color
, fontStyle :: String , fontStyle :: String
, fontWeight :: String , fontWeight :: String
, fontFamily :: String , fontFamily :: String
, fontSize :: Int , fontSize :: Int
, align :: String , align :: String
, verticalAlign :: String , verticalAlign :: String
, lineHeight :: Int , lineHeight :: Int
, width :: Int , width :: Int
, height :: Int , height :: Int
, textBorderColor :: String , textBorderColor :: String
, textBorderWidth :: Int , textBorderWidth :: Int
, textShadowColor :: String , textShadowColor :: String
, textShadowBlur :: Int , textShadowBlur :: Int
, textShadowOffsetX :: Int , textShadowOffsetX :: Int
, textShadowOffsetY :: Int , textShadowOffsetY :: Int
, rich :: Rich , rich :: Rich
} }
foreign import data TextStyleProps :: Type foreign import data TextStyleProps :: Type
...@@ -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
...@@ -148,18 +155,16 @@ unsafeEventValue e = (unsafeCoerce e).target.value ...@@ -148,18 +155,16 @@ unsafeEventValue e = (unsafeCoerce e).target.value
getDeviseID :: forall eff. Eff (dom :: DOM | eff) (Maybe String) 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
...@@ -169,7 +174,7 @@ newtype LoginRes = LoginRes ...@@ -169,7 +174,7 @@ newtype LoginRes = LoginRes
newtype LoginReq = LoginReq newtype LoginReq = LoginReq
{ username :: String { username :: String
, password :: String , password :: String
} }
...@@ -207,7 +212,7 @@ loginReq encodeData = ...@@ -207,7 +212,7 @@ loginReq encodeData =
instance decodeLoginRes :: DecodeJson LoginRes where instance decodeLoginRes :: DecodeJson LoginRes where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
token <- obj .? "token" token <- obj .? "token"
pure $ LoginRes { token} pure $ LoginRes { token}
......
This diff is collapsed.
...@@ -25,12 +25,12 @@ data Routes ...@@ -25,12 +25,12 @@ data Routes
instance showRoutes :: Show Routes where instance showRoutes :: Show Routes where
show Home = "Home" show Home = "Home"
show Login = "Login" show Login = "Login"
show AddCorpus = "AddCorpus" show AddCorpus = "AddCorpus"
show DocView = "DocView" show DocView = "DocView"
show SearchView = "SearchView" show SearchView = "SearchView"
show UserPage = "UserPage" show UserPage = "UserPage"
int :: Match Int int :: Match Int
int = floor <$> num int = floor <$> num
...@@ -45,20 +45,30 @@ routing = ...@@ -45,20 +45,30 @@ routing =
<|> addcorpusRoute <|> addcorpusRoute
<|> home <|> home
where where
userPageRoute = UserPage <$ route "userPage" userPageRoute = UserPage <$ route "userPage"
searchRoute = SearchView <$ route "search" searchRoute = SearchView <$ route "search"
docviewRoute = DocView <$ route "docView" docviewRoute = DocView <$ route "docView"
addcorpusRoute = AddCorpus <$ route "addCorpus" addcorpusRoute = AddCorpus <$ route "addCorpus"
loginRoute = Login <$ route "login" loginRoute = Login <$ route "login"
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
ls <- localStorage w ls <- localStorage w
token <- getItem "accessToken" ls token <- getItem "accessToken" ls
let tkn = token let tkn = token
liftEff $ log $ "JWToken : " <> show tkn liftEff $ log $ "JWToken : " <> show tkn
case tkn of case tkn of
......
...@@ -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,44 +48,42 @@ performAction GO _ _ = void do ...@@ -47,44 +48,42 @@ 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' []
, div [className "form-group"]
[
input [className "form-control",
_id "id_password",
name "query",
placeholder "Enter Query",
_type "text",
value state.query,
onInput \e -> dispatch (SetQuery (unsafeEventValue e))
] []
, br'[]
]
]
, div [className "col-md-2"]
[ br' [] [ br' []
, br' [] , br' []
-- TODO put Gargantext logo as search button , div [ className "form-group"]
, button [onClick \_ -> dispatch GO] [text "GO"] [ input [ className "form-control"
] , _id "id_password"
] , name "query"
] , placeholder "Query, URL or FILE (works best with Firefox or Chromium browsers)"
, _type "text"
, value state.query
, onInput \e -> dispatch (SetQuery (unsafeEventValue e))
] []
, br'[]
]
]
, div [ className "col-md-2"]
[ br' []
, br' []
, 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