[refactor] some more hereComponent refactoring

parent ab6bd6c3
......@@ -114,13 +114,13 @@ type RatingSimpleLoaderProps =
ratingSimpleLoader :: R2.Component RatingSimpleLoaderProps
ratingSimpleLoader = R.createElement ratingSimpleLoaderCpt
ratingSimpleLoaderCpt :: R.Component RatingSimpleLoaderProps
ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where
cpt { docId
, corpusId
, session
} _ = do
ratingSimpleLoaderCpt = R2.hereComponent here "ratingSimpleLoader" hCpt where
hCpt hp { docId
, corpusId
, session
} _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[ratingSimpleLoader]"
, herePrefix: hp
, loader: loadDocumentContext session
, path: { docId, corpusId }
, render: \{ nc_category } -> do
......
......@@ -30,9 +30,8 @@ here = R2.here "Gargantext.Components.Corpus.EditionBlock"
editionBlock :: R2.Leaf Props
editionBlock = R2.leaf editionBlockCpt
editionBlockCpt :: R.Component Props
editionBlockCpt = here.component "main" cpt where
cpt { nodeId
} _ = do
editionBlockCpt = R2.hereComponent here "editionBlock" hCpt where
hCpt hp { nodeId } _ = do
-- | States
-- |
session <- useSession
......@@ -42,7 +41,7 @@ editionBlockCpt = here.component "main" cpt where
-- | Computed
-- |
let
errorHandler = logRESTError (R2.herePrefix here "[corpusLayout]")
errorHandler = logRESTError hp
-- | Hooks
-- |
......@@ -94,7 +93,7 @@ type Props_ =
editionBlock_ :: R2.Leaf Props_
editionBlock_ = R2.leaf editionBlockCpt_
editionBlockCpt_ :: R.Component Props_
editionBlockCpt_ = here.component "main_" cpt where
editionBlockCpt_ = here.component "editionBlock_" cpt where
cpt { nodeId
, hyperdata
} _ = do
......
......@@ -36,7 +36,7 @@ import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Reload (textsReloadContext)
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
......@@ -121,23 +121,23 @@ type Props = (
docView :: R2.Component Props
docView = R.createElement docViewCpt
docViewCpt :: R.Component Props
docViewCpt = here.component "docView" cpt where
cpt { layout: { cacheState
, chart
, chartReload
, frontends
, listId
, mCorpusId
, nodeId
, session
, showSearch
, tabType
, totalRecords
, yearFilter
}
, params
, query
} _ = do
docViewCpt = R2.hereComponent here "docView" hCpt where
hCpt hp { layout: { cacheState
, chart
, chartReload
, frontends
, listId
, mCorpusId
, nodeId
, session
, showSearch
, tabType
, totalRecords
, yearFilter
}
, params
, query
} _ = do
-- State
{ errors } <- Store.use
cacheState' <- T.useLive T.unequal cacheState
......@@ -155,7 +155,7 @@ docViewCpt = here.component "docView" cpt where
-- @onCreateDocumentEnd <AsyncProgress>
onCreateDocumentEnd <- pure $ \asyncProgress -> do
here.log2 "[DocsTables] NodeDocument task:" asyncProgress
R2.hpLog2 hp "NodeDocument task:" asyncProgress
T.write_ false onDocumentCreationPendingBox
toggleModal unit
......@@ -171,7 +171,7 @@ docViewCpt = here.component "docView" cpt where
eTask <- DFC.create session nodeId fdata
handleRESTError (R2.herePrefix here "[docView]") errors eTask
handleRESTError hp errors eTask
\t -> liftEffect $ launchDocumentCreationProgress
errors
session
......@@ -390,17 +390,17 @@ filterDocsByYear year docs = A.filter filterFunc docs
pageLayout :: R2.Component ( key :: String | PageLayoutProps )
pageLayout = R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component ( key :: String | PageLayoutProps )
pageLayoutCpt = here.component "pageLayout" cpt where
cpt props@{ cacheState
, listId
, mCorpusId
, nodeId
, params
, query
, session
, tabType
, yearFilter
} _ = do
pageLayoutCpt = R2.hereComponent here "pageLayout" hCpt where
hCpt hp props@{ cacheState
, listId
, mCorpusId
, nodeId
, params
, query
, session
, tabType
, yearFilter
} _ = do
cacheState' <- T.useLive T.unequal cacheState
yearFilter' <- T.useLive T.unequal yearFilter
......@@ -459,7 +459,7 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, localCategories
, params: paramsS } []
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[pageLayout]"
, herePrefix: hp
, path: path { params = paramsS' }
, loader
, render }
......
......@@ -26,7 +26,6 @@ import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData,
import Gargantext.Components.GraphQL.Endpoints (getContextNgrams)
import Gargantext.Components.NgramsTable.AutoSync (useAutoSync)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config.REST (logRESTError)
import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, coreDispatch, findNgramRoot, setTermListA, computeCache)
import Gargantext.Core.NgramsTable.Types (CoreAction(..), NgramsTable(..), NgramsTerm, State, Versioned(..), replace)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
......@@ -66,15 +65,15 @@ options =
layout :: forall r. R2.OptLeaf Options Props r
layout = R2.optLeaf layoutCpt options
layoutCpt :: R.Component Props
layoutCpt = here.component "layout" cpt where
cpt props@{ path: path@{ listIds
, nodeId }
, session } _ = do
layoutCpt = R2.hereComponent here "layout" hCpt where
hCpt hp props@{ path: path@{ listIds
, nodeId }
, session } _ = do
case A.head listIds of
Nothing -> pure $ H.div {} [ H.text "No list supplied!" ]
Just listId ->
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[layout]"
, herePrefix: hp
, loader: \p -> getContextNgrams session p.contextId p.listId
, path: { contextId: nodeId, listId }
, render: \contextNgrams ->
......
......@@ -343,16 +343,15 @@ type PageProps = ( rowsLoaded :: Rows | PageLayoutProps )
pageLayout :: R2.Component PageLayoutProps
pageLayout = R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt
where
cpt { container, deletions, frontends, path, session, totalRecords } _ = do
path' <- T.useLive T.unequal path
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[pageLayout]"
, loader: loadPage
, path: path'
, render: \rowsLoaded -> page { container, deletions, frontends, path, rowsLoaded, session, totalRecords } [] }
pageLayoutCpt = R2.hereComponent here "pageLayout" hCpt where
hCpt hp { container, deletions, frontends, path, session, totalRecords } _ = do
path' <- T.useLive T.unequal path
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: loadPage
, path: path'
, render: \rowsLoaded -> page { container, deletions, frontends, path, rowsLoaded, session, totalRecords } [] }
page :: R2.Component PageProps
page = R.createElement pageCpt
......
......@@ -30,7 +30,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..
import Gargantext.Components.GraphQL.Endpoints (getNode, getTreeFirstLevel)
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, TreeNode)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoader)
......@@ -57,12 +57,12 @@ data FolderStyle = FolderUp | FolderChild
folderView :: R2.Leaf Props
folderView = R2.leaf folderViewCpt
folderViewCpt :: R.Component Props
folderViewCpt = here.component "folderViewCpt" cpt where
cpt { nodeId, session } _ = do
folderViewCpt = R2.hereComponent here "folderViewCpt" hCpt where
hCpt hp { nodeId, session } _ = do
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[folderView]"
, herePrefix: hp
, loader: loadFolders
, path: { nodeId, session, reload: reload'}
, render: \folders -> folderViewMain { folders
......@@ -264,12 +264,12 @@ backButtonCpt = here.component "backButton" cpt where
backButtonSmart :: R2.Component (nodeId :: Int, session :: Session)
backButtonSmart = R.createElement backButtonSmartCpt
backButtonSmartCpt :: R.Component (nodeId :: Int, session :: Session)
backButtonSmartCpt = here.component "backButtonSmart" cpt where
cpt {nodeId, session} _ = do
backButtonSmartCpt = R2.hereComponent here "backButtonSmart" hCpt where
hCpt hp { nodeId, session } _ = do
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[backButtonSmart]"
, herePrefix: hp
, loader: loadNode
, path: { nodeId, session, reload: reload' }
, render: \node -> backButtonSmartMain { node, session } []
......
......@@ -37,7 +37,7 @@ import URI.Fragment as Fragment
import Effect (Effect)
import Effect.Console (log)
import Toestand as T
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Utils.Toestand as T2
import Gargantext.Hooks.Loader (useLoader)
......@@ -165,15 +165,15 @@ componentCpt = here.component "breadcrumb" cpt where
breadcrumbView :: R2.Leaf Props
breadcrumbView = R2.leaf breadcrumbViewCpt
breadcrumbViewCpt :: R.Component Props
breadcrumbViewCpt = here.component "breadcrumbViewCpt" cpt where
cpt { nodeId, session } _ = do
breadcrumbViewCpt = R2.hereComponent here "breadcrumbViewCpt" hCpt where
hCpt hp { nodeId, session } _ = do
let session' = session
case session' of
Nothing -> pure $ H.div {} []
Just (session') -> do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[breadcrumbView]"
, herePrefix: hp
, loader: loadBreadcrumbData
, path: { nodeId: nodeId
, session: session'
......
......@@ -110,11 +110,11 @@ treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = here.component "treeLoader" cpt where
treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
-- treeLoaderCpt :: R.Memo LoaderProps
-- treeLoaderCpt = R.memo (here.component "treeLoader" cpt) memoCmp where
-- memoCmp ({ root: t1 }) ({ root: t2 }) = t1 == t2
cpt p@{ root, session } _ = do
hCpt hp p@{ root, session } _ = do
-- States
-- app <- T.useLive T.unequal p.reloadRoot
state /\ stateBox <- R2.useBox' Nothing
......@@ -144,7 +144,7 @@ treeLoaderCpt = here.component "treeLoader" cpt where
props = Record.merge common extra where
common = RecordE.pick p :: Record Common
extra = { reloadTree: p.reload, root, session, tree: tree' }
errorHandler = logRESTError (R2.herePrefix here "[treeLoader]")
errorHandler = logRESTError hp
getNodeTree :: Session -> ID -> AffRESTError FTree
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
......@@ -255,10 +255,10 @@ renderTreeChildrenCpt = here.component "renderTreeChildren" cpt where
childLoader :: R2.Component ChildLoaderProps
childLoader = R.createElement childLoaderCpt
childLoaderCpt :: R.Component ChildLoaderProps
childLoaderCpt = here.component "childLoader" cpt where
cpt p@{ reloadTree
, render
, root } _ = do
childLoaderCpt = R2.hereComponent here "childLoader" hCpt where
hCpt hp p@{ reloadTree
, render
, root } _ = do
-- States
{ reloadRoot } <- Store.use
reload <- T.useBox T2.newReload
......@@ -287,7 +287,7 @@ childLoaderCpt = here.component "childLoader" cpt where
}
where
errorHandler = logRESTError (R2.herePrefix here "[childLoader]")
errorHandler = logRESTError hp
fetch _ = getNodeTreeFirstLevel p.session p.id
paint reload tree' = render (Record.merge base extra) where
base = nodeProps { reload = reload }
......
......@@ -30,7 +30,6 @@ import Gargantext.Components.Forest.Tree.Node.Tools.Sync (nodeActionsGraph, node
import Gargantext.Components.GraphExplorer.API as GraphAPI
import Gargantext.Components.Lang (Lang(EN))
import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Config.REST (logRESTError)
import Gargantext.Context.Progress (asyncContext, asyncProgress)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderEffect)
......@@ -604,12 +603,12 @@ nodeActionsCpt = here.component "nodeActions" cpt where
graphNodeActions :: R2.Leaf NodeActionsCommon
graphNodeActions = R2.leaf graphNodeActionsCpt
graphNodeActionsCpt :: R.Component NodeActionsCommon
graphNodeActionsCpt = here.component "graphNodeActions" cpt where
cpt { id, refresh, session } _ = do
graphNodeActionsCpt = R2.hereComponent here "graphNodeActions" hCpt where
hCpt hp { id, refresh, session } _ = do
-- Hooks
useLoader
{ errorHandler: Nothing
, herePrefix: R2.herePrefix here "[graphNodeActions]"
, herePrefix: hp
, loader: graphVersions session
, path: id
, render: \gv -> graphNodeActionsLoaded { gv, id, refresh, session }
......@@ -636,12 +635,12 @@ graphNodeActionsLoadedCpt = here.component "graphNodeActionsLoaded" cpt where
listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions = R2.leaf listNodeActionsCpt
listNodeActionsCpt :: R.Component NodeActionsCommon
listNodeActionsCpt = here.component "listNodeActions" cpt where
cpt { id, refresh, session } _ = do
listNodeActionsCpt = R2.hereComponent here "listNodeActions" hCpt where
hCpt hp { id, refresh, session } _ = do
-- Hooks
useLoader
{ errorHandler: Nothing
, herePrefix: R2.herePrefix here "[listNodeActions]"
, herePrefix: hp
, loader: loadCorpusWithChild
, path: { nodeId: id, session }
, render: \corpusData -> listNodeActionsLoaded { corpusData, id, refresh, session }
......
......@@ -31,10 +31,10 @@ type ActionManageTeam = (
actionManageTeam :: R2.Component ActionManageTeam
actionManageTeam = R.createElement actionManageTeamCpt
actionManageTeamCpt :: R.Component ActionManageTeam
actionManageTeamCpt = here.component "actionManageTeam" cpt where
cpt { id, session } _ = do
actionManageTeamCpt = R2.hereComponent here "actionManageTeam" hCpt where
hCpt hp { id, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[actionManageTeam]"
, herePrefix: hp
, loader: loadTeam
, path: { nodeId: id, session }
, render: \team -> teamLayoutWrapper { team
......
......@@ -37,11 +37,11 @@ type Props =
actionSearch :: R2.Component Props
actionSearch = R.createElement actionSearchCpt
actionSearchCpt :: R.Component Props
actionSearchCpt = here.component "actionSearch" cpt where
cpt props@({ session }) _ = do
actionSearchCpt = R2.hereComponent here "actionSearch" hCpt where
hCpt hp props@({ session }) _ = do
{ errors } <- Store.use
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[actionSearch]"
, herePrefix: hp
, loader: loadLanguages
, path: { session }
, render: \langs ->
......
......@@ -128,10 +128,10 @@ type ComponentIMTProps =
componentIMT :: R2.Component ComponentIMTProps
componentIMT = R.createElement componentIMTCpt
componentIMTCpt :: R.Component ComponentIMTProps
componentIMTCpt = here.component "componentIMT" cpt where
cpt { search, session } _ = do
componentIMTCpt = R2.hereComponent here "componentIMT" hCpt where
hCpt hp { search, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[componentIMT]"
, herePrefix: hp
, loader: \_ -> getIMTSchools session
, path: unit
, render: \schools -> componentWithIMTOrgs { schools, search } [] }
......@@ -392,10 +392,10 @@ type PubmedInputProps = (
pubmedInput :: R2.Component PubmedInputProps
pubmedInput = R.createElement pubmedInputCpt
pubmedInputCpt :: R.Component PubmedInputProps
pubmedInputCpt = here.component "pubmedInput" cpt where
cpt { search, session: session@(Session { treeId }) } _ = do
pubmedInputCpt = R2.hereComponent here "pubmedInput" hCpt where
hCpt hp { search, session: session@(Session { treeId }) } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[pubmedInput]"
, herePrefix: hp
, loader: \_ -> getUser session treeId
, path: unit
, render: \user -> pubmedInputLoaded { pubmedAPIKey: user.u_hyperdata.pubmed_api_key
......@@ -444,10 +444,10 @@ type EPOInputProps = (
epoInput :: R2.Component EPOInputProps
epoInput = R.createElement epoInputCpt
epoInputCpt :: R.Component EPOInputProps
epoInputCpt = here.component "epoInput" cpt where
cpt { search, session: session@(Session { treeId }) } _ = do
epoInputCpt = R2.hereComponent here "epoInput" hCpt where
hCpt hp { search, session: session@(Session { treeId }) } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[epoInput]"
, herePrefix: hp
, loader: \_ -> getUser session treeId
, path: unit
, render: \user -> epoInputLoaded { epoAPIUser: user.u_hyperdata.epo_api_user
......
......@@ -65,15 +65,14 @@ type ShareNode =
shareNode :: R2.Component ShareNode
shareNode = R.createElement shareNodeCpt
shareNodeCpt :: R.Component ShareNode
shareNodeCpt = here.component "shareNode" cpt
where
cpt { id, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[shareNode]"
, loader: getCompletionsReq
, path: { session }
, render: \completions -> shareNodeInner { completions, id, session } []
}
shareNodeCpt = R2.hereComponent here "shareNode" hCpt where
hCpt hp { id, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: getCompletionsReq
, path: { session }
, render: \completions -> shareNodeInner { completions, id, session } []
}
type ShareNodeInner =
( completions :: Array String
......
......@@ -106,10 +106,10 @@ type UploadFile =
uploadFileView :: R2.Leaf Props
uploadFileView = R2.leaf uploadFileViewCpt
uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = here.component "uploadFileView" cpt where
cpt props@({ session }) _ = do
uploadFileViewCpt = R2.hereComponent here "uploadFileView" hCpt where
hCpt hp props@({ session }) _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[uploadFileView]"
, herePrefix: hp
, loader: loadLanguages
, path: { session }
, render: \langs ->
......@@ -731,10 +731,10 @@ uploadTermButtonCpt = here.component "uploadTermButton" cpt
uploadFrameCalcView :: R2.Component Props
uploadFrameCalcView = R.createElement uploadFrameCalcViewCpt
uploadFrameCalcViewCpt :: R.Component Props
uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt where
cpt props@({ session }) _ = do
uploadFrameCalcViewCpt = R2.hereComponent here "uploadFrameCalcView" hCpt where
hCpt hp props@({ session }) _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[uploadFrameCalcView]"
, herePrefix: hp
, loader: loadLanguages
, path: { session }
, render: \langs ->
......
......@@ -39,11 +39,11 @@ type ActionWriteNodesDocuments =
actionWriteNodesDocuments :: R2.Component ActionWriteNodesDocuments
actionWriteNodesDocuments = R.createElement actionWriteNodesDocumentsCpt
actionWriteNodesDocumentsCpt :: R.Component ActionWriteNodesDocuments
actionWriteNodesDocumentsCpt = here.component "actionWriteNodesDocuments" cpt where
cpt props@({ session }) _ = do
actionWriteNodesDocumentsCpt = R2.hereComponent here "actionWriteNodesDocuments" hCpt where
hCpt hp props@({ session }) _ = do
{ errors } <- Store.use
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[actionWriteNodesDocuments]"
, herePrefix: hp
, loader: loadLanguages
, path: { session }
, render: \langs ->
......
......@@ -39,41 +39,40 @@ type Props = (
asyncProgressBar :: R2.Component Props
asyncProgressBar = R.createElement asyncProgressBarCpt
asyncProgressBarCpt :: R.Component Props
asyncProgressBarCpt = here.component "asyncProgressBar" cpt
where
cpt props@{ asyncTask: (GT.AsyncTaskWithType {task: GT.AsyncTask {id}})
, barType
, onFinish
} _ = do
{ errors } <- AppStore.use
progress <- T.useBox 0.0
intervalIdRef <- R.useRef Nothing
R.useEffectOnce' $ do
intervalId <- setInterval 1000 $ do
launchAff_ $ do
let rdata = (RX.pick props :: Record QueryProgressData)
eAsyncProgress <- queryProgress rdata
handleRESTError (R2.herePrefix here "[asyncProgressBar]") errors eAsyncProgress $
\asyncProgress -> liftEffect $ do
let GT.AsyncProgress { status } = asyncProgress
T.write_ (min 100.0 $ GT.progressPercent asyncProgress) progress
if (status == GT.IsFinished) || (status == GT.IsKilled) || (status == GT.IsFailure) then do
_ <- case R.readRef intervalIdRef of
Nothing -> pure unit
Just iid -> clearInterval iid
handleErrorInAsyncProgress errors asyncProgress
onFinish unit
else
pure unit
R.setRef intervalIdRef $ Just intervalId
pure unit
pure $ progressIndicator { barType, label: id, progress }
asyncProgressBarCpt = R2.hereComponent here "asyncProgressBar" hCpt where
hCpt hp props@{ asyncTask: (GT.AsyncTaskWithType {task: GT.AsyncTask {id}})
, barType
, onFinish
} _ = do
{ errors } <- AppStore.use
progress <- T.useBox 0.0
intervalIdRef <- R.useRef Nothing
R.useEffectOnce' $ do
intervalId <- setInterval 1000 $ do
launchAff_ $ do
let rdata = (RX.pick props :: Record QueryProgressData)
eAsyncProgress <- queryProgress rdata
handleRESTError hp errors eAsyncProgress $
\asyncProgress -> liftEffect $ do
let GT.AsyncProgress { status } = asyncProgress
T.write_ (min 100.0 $ GT.progressPercent asyncProgress) progress
if (status == GT.IsFinished) || (status == GT.IsKilled) || (status == GT.IsFailure) then do
_ <- case R.readRef intervalIdRef of
Nothing -> pure unit
Just iid -> clearInterval iid
handleErrorInAsyncProgress errors asyncProgress
onFinish unit
else
pure unit
R.setRef intervalIdRef $ Just intervalId
pure unit
pure $ progressIndicator { barType, label: id, progress }
--------------------------------------------------------------
......
......@@ -41,33 +41,32 @@ type SubTreeParamsProps =
subTreeView :: R2.Component SubTreeParamsProps
subTreeView = R.createElement $ R.memo' subTreeViewCpt
subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = here.component "subTreeView" cpt
where
cpt { action
, dispatch
, id
, nodeType
, session
, subTreeParams
} _ = do
let
SubTreeParams {showtypes} = subTreeParams
-- (valAction /\ setAction) = action
-- _ <- pure $ setAction (const $ setTreeOut valAction Nothing)
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[subTreeView]"
, loader: loadSubTree showtypes
, path: session
, render: \tree ->
subTreeViewLoaded { action
, dispatch
, id
, nodeType
, session
, subTreeParams
, tree
} [] }
subTreeViewCpt = R2.hereComponent here "subTreeView" hCpt where
hCpt hp { action
, dispatch
, id
, nodeType
, session
, subTreeParams
} _ = do
let
SubTreeParams {showtypes} = subTreeParams
-- (valAction /\ setAction) = action
-- _ <- pure $ setAction (const $ setTreeOut valAction Nothing)
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: loadSubTree showtypes
, path: session
, render: \tree ->
subTreeViewLoaded { action
, dispatch
, id
, nodeType
, session
, subTreeParams
, tree
} [] }
loadSubTree :: Array GT.NodeType -> Session -> AffRESTError FTree
loadSubTree nodetypes session = getSubTree session treeId nodetypes
......
......@@ -17,10 +17,10 @@ type ForgotPasswordProps = ( server :: String, uuid :: String )
forgotPasswordLayout :: R2.Component ForgotPasswordProps
forgotPasswordLayout = R.createElement forgotPasswordLayoutCpt
forgotPasswordLayoutCpt :: R.Component ForgotPasswordProps
forgotPasswordLayoutCpt = here.component "forgotPasswordLayout" cpt where
cpt { server, uuid } _ = do
forgotPasswordLayoutCpt = R2.hereComponent here "forgotPasswordLayout" hCpt where
hCpt hp { server, uuid } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[forgotPasswordLayout]"
, herePrefix: hp
, loader: loadPassword
, path: { server, uuid }
, render: \{ password } ->
......
......@@ -36,11 +36,11 @@ type Props =
docFocus :: R2.Leaf ( key :: String | Props )
docFocus = R2.leaf docFocusCpt
docFocusCpt :: R.Component ( key :: String | Props )
docFocusCpt = here.component "main" cpt where
cpt { graphSideDoc: GraphSideDoc { docId, listId, corpusId }
, session
, closeCallback
} _ = do
docFocusCpt = R2.hereComponent here "main" hCpt where
hCpt hp { graphSideDoc: GraphSideDoc { docId, listId, corpusId }
, session
, closeCallback
} _ = do
-- | States
-- |
state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData)
......@@ -64,7 +64,7 @@ docFocusCpt = here.component "main" cpt where
-- | Hooks
-- |
useLoaderEffect
{ errorHandler: logRESTError (R2.herePrefix here "[docFocus]")
{ errorHandler: logRESTError hp
, loader: loadData
, path
, state
......
......@@ -20,7 +20,7 @@ import Gargantext.Components.GraphQL.Team (Team, teamQuery)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, treeFirstLevelQuery, BreadcrumbInfo, breadcrumbQuery)
import Gargantext.Components.GraphQL.User (UserInfo, userInfoQuery, User, userQuery)
import Gargantext.Components.Lang (Lang)
import Gargantext.Config.REST (RESTError(..), AffRESTError, logRESTError)
import Gargantext.Config.REST (RESTError(..), AffRESTError)
import Gargantext.Core.NgramsTable.Types (NgramsTerm(..))
import Gargantext.Sessions (Session(..))
import Gargantext.Types (CorpusId, NodeType)
......
......@@ -114,22 +114,21 @@ type LangSwitcherProps = (
langSwitcher :: R2.Component LangSwitcherProps
langSwitcher = R.createElement langSwitcherCpt
langSwitcherCpt :: R.Component LangSwitcherProps
langSwitcherCpt = here.component "langSwitcher" cpt
where
cpt { lang, langs} _ = do
currentLang <- T.useLive T.unequal lang
let option l = H.option { value: show l} [ H.text $ show l]
let options = map option langs
pure $ R2.select { className: "form-control"
, defaultValue: show currentLang
, on: {change: onChange lang } } options
where
onChange box e = do
let value = R.unsafeEventValue e
let mLang = A.head $ A.filter (\l -> value == show l) langs
case mLang of
Nothing -> pure unit
Just l -> do
T.write_ l box
langSwitcherCpt = here.component "langSwitcher" cpt where
cpt { lang, langs} _ = do
currentLang <- T.useLive T.unequal lang
let option l = H.option { value: show l} [ H.text $ show l]
let options = map option langs
pure $ R2.select { className: "form-control"
, defaultValue: show currentLang
, on: {change: onChange lang } } options
where
onChange box e = do
let value = R.unsafeEventValue e
let mLang = A.head $ A.filter (\l -> value == show l) langs
case mLang of
Nothing -> pure unit
Just l -> do
T.write_ l box
......@@ -117,10 +117,10 @@ type ListTreeChildrenProps =
listTreeChildren :: R2.Component ListTreeChildrenProps
listTreeChildren = R.createElement listTreeChildrenCpt
listTreeChildrenCpt :: R.Component ListTreeChildrenProps
listTreeChildrenCpt = here.component "listTreeChildren" cpt where
cpt { render, root, selection, session } _ = do
listTreeChildrenCpt = R2.hereComponent here "listTreeChildren" hCpt where
hCpt hp { render, root, selection, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[listTreeChildren]"
, herePrefix: hp
, loader: loadTreeChildren
, path: { root, session }
, render: \loaded ->
......
......@@ -17,15 +17,13 @@ type Props =
loadingSpinner :: Record Props -> R.Element
loadingSpinner props = R.createElement loadingSpinnerCpt props []
loadingSpinnerCpt :: R.Component Props
loadingSpinnerCpt = here.component "LoadingSpinner" cpt
where
-- cpt _ _ = H.i {className: "spinner fa fa-smile-o fa-spin fa-3x fa-fw"} [H.text ""]
-- cpt _ _ = H.i {className: "fa fa-globe fa-spin fa-3x fa-fw"} [H.text ""]
-- cpt _ _ = H.i {className: "fa fa-circle-o-notch fa-spin fa-3x fa-fw"} [H.text ""]
cpt { additionalClass } _ = do
pure $ H.i { className: "fa fa-spinner fa-pulse fa-3x fa-fw " <> c } [H.text ""]
where
c = fromMaybe "" additionalClass
loadingSpinnerCpt = here.component "LoadingSpinner" cpt where
-- cpt _ _ = H.i {className: "spinner fa fa-smile-o fa-spin fa-3x fa-fw"} [H.text ""]
-- cpt _ _ = H.i {className: "fa fa-globe fa-spin fa-3x fa-fw"} [H.text ""]
-- cpt _ _ = H.i {className: "fa fa-circle-o-notch fa-spin fa-3x fa-fw"} [H.text ""]
cpt { additionalClass } _ = do
pure $ H.i { className: "fa fa-spinner fa-pulse fa-3x fa-fw " <> c } [H.text ""]
where
c = fromMaybe "" additionalClass
......@@ -23,20 +23,18 @@ type Props = ( setVisible :: R.Setter Boolean )
modal :: R2.Component Props
modal = R.createElement modalCpt
modalCpt :: R.Component Props
modalCpt = here.component "modal" cpt
where
cpt {setVisible} children = do
host <- R2.getPortalHost
root <- R.useRef null -- used to close when user clicks outside
R2.useLayoutEffectOnce $ modalEffect root setVisible
pure $ R.createPortal
[ H.div { ref: root, className: "modal", data: {toggle: "popover", placement: "right"}}
[ H.div { className: "popover-content" }
[ H.div { className: "card" }
[ H.ul { className: "list-group" } children ]]]]
host
modalCpt = R2.hereComponent here "modal" hCpt where
hCpt _hp {setVisible} children = do
host <- R2.getPortalHost
root <- R.useRef null -- used to close when user clicks outside
R2.useLayoutEffectOnce $ modalEffect root setVisible
pure $ R.createPortal
[ H.div { ref: root, className: "modal", data: {toggle: "popover", placement: "right"}}
[ H.div { className: "popover-content" }
[ H.div { className: "card" }
[ H.ul { className: "list-group" } children ]]]]
host
modalEffect
:: R.Ref (Nullable DOM.Element)
......
......@@ -1021,15 +1021,15 @@ type MainNgramsTableCacheProps =
mainNgramsTableCacheOn :: R2.Leaf MainNgramsTableCacheProps
mainNgramsTableCacheOn = R2.leaf mainNgramsTableCacheOnCpt
mainNgramsTableCacheOnCpt :: R.Component MainNgramsTableCacheProps
mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
cpt { afterSync
, defaultListId
, path
, session
, state
, tabNgramType
, treeEdit
, withAutoUpdate } _ = do
mainNgramsTableCacheOnCpt = R2.hereComponent here "mainNgramsTableCacheOn" hCpt where
hCpt hp { afterSync
, defaultListId
, path
, session
, state
, tabNgramType
, treeEdit
, withAutoUpdate } _ = do
-- let path = initialPageParams session nodeId [defaultListId] tabType
......@@ -1052,8 +1052,9 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
, renderer: render
, spinnerClass: Nothing
}
where
errorHandler = logRESTError hp
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ Routes.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
errorHandler = logRESTError (R2.herePrefix here "[mainNgramsTableCacheOn]")
mkRequest :: PageParams -> GUC.Request
mkRequest path@{ session } = GUC.makeGetRequest session $ url path
where
......@@ -1068,14 +1069,14 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
mainNgramsTableCacheOff :: R2.Leaf MainNgramsTableCacheProps
mainNgramsTableCacheOff = R2.leaf mainNgramsTableCacheOffCpt
mainNgramsTableCacheOffCpt :: R.Component MainNgramsTableCacheProps
mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
cpt { afterSync
, path
, session
, state
, tabNgramType
, treeEdit
, withAutoUpdate } _ = do
mainNgramsTableCacheOffCpt = R2.hereComponent here "mainNgramsTableCacheOff" hCpt where
hCpt hp { afterSync
, path
, session
, state
, tabNgramType
, treeEdit
, withAutoUpdate } _ = do
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, cacheState: NT.CacheOff
, path
......@@ -1086,7 +1087,7 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
, versionedWithCount
, withAutoUpdate } []
useLoaderBox { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[mainNgramsTableCacheOff]"
, herePrefix: hp
, loader
, path
, render }
......
......@@ -70,13 +70,13 @@ type KeyLayoutProps =
annuaireLayoutWithKey :: R2.Leaf KeyLayoutProps
annuaireLayoutWithKey = R2.leaf annuaireLayoutWithKeyCpt
annuaireLayoutWithKeyCpt :: R.Component KeyLayoutProps
annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where
cpt { frontends, nodeId, session } _ = do
annuaireLayoutWithKeyCpt = R2.hereComponent here "annuaireLayoutWithKey" hCpt where
hCpt hp { frontends, nodeId, session } _ = do
path <- T.useBox nodeId
path' <- T.useLive T.unequal path
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[annuaireLayoutWithKey]"
, herePrefix: hp
, loader: getAnnuaireInfo session
, path: path'
, render: \info -> annuaire { frontends, info, path, session } }
......@@ -135,16 +135,15 @@ type PageLayoutProps =
pageLayout :: Record PageLayoutProps -> R.Element
pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt
where
cpt { frontends, pagePath, session } _ = do
pagePath' <- T.useLive T.unequal pagePath
pageLayoutCpt = R2.hereComponent here "pageLayout" hCpt where
hCpt hp { frontends, pagePath, session } _ = do
pagePath' <- T.useLive T.unequal pagePath
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[pageLayout]"
, loader: loadPage session
, path: pagePath'
, render: \table -> page { session, table, frontends, pagePath } }
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: loadPage session
, path: pagePath'
, render: \table -> page { session, table, frontends, pagePath } }
type PageProps =
( frontends :: Frontends
......
......@@ -21,7 +21,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter)
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.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
......@@ -92,10 +92,11 @@ userLayoutCpt = here.component "userLayout" cpt
userLayoutWithKey :: R2.Leaf ( key :: String | LayoutProps )
userLayoutWithKey = R2.leaf userLayoutWithKeyCpt
userLayoutWithKeyCpt :: R.Component ( key :: String | LayoutProps )
userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
cpt { frontends
, nodeId
, session } _ = do
-- userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
userLayoutWithKeyCpt = R2.hereComponent here "userLayoutWithKey" hCpt where
hCpt hp { frontends
, nodeId
, session } _ = do
{ errors, sidePanelLists, sidePanelTexts } <- AppStore.use
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
......@@ -105,7 +106,7 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
cacheState <- T.useBox LT.CacheOn
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[userLayoutWithKey]"
, herePrefix: hp
, loader: getUserInfoWithReload
, path: { nodeId: userId, reload: reload', session }
, render: \userInfo@{ ui_username } ->
......@@ -132,7 +133,7 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
launchAff_ $ do
let Session {userId} = session
res <- saveUserInfo session userId ui
handleRESTError (R2.herePrefix here "[userLayoutWithKey]") errors res $ \_ ->
handleRESTError hp errors res $ \_ ->
liftEffect $ T2.reload reload
--saveContactHyperdata :: Session -> Int -> HyperdataUser -> AffRESTError Int
......@@ -161,11 +162,11 @@ type PubmedSettingsProps =
pubmedSettings :: R2.Leaf PubmedSettingsProps
pubmedSettings = R2.leaf pubmedSettingsCpt
pubmedSettingsCpt :: R.Component PubmedSettingsProps
pubmedSettingsCpt = here.component "pubmedSettings" cpt where
cpt { nodeId
, session } _ = do
pubmedSettingsCpt = R2.hereComponent here "pubmedSettings" hCpt where
hCpt hp { nodeId
, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[pubmedSettings]"
, herePrefix: hp
, loader: \_ -> getUser session nodeId
, path: unit
, render: \user -> pubmedSettingsLoaded { nodeId
......@@ -207,11 +208,11 @@ type EPOSettingsProps =
epoSettings :: R2.Leaf EPOSettingsProps
epoSettings = R2.leaf epoSettingsCpt
epoSettingsCpt :: R.Component EPOSettingsProps
epoSettingsCpt = here.component "epoSettings" cpt where
cpt { nodeId
, session } _ = do
epoSettingsCpt = R2.hereComponent here "epoSettings" hCpt where
hCpt hp { nodeId
, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[epoSettings]"
, herePrefix: hp
, loader: \_ -> getUser session nodeId
, path: unit
, render: \user -> epoSettingsLoaded { nodeId
......@@ -258,10 +259,10 @@ type EditableUserField =
editableUserField :: R2.Leaf EditableUserField
editableUserField = R2.leaf editableUserFieldCpt
editableUserFieldCpt :: R.Component EditableUserField
editableUserFieldCpt = here.component "editableUserField" cpt where
cpt { callback
, description
, mValue } _ = do
editableUserFieldCpt = R2.hereComponent here "editableUserField" hCpt where
hCpt hp { callback
, description
, mValue } _ = do
{ errors } <- AppStore.use
box <- T.useBox $ fromMaybe "" mValue
......@@ -278,14 +279,12 @@ editableUserFieldCpt = here.component "editableUserField" cpt where
where
onUpdate errors s = do
here.log2 ("[editableUserField] " <> description) s
case s of
"" -> pure unit
_ -> do
launchAff_ $ do
res <- callback s
handleRESTError (R2.herePrefix here "[editableUserField]") errors res $ \_result ->
liftEffect $ here.log ("[editableUserField] " <> description <> " updated")
handleRESTError hp errors res (const $ pure unit)
------------------------------------------------------------
......
......@@ -31,10 +31,9 @@ type Props =
contactLayout :: R2.Leaf ( key :: String | Props )
contactLayout = R2.leaf contactLayoutCpt
contactLayoutCpt :: R.Component ( key :: String | Props )
contactLayoutCpt = here.component "layout" cpt where
contactLayoutCpt = R2.hereComponent here "layout" hCpt where
-- Component
cpt { nodeId
} _ = do
hCpt hp { nodeId } _ = do
session <- useSession
......@@ -42,7 +41,7 @@ contactLayoutCpt = here.component "layout" cpt where
useLoader
{ errorHandler: Nothing
, herePrefix: R2.herePrefix here "[contactLayout]"
, herePrefix: hp
, loader: getAnnuaireContact session
, path: nodeId
, render:
......
......@@ -33,23 +33,22 @@ cacheName = "metrics"
metricsLoadView :: forall a. Eq a => Record (MetricsLoadViewProps a) -> R.Element
metricsLoadView p = R.createElement metricsLoadViewCpt p []
metricsLoadViewCpt :: forall a. Eq a => R.Component (MetricsLoadViewProps a)
metricsLoadViewCpt = here.component "metricsLoadView" cpt
where
cpt { getMetrics
, loaded
, onClick
, onInit
, path
, reload
, session } _ = do
{ errors } <- Store.use
reload' <- T.useLive T.unequal reload
metricsLoadViewCpt = R2.hereComponent here "metricsLoadView" hCpt where
hCpt hp { getMetrics
, loaded
, onClick
, onInit
, path
, reload
, session } _ = do
{ errors } <- Store.use
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[metricsLoadView]"
, loader: getMetrics session
, path: reload' /\ path
, render: \l -> loaded { path, reload, session, onClick, onInit } l }
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: getMetrics session
, path: reload' /\ path
, render: \l -> loaded { path, reload, session, onClick, onInit } l }
type MetricsWithCacheLoadViewProps res ret =
( getMetricsHash :: Session -> ReloadPath -> AffRESTError Hash
......
......@@ -47,12 +47,12 @@ type ViewProps =
corpusCodeLayout :: R2.Leaf Props
corpusCodeLayout = R2.leaf corpusCodeLayoutCpt
corpusCodeLayoutCpt :: R.Component Props
corpusCodeLayoutCpt = here.component "corpusCodeLayout" cpt where
cpt { nodeId, session, boxes } _ = do
corpusCodeLayoutCpt = R2.hereComponent here "corpusCodeLayout" hCpt where
hCpt hp { nodeId, session, boxes } _ = do
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[corpusCodeLayout]"
, herePrefix: hp
, loader: loadCorpusWithReload
, path: { nodeId, reload: reload', session }
, render: \corpus -> corpusCodeView { corpus, nodeId, reload, session, boxes } }
......
......@@ -47,38 +47,37 @@ type KeyProps =
dashboardLayoutWithKey :: R2.Component KeyProps
dashboardLayoutWithKey = R.createElement dashboardLayoutWithKeyCpt
dashboardLayoutWithKeyCpt :: R.Component KeyProps
dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
where
cpt { nodeId, session } _ = do
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[dashboardLayoutWithKey]"
, loader: DT.loadDashboardWithReload
, path: { nodeId, reload: reload', session }
, render: \(DT.DashboardData { hyperdata: DT.Hyperdata h, parentId }) -> do
let { charts, fields } = h
dashboardLayoutLoaded { charts
, corpusId: parentId
, defaultListId: 0
, fields
, nodeId
, onChange: onChange nodeId reload (DT.Hyperdata h)
, session } [] }
where
onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
, fields :: FTFieldList } -> Effect Unit
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
launchAff_ do
res <- DT.saveDashboard { hyperdata: DT.Hyperdata $ h { charts = charts, fields = fields }
, nodeId:nodeId'
, session }
liftEffect $ do
_ <- case res of
Left err -> here.warn2 "[dashboardLayoutWithKey] onChange RESTError" err
_ -> pure unit
T2.reload reload
dashboardLayoutWithKeyCpt = R2.hereComponent here "dashboardLayoutWithKey" hCpt where
hCpt hp { nodeId, session } _ = do
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { errorHandler: Nothing
, herePrefix: hp
, loader: DT.loadDashboardWithReload
, path: { nodeId, reload: reload', session }
, render: \(DT.DashboardData { hyperdata: DT.Hyperdata h, parentId }) -> do
let { charts, fields } = h
dashboardLayoutLoaded { charts
, corpusId: parentId
, defaultListId: 0
, fields
, nodeId
, onChange: onChange nodeId reload (DT.Hyperdata h)
, session } [] }
where
onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
, fields :: FTFieldList } -> Effect Unit
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
launchAff_ do
res <- DT.saveDashboard { hyperdata: DT.Hyperdata $ h { charts = charts, fields = fields }
, nodeId:nodeId'
, session }
liftEffect $ do
_ <- case res of
Left err -> R2.hpWarn2 hp "onChange RESTError" err
_ -> pure unit
T2.reload reload
type LoadedProps =
( charts :: Array P.PredefinedChart
......
......@@ -32,11 +32,11 @@ here = R2.here "Gargantext.Components.Nodes.Corpus.Document"
node :: R2.Leaf ( key :: String | Props )
node = R2.leaf nodeCpt
nodeCpt :: R.Component ( key :: String | Props )
nodeCpt = here.component "node" cpt where
cpt { listId
, mCorpusId
, nodeId
} _ = do
nodeCpt = R2.hereComponent here "node" hCpt where
hCpt hp { listId
, mCorpusId
, nodeId
} _ = do
-- | States
-- |
session <- useSession
......@@ -55,7 +55,7 @@ nodeCpt = here.component "node" cpt where
-- | Hooks
-- |
useLoaderEffect
{ errorHandler: logRESTError (R2.herePrefix here "[documentLayoutWithKey]")
{ errorHandler: logRESTError hp
, loader: loadData
, path
, state
......
......@@ -34,8 +34,8 @@ node :: R2.Leaf MainProps
node = R2.leaf nodeCpt
nodeCpt :: R.Component MainProps
nodeCpt = here.component "node" cpt where
cpt { nodeId } _ = do
nodeCpt = R2.hereComponent here "node" hCpt where
hCpt hp { nodeId } _ = do
-- | States
-- |
session <- useSession
......@@ -45,7 +45,7 @@ nodeCpt = here.component "node" cpt where
-- | Computed
-- |
let errorHandler = logRESTError (R2.herePrefix here "[phylo]")
let errorHandler = logRESTError hp
-- | Hooks
-- |
......
......@@ -50,10 +50,10 @@ type FileLayoutProps = ( nodeId :: NodeID, session :: Session )
fileLayout :: R2.Leaf FileLayoutProps
fileLayout = R2.leaf fileLayoutCpt
fileLayoutCpt :: R.Component FileLayoutProps
fileLayoutCpt = here.component "fileLayout" cpt where
cpt { nodeId, session } _ = do
fileLayoutCpt = R2.hereComponent here "fileLayout" hCpt where
hCpt hp { nodeId, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[fileLayout]"
, herePrefix: hp
, loader: loadFile session
, path: nodeId
, render: onLoad }
......
......@@ -32,10 +32,10 @@ node :: R2.Leaf ( key :: String | Props )
node = R2.leaf nodeCpt
nodeCpt :: R.Component ( key :: String | Props )
nodeCpt = here.component "node" cpt where
cpt { nodeId
, nodeType
} _ = do
nodeCpt = R2.hereComponent here "node" hCpt where
hCpt hp { nodeId
, nodeType
} _ = do
-- | States
-- |
session <- useSession
......@@ -46,7 +46,7 @@ nodeCpt = here.component "node" cpt where
-- | Hooks
-- |
useLoaderEffect
{ errorHandler: logRESTError (R2.herePrefix here "[frameLayout]")
{ errorHandler: logRESTError hp
, loader: loadframeWithReload
, path:
{ nodeId
......
......@@ -41,8 +41,8 @@ here = R2.here "Gargantext.Components.Nodes.Graph"
node :: R2.Leaf ( key :: String | Props )
node = R2.leaf nodeCpt
nodeCpt :: R.Component ( key :: String | Props )
nodeCpt = here.component "node" cpt where
cpt { graphId } _ = do
nodeCpt = R2.hereComponent here "node" hCpt where
hCpt hp { graphId } _ = do
-- | States
-- |
{ graphVersion
......@@ -56,7 +56,7 @@ nodeCpt = here.component "node" cpt where
-- | Computed
-- |
let errorHandler = logRESTError (R2.herePrefix here "[node]")
let errorHandler = logRESTError hp
-- | Hooks
-- |
......
......@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.String (take)
import Gargantext.Config (publicBackend)
import Gargantext.Config.REST (AffRESTError, get, logRESTError)
import Gargantext.Config.REST (AffRESTError, get)
import Gargantext.Ends (backendUrl)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
......@@ -68,10 +68,10 @@ loadPublicData _l = do
renderPublic :: R2.Leaf ()
renderPublic = R2.leaf renderPublicCpt
renderPublicCpt :: R.Component ()
renderPublicCpt = here.component "renderPublic" cpt where
cpt _ _ = do
renderPublicCpt = R2.hereComponent here "renderPublic" hCpt where
hCpt hp _ _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[renderPublic]"
, herePrefix: hp
, loader: loadPublicData
, path: { reload: 0 }
, render: loaded }
......
......@@ -58,12 +58,12 @@ listsLayoutCpt = here.component "listsLayout" cpt where
listsLayoutWithKey :: R2.Component ( key :: String | Props )
listsLayoutWithKey = R.createElement listsLayoutWithKeyCpt
listsLayoutWithKeyCpt :: R.Component ( key :: String | Props )
listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
cpt { boxes
, nodeId
, session
, sessionUpdate
, sidePanel } _ = do
listsLayoutWithKeyCpt = R2.hereComponent here "listsLayoutWithKey" hCpt where
hCpt hp { boxes
, nodeId
, session
, sessionUpdate
, sidePanel } _ = do
activeTab <- T.useBox 0
let path = { nodeId, session }
......@@ -75,7 +75,7 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
T.listen (\{ new } -> afterCacheStateChange new) cacheState
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[listsLayoutWithKey]"
, herePrefix: hp
, path
, loader: loadCorpusWithChild
, render: \corpusData@{ corpusId, corpusNode: NodePoly poly } ->
......@@ -191,19 +191,19 @@ type NgramsDocListProps =
ngramsDocList :: R2.Component NgramsDocListProps
ngramsDocList = R.createElement ngramsDocListCpt
ngramsDocListCpt :: R.Component NgramsDocListProps
ngramsDocListCpt = here.component "ngramsDocList" cpt where
cpt { mCorpusId: Nothing } _ = do
ngramsDocListCpt = R2.hereComponent here "ngramsDocList" hCpt where
hCpt hp { mCorpusId: Nothing } _ = do
pure $ H.div {} []
cpt { mListId: Nothing } _ = do
hCpt hp { mListId: Nothing } _ = do
pure $ H.div {} []
cpt { mNgrams: Nothing } _ = do
hCpt hp { mNgrams: Nothing } _ = do
pure $ H.div {} []
cpt { mCorpusId: Just corpusId
, mListId: Just listId
, mNgrams: Just ngrams
, session } _ = do
hCpt hp { mCorpusId: Just corpusId
, mListId: Just listId
, mNgrams: Just ngrams
, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[ngramsDocList]"
, herePrefix: hp
, path: { corpusId, ngrams, session }
, loader: loaderNgramsDocList
, render: \ctx -> ngramsDocListLoaded { contexts: ctx
......
......@@ -29,7 +29,6 @@ import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Reload (textsReloadContext)
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Config.REST (logRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader, useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
......@@ -75,10 +74,10 @@ textsLayoutCpt = here.component "textsLayout" cpt where
textsLayoutWithKey :: R2.Leaf ( key :: String | Props )
textsLayoutWithKey = R2.leaf textsLayoutWithKeyCpt
textsLayoutWithKeyCpt :: R.Component ( key :: String | Props )
textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt where
cpt { frontends
, nodeId
} _ = do
textsLayoutWithKeyCpt = R2.hereComponent here "textsLayoutWithKey" hCpt where
hCpt hp { frontends
, nodeId
} _ = do
session <- useSession
cacheState <- T.useBox $ getCacheState LT.CacheOff session nodeId
......@@ -92,7 +91,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt where
T.listen (\{ new } -> afterCacheStateChange new) cacheState
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[textsLayoutWithKey]"
, herePrefix: hp
, loader: loadCorpusWithChild
, path: { nodeId, session }
, render: \corpusData@{ corpusId, corpusNode } ->
......@@ -508,10 +507,10 @@ type SideText =
sideText :: R2.Leaf ( key :: String | SideText )
sideText = R2.leaf sideTextCpt
sideTextCpt :: R.Component ( key :: String | SideText )
sideTextCpt = here.component "sideText" cpt where
cpt { sidePanelText: { corpusId, listId, nodeId }
, session
} _ = do
sideTextCpt = R2.hereComponent here "sideText" hCpt where
hCpt hp { sidePanelText: { corpusId, listId, nodeId }
, session
} _ = do
-- | States
-- |
-- state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData)
......@@ -547,7 +546,7 @@ sideTextCpt = here.component "sideText" cpt where
-- }
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[sideText]"
, herePrefix: hp
, loader: \{ path } -> loadData path
, path: { path }
, render: \loaded -> loadedSideText { loaded
......
......@@ -36,11 +36,11 @@ type Props =
docFocus :: R2.Leaf ( key :: String | Props )
docFocus = R2.leaf docFocusCpt
docFocusCpt :: R.Component ( key :: String | Props )
docFocusCpt = here.component "main" cpt where
cpt { frameDoc: FrameDoc { docId, listId, corpusId }
, session
, closeCallback
} _ = do
docFocusCpt = R2.hereComponent here "main" hCpt where
hCpt hp { frameDoc: FrameDoc { docId, listId, corpusId }
, session
, closeCallback
} _ = do
-- | States
-- |
state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData)
......@@ -64,7 +64,7 @@ docFocusCpt = here.component "main" cpt where
-- | Hooks
-- |
useLoaderEffect
{ errorHandler: logRESTError (R2.herePrefix here "[docFocus]")
{ errorHandler: logRESTError hp
, loader: loadData
, path
, state
......
......@@ -63,79 +63,78 @@ data RangeUpdate = SetMin Number | SetMax Number
rangeSlider :: Record Props -> R.Element
rangeSlider props = R.createElement rangeSliderCpt props []
rangeSliderCpt :: R.Component Props
rangeSliderCpt = here.component "rangeSlider" cpt
where
cpt props _ = do
-- rounding precision (i.e. how many decimal digits are in epsilon)
let (Range.Closed { min: minR, max: maxR }) = props.initialValue
let decPrecision num =
-- int digits
(fromMaybe 0 $ fromNumber $ DN.ceil $ (DN.log num) / DN.ln10)
-- float digits
+ (fromMaybe 0 $ fromNumber $ DN.ceil $ -(DN.log (num - (DN.floor num))) / DN.ln10)
let epsilonPrecision = decPrecision props.epsilon
let minPrecision = decPrecision minR
let maxPrecision = decPrecision maxR
--let precision = fromMaybe 0 $ fromNumber $ max 0.0 epsilonPrecision
let precision = fromMaybe 0 $ maximum [0, epsilonPrecision, minPrecision, maxPrecision]
-- scale bar
scaleElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref
-- scale sel bar
scaleSelElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref
-- low knob
lowElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- a dom ref to the low knob
-- high knob
highElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- a dom ref to the high knob
-- The value of the user's selection
value <- T.useBox $ initialValue props
value' <- T.useLive T.unequal value
-- the knob we are currently in a drag for. set by mousedown on a knob
dragKnob <- T.useBox (Nothing :: Maybe Knob)
dragKnob' <- T.useLive T.unequal dragKnob
-- the handler functions for trapping mouse events, so they can be removed
mouseMoveHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
mouseUpHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
let destroy = \_ -> do
destroyEventHandler "mousemove" mouseMoveHandler
destroyEventHandler "mouseup" mouseUpHandler
R.setRef mouseMoveHandler $ Nothing
R.setRef mouseUpHandler $ Nothing
R2.useLayoutEffect1' dragKnob' $ \_ -> do
let scalePos = R2.readPositionRef scaleElem
let lowPos = R2.readPositionRef lowElem
let highPos = R2.readPositionRef highElem
case dragKnob' of
Just knob -> do
let drag = (getDragScale knob scalePos lowPos highPos) :: Maybe Range.NumberRange
let onMouseMove = EL.callback $ \(event :: Event.MouseEvent) -> do
case reproject drag scalePos props.bounds props.epsilon (R2.domMousePosition event) of
Just val -> do
setKnob knob value value' val
props.onChange $ knobSetter knob value' val
Nothing -> destroy unit
let onMouseUp = EL.callback $ \(_event :: Event.MouseEvent) -> do
--props.onChange $ knobSetter knob value val
T.write_ Nothing dragKnob
destroy unit
EL.addEventListener document "mousemove" onMouseMove
EL.addEventListener document "mouseup" onMouseUp
R.setRef mouseMoveHandler $ Just onMouseMove
R.setRef mouseUpHandler $ Just onMouseUp
Nothing -> destroy unit
pure $ H.div { className, aria }
[ renderScale scaleElem props value'
, renderScaleSel scaleSelElem props value'
, renderKnob MinKnob lowElem value' props.bounds dragKnob precision props.status
, renderKnob MaxKnob highElem value' props.bounds dragKnob precision props.status
]
className = "range-slider"
aria = { label: "Range Slider Control. Expresses filtering data by a minimum and maximum value range through two slider knobs. Knobs can be adjusted with the arrow keys." }
rangeSliderCpt = here.component "rangeSlider" cpt where
cpt props _ = do
-- rounding precision (i.e. how many decimal digits are in epsilon)
let (Range.Closed { min: minR, max: maxR }) = props.initialValue
let decPrecision num =
-- int digits
(fromMaybe 0 $ fromNumber $ DN.ceil $ (DN.log num) / DN.ln10)
-- float digits
+ (fromMaybe 0 $ fromNumber $ DN.ceil $ -(DN.log (num - (DN.floor num))) / DN.ln10)
let epsilonPrecision = decPrecision props.epsilon
let minPrecision = decPrecision minR
let maxPrecision = decPrecision maxR
--let precision = fromMaybe 0 $ fromNumber $ max 0.0 epsilonPrecision
let precision = fromMaybe 0 $ maximum [0, epsilonPrecision, minPrecision, maxPrecision]
-- scale bar
scaleElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref
-- scale sel bar
scaleSelElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref
-- low knob
lowElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- a dom ref to the low knob
-- high knob
highElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- a dom ref to the high knob
-- The value of the user's selection
value <- T.useBox $ initialValue props
value' <- T.useLive T.unequal value
-- the knob we are currently in a drag for. set by mousedown on a knob
dragKnob <- T.useBox (Nothing :: Maybe Knob)
dragKnob' <- T.useLive T.unequal dragKnob
-- the handler functions for trapping mouse events, so they can be removed
mouseMoveHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
mouseUpHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
let destroy = \_ -> do
destroyEventHandler "mousemove" mouseMoveHandler
destroyEventHandler "mouseup" mouseUpHandler
R.setRef mouseMoveHandler $ Nothing
R.setRef mouseUpHandler $ Nothing
R2.useLayoutEffect1' dragKnob' $ \_ -> do
let scalePos = R2.readPositionRef scaleElem
let lowPos = R2.readPositionRef lowElem
let highPos = R2.readPositionRef highElem
case dragKnob' of
Just knob -> do
let drag = (getDragScale knob scalePos lowPos highPos) :: Maybe Range.NumberRange
let onMouseMove = EL.callback $ \(event :: Event.MouseEvent) -> do
case reproject drag scalePos props.bounds props.epsilon (R2.domMousePosition event) of
Just val -> do
setKnob knob value value' val
props.onChange $ knobSetter knob value' val
Nothing -> destroy unit
let onMouseUp = EL.callback $ \(_event :: Event.MouseEvent) -> do
--props.onChange $ knobSetter knob value val
T.write_ Nothing dragKnob
destroy unit
EL.addEventListener document "mousemove" onMouseMove
EL.addEventListener document "mouseup" onMouseUp
R.setRef mouseMoveHandler $ Just onMouseMove
R.setRef mouseUpHandler $ Just onMouseUp
Nothing -> destroy unit
pure $ H.div { className, aria }
[ renderScale scaleElem props value'
, renderScaleSel scaleSelElem props value'
, renderKnob MinKnob lowElem value' props.bounds dragKnob precision props.status
, renderKnob MaxKnob highElem value' props.bounds dragKnob precision props.status
]
className = "range-slider"
aria = { label: "Range Slider Control. Expresses filtering data by a minimum and maximum value range through two slider knobs. Knobs can be adjusted with the arrow keys." }
destroyEventHandler
:: forall e
......
......@@ -37,7 +37,7 @@ import Gargantext.Components.Tile (tileBlock)
import Gargantext.Components.TopBar as TopBar
import Gargantext.Components.TreeSearch (treeSearch)
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Context.Session as SessionContext
import Gargantext.Ends (Backend)
import Gargantext.Hooks.Resize (ResizeType(..), useResizeHandler)
......
......@@ -62,10 +62,10 @@ tab :: R2.Component TabProps
tab = R.createElement tabCpt
-- | A tab only shows its contents if it is currently selected
tabCpt :: R.Component TabProps
tabCpt = here.component "tab" cpt
where
cpt { selected, index } children = pure $ H.div { className } children'
where
same = selected == index
className = "tab-pane" <> (if same then "show active" else "fade")
children' = if same then children else []
tabCpt = here.component "tab" cpt where
cpt { selected, index } children = do
pure $ H.div { className } children'
where
same = selected == index
className = "tab-pane" <> (if same then "show active" else "fade")
children' = if same then children else []
......@@ -75,29 +75,27 @@ type ThemeSwitcherProps = (
themeSwitcher :: R2.Component ThemeSwitcherProps
themeSwitcher = R.createElement themeSwitcherCpt
themeSwitcherCpt :: R.Component ThemeSwitcherProps
themeSwitcherCpt = here.component "themeSwitcher" cpt
where
cpt { theme, themes } _ = do
currentTheme <- T.useLive T.unequal theme
let option (Theme { name }) = H.option { value: name } [ H.text name ]
let options = map option themes
R.useEffectOnce' $ markThemeToDOMTree currentTheme
pure $ R2.select { className: "form-control rounded-circle-2"
, defaultValue: themeName currentTheme
, on: { change: onChange theme } } options
where
onChange box e = do
let value = R.unsafeEventValue e
let mTheme = A.head $ A.filter (\(Theme { name }) -> value == name) themes
case mTheme of
Nothing -> pure unit
Just t -> do
switchTheme t
markThemeToDOMTree t
T.write_ t box
themeSwitcherCpt = here.component "themeSwitcher" cpt where
cpt { theme, themes } _ = do
currentTheme <- T.useLive T.unequal theme
let option (Theme { name }) = H.option { value: name } [ H.text name ]
let options = map option themes
R.useEffectOnce' $ markThemeToDOMTree currentTheme
pure $ R2.select { className: "form-control rounded-circle-2"
, defaultValue: themeName currentTheme
, on: { change: onChange theme } } options
where
onChange box e = do
let value = R.unsafeEventValue e
let mTheme = A.head $ A.filter (\(Theme { name }) -> value == name) themes
case mTheme of
Nothing -> pure unit
Just t -> do
switchTheme t
markThemeToDOMTree t
T.write_ t box
......@@ -9,7 +9,7 @@ import Gargantext.Components.Bootstrap (formSelect')
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), ModalSizing(..), Position(..), TooltipPosition(..), Variant(..))
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (AppRoute(..), appPath, nodeTypeAppRoute)
......@@ -142,11 +142,11 @@ treeSearchContainer :: R2.Leaf ContainerProps
treeSearchContainer = R2.leaf treeSearchContainerCpt
treeSearchContainerCpt :: R.Component ContainerProps
treeSearchContainerCpt = here.component "treeSearchContainerCpt" cpt where
cpt {query, visible, session } _ = do
treeSearchContainerCpt = R2.hereComponent here "treeSearchContainerCpt" hCpt where
hCpt hp {query, visible, session } _ = do
useLoader { errorHandler: Nothing
, herePrefix: R2.herePrefix here "[treeSearchContainer]"
, herePrefix: hp
, path: { session, query }
, loader: loadSearch
, render: \searchData -> treeSearchRenderContainer { visible, session, searchData }
......
......@@ -38,9 +38,8 @@ here = R2.here "Gargantext.Context.Progress"
asyncProgress :: R2.Component AsyncProps
asyncProgress = R2.component asyncProgressCpt
asyncProgressCpt :: R.Component AsyncProps
asyncProgressCpt = R.hooksComponent "asyncProgress" cpt where
cpt props@{ onFinish
} children = do
asyncProgressCpt = R2.hereComponent here "asyncProgress" hCpt where
hCpt hp props@{ onFinish } children = do
{ errors } <- AppStore.use
-- States
......@@ -63,7 +62,7 @@ asyncProgressCpt = R.hooksComponent "asyncProgress" cpt where
Right _ -> T.write_ 1000 interval
interval' <- T.read interval
resetInterval intervalIdRef (Just interval') exec
handleRESTError (R2.herePrefix here "[asyncProgress]") errors eAsyncProgress onProgress
handleRESTError hp errors eAsyncProgress onProgress
onProgress :: AsyncProgress -> Aff Unit
onProgress value = liftEffect do
......
......@@ -115,9 +115,21 @@ type Prefix = String
newtype HerePrefix = HerePrefix { here :: Here
, prefix :: Prefix }
hpLog2 :: forall a b. HerePrefix -> a -> b -> Effect Unit
hpLog2 (HerePrefix { here: h, prefix }) = h.log3 prefix
hpWarn2 :: forall a b. HerePrefix -> a -> b -> Effect Unit
hpWarn2 (HerePrefix { here: h, prefix }) = h.warn3 prefix
herePrefix :: Here -> Prefix -> HerePrefix
herePrefix here prefix = HerePrefix { here, prefix }
hereComponent :: forall p. Here -> Prefix -> (HerePrefix -> R.HooksComponent p) -> R.Component p
hereComponent here' prefix hpComponent = here'.component prefix (hpComponent hp)
where
hp :: HerePrefix
hp = herePrefix here' prefix
-- newtypes
type NTHooksComponent props = props -> Array R.Element -> R.Hooks R.Element
newtype NTComponent p = NTComponent (EffectFn1 p R.Element)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment