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(..))
...
@@ -9,7 +9,8 @@ import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
import Effect.Class (liftEffect)
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
import Thermite (Render, Spec
, simpleSpec, defaultPerformAction
, simpleSpec, defaultPerformAction
, PerformAction, modifyState)
, PerformAction, modifyState)
...
@@ -18,73 +19,134 @@ import Effect.Aff (Aff)
...
@@ -18,73 +19,134 @@ import Effect.Aff (Aff)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User(..))
import Gargantext.Utils.DecodeMaybe ((.?|))
import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
------------------------------------------------------------------------------
type State = { info :: Maybe AnnuaireInfo
, table :: Maybe AnnuaireTable
}
defaultAnnuaire :: AnnuaireTabl
e
initialState :: Stat
e
defaultAnnuaire = AnnuaireTable {annuaireTable : [IndividuRow {id: 0, name :"nothing, error"}]
}
initialState = { info : Nothing, table : Nothing
}
t
oRows :: AnnuaireTable -> Array IndividuRow
t
ype Offset = Int
t
oRows (AnnuaireTable {annuaireTable : default}) = defaul
t
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
toRows :: AnnuaireTable -> Array (Maybe User)
render dispatch _ state _ = [ h1 [] [text "Annuaire 2"]
toRows (AnnuaireTable a) = a.annuaireTable
, p [] [text $ foldl (<>) " "
$ map (\(IndividuRow {id:_,name:n}) -> n)
$ maybe (toRows defaultAnnuaire) toRows state.annuaire]
]
layoutAnnuaire :: Spec State {} Action
layoutAnnuaire :: Spec State {} Action
layoutAnnuaire = simpleSpec performAction render
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
, name :: String
, date :: String
, hyperdata :: String
}
}
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array IndividuRow}
instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
instance decodeIndividuRow :: DecodeJson IndividuRow where
decodeJson json = do
decodeJson json = do
obj <- decodeJson json
obj <- decodeJson json
id <- obj .? "id"
id <- obj .? "id"
typename <- obj .? "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
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
instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
decodeJson json = do
decodeJson json = do
obj <- decodeJson json
obj <- decodeJson json
annuaire' <- obj .? "annuaire"
annuaire' <- obj .? "annuaire"
pure $ AnnuaireTable { annuaireTable : annuaire'}
pure $ AnnuaireTable { annuaireTable : annuaire'}
------------------------------------------------------------------------
------
------------------------------------------------------------------------
get
Annuair
e :: Int -> Aff (Either String AnnuaireTable)
get
Tabl
e :: Int -> Aff (Either String AnnuaireTable)
get
Annuair
e id = get $ toUrl Back Children id
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 :: PerformAction State {} Action
performAction (Load aId) _ _ = do
performAction (Load aId) _ _ = do
either
Annuaire <- lift $ getAnnuair
e aId
either
Table <- lift $ getTabl
e aId
_ <- case either
Annuair
e of
_ <- case either
Tabl
e of
(Right
annuaire') -> void $ modifyState $ _annuaire ?~ annuair
e'
(Right
table') -> void $ modifyState $ _table ?~ tabl
e'
(Left err) -> do
(Left err) -> do
liftEffect $ log err
liftEffect $ log err
liftEffect <<< log $ "Fetching annuaire..."
performAction _ _ _ = pure unit
------------------------------------------------------------------------------
------------------------------------------------------------------------------
type State = { annuaire :: Maybe AnnuaireTable}
initialState :: State
eitherInfo <- lift $ getInfo aId
initialState = { annuaire : Nothing }
_ <- case eitherInfo of
(Right info') -> void $ modifyState $ _info ?~ info'
(Left err) -> do
liftEffect $ log err
data Action
liftEffect <<< log $ "Fetching annuaire page..."
= Load Int
performAction _ _ _ = pure unit
-- | ChangePageSize PageSizes
-- | ChangePage Int
------------------------------------------------------------------------------
_annuaire :: Lens' State (Maybe AnnuaireTable)
_annuaire = lens (\s -> s.annuaire) (\s ss -> s{annuaire = ss})
------------------------------------------------------------------------------
------------------------------------------------------------------------------
_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)
...
@@ -45,7 +45,7 @@ import Unsafe.Coerce (unsafeCoerce)
-- Right now it doesn't make sense to reload mock data.
-- Right now it doesn't make sense to reload mock data.
data Action
data Action
= LoadData
= LoadData
Int
| ChangePageSize PageSizes
| ChangePageSize PageSizes
| ChangePage Int
| ChangePage Int
...
@@ -185,20 +185,26 @@ performAction (ChangePageSize ps) _ _ = void $ modifyState $ changePageSize ps
...
@@ -185,20 +185,26 @@ performAction (ChangePageSize ps) _ _ = void $ modifyState $ changePageSize ps
performAction (ChangePage p) _ _ = void $ modifyState \(TableData td) -> TableData $ td { currentPage = p }
performAction (ChangePage p) _ _ = void $ modifyState \(TableData td) -> TableData $ td { currentPage = p }
performAction
LoadData
_ _ = do
performAction
(LoadData n)
_ _ = do
res <- lift $ loadPage
res <- lift $ loadPage
n
case res of
case res of
Left err -> pure unit
Left err -> do
Right resData -> void $ modifyState $ const resData
_ <- 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 ::
Int ->
Aff (Either String CorpusTableData)
loadPage = do
loadPage
n
= do
res <- get $ toUrl Back Children
452132
res <- get $ toUrl Back Children
n
-- res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10"
-- res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10"
case res of
case res of
Left err -> do
Left err -> do
_ <- liftEffect $ log $ show err
_ <- liftEffect $ log $ show err
_ <- liftEffect $ log $ show "loading page documents"
pure $ Left $ show err
pure $ Left $ show err
Right resData -> do
Right resData -> do
let docs = toTableData (res2corpus $ resData)
let docs = toTableData (res2corpus $ resData)
...
...
src/Gargantext/Pages/Layout.purs
View file @
aa8be585
...
@@ -35,9 +35,9 @@ dispatchAction dispatcher _ AddCorpus = do
...
@@ -35,9 +35,9 @@ dispatchAction dispatcher _ AddCorpus = do
dispatcher $ SetRoute AddCorpus
dispatcher $ SetRoute AddCorpus
dispatcher $ AddCorpusA AC.LoadDatabaseDetails
dispatcher $ AddCorpusA AC.LoadDatabaseDetails
dispatchAction dispatcher _
DocView
= do
dispatchAction dispatcher _
(DocView n)
= do
dispatcher $ SetRoute
DocView
dispatcher $ SetRoute
(DocView n)
dispatcher $ DocViewA $ DV.LoadData
dispatcher $ DocViewA $ DV.LoadData
n
dispatchAction dispatcher _ SearchView = do
dispatchAction dispatcher _ SearchView = do
dispatcher $ SetRoute SearchView
dispatcher $ SetRoute SearchView
...
...
src/Gargantext/Pages/Layout/Specs.purs
View file @
aa8be585
...
@@ -58,7 +58,7 @@ pagesComponent s =
...
@@ -58,7 +58,7 @@ pagesComponent s =
selectSpec Login = focus _loginState _loginAction LN.renderSpec
selectSpec Login = focus _loginState _loginAction LN.renderSpec
selectSpec Home = layout0 $ noState (L.layoutLanding EN)
selectSpec Home = layout0 $ noState (L.layoutLanding EN)
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 i)
= layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser
selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser
selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState _docAnnotationViewAction D.docview
selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState _docAnnotationViewAction D.docview
selectSpec Tabview = layout0 $ noState TV.pureTab1
selectSpec Tabview = layout0 $ noState TV.pureTab1
...
...
src/Gargantext/Router.purs
View file @
aa8be585
...
@@ -17,7 +17,7 @@ data Routes
...
@@ -17,7 +17,7 @@ data Routes
= Home
= Home
| Login
| Login
| AddCorpus
| AddCorpus
| DocView
| DocView
Int
| SearchView
| SearchView
| UserPage Int
| UserPage Int
| DocAnnotation Int
| DocAnnotation Int
...
@@ -33,7 +33,7 @@ data Routes
...
@@ -33,7 +33,7 @@ data Routes
instance showRoutes :: Show Routes where
instance showRoutes :: Show Routes where
show Login = "Login"
show Login = "Login"
show AddCorpus = "AddCorpus"
show AddCorpus = "AddCorpus"
show
DocView
= "DocView"
show
(DocView i)
= "DocView"
show SearchView = "Search"
show SearchView = "Search"
show (UserPage i) = "User"
show (UserPage i) = "User"
show (DocAnnotation i)= "Document"
show (DocAnnotation i)= "Document"
...
@@ -56,7 +56,7 @@ routing =
...
@@ -56,7 +56,7 @@ routing =
<|> DocAnnotation <$> (route "document" *> int)
<|> DocAnnotation <$> (route "document" *> int)
<|> UserPage <$> (route "user" *> int)
<|> UserPage <$> (route "user" *> int)
<|> SearchView <$ route "search"
<|> SearchView <$ route "search"
<|> DocView <$
route "docView"
<|> DocView <$
> (route "docView" *> int)
<|> AddCorpus <$ route "addCorpus"
<|> AddCorpus <$ route "addCorpus"
<|> CorpusAnalysis <$ route "corpus"
<|> CorpusAnalysis <$ route "corpus"
<|> PGraphExplorer <$ route "graph"
<|> 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