Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
76e18024
Commit
76e18024
authored
Mar 16, 2018
by
Abinaya Sudhir
Browse files
Options
Browse Files
Download
Plain Diff
pulled code
parents
ac67045d
dfb784a8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
661 additions
and
662 deletions
+661
-662
AddCorpusview.purs
src/AddCorpusview.purs
+10
-5
Chart.purs
src/Chart.purs
+118
-114
DocView.purs
src/DocView.purs
+142
-118
Landing.purs
src/Landing.purs
+57
-176
Login.purs
src/Login.purs
+14
-9
Navigation.purs
src/Navigation.purs
+176
-118
PageRouter.purs
src/PageRouter.purs
+26
-16
SearchForm.purs
src/SearchForm.purs
+35
-36
UserPage.purs
src/UserPage.purs
+83
-70
No files found.
src/AddCorpusview.purs
View file @
76e18024
...
...
@@ -30,6 +30,7 @@ import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, _render, cotransform, focus, foreach, modifyState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce)
import Landing as L
type State =
...
...
@@ -47,7 +48,7 @@ newtype Response = Response
initialState :: State
initialState =
{
select_database : true
select_database
: true
, unselect_database : true
, response : []
}
...
...
@@ -61,7 +62,10 @@ data Action
| 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
modifyState id
...
...
@@ -91,7 +95,8 @@ addcorpusviewSpec = simpleSpec performAction render
render :: Render State props Action
render dispatch _ state _ =
[
div [className "container"]
div [className "container"] [L.jumboTitle false]
, div [className "container"]
[
div [className "jumbotron"]
[ div [className "row"]
...
...
@@ -180,7 +185,7 @@ getDatabaseDetails reqBody = do
instance decodeJsonresponse :: DecodeJson Response where
decodeJson json = do
obj <- decodeJson json
obj
<- decodeJson json
count <- obj .? "count"
name <- obj .? "name"
name
<- obj .? "name"
pure $ Response {count,name }
src/Chart.purs
View file @
76e18024
...
...
@@ -44,47 +44,47 @@ group = unsafeMkProps "group"
-- onEvents :: String -- PropTypes.object
type EchartsProps eff =
{ className :: String,
style :: String, -- object,
theme :: String,
group :: String,
option :: Option, -- PropTypes.object.isRequired,
initOpts :: String, -- PropTypes.object,
notMerge :: Boolean,
lazyUpdate:: Boolean,
loading :: Boolean,
optsLoading
::
OptsLoading, -- PropTypes.object,
onReady :: String, -- PropTypes.func,
resizable :: Boolean, -- PropTypes.bool,
onEvents :: String -- PropTypes.object
{ className
:: String,
style
:: String, -- object,
theme
:: String,
group
:: String,
option
:: Option, -- PropTypes.object.isRequired,
initOpts
:: String, -- PropTypes.object,
notMerge
:: Boolean,
lazyUpdate
:: Boolean,
loading
:: Boolean,
optsLoading
::
OptsLoading, -- PropTypes.object,
onReady
:: String, -- PropTypes.func,
resizable
:: Boolean, -- PropTypes.bool,
onEvents
:: String -- PropTypes.object
}
type OptsLoading =
{ text :: String,
color :: Color, --- color
{ text
:: String,
color
:: Color, --- color
textColor :: Color, --color
maskColor:: Color, --color
zlevel :: Int
maskColor
:: Color, --color
zlevel
:: Int
}
type Option =
{ title :: Title
, legend :: Legend
, tooltip :: Tooltip
, grid :: Grid
, xAxis :: Array XAxis
, yAxis :: Array YAxis
, series :: Array Series
{ title
:: Title
, legend
:: Legend
, tooltip
:: Tooltip
, grid
:: Grid
, xAxis
:: Array XAxis
, yAxis
:: Array YAxis
, series
:: Array Series
, dataZoom :: Array DataZoom
}
type DataZoom =
{"type":: String
, xAxisIndex:: Int
, filterMode:: String
, start:: Int
, end:: Int
{"type"
:: String
, xAxisIndex
:: Int
, filterMode
:: String
, start
:: Int
, end
:: Int
}
type Grid =
...
...
@@ -92,66 +92,66 @@ type Grid =
}
type Legend =
{"type" :: String
, show :: Boolean
{"type"
:: String
, show
:: Boolean
, zlevel :: Number
, z :: Number
, left :: Number
, top :: Number
, right :: Number
, z
:: Number
, left
:: Number
, top
:: Number
, right
:: Number
, bottom :: Number
, width :: Number
, width
:: Number
, height :: Number
, orient :: String
, align :: String
, padding :: Number
, itemGap :: Number
, itemWidth :: Number
, itemHeight :: Number
, formatter :: String
, selectedMode :: Boolean
, align
:: String
, padding
:: Number
, itemGap
:: Number
, itemWidth
:: Number
, itemHeight
:: Number
, formatter
:: String
, selectedMode
:: Boolean
, inactiveColor :: Color
, selected :: String -- object
, "data" :: Array Data
, selected
:: String -- object
, "data"
:: Array Data
}
type Data =
{
name
:: String
, icon :: String
{
name
:: String
, icon
:: String
, textStyle :: {}
}
type SubtextStyle =
{ color :: Color
, fontStyle :: String
{ color
:: Color
, fontStyle
:: String
, fontWeight :: String
, fontFamily :: String
, fontSize :: Int
, align :: String
, fontSize
:: Int
, align
:: String
, verticalAlign :: String
, lineHeight :: Number
, width :: Number
, height :: Number
, lineHeight
:: Number
, width
:: Number
, height
:: Number
, textBorderColor :: String
, textBorderWidth :: Number
, textShadowColor :: String
, textShadowBlur :: Number
, textShadowBlur
:: Number
, textShadowOffsetX :: Number
, textShadowOffsetY :: Number
, rich :: Rich
, rich
:: Rich
}
type Tooltip =
{ trigger :: String
{ trigger
:: String
, formatter :: String -- TODO function
}
type XAxis =
{ "data" :: Array String
, "type" :: String
{ "data"
:: Array String
, "type"
:: String
, axisTick :: AxisTick
}
type AxisTick =
...
...
@@ -160,10 +160,10 @@ type AxisTick =
}
type YAxis =
{ "type" :: String
, name :: String
, min :: Int
, position :: String
{ "type"
:: String
, name
:: String
, min
:: Int
, position
:: String
, axisLabel :: AxisLabel
}
...
...
@@ -173,37 +173,37 @@ type AxisLabel =
type Series =
{
name
:: String
{
name
:: String
, "type" :: String
, "data" :: Array Int
}
type Title =
{ text :: String
, show :: Boolean
, link :: String
, target :: String
, textStyle :: TextStyle
, subtext :: String
, sublink :: String
, subtarget :: String
{ text
:: String
, show
:: Boolean
, link
:: String
, target
:: String
, textStyle
:: TextStyle
, subtext
:: String
, sublink
:: String
, subtarget
:: String
, subtextStyle :: SubtextStyle
, padding :: Number
, itemGap :: Number
, zlevel :: Number
, z :: Number
, left :: Number
, top :: Number
, right :: Number
, bottom :: Number
, padding
:: Number
, itemGap
:: Number
, zlevel
:: Number
, z
:: Number
, left
:: Number
, top
:: Number
, right
:: Number
, bottom
:: Number
, backgroundColor :: Color
, borderColor :: Color
, borderWidth :: Number
, borderRadius :: Number -- NumberOrArray
, shadowBlur :: Number
, shadowColor :: Color
, shadowOffsetX :: Number
, shadowOffsetY :: Number
, borderColor
:: Color
, borderWidth
:: Number
, borderRadius
:: Number -- NumberOrArray
, shadowBlur
:: Number
, shadowColor
:: Color
, shadowOffsetX
:: Number
, shadowOffsetY
:: Number
}
-- data NumberOrArray = Number | Array Number
...
...
@@ -224,23 +224,23 @@ loading :: Boolean -> Props
loading = unsafeMkProps "loading"
type TextStyle =
{ color :: Color
, fontStyle :: String
{ color
:: Color
, fontStyle
:: String
, fontWeight :: String
, fontFamily :: String
, fontSize :: Int
, align :: String
, verticalAlign :: String
, lineHeight :: Int
, width :: Int
, height :: Int
, fontSize
:: Int
, align
:: String
, verticalAlign
:: String
, lineHeight
:: Int
, width
:: Int
, height
:: Int
, textBorderColor :: String
, textBorderWidth :: Int
, textShadowColor :: String
, textShadowBlur :: Int
, textShadowBlur
:: Int
, textShadowOffsetX :: Int
, textShadowOffsetY :: Int
, rich :: Rich
, rich
:: Rich
}
foreign import data TextStyleProps :: Type
...
...
@@ -373,16 +373,20 @@ yAxisIndex = unsafeMkProps "yAxisIndex"
-- , p''
-- ]
ex1
:: ReactElement
ex1
= echarts
histogram
:: ReactElement
histogram
= echarts
[ option
[ tooltip [trigger "axis"]
, 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
[ type' "category"
, 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]
, yAxis [ya1, ya2]
...
...
@@ -408,22 +412,22 @@ dz2 = unsafeFromPropsArray
ya1 = unsafeFromPropsArray
[ type' "value"
, name "
Publications (by year)
"
, name "
Score metric
"
, min 0
, position "
lef
t"
, position "
righ
t"
, axisLabel [formatter "{value}"]
]
ya2 = unsafeFromPropsArray
[ type' "value"
, name "
Score metric
"
, name "
Publications (by year)
"
, min 0
, position "
righ
t"
, position "
lef
t"
, axisLabel [formatter "{value}"]
]
sd1 = unsafeFromPropsArray
[ name "
Query A
"
[ name "
Map terms coverage
"
, type' "line"
, label [normal[showp true, position "top"]]
, lineStyle [ normal
...
...
@@ -432,26 +436,26 @@ sd1 = unsafeFromPropsArray
, shadowBlur 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
]
]
sd
2
= unsafeFromPropsArray
[ name "
Query B
"
sd
3
= unsafeFromPropsArray
[ name "
All
"
, type' "bar"
, label [normal[showp true, position "top"]]
, yAxisIndex 1
, data' [2
2, 22, 23, 77, 24, 55, 55, 89, 98, 164, 106, 2
24]
, data' [2
01, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 23
24]
]
sd3 = unsafeFromPropsArray
[ name "Query C"
sd2 = unsafeFromPropsArray
[ name "Favorites"
, type' "bar"
, label [normal[showp true, position "top"]]
, yAxisIndex 1
, data' [2
01, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 23
24]
, data' [2
2, 22, 23, 77, 24, 55, 139, 350, 150, 164, 106, 2
24]
]
p'' :: ReactElement
p'' = p [] []
src/DocView.purs
View file @
76e18024
This diff is collapsed.
Click to expand it.
src/Landing.purs
View file @
76e18024
This diff is collapsed.
Click to expand it.
src/Login.purs
View file @
76e18024
...
...
@@ -26,6 +26,9 @@ import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
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
{ username :: String
, password :: String
...
...
@@ -49,7 +52,11 @@ data Action
| 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
modifyState id
...
...
@@ -148,18 +155,16 @@ unsafeEventValue e = (unsafeCoerce e).target.value
getDeviseID :: forall eff. Eff (dom :: DOM | eff) (Maybe String)
getDeviseID = do
w <- window
w
<- window
ls <- localStorage w
i <- getItem "token" ls
pure $ i
getItem "token" ls
setToken :: forall e . String -> Eff (dom :: DOM | e) Unit
setToken s = do
w <- window
w
<- window
ls <- localStorage w
liftEff $ setItem "token" s ls
pure unit
setItem "token" s ls
...
...
@@ -169,7 +174,7 @@ newtype LoginRes = LoginRes
newtype LoginReq = LoginReq
{
username :: String
{ username :: String
, password :: String
}
...
...
@@ -207,7 +212,7 @@ loginReq encodeData =
instance decodeLoginRes :: DecodeJson LoginRes where
decodeJson json = do
obj <- decodeJson json
obj
<- decodeJson json
token <- obj .? "token"
pure $ LoginRes { token}
...
...
src/Navigation.purs
View file @
76e18024
This diff is collapsed.
Click to expand it.
src/PageRouter.purs
View file @
76e18024
...
...
@@ -25,12 +25,12 @@ data Routes
instance showRoutes :: Show Routes where
show Home = "Home"
show Login = "Login"
show AddCorpus = "AddCorpus"
show DocView = "DocView"
show Home
= "Home"
show Login
= "Login"
show AddCorpus
= "AddCorpus"
show DocView
= "DocView"
show SearchView = "SearchView"
show UserPage = "UserPage"
show UserPage
= "UserPage"
int :: Match Int
int = floor <$> num
...
...
@@ -45,20 +45,30 @@ routing =
<|> addcorpusRoute
<|> home
where
userPageRoute
= UserPage
<$ route "userPage"
searchRoute = SearchView <$ route "search"
docviewRoute
= DocView
<$ route "docView"
addcorpusRoute = AddCorpus <$ route "addCorpus"
loginRoute
= Login
<$ route "login"
home
= Home
<$ lit ""
route str = lit "" *> lit str
userPageRoute
= UserPage
<$ route "userPage"
searchRoute
= SearchView <$ route "search"
docviewRoute
= DocView
<$ route "docView"
addcorpusRoute = AddCorpus
<$ route "addCorpus"
loginRoute
= Login
<$ route "login"
home
= Home
<$ lit ""
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
liftEff $ log $ "change route : " <> show new
w <- window
ls <- localStorage w
token <- getItem "accessToken" ls
w
<- window
ls
<- localStorage w
token
<- getItem "accessToken" ls
let tkn = token
liftEff $ log $ "JWToken : " <> show tkn
case tkn of
...
...
src/SearchForm.purs
View file @
76e18024
...
...
@@ -6,11 +6,12 @@ import Control.Monad.Cont.Trans (lift)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div)
import React.DOM (br', button, div, h3, input, text)
import React.DOM.Props (_id, _type, className, name, onClick, onInput, placeholder, value)
import React.DOM (br', button, div, h3, input, text
, i, span, img
)
import React.DOM.Props (_id, _type, className, name, onClick, onInput, placeholder, value
, aria, src, title
)
import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
import Landing as L
type State =
{
...
...
@@ -47,44 +48,42 @@ performAction GO _ _ = void do
unsafeEventValue :: forall event. event -> String
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, ajax::AJAX, dom::DOM | eff) State props Action
searchSpec :: forall props eff . Spec ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
searchSpec = simpleSpec performAction render
where
render :: Render State props Action
render dispatch _ state _ =
[
div [className "container"]
[
div [className "jumbotron"]
[
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"]
[ div [className "container"] [L.jumboTitle false]
, div [className "container"]
[ div [className "jumbotron" ]
[ div [className "row" ]
[ div [className "col-md-10" ]
[ br' []
, br' []
-- TODO put Gargantext logo as search button
, button [onClick \_ -> dispatch GO] [text "GO"]
]
]
]
, div [ className "form-group"]
[ 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' []
]
]
]
]
]
src/UserPage.purs
View file @
76e18024
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment