Commit 44d47d07 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[tree] Some graph refresh icon refactoring

Related to #131
parent 608fc7bd
...@@ -168,14 +168,14 @@ type PerformActionProps = ...@@ -168,14 +168,14 @@ type PerformActionProps =
performAction :: Record PerformActionProps performAction :: Record PerformActionProps
-> Action -> Action
-> Aff Unit -> Aff Unit
performAction { openNodes: (_ /\ setOpenNodes) performAction p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload) , reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id}) _) } DeleteNode = do , tree: (NTree (LNode {id}) _) } DeleteNode = do
void $ deleteNode session id void $ deleteNode session id
liftEffect do liftEffect do
setOpenNodes (Set.delete (mkNodeId session id)) setOpenNodes (Set.delete (mkNodeId session id))
setReload (_ + 1) performAction p RefreshTree
performAction { reload: (_ /\ setReload) performAction { reload: (_ /\ setReload)
, session , session
...@@ -184,21 +184,20 @@ performAction { reload: (_ /\ setReload) ...@@ -184,21 +184,20 @@ performAction { reload: (_ /\ setReload)
liftEffect $ setAsyncTasks $ A.cons task liftEffect $ setAsyncTasks $ A.cons task
liftEffect $ log2 "[performAction] SearchQuery task:" task liftEffect $ log2 "[performAction] SearchQuery task:" task
performAction { reload: (_ /\ setReload) performAction p@{ reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id}) _) } (Submit name) = do , tree: (NTree (LNode {id}) _) } (Submit name) = do
void $ renameNode session id $ RenameValue {name} void $ renameNode session id $ RenameValue {name}
liftEffect do performAction p RefreshTree
setReload (_ + 1)
performAction { openNodes: (_ /\ setOpenNodes) performAction p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload) , reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id}) _) } (CreateSubmit name nodeType) = do , tree: (NTree (LNode {id}) _) } (CreateSubmit name nodeType) = do
void $ createNode session id $ CreateValue {name, nodeType} void $ createNode session id $ CreateValue {name, nodeType}
liftEffect do liftEffect do
setOpenNodes (Set.insert (mkNodeId session id)) setOpenNodes (Set.insert (mkNodeId session id))
setReload (_ + 1) performAction p RefreshTree
performAction { session performAction { session
, tasks: (_ /\ setAsyncTasks) , tasks: (_ /\ setAsyncTasks)
...@@ -206,3 +205,6 @@ performAction { session ...@@ -206,3 +205,6 @@ performAction { session
task <- uploadFile session nodeType id fileType {mName, contents} task <- uploadFile session nodeType id fileType {mName, contents}
liftEffect $ setAsyncTasks $ A.cons task liftEffect $ setAsyncTasks $ A.cons task
liftEffect $ log2 "uploaded, task:" task liftEffect $ log2 "uploaded, task:" task
performAction { reload: (_ /\ setReload) } RefreshTree = do
liftEffect $ setReload (_ + 1)
...@@ -19,6 +19,7 @@ data Action = CreateSubmit String GT.NodeType ...@@ -19,6 +19,7 @@ data Action = CreateSubmit String GT.NodeType
| SearchQuery GT.AsyncTaskWithType | SearchQuery GT.AsyncTaskWithType
| Submit String | Submit String
| UploadFile GT.NodeType FileType (Maybe String) UploadFileContents | UploadFile GT.NodeType FileType (Maybe String) UploadFileContents
| RefreshTree
----------------------------------------------------- -----------------------------------------------------
-- UploadFile Action -- UploadFile Action
......
...@@ -24,7 +24,7 @@ import Gargantext.Components.Forest.Tree.Node.Action (Action(..), DroppedFile(.. ...@@ -24,7 +24,7 @@ import Gargantext.Components.Forest.Tree.Node.Action (Action(..), DroppedFile(..
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), createNodeView) import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), createNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox) import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView, uploadTermListView, copyFromCorpusView) import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView, uploadTermListView, copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar) import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
import Gargantext.Components.GraphExplorer.API as GEAPI import Gargantext.Components.GraphExplorer.API as GEAPI
import Gargantext.Components.Search.SearchBar (searchBar) import Gargantext.Components.Search.SearchBar (searchBar)
import Gargantext.Components.Search.SearchField (Search, defaultSearch, isIsTex) import Gargantext.Components.Search.SearchField (Search, defaultSearch, isIsTex)
...@@ -89,9 +89,13 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el ...@@ -89,9 +89,13 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
} }
[ nodeText { isSelected: (mCorpusId mCurrentRoute) == (Just id) [ nodeText { isSelected: (mCorpusId mCurrentRoute) == (Just id)
, name: name' props } ] , name: name' props } ]
, nodeActions { id, nodeType, session } , nodeActions { id
, nodeType
, refreshTree: const $ dispatch RefreshTree
, session }
, fileTypeView {dispatch, droppedFile, id, isDragOver, nodeType} , fileTypeView {dispatch, droppedFile, id, isDragOver, nodeType}
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t , H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, barType: Pie
, corpusId: id , corpusId: id
, onFinish: const $ onAsyncTaskFinish t , onFinish: const $ onAsyncTaskFinish t
, session }) asyncTasks) , session }) asyncTasks)
...@@ -192,6 +196,7 @@ type NodeActionsProps = ...@@ -192,6 +196,7 @@ type NodeActionsProps =
( (
id :: ID id :: ID
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, refreshTree :: Unit -> Aff Unit
, session :: Session , session :: Session
) )
...@@ -201,24 +206,21 @@ nodeActions p = R.createElement nodeActionsCpt p [] ...@@ -201,24 +206,21 @@ nodeActions p = R.createElement nodeActionsCpt p []
nodeActionsCpt :: R.Component NodeActionsProps nodeActionsCpt :: R.Component NodeActionsProps
nodeActionsCpt = R.hooksComponent "G.C.F.T.N.B.nodeActions" cpt nodeActionsCpt = R.hooksComponent "G.C.F.T.N.B.nodeActions" cpt
where where
cpt { id, nodeType: GT.Graph, session } _ = do cpt { id, nodeType: GT.Graph, refreshTree, session } _ = do
refresh <- R.useState' 0 useLoader id (graphVersions session) $ \gv ->
nodeActionsGraph { id, graphVersions: gv, session, triggerRefresh: triggerRefresh refreshTree }
useLoader (id /\ fst refresh) (graphVersions session) $ \gv ->
nodeActionsGraph { id, graphVersions: gv, session, triggerRefresh: triggerRefresh refresh }
cpt _ _ = do cpt _ _ = do
pure $ H.div {} [] pure $ H.div {} []
graphVersions session (graphId /\ _) = graphVersions session graphId = GEAPI.graphVersions { graphId, session }
GEAPI.graphVersions { graphId, session } triggerRefresh refreshTree = refreshTree
triggerRefresh (_ /\ setRefresh) _ = setRefresh $ (+) 1
type NodeActionsGraphProps = type NodeActionsGraphProps =
( (
id :: ID id :: ID
, graphVersions :: Record GEAPI.GraphVersions , graphVersions :: Record GEAPI.GraphVersions
, session :: Session , session :: Session
, triggerRefresh :: Unit -> Effect Unit , triggerRefresh :: Unit -> Aff Unit
) )
nodeActionsGraph :: Record NodeActionsGraphProps -> R.Element nodeActionsGraph :: Record NodeActionsGraphProps -> R.Element
...@@ -239,7 +241,7 @@ type GraphUpdateButtonProps = ...@@ -239,7 +241,7 @@ type GraphUpdateButtonProps =
( (
id :: ID id :: ID
, session :: Session , session :: Session
, triggerRefresh :: Unit -> Effect Unit , triggerRefresh :: Unit -> Aff Unit
) )
graphUpdateButton :: Record GraphUpdateButtonProps -> R.Element graphUpdateButton :: Record GraphUpdateButtonProps -> R.Element
...@@ -262,7 +264,7 @@ graphUpdateButtonCpt = R.hooksComponent "G.C.F.T.N.B.graphUpdateButton" cpt ...@@ -262,7 +264,7 @@ graphUpdateButtonCpt = R.hooksComponent "G.C.F.T.N.B.graphUpdateButton" cpt
liftEffect $ setEnabled $ const false liftEffect $ setEnabled $ const false
g <- GEAPI.updateGraphVersions { graphId: id, session } g <- GEAPI.updateGraphVersions { graphId: id, session }
liftEffect $ setEnabled $ const true liftEffect $ setEnabled $ const true
liftEffect $ triggerRefresh unit triggerRefresh unit
pure unit pure unit
-- END nodeActions -- END nodeActions
......
...@@ -19,9 +19,13 @@ import Reactix as R ...@@ -19,9 +19,13 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
data BarType = Bar | Pie
type Props = type Props =
( (
asyncTask :: GT.AsyncTaskWithType asyncTask :: GT.AsyncTaskWithType
, barType :: BarType
, corpusId :: ID , corpusId :: ID
, onFinish :: Unit -> Effect Unit , onFinish :: Unit -> Effect Unit
, session :: Session , session :: Session
......
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