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
9264eae1
Commit
9264eae1
authored
Oct 05, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Annuaire] Back connection ok.
parent
aa8be585
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
Annuaire.purs
src/Gargantext/Pages/Corpus/Annuaire.purs
+16
-16
Documents.purs
src/Gargantext/Pages/Corpus/Doc/Facets/Documents.purs
+3
-4
No files found.
src/Gargantext/Pages/Corpus/Annuaire.purs
View file @
9264eae1
...
@@ -28,17 +28,16 @@ type State = { info :: Maybe AnnuaireInfo
...
@@ -28,17 +28,16 @@ type State = { info :: Maybe AnnuaireInfo
, table :: Maybe AnnuaireTable
, table :: Maybe AnnuaireTable
}
}
initialState :: State
initialState = { info : Nothing, table : Nothing }
type Offset = Int
type Offset = Int
type Limit = Int
type Limit = Int
data Action
data Action = Load Int
= Load Int
-- | ChangePageSize PageSizes
-- | ChangePageSize PageSizes
-- | ChangePage Int
-- | ChangePage Int
------------------------------------------------------------------------------
------------------------------------------------------------------------------
initialState :: State
initialState = { info : Nothing, table : Nothing }
defaultAnnuaireTable :: AnnuaireTable
defaultAnnuaireTable :: AnnuaireTable
defaultAnnuaireTable = AnnuaireTable { annuaireTable : [Nothing] }
defaultAnnuaireTable = AnnuaireTable { annuaireTable : [Nothing] }
...
@@ -51,7 +50,7 @@ defaultAnnuaireInfo = AnnuaireInfo { id : 0
...
@@ -51,7 +50,7 @@ defaultAnnuaireInfo = AnnuaireInfo { id : 0
, date : ""
, date : ""
, hyperdata : ""
, hyperdata : ""
}
}
------------------------------------------------------------------------------
toRows :: AnnuaireTable -> Array (Maybe User)
toRows :: AnnuaireTable -> Array (Maybe User)
toRows (AnnuaireTable a) = a.annuaireTable
toRows (AnnuaireTable a) = a.annuaireTable
...
@@ -81,7 +80,8 @@ render dispatch _ state _ = [ div [className "row"]
...
@@ -81,7 +80,8 @@ render dispatch _ state _ = [ div [className "row"]
$ maybe (toRows defaultAnnuaireTable) toRows state.table]
$ maybe (toRows defaultAnnuaireTable) toRows state.table]
]
]
where
where
(AnnuaireInfo info) = maybe defaultAnnuaireInfo identity state.info
(AnnuaireInfo info) = maybe defaultAnnuaireInfo identity state.info
(AnnuaireTable table) = maybe defaultAnnuaireTable identity state.table
------------------------------------------------------------------------------
------------------------------------------------------------------------------
newtype AnnuaireInfo = AnnuaireInfo { id :: Int
newtype AnnuaireInfo = AnnuaireInfo { id :: Int
...
@@ -116,20 +116,14 @@ instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
...
@@ -116,20 +116,14 @@ instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array (Maybe User)}
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
rows <- decodeJson json
annuaire' <- obj .? "annuaire"
pure $ AnnuaireTable { annuaireTable : rows}
pure $ AnnuaireTable { annuaireTable : annuaire'}
------------------------------------------------------------------------
getTable :: Int -> Aff (Either String AnnuaireTable)
getTable 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
eitherTable <- lift $ getTable aId
eitherTable <- lift $ getTable aId
liftEffect $ log "Feching Table"
_ <- case eitherTable of
_ <- case eitherTable of
(Right table') -> void $ modifyState $ _table ?~ table'
(Right table') -> void $ modifyState $ _table ?~ table'
(Left err) -> do
(Left err) -> do
...
@@ -143,6 +137,12 @@ performAction (Load aId) _ _ = do
...
@@ -143,6 +137,12 @@ performAction (Load aId) _ _ = do
liftEffect <<< log $ "Fetching annuaire page..."
liftEffect <<< log $ "Fetching annuaire page..."
performAction _ _ _ = pure unit
performAction _ _ _ = pure unit
------------------------------------------------------------------------
getTable :: Int -> Aff (Either String AnnuaireTable)
getTable id = get $ toUrl Back Children id
getInfo :: Int -> Aff (Either String AnnuaireInfo)
getInfo id = get $ toUrl Back Node id
------------------------------------------------------------------------------
------------------------------------------------------------------------------
_table :: Lens' State (Maybe AnnuaireTable)
_table :: Lens' State (Maybe AnnuaireTable)
_table = lens (\s -> s.table) (\s ss -> s{table = ss})
_table = lens (\s -> s.table) (\s ss -> s{table = ss})
...
...
src/Gargantext/Pages/Corpus/Doc/Facets/Documents.purs
View file @
9264eae1
...
@@ -83,7 +83,6 @@ derive instance genericCorpus :: Generic CorpusView _
...
@@ -83,7 +83,6 @@ derive instance genericCorpus :: Generic CorpusView _
instance showCorpus :: Show CorpusView where
instance showCorpus :: Show CorpusView where
show = genericShow
show = genericShow
newtype Response = Response
newtype Response = Response
{ cid :: Int
{ cid :: Int
, created :: String
, created :: String
...
@@ -92,7 +91,6 @@ newtype Response = Response
...
@@ -92,7 +91,6 @@ newtype Response = Response
, ngramCount :: Int
, ngramCount :: Int
}
}
newtype Hyperdata = Hyperdata
newtype Hyperdata = Hyperdata
{ title :: String
{ title :: String
, source :: String
, source :: String
...
@@ -200,16 +198,17 @@ performAction (LoadData n) _ _ = do
...
@@ -200,16 +198,17 @@ performAction (LoadData n) _ _ = do
loadPage :: Int -> Aff (Either String CorpusTableData)
loadPage :: Int -> Aff (Either String CorpusTableData)
loadPage n = do
loadPage n = do
res <- get $ toUrl Back Children n
res <- get $ toUrl Back Children n
-- TODO: offset and limit
-- 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: loading page documents"
_ <- 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)
_ <- liftEffect $ log $ show "Ok: loading page documents"
_ <- liftEffect $ log $ show $ map (\({ row: r, delete :_}) -> show r) ((\(TableData docs') -> docs'.rows) docs)
_ <- liftEffect $ log $ show $ map (\({ row: r, delete :_}) -> show r) ((\(TableData docs') -> docs'.rows) docs)
_ <- liftEffect $ log $ show "loading page documents"
pure $ Right docs
pure $ Right docs
where
where
res2corpus :: Array Response -> Array CorpusView
res2corpus :: Array Response -> Array CorpusView
...
...
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