Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
21383650
Commit
21383650
authored
Apr 23, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tasks, ngramstable] async tasks refresh, fix ngrams loader bug
parent
a51fcc34
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
17 deletions
+46
-17
AsyncTasks.purs
src/Gargantext/AsyncTasks.purs
+20
-4
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+2
-2
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+11
-0
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+9
-7
Loader.purs
src/Gargantext/Components/NgramsTable/Loader.purs
+3
-3
Loader.purs
src/Gargantext/Hooks/Loader.purs
+1
-1
No files found.
src/Gargantext/AsyncTasks.purs
View file @
21383650
...
...
@@ -10,14 +10,13 @@ import Data.Either (Either(..))
import Data.Map as Map
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Effect (Effect)
import Reactix as R
import Toestand as T
import Web.Storage.Storage as WSS
import Gargantext.Types as GT
import Gargantext.Utils as GU
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Toestand as T
import Web.Storage.Storage as WSS
localStorageKey :: String
localStorageKey = "garg-async-tasks"
...
...
@@ -73,3 +72,20 @@ remove :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
remove id task storage = T.modify_ newStorage storage
where
newStorage s = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts task)) id s
-- When a task is finished: which tasks cause forest or app reload
asyncTaskTriggersAppReload :: GT.AsyncTaskType -> Boolean
asyncTaskTriggersAppReload GT.UpdateNgramsCharts = true
asyncTaskTriggersAppReload _ = false
asyncTaskTTriggersAppReload :: GT.AsyncTaskWithType -> Boolean
asyncTaskTTriggersAppReload (GT.AsyncTaskWithType { typ }) = asyncTaskTriggersAppReload typ
asyncTaskTriggersTreeReload :: GT.AsyncTaskType -> Boolean
asyncTaskTriggersTreeReload GT.Form = true
asyncTaskTriggersTreeReload GT.UploadFile = true
asyncTaskTriggersTreeReload _ = false
asyncTaskTTriggersTreeReload :: GT.AsyncTaskWithType -> Boolean
asyncTaskTTriggersTreeReload (GT.AsyncTaskWithType { typ }) = asyncTaskTriggersTreeReload typ
src/Gargantext/Components/Forest/Tree.purs
View file @
21383650
...
...
@@ -99,7 +99,7 @@ tree props = R.createElement treeCpt props []
treeCpt :: R.Component TreeProps
treeCpt = here.component "tree" cpt where
cpt p@{ session, tree: NTree (LNode { id, name, nodeType }) children } _ = do
cpt p@{
reload,
session, tree: NTree (LNode { id, name, nodeType }) children } _ = do
setPopoverRef <- R.useRef Nothing
folderOpen <- T2.useMemberBox nodeId p.forestOpen
folderOpen' <- T.useLive T.unequal folderOpen
...
...
@@ -123,7 +123,7 @@ treeCpt = here.component "tree" cpt where
nodeProps = RecordE.pick p :: Record NodeProps
nsprops extra = Record.merge common extra' where
common = RecordE.pick p :: Record NSCommon
extra' = Record.merge extra { dispatch } where
extra' = Record.merge extra { dispatch
, reload
} where
dispatch a = performAction a (Record.merge common' spr) where
common' = RecordE.pick p :: Record PACommon
spr = { setPopoverRef: extra.setPopoverRef }
...
...
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
21383650
...
...
@@ -51,6 +51,7 @@ type NodeMainSpanProps =
, isLeaf :: IsLeaf
, name :: Name
, nodeType :: GT.NodeType
, reload :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload
, route :: T.Box Routes.AppRoute
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
...
...
@@ -83,6 +84,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
, isLeaf
, name
, nodeType
, reload
, reloadRoot
, route
, session
...
...
@@ -146,6 +148,15 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
where
onTaskFinish id' t _ = do
GAT.finish id' t tasks
if GAT.asyncTaskTTriggersAppReload t then do
here.log2 "reloading root for task" t
T2.reload reloadRoot
else if GAT.asyncTaskTTriggersTreeReload t then do
here.log2 "reloading tree for task" t
T2.reload reload
else do
here.log2 "task doesn't trigger a reload" t
pure unit
-- snd tasks $ GAT.Finish id' t
-- mT <- T.read tasks
-- case mT of
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
21383650
...
...
@@ -1110,7 +1110,7 @@ coreDispatch path state (Synchronize { afterSync }) =
coreDispatch _ state (CommitPatch pt) =
commitPatch pt state
coreDispatch _ state ResetPatches =
T.modify_ (
\s -> s
{ ngramsLocalPatch = { ngramsPatches: mempty } }) state
T.modify_ (
_
{ ngramsLocalPatch = { ngramsPatches: mempty } }) state
isSingleNgramsTerm :: NgramsTerm -> Boolean
isSingleNgramsTerm nt = isSingleTerm $ ngramsTermText nt
...
...
@@ -1141,32 +1141,34 @@ syncResetButtonsCpt :: R.Component SyncResetButtonsProps
syncResetButtonsCpt = here.component "syncResetButtons" cpt
where
cpt { afterSync, ngramsLocalPatch, performAction } _ = do
--
synchronizing <- T.useBox false
--
synchronizing' <- T.useLive T.unequal synchronizing
synchronizing <- T.useBox false
synchronizing' <- T.useLive T.unequal synchronizing
let
hasChanges = ngramsLocalPatch /= mempty
hasChangesClass = if hasChanges then "" else " disabled"
synchronizingClass = if synchronizing' then " disabled" else ""
resetClick _ = do
performAction ResetPatches
synchronizeClick _ = delay unit $ \_ -> do
--
T.write_ true synchronizing
T.write_ true synchronizing
performAction $ Synchronize { afterSync: newAfterSync }
newAfterSync x = do
afterSync x
--
liftEffect $ T.write_ false synchronizing
liftEffect $ T.write_ false synchronizing
pure $ H.div { className: "btn-toolbar" }
[ H.div { className: "btn-group mr-2" }
[ H.button { className: "btn btn-danger " <> hasChangesClass
[ H.button { className: "btn btn-danger " <> hasChangesClass
<> synchronizingClass
, on: { click: resetClick }
} [ H.text "Reset" ]
]
, H.div { className: "btn-group mr-2" }
[ H.button { className: "btn btn-primary " <> hasChangesClass
[ H.button { className: "btn btn-primary " <> hasChangesClass
<> synchronizingClass
, on: { click: synchronizeClick }
} [ H.text "Sync" ]
]
...
...
src/Gargantext/Components/NgramsTable/Loader.purs
View file @
21383650
...
...
@@ -88,10 +88,10 @@ useCachedAPILoaderEffect { cacheEndpoint
-- log2 "[useCachedAPILoaderEffect] cached version" version
-- log2 "[useCachedAPILoaderEffect] real version" cacheReal
_ <- GUC.deleteReq cache req
vr'@(Versioned { version:
_
, data: _ }) <- GUC.cachedJson cache req
if version == cacheReal then
vr'@(Versioned { version:
version'
, data: _ }) <- GUC.cachedJson cache req
if version
'
== cacheReal then
pure vr'
else
throwError $ error $ "Fetched clean cache but hashes don't match: " <> show version <> " != " <> show cacheReal
throwError $ error $ "
[NgramsTable.Loader]
Fetched clean cache but hashes don't match: " <> show version <> " != " <> show cacheReal
liftEffect $ do
T.write_ (Just $ handleResponse val) state
src/Gargantext/Hooks/Loader.purs
View file @
21383650
...
...
@@ -157,6 +157,6 @@ useCachedAPILoaderEffect { cacheEndpoint
if h == cacheReal then
pure hr'
else
throwError $ error $ "Fetched clean cache but hashes don't match: " <> h <> " != " <> cacheReal
throwError $ error $ "
[Hooks.Loader]
Fetched clean cache but hashes don't match: " <> h <> " != " <> cacheReal
liftEffect $ do
T.write_ (Just $ handleResponse val) state
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment