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
aa8be585
Commit
aa8be585
authored
Oct 05, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PAGES] Corpus Documents are not loaded.
parent
b1ff0afb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
58 deletions
+126
-58
Annuaire.purs
src/Gargantext/Pages/Corpus/Annuaire.purs
+105
-43
Documents.purs
src/Gargantext/Pages/Corpus/Doc/Facets/Documents.purs
+14
-8
Layout.purs
src/Gargantext/Pages/Layout.purs
+3
-3
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+1
-1
Router.purs
src/Gargantext/Router.purs
+3
-3
No files found.
src/Gargantext/Pages/Corpus/Annuaire.purs
View file @
aa8be585
...
...
@@ -9,7 +9,8 @@ import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Maybe (Maybe(..), maybe)
import Effect.Class (liftEffect)
import React.DOM (div, h1, p, text)
import React.DOM (div, h1, h3, hr, i, p, text)
import React.DOM.Props (className, style)
import Thermite (Render, Spec
, simpleSpec, defaultPerformAction
, PerformAction, modifyState)
...
...
@@ -18,73 +19,134 @@ import Effect.Aff (Aff)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User(..))
import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
------------------------------------------------------------------------------
type State = { info :: Maybe AnnuaireInfo
, table :: Maybe AnnuaireTable
}
defaultAnnuaire :: AnnuaireTabl
e
defaultAnnuaire = AnnuaireTable {annuaireTable : [IndividuRow {id: 0, name :"nothing, error"}]
}
initialState :: Stat
e
initialState = { info : Nothing, table : Nothing
}
t
oRows :: AnnuaireTable -> Array IndividuRow
t
oRows (AnnuaireTable {annuaireTable : default}) = defaul
t
t
ype Offset = Int
t
ype Limit = In
t
data Action
= Load Int
-- | ChangePageSize PageSizes
-- | ChangePage Int
------------------------------------------------------------------------------
defaultAnnuaireTable :: AnnuaireTable
defaultAnnuaireTable = AnnuaireTable { annuaireTable : [Nothing] }
defaultAnnuaireInfo :: AnnuaireInfo
defaultAnnuaireInfo = AnnuaireInfo { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : ""
, date : ""
, hyperdata : ""
}
render :: Render State {} Action
render dispatch _ state _ = [ h1 [] [text "Annuaire 2"]
, p [] [text $ foldl (<>) " "
$ map (\(IndividuRow {id:_,name:n}) -> n)
$ maybe (toRows defaultAnnuaire) toRows state.annuaire]
]
toRows :: AnnuaireTable -> Array (Maybe User)
toRows (AnnuaireTable a) = a.annuaireTable
layoutAnnuaire :: Spec State {} Action
layoutAnnuaire = simpleSpec performAction render
render :: Render State {} Action
render dispatch _ state _ = [ div [className "row"]
[ div [className "col-md-3"] [ h3 [] [text info.name] ]
, div [className "col-md-9"] [ hr [style {height : "2px",backgroundColor : "black"}] ]
]
, div [className "row"] [ div [className "jumbotron1", style {padding : "12px 0px 20px 12px"}]
[ div [ className "col-md-8 content"]
[ p [] [ i [className "fa fa-globe"] []
, text info.name
]
]
, div [ className "col-md-4 content"]
[ p [] [ i [className "fa fa-calendar"] []
, text info.date
]
]
]
]
, p [] [text $ foldl (<>) " "
$ map (maybe "Nothing" (\(User u) -> show u.name))
$ maybe (toRows defaultAnnuaireTable) toRows state.table]
]
where
(AnnuaireInfo info) = maybe defaultAnnuaireInfo identity state.info
------------------------------------------------------------------------------
newtype IndividuRow = IndividuRow { id :: Int
newtype AnnuaireInfo = AnnuaireInfo { id :: Int
, typename :: Int
, userId :: Int
, parentId :: Int
, name :: String
, date :: String
, hyperdata :: String
}
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array IndividuRow}
instance decodeIndividuRow :: DecodeJson IndividuRow where
instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
typename <- obj .? "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
pure $ IndividuRow { id : id, name : name}
date <- obj .? "date"
hyperdata <- obj .? "hyperdata"
pure $ AnnuaireInfo { id : id
, typename : typename
, userId : userId
, parentId : parentId
, name : name
, date : date
, hyperdata: hyperdata
}
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array (Maybe User)}
instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
decodeJson json = do
obj <- decodeJson json
annuaire' <- obj .? "annuaire"
pure $ AnnuaireTable { annuaireTable : annuaire'}
------------------------------------------------------------------------
------
get
Annuair
e :: Int -> Aff (Either String AnnuaireTable)
get
Annuair
e id = get $ toUrl Back Children id
------------------------------------------------------------------------
get
Tabl
e :: Int -> Aff (Either String AnnuaireTable)
get
Tabl
e id = get $ toUrl Back Children id
getInfo :: Int -> Aff (Either String AnnuaireInfo)
getInfo id = get $ toUrl Back Node id
------------------------------------------------------------------------
performAction :: PerformAction State {} Action
performAction (Load aId) _ _ = do
either
Annuaire <- lift $ getAnnuair
e aId
_ <- case either
Annuair
e of
(Right
annuaire') -> void $ modifyState $ _annuaire ?~ annuair
e'
either
Table <- lift $ getTabl
e aId
_ <- case either
Tabl
e of
(Right
table') -> void $ modifyState $ _table ?~ tabl
e'
(Left err) -> do
liftEffect $ log err
liftEffect <<< log $ "Fetching annuaire..."
performAction _ _ _ = pure unit
------------------------------------------------------------------------------
------------------------------------------------------------------------------
type State = { annuaire :: Maybe AnnuaireTable}
initialState :: State
initialState = { annuaire : Nothing }
eitherInfo <- lift $ getInfo aId
_ <- case eitherInfo of
(Right info') -> void $ modifyState $ _info ?~ info'
(Left err) -> do
liftEffect $ log err
data Action
= Load Int
-- | ChangePageSize PageSizes
-- | ChangePage Int
------------------------------------------------------------------------------
_annuaire :: Lens' State (Maybe AnnuaireTable)
_annuaire = lens (\s -> s.annuaire) (\s ss -> s{annuaire = ss})
liftEffect <<< log $ "Fetching annuaire page..."
performAction _ _ _ = pure unit
------------------------------------------------------------------------------
_table :: Lens' State (Maybe AnnuaireTable)
_table = lens (\s -> s.table) (\s ss -> s{table = ss})
_info :: Lens' State (Maybe AnnuaireInfo)
_info = lens (\s -> s.info) (\s ss -> s{info = ss})
------------------------------------------------------------------------------
src/Gargantext/Pages/Corpus/Doc/Facets/Documents.purs
View file @
aa8be585
...
...
@@ -45,7 +45,7 @@ import Unsafe.Coerce (unsafeCoerce)
-- Right now it doesn't make sense to reload mock data.
data Action
= LoadData
= LoadData
Int
| ChangePageSize PageSizes
| ChangePage Int
...
...
@@ -185,20 +185,26 @@ performAction (ChangePageSize ps) _ _ = void $ modifyState $ changePageSize ps
performAction (ChangePage p) _ _ = void $ modifyState \(TableData td) -> TableData $ td { currentPage = p }
performAction
LoadData
_ _ = do
res <- lift $ loadPage
performAction
(LoadData n)
_ _ = do
res <- lift $ loadPage
n
case res of
Left err -> pure unit
Right resData -> void $ modifyState $ const resData
Left err -> do
_ <- liftEffect $ log $ show err
_ <- liftEffect $ log $ show "Error: loading page documents"
pure unit
Right resData -> do
_ <- liftEffect $ log $ show "OK: loading page documents"
void $ modifyState $ const resData
loadPage :: Aff (Either String CorpusTableData)
loadPage = do
res <- get $ toUrl Back Children
452132
loadPage ::
Int ->
Aff (Either String CorpusTableData)
loadPage
n
= do
res <- get $ toUrl Back Children
n
-- res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10"
case res of
Left err -> do
_ <- liftEffect $ log $ show err
_ <- liftEffect $ log $ show "loading page documents"
pure $ Left $ show err
Right resData -> do
let docs = toTableData (res2corpus $ resData)
...
...
src/Gargantext/Pages/Layout.purs
View file @
aa8be585
...
...
@@ -35,9 +35,9 @@ dispatchAction dispatcher _ AddCorpus = do
dispatcher $ SetRoute AddCorpus
dispatcher $ AddCorpusA AC.LoadDatabaseDetails
dispatchAction dispatcher _
DocView
= do
dispatcher $ SetRoute
DocView
dispatcher $ DocViewA $ DV.LoadData
dispatchAction dispatcher _
(DocView n)
= do
dispatcher $ SetRoute
(DocView n)
dispatcher $ DocViewA $ DV.LoadData
n
dispatchAction dispatcher _ SearchView = do
dispatcher $ SetRoute SearchView
...
...
src/Gargantext/Pages/Layout/Specs.purs
View file @
aa8be585
...
...
@@ -58,7 +58,7 @@ pagesComponent s =
selectSpec Login = focus _loginState _loginAction LN.renderSpec
selectSpec Home = layout0 $ noState (L.layoutLanding EN)
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec
DocView
= layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec
(DocView i)
= layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser
selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState _docAnnotationViewAction D.docview
selectSpec Tabview = layout0 $ noState TV.pureTab1
...
...
src/Gargantext/Router.purs
View file @
aa8be585
...
...
@@ -17,7 +17,7 @@ data Routes
= Home
| Login
| AddCorpus
| DocView
| DocView
Int
| SearchView
| UserPage Int
| DocAnnotation Int
...
...
@@ -33,7 +33,7 @@ data Routes
instance showRoutes :: Show Routes where
show Login = "Login"
show AddCorpus = "AddCorpus"
show
DocView
= "DocView"
show
(DocView i)
= "DocView"
show SearchView = "Search"
show (UserPage i) = "User"
show (DocAnnotation i)= "Document"
...
...
@@ -56,7 +56,7 @@ routing =
<|> DocAnnotation <$> (route "document" *> int)
<|> UserPage <$> (route "user" *> int)
<|> SearchView <$ route "search"
<|> DocView <$
route "docView"
<|> DocView <$
> (route "docView" *> int)
<|> AddCorpus <$ route "addCorpus"
<|> CorpusAnalysis <$ route "corpus"
<|> PGraphExplorer <$ route "graph"
...
...
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