Commit fe2bbca3 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[loader] rewrite params for useLoader

parent 034ea2e7
Pipeline #1706 canceled with stage
...@@ -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
......
...@@ -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(..), NodePath(..), NodeID) 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)
......
...@@ -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
......
...@@ -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 }
......
...@@ -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
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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_ $
......
...@@ -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
......
...@@ -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)
......
...@@ -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