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
fe2bbca3
Commit
fe2bbca3
authored
Aug 10, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[loader] rewrite params for useLoader
parent
034ea2e7
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
317 additions
and
223 deletions
+317
-223
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+5
-1
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+15
-21
FolderView.purs
src/Gargantext/Components/FolderView.purs
+14
-4
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+15
-6
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+13
-8
SubTree.purs
...Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
+21
-16
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+5
-1
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+11
-7
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+12
-4
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+29
-26
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+19
-17
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+6
-2
Common.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
+6
-2
Dashboard.purs
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
+13
-10
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+5
-2
File.purs
src/Gargantext/Components/Nodes/File.purs
+5
-1
Frame.purs
src/Gargantext/Components/Nodes/Frame.purs
+6
-2
Public.purs
src/Gargantext/Components/Nodes/Home/Public.purs
+7
-2
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+38
-39
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+43
-33
Router.purs
src/Gargantext/Components/Router.purs
+0
-2
Loader.purs
src/Gargantext/Hooks/Loader.purs
+29
-17
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
fe2bbca3
...
@@ -331,7 +331,11 @@ pageLayoutCpt = here.component "pageLayout" cpt where
...
@@ -331,7 +331,11 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, totalRecords = count }
, totalRecords = count }
, localCategories
, localCategories
, params: paramsS } []
, params: paramsS } []
useLoader (path { params = paramsS' }) loader render
let errorHandler err = here.log2 "[pageLayout] RESTError" err
useLoader { errorHandler
, path: path { params = paramsS' }
, loader
, render }
type PageProps = (
type PageProps = (
documents :: Array DocumentsView
documents :: Array DocumentsView
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
fe2bbca3
...
@@ -34,7 +34,7 @@ import Gargantext.Hooks.Loader (useLoader)
...
@@ -34,7 +34,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(Search, NodeAPI))
import Gargantext.Routes (SessionRoute(Search, NodeAPI))
import Gargantext.Routes as Routes
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, post, deleteWithBody)
import Gargantext.Sessions (Session, sessionId, post, deleteWithBody)
import Gargantext.Types (NodeType(..), OrderBy(..), Node
Path(..), Node
ID)
import Gargantext.Types (NodeType(..), OrderBy(..), NodeID)
import Gargantext.Utils (toggleSet, zeroPad)
import Gargantext.Utils (toggleSet, zeroPad)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -122,7 +122,6 @@ instance Eq Rows where
...
@@ -122,7 +122,6 @@ instance Eq Rows where
-- | Main layout of the Documents Tab of a Corpus
-- | Main layout of the Documents Tab of a Corpus
docView :: Record Props -> R.Element
docView :: Record Props -> R.Element
docView props = R.createElement docViewCpt props []
docView props = R.createElement docViewCpt props []
docViewCpt :: R.Component Props
docViewCpt :: R.Component Props
docViewCpt = here.component "docView" cpt
docViewCpt = here.component "docView" cpt
where
where
...
@@ -172,7 +171,6 @@ togglePendingDeletion (_ /\ setDeletions) nid = setDeletions setter
...
@@ -172,7 +171,6 @@ togglePendingDeletion (_ /\ setDeletions) nid = setDeletions setter
docViewGraph :: Record Props -> R.Element
docViewGraph :: Record Props -> R.Element
docViewGraph props = R.createElement docViewCpt props []
docViewGraph props = R.createElement docViewCpt props []
docViewGraphCpt :: R.Component Props
docViewGraphCpt :: R.Component Props
docViewGraphCpt = here.component "docViewGraph" cpt
docViewGraphCpt = here.component "docViewGraph" cpt
where
where
...
@@ -266,7 +264,6 @@ doc2view ( Document { id
...
@@ -266,7 +264,6 @@ doc2view ( Document { id
contact2view :: Contact -> ContactsView
contact2view :: Contact -> ContactsView
contact2view (Contact { c_id
contact2view (Contact { c_id
, c_created: date
, c_hyperdata
, c_hyperdata
, c_annuaireId
, c_annuaireId
, c_score
, c_score
...
@@ -278,7 +275,8 @@ contact2view (Contact { c_id
...
@@ -278,7 +275,8 @@ contact2view (Contact { c_id
, delete: false
, delete: false
}
}
err2view message =
err2view :: forall a. a -> DocumentsView
err2view _message =
DocumentsView { id: 1
DocumentsView { id: 1
, date: ""
, date: ""
, title : "SearchNoResult"
, title : "SearchNoResult"
...
@@ -307,15 +305,17 @@ type PageProps = ( rowsLoaded :: Rows | PageLayoutProps )
...
@@ -307,15 +305,17 @@ type PageProps = ( rowsLoaded :: Rows | PageLayoutProps )
-- | Loads and renders a page
-- | Loads and renders a page
pageLayout :: R2.Component PageLayoutProps
pageLayout :: R2.Component PageLayoutProps
pageLayout = R.createElement pageLayoutCpt
pageLayout = R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt
pageLayoutCpt = here.component "pageLayout" cpt
where
where
cpt { container, deletions, frontends, path, session, totalRecords } _ = do
cpt { container, deletions, frontends, path, session, totalRecords } _ = do
path' <- T.useLive T.unequal path
path' <- T.useLive T.unequal path
useLoader path' loadPage $ \rowsLoaded ->
useLoader { errorHandler
page { container, deletions, frontends, path, rowsLoaded, session, totalRecords } []
, loader: loadPage
, path: path'
, render: \rowsLoaded -> page { container, deletions, frontends, path, rowsLoaded, session, totalRecords } [] }
errorHandler err = here.log2 "[pageLayout] RESTError" err
page :: R2.Component PageProps
page :: R2.Component PageProps
page = R.createElement pageCpt
page = R.createElement pageCpt
...
@@ -330,12 +330,11 @@ pageCpt = here.component "page" cpt
...
@@ -330,12 +330,11 @@ pageCpt = here.component "page" cpt
, rowsLoaded
, rowsLoaded
, session
, session
, totalRecords } _ = do
, totalRecords } _ = do
path'
@{ nodeId, listId, query }
<- T.useLive T.unequal path
path' <- T.useLive T.unequal path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
deletions' <- T.useLive T.unequal deletions
deletions' <- T.useLive T.unequal deletions
let isChecked id = Set.member id deletions'.pending
let isDeleted (DocumentsView {id}) = Set.member id deletions'.deleted
isDeleted (DocumentsView {id}) = Set.member id deletions'.deleted
rows path' = case rowsLoaded of
rows path' = case rowsLoaded of
Docs {docs} -> docRow path' <$> Seq.filter (not <<< isDeleted) docs
Docs {docs} -> docRow path' <$> Seq.filter (not <<< isDeleted) docs
...
@@ -362,17 +361,12 @@ pageCpt = here.component "page" cpt
...
@@ -362,17 +361,12 @@ pageCpt = here.component "page" cpt
documentUrl id { listId, nodeId } =
documentUrl id { listId, nodeId } =
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
pairUrl (Pair {id,label})
| id > 1 = H.a { href, target: "blank" } [ H.text label ]
where href = url session $ NodePath (sessionId session) NodeContact (Just id)
| otherwise = H.text label
contactRow path' (ContactsView { id, hyperdata: HyperdataRowContact { firstname, lastname, labs }
contactRow path' (ContactsView { id, hyperdata: HyperdataRowContact { firstname, lastname, labs }
,
score,
annuaireId, delete
, annuaireId, delete
}) =
}) =
{ row:
{ row:
T.makeRow [ H.div {} [ H.a { className: gi Favorite, on: {click: markClick path'} } [] ]
T.makeRow [ H.div {} [ H.a { className: gi Favorite, on: {click: markClick path'} } [] ]
, maybeStricken delete [ H.a {
target: "_blank", href: contactUrl annuaireId id
}
, maybeStricken delete [ H.a {
target: "_blank", href: contactUrl id
}
[ H.text $ firstname <> " " <> lastname ]
[ H.text $ firstname <> " " <> lastname ]
]
]
, maybeStricken delete [ H.text labs ]
, maybeStricken delete [ H.text labs ]
...
@@ -381,9 +375,9 @@ pageCpt = here.component "page" cpt
...
@@ -381,9 +375,9 @@ pageCpt = here.component "page" cpt
}
}
where
where
markClick { nodeId } _ = markCategory session nodeId Favorite [id]
markClick { nodeId } _ = markCategory session nodeId Favorite [id]
contactUrl
aId
id' = url frontends $ Routes.ContactPage (sessionId session) annuaireId id'
contactUrl id' = url frontends $ Routes.ContactPage (sessionId session) annuaireId id'
docRow path' dv@(DocumentsView {id,
score, title, source, authors, pairs
, delete, category}) =
docRow path' dv@(DocumentsView {id,
title, source
, delete, category}) =
{ row:
{ row:
T.makeRow [ H.div {} [ H.a { className: gi category, on: {click: markClick path'} } [] ]
T.makeRow [ H.div {} [ H.a { className: gi category, on: {click: markClick path'} } [] ]
, maybeStricken delete [ H.text $ publicationDate dv ]
, maybeStricken delete [ H.text $ publicationDate dv ]
...
@@ -400,7 +394,7 @@ pageCpt = here.component "page" cpt
...
@@ -400,7 +394,7 @@ pageCpt = here.component "page" cpt
| otherwise = H.div {}
| otherwise = H.div {}
publicationDate :: DocumentsView -> String
publicationDate :: DocumentsView -> String
publicationDate (DocumentsView {
publication_year, publication_month, publication_day
}) =
publicationDate (DocumentsView {
publication_year, publication_month
}) =
(zeroPad 2 publication_year) <> "-" <> (zeroPad 2 publication_month)
(zeroPad 2 publication_year) <> "-" <> (zeroPad 2 publication_month)
-- <> "-" <> (zeroPad 2 publication_day)
-- <> "-" <> (zeroPad 2 publication_day)
...
...
src/Gargantext/Components/FolderView.purs
View file @
fe2bbca3
...
@@ -59,15 +59,18 @@ data FolderStyle = FolderUp | FolderChild
...
@@ -59,15 +59,18 @@ data FolderStyle = FolderUp | FolderChild
folderView :: R2.Leaf Props
folderView :: R2.Leaf Props
folderView props = R.createElement folderViewCpt props []
folderView props = R.createElement folderViewCpt props []
folderViewCpt :: R.Component Props
folderViewCpt :: R.Component Props
folderViewCpt = here.component "folderViewCpt" cpt where
folderViewCpt = here.component "folderViewCpt" cpt where
cpt {nodeId, session, backFolder, tasks, reloadForest} _ = do
cpt {nodeId, session, backFolder, tasks, reloadForest} _ = do
setPopoverRef <- R.useRef Nothing
setPopoverRef <- R.useRef Nothing
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
reload' <- T.useLive T.unequal reload
useLoader { nodeId, session, reload: reload'} loadFolders $
useLoader { errorHandler
\folders -> folderViewMain {folders, nodeId, session, backFolder, tasks, reload, setPopoverRef, reloadForest}
, loader: loadFolders
, path: { nodeId, session, reload: reload'}
, render: \folders -> folderViewMain {folders, nodeId, session, backFolder, tasks, reload, setPopoverRef, reloadForest} }
where
errorHandler err = here.log2 "[folderView] RESTError" err
type FolderViewProps =
type FolderViewProps =
(
(
...
@@ -86,7 +89,14 @@ folderViewMain props = R.createElement folderViewMainCpt props []
...
@@ -86,7 +89,14 @@ folderViewMain props = R.createElement folderViewMainCpt props []
folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt = here.component "folderViewMainCpt" cpt where
folderViewMainCpt = here.component "folderViewMainCpt" cpt where
cpt {nodeId, session, backFolder, tasks, setPopoverRef, reload, reloadForest, folders: tree@(NTree (LNode {parent_id: parentId, nodeType}) (folders))} _ = do
cpt { backFolder
, folders: NTree (LNode {parent_id: parentId, nodeType}) (folders)
, nodeId
, reload
, reloadForest
, session
, setPopoverRef
, tasks } _ = do
let foldersS = A.sortBy sortFolders folders
let foldersS = A.sortBy sortFolders folders
let backHome = isBackHome nodeType
let backHome = isBackHome nodeType
let parent = makeParentFolder parentId session backFolder backHome
let parent = makeParentFolder parentId session backFolder backHome
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
fe2bbca3
...
@@ -80,11 +80,16 @@ treeLoaderCpt = here.component "treeLoader" cpt where
...
@@ -80,11 +80,16 @@ treeLoaderCpt = here.component "treeLoader" cpt where
cpt p@{ root, session } _ = do
cpt p@{ root, session } _ = do
-- app <- T.useLive T.unequal p.reloadRoot
-- app <- T.useLive T.unequal p.reloadRoot
let fetch { root: r } = getNodeTree session r
let fetch { root: r } = getNodeTree session r
useLoader { root } fetch loaded where
useLoader { errorHandler
loaded tree' = tree props where
, loader: fetch
props = Record.merge common extra where
, path: { root }
common = RecordE.pick p :: Record Common
, render: loaded }
extra = { tree: tree', reloadTree: p.reload, session }
where
loaded tree' = tree props where
props = Record.merge common extra where
common = RecordE.pick p :: Record Common
extra = { tree: tree', reloadTree: p.reload, session }
errorHandler err = here.log2 "[treeLoader] RESTError" err
getNodeTree :: Session -> ID -> Aff (Either RESTError FTree)
getNodeTree :: Session -> ID -> Aff (Either RESTError FTree)
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
...
@@ -185,8 +190,12 @@ childLoaderCpt = here.component "childLoader" cpt where
...
@@ -185,8 +190,12 @@ childLoaderCpt = here.component "childLoader" cpt where
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
let reloads = [ reload, p.reloadRoot, p.reloadTree ]
let reloads = [ reload, p.reloadRoot, p.reloadTree ]
cache <- (A.cons p.id) <$> traverse (T.useLive T.unequal) reloads
cache <- (A.cons p.id) <$> traverse (T.useLive T.unequal) reloads
useLoader cache fetch (paint reload)
useLoader { errorHandler
, loader: fetch
, path: cache
, render: paint reload }
where
where
errorHandler err = here.log2 "[childLoader] RESTError" err
fetch _ = getNodeTreeFirstLevel p.session p.id
fetch _ = getNodeTreeFirstLevel p.session p.id
paint reload tree' = render (Record.merge base extra) where
paint reload tree' = render (Record.merge base extra) where
base = nodeProps { reload = reload }
base = nodeProps { reload = reload }
...
...
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
fe2bbca3
...
@@ -307,22 +307,27 @@ nodeActionsCpt = here.component "nodeActions" cpt where
...
@@ -307,22 +307,27 @@ nodeActionsCpt = here.component "nodeActions" cpt where
graphNodeActions :: R2.Leaf NodeActionsCommon
graphNodeActions :: R2.Leaf NodeActionsCommon
graphNodeActions props = R.createElement graphNodeActionsCpt props []
graphNodeActions props = R.createElement graphNodeActionsCpt props []
graphNodeActionsCpt :: R.Component NodeActionsCommon
graphNodeActionsCpt :: R.Component NodeActionsCommon
graphNodeActionsCpt = here.component "graphNodeActions" cpt where
graphNodeActionsCpt = here.component "graphNodeActions" cpt where
cpt { id, session, refresh } _ =
cpt { id, session, refresh } _ =
useLoader id (graphVersions session) $ \gv ->
useLoader { errorHandler
nodeActionsGraph { graphVersions: gv, session, id, refresh } []
, loader: graphVersions session
, path: id
, render: \gv -> nodeActionsGraph { graphVersions: gv, session, id, refresh } [] }
graphVersions session graphId = GraphAPI.graphVersions { graphId, session }
graphVersions session graphId = GraphAPI.graphVersions { graphId, session }
errorHandler err = here.log2 "[graphNodeActions] RESTError" err
listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions props = R.createElement listNodeActionsCpt props []
listNodeActions props = R.createElement listNodeActionsCpt props []
listNodeActionsCpt :: R.Component NodeActionsCommon
listNodeActionsCpt :: R.Component NodeActionsCommon
listNodeActionsCpt = here.component "listNodeActions" cpt where
listNodeActionsCpt = here.component "listNodeActions" cpt where
cpt { id, session, refresh } _ =
cpt { id, session, refresh } _ =
useLoader { nodeId: id, session } loadCorpusWithChild $ \{ corpusId } ->
useLoader { errorHandler
nodeActionsNodeList
, path: { nodeId: id, session }
{ listId: id, nodeId: corpusId, session, refresh: refresh
, loader: loadCorpusWithChild
, nodeType: GT.TabNgramType GT.CTabTerms }
, render: \{ corpusId } -> nodeActionsNodeList
{ listId: id, nodeId: corpusId, session, refresh: refresh
, nodeType: GT.TabNgramType GT.CTabTerms } }
where
errorHandler err = here.log2 "[listNodeActions] RESTError" err
src/Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
View file @
fe2bbca3
...
@@ -6,6 +6,12 @@ import Data.Array as A
...
@@ -6,6 +6,12 @@ import Data.Array as A
import Data.Either (Either)
import Data.Either (Either)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import React.SyntheticEvent as E
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
import Gargantext.Components.Forest.Tree.Node.Action (Props, Action, subTreeOut, setTreeOut)
import Gargantext.Components.Forest.Tree.Node.Action (Props, Action, subTreeOut, setTreeOut)
import Gargantext.Components.Forest.Tree.Node.Tools (nodeText)
import Gargantext.Components.Forest.Tree.Node.Tools (nodeText)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
...
@@ -16,11 +22,6 @@ import Gargantext.Routes as GR
...
@@ -16,11 +22,6 @@ import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), get)
import Gargantext.Sessions (Session(..), get)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import React.SyntheticEvent as E
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools.SubTree"
here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools.SubTree"
...
@@ -55,17 +56,21 @@ subTreeViewCpt = here.component "subTreeView" cpt
...
@@ -55,17 +56,21 @@ subTreeViewCpt = here.component "subTreeView" cpt
-- (valAction /\ setAction) = action
-- (valAction /\ setAction) = action
-- _ <- pure $ setAction (const $ setTreeOut valAction Nothing)
-- _ <- pure $ setAction (const $ setTreeOut valAction Nothing)
useLoader session (loadSubTree showtypes) $
useLoader { errorHandler
\tree ->
, loader: loadSubTree showtypes
subTreeViewLoaded { action
, path: session
, dispatch
, render: \tree ->
, handed
subTreeViewLoaded { action
, id
, dispatch
, nodeType
, handed
, session
, id
, subTreeParams
, nodeType
, tree
, session
} []
, subTreeParams
, tree
} [] }
where
errorHandler err = here.log2 "RESTError" err
loadSubTree :: Array GT.NodeType -> Session -> Aff (Either RESTError FTree)
loadSubTree :: Array GT.NodeType -> Session -> Aff (Either RESTError FTree)
loadSubTree nodetypes session = getSubTree session treeId nodetypes
loadSubTree nodetypes session = getSubTree session treeId nodetypes
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
fe2bbca3
...
@@ -69,8 +69,12 @@ explorerLayoutCpt = here.component "explorerLayout" cpt where
...
@@ -69,8 +69,12 @@ explorerLayoutCpt = here.component "explorerLayout" cpt where
cpt props@{ boxes: { graphVersion }, graphId, session } _ = do
cpt props@{ boxes: { graphVersion }, graphId, session } _ = do
graphVersion' <- T.useLive T.unequal graphVersion
graphVersion' <- T.useLive T.unequal graphVersion
useLoader graphId (getNodes session graphVersion') handler
useLoader { errorHandler
, loader: getNodes session graphVersion'
, path: graphId
, render: handler }
where
where
errorHandler err = here.log2 "[explorerLayout] RESTError" err
handler loaded@(GET.HyperdataGraph { graph: hyperdataGraph }) =
handler loaded@(GET.HyperdataGraph { graph: hyperdataGraph }) =
explorerWriteGraph (Record.merge props { graph, hyperdataGraph: loaded, mMetaData' }) []
explorerWriteGraph (Record.merge props { graph, hyperdataGraph: loaded, mMetaData' }) []
where
where
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
fe2bbca3
...
@@ -28,11 +28,6 @@ import Data.Tuple (Tuple(..), fst)
...
@@ -28,11 +28,6 @@ import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Components as NTC
...
@@ -42,7 +37,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
...
@@ -42,7 +37,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.REST (RESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (
loader,
useLoader)
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get)
import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...
@@ -51,6 +46,10 @@ import Gargantext.Utils.CacheAPI as GUC
...
@@ -51,6 +46,10 @@ import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Unsafe.Coerce (unsafeCoerce)
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.NgramsTable"
here = R2.here "Gargantext.Components.NgramsTable"
...
@@ -579,7 +578,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
...
@@ -579,7 +578,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
, tasks
, tasks
, versionedWithCount
, versionedWithCount
, withAutoUpdate } []
, withAutoUpdate } []
useLoader path' loader render
useLoader { errorHandler
, loader
, path: path'
, render }
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
-- NOTE With cache on
-- NOTE With cache on
-- versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
-- versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
...
...
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
fe2bbca3
...
@@ -79,8 +79,12 @@ annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where
...
@@ -79,8 +79,12 @@ annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where
path <- T.useBox nodeId
path <- T.useBox nodeId
path' <- T.useLive T.unequal path
path' <- T.useLive T.unequal path
useLoader path' (getAnnuaireInfo session) $
useLoader { errorHandler
\info -> annuaire { frontends, info, path, session }
, loader: getAnnuaireInfo session
, path: path'
, render: \info -> annuaire { frontends, info, path, session } }
where
errorHandler err = here.log2 "[annuaireLayoutWithKey] RESTError" err
type AnnuaireProps =
type AnnuaireProps =
( session :: Session
( session :: Session
...
@@ -142,8 +146,12 @@ pageLayoutCpt = here.component "pageLayout" cpt
...
@@ -142,8 +146,12 @@ pageLayoutCpt = here.component "pageLayout" cpt
cpt { frontends, pagePath, session } _ = do
cpt { frontends, pagePath, session } _ = do
pagePath' <- T.useLive T.unequal pagePath
pagePath' <- T.useLive T.unequal pagePath
useLoader pagePath' (loadPage session) $
useLoader { errorHandler
\table -> page { session, table, frontends, pagePath }
, loader: loadPage session
, path: pagePath'
, render: \table -> page { session, table, frontends, pagePath } }
where
errorHandler err = here.log2 "[pageLayout] RESTError" err
type PageProps =
type PageProps =
( session :: Session
( session :: Session
...
...
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
fe2bbca3
...
@@ -4,22 +4,18 @@ module Gargantext.Components.Nodes.Annuaire.User
...
@@ -4,22 +4,18 @@ module Gargantext.Components.Nodes.Annuaire.User
)
)
where
where
import Data.Either (Either(..))
import Gargantext.Prelude
import Data.Either (Either)
import Data.Lens as L
import Data.Lens as L
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.REST (RESTError)
...
@@ -30,6 +26,9 @@ import Gargantext.Sessions (WithSession, WithSessionContext, Session, get, put,
...
@@ -30,6 +26,9 @@ import Gargantext.Sessions (WithSession, WithSessionContext, Session, get, put,
import Gargantext.Types (NodeType(..), SidePanelState)
import Gargantext.Types (NodeType(..), SidePanelState)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Annuaire.User"
here = R2.here "Gargantext.Components.Nodes.Annuaire.User"
...
@@ -217,25 +216,29 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt
...
@@ -217,25 +216,29 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt
cacheState <- T.useBox LT.CacheOn
cacheState <- T.useBox LT.CacheOn
useLoader {nodeId, reload: reload', session} getUserWithReload $
useLoader { errorHandler
\contactData@{contactNode: Contact {name, hyperdata}} ->
, loader: getUserWithReload
H.ul { className: "col-md-12 list-group" } [
, path: { nodeId, reload: reload', session }
display { title: fromMaybe "no name" name }
, render: \contactData@{contactNode: Contact {name, hyperdata}} ->
(contactInfos hyperdata (onUpdateHyperdata reload))
H.ul { className: "col-md-12 list-group" } [
, Tabs.tabs {
display { title: fromMaybe "no name" name }
cacheState
(contactInfos hyperdata (onUpdateHyperdata reload))
, contactData
, Tabs.tabs {
, frontends
cacheState
, nodeId
, contactData
, reloadForest
, frontends
, reloadRoot
, nodeId
, session
, reloadForest
, sidePanel
, reloadRoot
, sidePanelState
, session
, tasks
, sidePanel
}
, sidePanelState
]
, tasks
}
]
}
where
where
errorHandler err = here.log2 "[userLayoutWithKey] RESTError" err
onUpdateHyperdata :: T2.ReloadS -> HyperdataUser -> Effect Unit
onUpdateHyperdata :: T2.ReloadS -> HyperdataUser -> Effect Unit
onUpdateHyperdata reload hd = do
onUpdateHyperdata reload hd = do
launchAff_ $ do
launchAff_ $ do
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
fe2bbca3
...
@@ -195,7 +195,6 @@ contactLayoutCpt = here.component "contactLayout" cpt where
...
@@ -195,7 +195,6 @@ contactLayoutCpt = here.component "contactLayout" cpt where
contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps
contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps
contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props []
contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props []
contactLayoutWithKeyCpt :: R.Component AnnuaireKeyLayoutProps
contactLayoutWithKeyCpt :: R.Component AnnuaireKeyLayoutProps
contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
cpt { annuaireId
cpt { annuaireId
...
@@ -210,23 +209,26 @@ contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
...
@@ -210,23 +209,26 @@ contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
_ <- T.useLive T.unequal reload
_ <- T.useLive T.unequal reload
cacheState <- T.useBox LT.CacheOn
cacheState <- T.useBox LT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $
useLoader { errorHandler
\contactData@{contactNode: Contact' {name, hyperdata}} ->
, loader: getAnnuaireContact session annuaireId
H.ul { className: "col-md-12 list-group" }
, path: nodeId
[ display { title: fromMaybe "no name" name }
, render: \contactData@{contactNode: Contact' {name, hyperdata}} ->
(contactInfos hyperdata (onUpdateHyperdata reload))
H.ul { className: "col-md-12 list-group" }
, Tabs.tabs
[ display { title: fromMaybe "no name" name }
{ cacheState
(contactInfos hyperdata (onUpdateHyperdata reload))
, contactData
, Tabs.tabs
, frontends
{ cacheState
, nodeId
, contactData
, session
, frontends
, sidePanel
, nodeId
, sidePanelState
, session
, reloadForest
, sidePanel
, reloadRoot
, sidePanelState
, tasks } ]
, reloadForest
, reloadRoot
, tasks } ] }
where
where
errorHandler err = here.log2 "[contactLayoutWithKey] RESTError" err
onUpdateHyperdata :: T2.ReloadS -> HyperdataContact -> Effect Unit
onUpdateHyperdata :: T2.ReloadS -> HyperdataContact -> Effect Unit
onUpdateHyperdata reload hd =
onUpdateHyperdata reload hd =
launchAff_ $
launchAff_ $
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
fe2bbca3
...
@@ -114,8 +114,12 @@ corpusLayoutWithKeyCpt = here.component "corpusLayoutWithKey" cpt where
...
@@ -114,8 +114,12 @@ corpusLayoutWithKeyCpt = here.component "corpusLayoutWithKey" cpt where
cpt { nodeId, session } _ = do
cpt { nodeId, session } _ = do
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
reload' <- T.useLive T.unequal reload
useLoader { nodeId, reload: reload', session } loadCorpusWithReload $
useLoader { errorHandler
\corpus -> corpusLayoutView { corpus, nodeId, reload, session }
, loader: loadCorpusWithReload
, path: { nodeId, reload: reload', session }
, render: \corpus -> corpusLayoutView { corpus, nodeId, reload, session } }
where
errorHandler err = here.log2 "[corpusLayoutWithKey] RESTError" err
type ViewProps =
type ViewProps =
( corpus :: NodePoly Hyperdata
( corpus :: NodePoly Hyperdata
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
View file @
fe2bbca3
...
@@ -37,8 +37,12 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
...
@@ -37,8 +37,12 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
cpt { getMetrics, loaded, path, reload, session, onClick, onInit } _ = do
cpt { getMetrics, loaded, path, reload, session, onClick, onInit } _ = do
reload' <- T.useLive T.unequal reload
reload' <- T.useLive T.unequal reload
useLoader (reload' /\ path) (getMetrics session) $ \l ->
useLoader { errorHandler
loaded { path, reload, session, onClick, onInit } l
, loader: getMetrics session
, path: reload' /\ path
, render: \l -> loaded { path, reload, session, onClick, onInit } l }
where
errorHandler err = here.log2 "RESTError" err
type MetricsWithCacheLoadViewProps res ret = (
type MetricsWithCacheLoadViewProps res ret = (
getMetricsHash :: Session -> ReloadPath -> Aff (Either RESTError Hash)
getMetricsHash :: Session -> ReloadPath -> Aff (Either RESTError Hash)
...
...
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
View file @
fe2bbca3
...
@@ -52,17 +52,20 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
...
@@ -52,17 +52,20 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
reload' <- T.useLive T.unequal reload
useLoader {nodeId, reload: reload', session} DT.loadDashboardWithReload $
useLoader { errorHandler
\(DT.DashboardData { hyperdata: DT.Hyperdata h, parentId }) -> do
, loader: DT.loadDashboardWithReload
let { charts, fields } = h
, path: { nodeId, reload: reload', session }
dashboardLayoutLoaded { charts
, render: \(DT.DashboardData { hyperdata: DT.Hyperdata h, parentId }) -> do
, corpusId: parentId
let { charts, fields } = h
, defaultListId: 0
dashboardLayoutLoaded { charts
, fields
, corpusId: parentId
, nodeId
, defaultListId: 0
, onChange: onChange nodeId reload (DT.Hyperdata h)
, fields
, session } []
, nodeId
, onChange: onChange nodeId reload (DT.Hyperdata h)
, session } [] }
where
where
errorHandler err = here.log2 "[dashboardLayoutWithKey] RESTError" err
onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
, fields :: FTFieldList } -> Effect Unit
, fields :: FTFieldList } -> Effect Unit
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
fe2bbca3
...
@@ -150,11 +150,14 @@ documentLayoutWithKeyCpt :: R.Component KeyLayoutProps
...
@@ -150,11 +150,14 @@ documentLayoutWithKeyCpt :: R.Component KeyLayoutProps
documentLayoutWithKeyCpt = here.component "documentLayoutWithKey" cpt
documentLayoutWithKeyCpt = here.component "documentLayoutWithKey" cpt
where
where
cpt { listId, mCorpusId, nodeId, session } _ = do
cpt { listId, mCorpusId, nodeId, session } _ = do
useLoader path loadData $ \loaded ->
useLoader { errorHandler
docViewWrapper { loaded, path } []
, loader: loadData
, path
, render: \loaded -> docViewWrapper { loaded, path } [] }
where
where
tabType = TabDocument (TabNgramType CTabTerms)
tabType = TabDocument (TabNgramType CTabTerms)
path = { listIds: [listId], mCorpusId, nodeId, session, tabType }
path = { listIds: [listId], mCorpusId, nodeId, session, tabType }
errorHandler err = here.log2 "[documentLayoutWithKey] RESTError" err
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Components/Nodes/File.purs
View file @
fe2bbca3
...
@@ -55,8 +55,12 @@ fileLayout props = R.createElement fileLayoutCpt props []
...
@@ -55,8 +55,12 @@ fileLayout props = R.createElement fileLayoutCpt props []
fileLayoutCpt :: R.Component FileLayoutProps
fileLayoutCpt :: R.Component FileLayoutProps
fileLayoutCpt = here.component "fileLayout" cpt where
fileLayoutCpt = here.component "fileLayout" cpt where
cpt { nodeId, session } _ = do
cpt { nodeId, session } _ = do
useLoader nodeId (loadFile session) onLoad
useLoader { errorHandler
, loader: loadFile session
, path: nodeId
, render: onLoad }
where
where
errorHandler err = here.log2 "RESTError" err
onLoad loaded = fileLayoutLoaded { loaded, nodeId, session }
onLoad loaded = fileLayoutLoaded { loaded, nodeId, session }
loadFile :: Session -> NodeID -> Aff (Either RESTError File)
loadFile :: Session -> NodeID -> Aff (Either RESTError File)
...
...
src/Gargantext/Components/Nodes/Frame.purs
View file @
fe2bbca3
...
@@ -66,8 +66,12 @@ frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where
...
@@ -66,8 +66,12 @@ frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where
cpt { nodeId, session, nodeType} _ = do
cpt { nodeId, session, nodeType} _ = do
reload <- T.useBox T2.newReload
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
reload' <- T.useLive T.unequal reload
useLoader {nodeId, reload: reload', session} loadframeWithReload $
useLoader { errorHandler
\frame -> frameLayoutView {frame, nodeId, reload, session, nodeType}
, loader: loadframeWithReload
, path: {nodeId, reload: reload', session}
, render: \frame -> frameLayoutView {frame, nodeId, reload, session, nodeType} }
where
errorHandler err = here.log2 "[frameLayoutWithKey] RESTError" err
type ViewProps =
type ViewProps =
( frame :: NodePoly Hyperdata
( frame :: NodePoly Hyperdata
...
...
src/Gargantext/Components/Nodes/Home/Public.purs
View file @
fe2bbca3
...
@@ -73,8 +73,13 @@ renderPublic props = R.createElement renderPublicCpt props []
...
@@ -73,8 +73,13 @@ renderPublic props = R.createElement renderPublicCpt props []
renderPublicCpt :: R.Component ()
renderPublicCpt :: R.Component ()
renderPublicCpt = here.component "renderPublic" cpt where
renderPublicCpt = here.component "renderPublic" cpt where
cpt _ _ = do
cpt _ _ = do
useLoader { reload: 0 } loadPublicData loaded where
useLoader { errorHandler
loaded publicData = publicLayout { publicData }
, loader: loadPublicData
, path: { reload: 0 }
, render: loaded }
where
loaded publicData = publicLayout { publicData }
errorHandler err = here.log2 "RESTError" err
publicLayout :: Record PublicDataProps -> R.Element
publicLayout :: Record PublicDataProps -> R.Element
publicLayout props = R.createElement publicLayoutCpt props []
publicLayout props = R.createElement publicLayoutCpt props []
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
fe2bbca3
module Gargantext.Components.Nodes.Lists where
module Gargantext.Components.Nodes.Lists where
import Data.Maybe (Maybe
(..)
)
import Data.Maybe (Maybe)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
...
@@ -12,15 +17,11 @@ import Gargantext.Components.Nodes.Lists.Tabs as Tabs
...
@@ -12,15 +17,11 @@ import Gargantext.Components.Nodes.Lists.Tabs as Tabs
import Gargantext.Components.Nodes.Lists.Types (CacheState(..), SidePanel)
import Gargantext.Components.Nodes.Lists.Types (CacheState(..), SidePanel)
import Gargantext.Components.Table as Table
import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
(Unit, bind, const, discard, pure, show, unit, ($), (<>))
import Gargantext.Prelude
import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState)
import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Lists"
here = R2.here "Gargantext.Components.Nodes.Lists"
...
@@ -56,7 +57,6 @@ type KeyProps = ( key :: String | Props )
...
@@ -56,7 +57,6 @@ type KeyProps = ( key :: String | Props )
listsLayoutWithKey :: R2.Component KeyProps
listsLayoutWithKey :: R2.Component KeyProps
listsLayoutWithKey = R.createElement listsLayoutWithKeyCpt
listsLayoutWithKey = R.createElement listsLayoutWithKeyCpt
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
cpt { nodeId
cpt { nodeId
...
@@ -65,11 +65,9 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
...
@@ -65,11 +65,9 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
, reloadRoot
, reloadRoot
, session
, session
, sessionUpdate
, sessionUpdate
, sidePanel
, sidePanelState
, tasks } _ = do
, tasks } _ = do
activeTab <- T.useBox 0
activeTab <- T.useBox 0
reloadMainPage' <- T.useLive T.unequal reloadMainPage
_
reloadMainPage' <- T.useLive T.unequal reloadMainPage
let path = { nodeId, session }
let path = { nodeId, session }
...
@@ -79,40 +77,42 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
...
@@ -79,40 +77,42 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
R.useEffectOnce' $ do
R.useEffectOnce' $ do
T.listen (\{ new } -> afterCacheStateChange new) cacheState
T.listen (\{ new } -> afterCacheStateChange new) cacheState
useLoader path loadCorpusWithChild $
useLoader { errorHandler
\corpusData@{ corpusId, corpusNode: NodePoly poly, defaultListId } ->
, path
let { date, hyperdata : Hyperdata h, name } = poly
, loader: loadCorpusWithChild
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
, render: \corpusData@{ corpusId, corpusNode: NodePoly poly } ->
in
let { date, hyperdata : Hyperdata h, name } = poly
R.fragment [
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
Table.tableHeaderLayout {
in
cacheState
R.fragment [
, date
Table.tableHeaderLayout {
, desc
cacheState
, key: "listsLayoutWithKey-header-" <> (show cacheState')
, date
, query
, desc
, title: "Corpus " <> name
, key: "listsLayoutWithKey-header-" <> (show cacheState')
, user: authors } []
, query
, Tabs.tabs {
, title: "Corpus " <> name
activeTab
, user: authors } []
, cacheState
, Tabs.tabs {
, corpusData
activeTab
, corpusId
, cacheState
, key: "listsLayoutWithKey-tabs-" <> (show cacheState')
, corpusData
, reloadForest
, corpusId
, reloadRoot
, key: "listsLayoutWithKey-tabs-" <> (show cacheState')
, session
, reloadForest
, tasks
, reloadRoot
}
, session
]
, tasks
}
] }
where
where
errorHandler err = here.log2 "[listsLayoutWithKey] RESTError" err
afterCacheStateChange cacheState = do
afterCacheStateChange cacheState = do
launchAff_ $ clearCache unit
launchAff_ $ clearCache unit
sessionUpdate $ setCacheState session nodeId cacheState
sessionUpdate $ setCacheState session nodeId cacheState
type SidePanelProps =
type SidePanelProps =
( session :: Session
( session :: Session
, sidePanel :: T.Box (Maybe (Record SidePanel))
, sidePanelState :: T.Box GT.SidePanelState
, sidePanelState :: T.Box GT.SidePanelState
)
)
...
@@ -123,7 +123,6 @@ sidePanelCpt :: R.Component SidePanelProps
...
@@ -123,7 +123,6 @@ sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = here.component "sidePanel" cpt
sidePanelCpt = here.component "sidePanel" cpt
where
where
cpt { session
cpt { session
, sidePanel
, sidePanelState } _ = do
, sidePanelState } _ = do
sidePanelState' <- T.useLive T.unequal sidePanelState
sidePanelState' <- T.useLive T.unequal sidePanelState
...
@@ -151,6 +150,6 @@ sidePanelDocView = R.createElement sidePanelDocViewCpt
...
@@ -151,6 +150,6 @@ sidePanelDocView = R.createElement sidePanelDocViewCpt
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt = here.component "sidePanelDocView" cpt where
sidePanelDocViewCpt = here.component "sidePanelDocView" cpt where
cpt {
session
} _ = do
cpt { } _ = do
-- pure $ H.h4 {} [ H.text txt ]
-- pure $ H.h4 {} [ H.text txt ]
pure $ H.div {} [ H.text "Hello ngrams" ]
pure $ H.div {} [ H.text "Hello ngrams" ]
src/Gargantext/Components/Nodes/Texts.purs
View file @
fe2bbca3
...
@@ -7,6 +7,10 @@ import Data.Maybe (Maybe(..))
...
@@ -7,6 +7,10 @@ import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.Show.Generic (genericShow)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Components.Charts.Options.ECharts (dispatchAction)
import Gargantext.Components.Charts.Options.ECharts (dispatchAction)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, EChartActionData)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, EChartActionData)
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable as DT
...
@@ -26,9 +30,6 @@ import Gargantext.Hooks.Loader (useLoader)
...
@@ -26,9 +30,6 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (WithSession, Session, getCacheState)
import Gargantext.Sessions (WithSession, Session, getCacheState)
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..))
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Texts"
here = R2.here "Gargantext.Components.Nodes.Texts"
...
@@ -75,7 +76,6 @@ type KeyProps = (
...
@@ -75,7 +76,6 @@ type KeyProps = (
textsLayoutWithKey :: R2.Component KeyProps
textsLayoutWithKey :: R2.Component KeyProps
textsLayoutWithKey = R.createElement textsLayoutWithKeyCpt
textsLayoutWithKey = R.createElement textsLayoutWithKeyCpt
textsLayoutWithKeyCpt :: R.Component KeyProps
textsLayoutWithKeyCpt :: R.Component KeyProps
textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
where
where
...
@@ -90,32 +90,35 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
...
@@ -90,32 +90,35 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
R.useEffectOnce' $ do
R.useEffectOnce' $ do
T.listen (\{ new } -> afterCacheStateChange new) cacheState
T.listen (\{ new } -> afterCacheStateChange new) cacheState
useLoader { nodeId, session } loadCorpusWithChild $
useLoader { errorHandler
\corpusData@{ corpusId, corpusNode, defaultListId } -> do
, loader: loadCorpusWithChild
let NodePoly { date, hyperdata: Hyperdata h, name } = corpusNode
, path: { nodeId, session }
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
, render: \corpusData@{ corpusId, corpusNode } -> do
title = "Corpus " <> name
let NodePoly { date, hyperdata: Hyperdata h, name } = corpusNode
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
R.fragment
title = "Corpus " <> name
[ Table.tableHeaderLayout { cacheState
, date
R.fragment
, desc
[ Table.tableHeaderLayout { cacheState
, query
, date
, title
, desc
, user: authors
, query
, key: "textsLayoutWithKey-" <> (show cacheState') } []
, title
, tabs { cacheState
, user: authors
, corpusData
, key: "textsLayoutWithKey-" <> (show cacheState') } []
, corpusId
, tabs { cacheState
, frontends
, corpusData
, session
, corpusId
, sidePanel
, frontends
, sidePanelState
, session
, yearFilter
, sidePanel
, eChartsInstance
, sidePanelState
}
, yearFilter
]
, eChartsInstance
}
] }
where
where
errorHandler err = here.log2 "[textsLayoutWithKey] RESTError" err
afterCacheStateChange cacheState = do
afterCacheStateChange cacheState = do
launchAff_ $ clearCache unit
launchAff_ $ clearCache unit
-- TODO
-- TODO
...
@@ -139,21 +142,28 @@ type TabsProps =
...
@@ -139,21 +142,28 @@ type TabsProps =
( cacheState :: T.Box LT.CacheState
( cacheState :: T.Box LT.CacheState
, corpusData :: CorpusData
, corpusData :: CorpusData
, corpusId :: NodeID
, corpusId :: NodeID
, eChartsInstance :: T.Box (Maybe EChartsInstance)
, frontends :: Frontends
, frontends :: Frontends
, session :: Session
, session :: Session
, sidePanel :: T.Box (Maybe (Record TT.SidePanel))
, sidePanel :: T.Box (Maybe (Record TT.SidePanel))
, sidePanelState :: T.Box SidePanelState
, sidePanelState :: T.Box SidePanelState
, yearFilter :: T.Box (Maybe Year)
, yearFilter :: T.Box (Maybe Year)
, eChartsInstance :: T.Box (Maybe EChartsInstance)
)
)
tabs :: Record TabsProps -> R.Element
tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props []
tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt
tabsCpt = here.component "tabs" cpt
where
where
cpt { cacheState, corpusId, corpusData, frontends, session, sidePanel, sidePanelState, yearFilter, eChartsInstance } _ = do
cpt { cacheState
, corpusId
, corpusData
, eChartsInstance
, frontends
, session
, sidePanel
, sidePanelState
, yearFilter } _ = do
let
let
path = initialPath
path = initialPath
...
@@ -344,9 +354,9 @@ docViewLayoutRec { cacheState
...
@@ -344,9 +354,9 @@ docViewLayoutRec { cacheState
, frontends
, frontends
, listId
, listId
, session
, session
, tabType
, sidePanel
, sidePanel
, sidePanelState
, sidePanelState
, tabType
, yearFilter
, yearFilter
} =
} =
{ cacheState
{ cacheState
...
...
src/Gargantext/Components/Router.purs
View file @
fe2bbca3
...
@@ -227,7 +227,6 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
...
@@ -227,7 +227,6 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
, route
, route
, sidePanelGraph
, sidePanelGraph
, sidePanelState
, sidePanelState
, sidePanelLists
, sidePanelTexts }
, sidePanelTexts }
, session} _ = do
, session} _ = do
{ mGraph, mMetaData, removedNodeIds, selectedNodeIds, sideTab } <- GEST.focusedSidePanel sidePanelGraph
{ mGraph, mMetaData, removedNodeIds, selectedNodeIds, sideTab } <- GEST.focusedSidePanel sidePanelGraph
...
@@ -241,7 +240,6 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
...
@@ -241,7 +240,6 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
GR.Lists _s _n -> do
GR.Lists _s _n -> do
pure $ wrapper
pure $ wrapper
[ Lists.sidePanel { session
[ Lists.sidePanel { session
, sidePanel: sidePanelLists
, sidePanelState } [] ]
, sidePanelState } [] ]
GR.PGraphExplorer _s g -> do
GR.PGraphExplorer _s g -> do
case (mGraph' /\ mGraphMetaData') of
case (mGraph' /\ mGraphMetaData') of
...
...
src/Gargantext/Hooks/Loader.purs
View file @
fe2bbca3
module Gargantext.Hooks.Loader where
module Gargantext.Hooks.Loader where
import Gargantext.Prelude
import Control.Bind ((=<<))
import Control.Monad.RWS (state)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Effect.Exception (error)
import Reactix as R
import Reactix as R
import Record as Record
import Simple.JSON as JSON
import Simple.JSON as JSON
import Toestand as T
import Toestand as T
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.REST (RESTError)
import Gargantext.Prelude
import Gargantext.Utils.Crypto (Hash)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Crypto (Hash)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
here :: R2.Here
here :: R2.Here
...
@@ -27,16 +32,20 @@ cacheName = "cache-api-loader"
...
@@ -27,16 +32,20 @@ cacheName = "cache-api-loader"
clearCache :: Unit -> Aff Unit
clearCache :: Unit -> Aff Unit
clearCache _ = GUC.delete $ GUC.CacheName cacheName
clearCache _ = GUC.delete $ GUC.CacheName cacheName
type UseLoader path state =
( errorHandler :: RESTError -> Effect Unit
, loader :: path -> Aff (Either RESTError state)
, path :: path
, render :: state -> R.Element
)
useLoader :: forall path st. Eq path => Eq st
useLoader :: forall path st. Eq path => Eq st
=> path
=> Record (UseLoader path st)
-> (path -> Aff (Either RESTError st))
-> (st -> R.Element)
-> R.Hooks R.Element
-> R.Hooks R.Element
useLoader
path loader' render
= do
useLoader
{ errorHandler, loader: loader', path, render }
= do
state <- T.useBox Nothing
state <- T.useBox Nothing
useLoaderEffect
path state loader'
useLoaderEffect
{ errorHandler, loader: loader', path, state: state }
pure $ loader { path, render, state } []
pure $ loader { path, render, state } []
...
@@ -48,22 +57,25 @@ type LoaderProps path st =
...
@@ -48,22 +57,25 @@ type LoaderProps path st =
loader :: forall path st. Eq path => Eq st => R2.Component (LoaderProps path st)
loader :: forall path st. Eq path => Eq st => R2.Component (LoaderProps path st)
loader = R.createElement loaderCpt
loader = R.createElement loaderCpt
loaderCpt :: forall path st. Eq path => Eq st => R.Component (LoaderProps path st)
loaderCpt :: forall path st. Eq path => Eq st => R.Component (LoaderProps path st)
loaderCpt = here.component "loader" cpt
loaderCpt = here.component "loader" cpt
where
where
cpt {
path,
render, state } _ = do
cpt { render, state } _ = do
state' <- T.useLive T.unequal state
state' <- T.useLive T.unequal state
pure $ maybe (loadingSpinner {}) render state'
pure $ maybe (loadingSpinner {}) render state'
type UseLoaderEffect path state =
( errorHandler :: RESTError -> Effect Unit
, loader :: path -> Aff (Either RESTError state)
, path :: path
, state :: T.Box (Maybe state)
)
useLoaderEffect :: forall st path. Eq path => Eq st =>
useLoaderEffect :: forall st path. Eq path => Eq st
path
=> Record (UseLoaderEffect path st)
-> T.Box (Maybe st)
-> (path -> Aff (Either RESTError st))
-> R.Hooks Unit
-> R.Hooks Unit
useLoaderEffect
path state loader
= do
useLoaderEffect
{ errorHandler, loader: loader', path, state }
= do
state' <- T.useLive T.unequal state
state' <- T.useLive T.unequal state
oPath <- R.useRef path
oPath <- R.useRef path
...
@@ -74,9 +86,9 @@ useLoaderEffect path state loader = do
...
@@ -74,9 +86,9 @@ useLoaderEffect path state loader = do
else do
else do
R.setRef oPath path
R.setRef oPath path
R2.affEffect "G.H.Loader.useLoaderEffect" $ do
R2.affEffect "G.H.Loader.useLoaderEffect" $ do
l <- loader path
l <- loader
'
path
case l of
case l of
Left
_err -> throwError $ error "[useLoaderEffect] RESTError"
Left
err -> liftEffect $ errorHandler err
Right l' -> liftEffect $ T.write_ (Just l') state
Right l' -> liftEffect $ T.write_ (Just l') state
...
@@ -141,7 +153,7 @@ useCachedAPILoaderEffect { cacheEndpoint
...
@@ -141,7 +153,7 @@ useCachedAPILoaderEffect { cacheEndpoint
launchAff_ $ do
launchAff_ $ do
cache <- GUC.openCache $ GUC.CacheName cacheName
cache <- GUC.openCache $ GUC.CacheName cacheName
-- TODO Parallelize?
-- TODO Parallelize?
hr@(HashedResponse { hash
, value
}) <- GUC.cachedJson cache req
hr@(HashedResponse { hash }) <- GUC.cachedJson cache req
cacheReal <- cacheEndpoint path
cacheReal <- cacheEndpoint path
case cacheReal of
case cacheReal of
Left _err -> throwError $ error $ "[useCachedAPILoaderEffect] RESTError"
Left _err -> throwError $ error $ "[useCachedAPILoaderEffect] RESTError"
...
...
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