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
d8717503
Commit
d8717503
authored
Sep 14, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/594-dev-ngrams-patch-fixes' into dev
parents
f824c0e3
058fa2fe
Pipeline
#4608
failed with stage
in 0 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
22 deletions
+35
-22
Types.purs
src/Gargantext/Components/Document/Types.purs
+0
-1
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+10
-4
SyncResetButton.purs
src/Gargantext/Components/NgramsTable/SyncResetButton.purs
+3
-2
Tree.purs
src/Gargantext/Components/NgramsTable/Tree.purs
+0
-1
Functions.purs
src/Gargantext/Core/NgramsTable/Functions.purs
+4
-7
Types.purs
src/Gargantext/Core/NgramsTable/Types.purs
+0
-2
Crypto.js
src/Gargantext/Utils/Crypto.js
+2
-2
Crypto.purs
src/Gargantext/Utils/Crypto.purs
+3
-2
crypto.js
src/external-deps/crypto.js
+12
-0
Spec.purs
test/Test/Gargantext/Utils/Spec.purs
+1
-1
No files found.
src/Gargantext/Components/Document/Types.purs
View file @
d8717503
...
...
@@ -35,7 +35,6 @@ initialState
initialState {loaded: {ngramsTable: Versioned {version}}} =
{ ngramsLocalPatch: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsSelection : mempty
, ngramsVersion: version
}
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
d8717503
...
...
@@ -93,7 +93,6 @@ initialState =
{ ngramsLocalPatch: mempty
, ngramsSelection: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: 0
}
...
...
@@ -824,6 +823,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
-- onNgramsClickRef <- R.useRef Nothing
-- onSaveRef <- R.useRef Nothing
state <- T.useBox initialState
-- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/594
-- Refreshing view when state.ngramsVersion changes.
ngramsVersion <- T.useFocused (_.ngramsVersion) (\a b -> b { ngramsVersion = a}) state
ngramsVersion' <- T.useLive T.unequal ngramsVersion
-- ngramsLocalPatch <- T.useFocused (_.ngramsLocalPatch) (\a b -> b { ngramsLocalPatch = a }) state
-- nodeId <- T.useFocused (_.nodeId) (\a b -> b { nodeId = a }) path
...
...
@@ -841,11 +846,11 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
case cacheState' of
NT.CacheOn -> pure $ R.fragment
[ loadedNgramsTableHeader { searchQuery, params }
, mainNgramsTableCacheOn (Record.merge props { state })
, mainNgramsTableCacheOn (Record.merge props {
key: show ngramsVersion',
state })
]
NT.CacheOff -> pure $ R.fragment
[
loadedNgramsTableHeader { searchQuery, params
}
, mainNgramsTableCacheOff (Record.merge props { state })
[
loadedNgramsTableHeader { searchQuery, params
}
, mainNgramsTableCacheOff (Record.merge props {
key: show ngramsVersion',
state })
]
...
...
@@ -1015,6 +1020,7 @@ ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where
type MainNgramsTableCacheProps =
( state :: T.Box State
, key :: String
| MainNgramsTableProps )
mainNgramsTableCacheOn :: R2.Leaf MainNgramsTableCacheProps
...
...
src/Gargantext/Components/NgramsTable/SyncResetButton.purs
View file @
d8717503
...
...
@@ -50,11 +50,12 @@ syncResetButtonsCpt = here.component "syncResetButtons" cpt
synchronizeClick _ = delay unit $ \_ -> do
T.write_ true synchronizing
performAction $ Synchronize { afterSync: newAfterSync }
performAction ResetPatches
newAfterSync x = do
afterSync x
liftEffect $ T.write_ false synchronizing
liftEffect $ do
T.write_ false synchronizing
performAction ResetPatches
pure $
...
...
src/Gargantext/Components/NgramsTable/Tree.purs
View file @
d8717503
...
...
@@ -340,7 +340,6 @@ renderNgramsItemCpt = here.component "renderNgramsItem" cpt
tbl :: NgramsTable
tbl = applyNgramsPatches { ngramsLocalPatch
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: 0 } ngramsTable
getNgramsChildren' :: NgramsTerm -> Array NgramsTerm
getNgramsChildren' n = A.fromFoldable $ ngramsChildren n
...
...
src/Gargantext/Core/NgramsTable/Functions.purs
View file @
d8717503
...
...
@@ -362,8 +362,8 @@ applyNgramsTablePatch (NgramsTablePatch ngramsPatches) (NgramsTable m) =
applyPatchMap applyNgramsPatch ngramsPatches m.ngrams_repo_elements }
applyNgramsPatches :: forall s. CoreState s -> NgramsTable -> NgramsTable
applyNgramsPatches {
ngramsLocalPatch, ngramsStagePatch, ngramsValidPatch
} =
applyNgramsTablePatch (
ngramsLocalPatch <> ngramsStagePatch <> ngramsValidPatch
)
applyNgramsPatches {
ngramsLocalPatch, ngramsStagePatch
} =
applyNgramsTablePatch (
ngramsLocalPatch <> ngramsStagePatch
)
-- First the valid patch, then the stage patch, and finally the local patch.
{-
...
...
@@ -436,8 +436,7 @@ syncPatches props state callback = do
s {
ngramsLocalPatch = fromNgramsPatches mempty
, ngramsStagePatch = fromNgramsPatches mempty
, ngramsValidPatch = fromNgramsPatches newPatch <> ngramsLocalPatch <> s.ngramsValidPatch
-- First the already valid patch, then the local patch, then the newly received newPatch.
-- First the local patch, then the newly received newPatch.
, ngramsVersion = newVersion
}) state
here.log2 "[syncPatches] ngramsVersion" newVersion
...
...
@@ -448,7 +447,6 @@ syncPatchesAsync :: forall p s. CoreParams p -> R.State (CoreState s) -> (Unit -
syncPatchesAsync props@{ listIds, tabType }
({ ngramsLocalPatch: ngramsLocalPatch@{ ngramsPatches }
, ngramsStagePatch
, ngramsValidPatch
, ngramsVersion
} /\ setState) callback = do
when (isEmptyNgramsTablePatch ngramsStagePatch) $ do
...
...
@@ -462,8 +460,7 @@ syncPatchesAsync props@{ listIds, tabType }
s {
ngramsLocalPatch = fromNgramsPatches mempty
, ngramsStagePatch = fromNgramsPatches mempty
, ngramsValidPatch = fromNgramsPatches newPatch <> ngramsLocalPatch <> s.ngramsValidPatch
-- First the already valid patch, then the local patch, then the newly received newPatch.
-- First the local patch, then the newly received newPatch.
, ngramsVersion = newVersion
}
here.log2 "[syncPatches] ngramsVersion" newVersion
...
...
src/Gargantext/Core/NgramsTable/Types.purs
View file @
d8717503
...
...
@@ -507,8 +507,6 @@ type CoreState s =
, ngramsStagePatch :: NgramsTablePatch
-- ^ These patches are staged (scheduled for synchronization).
-- Requests are being performed at the moment.
, ngramsValidPatch :: NgramsTablePatch
-- ^ These patches have been synchronized with the server.
, ngramsVersion :: Version
| s
}
...
...
src/Gargantext/Utils/Crypto.js
View file @
d8717503
//import crypto from 'crypto
';
import
{
subtle
}
from
'../../src/external-deps/crypto.js
'
;
async
function
getSHA256Hash
(
input
)
{
const
textAsBuffer
=
new
TextEncoder
().
encode
(
input
);
const
hashBuffer
=
await
globalThis
.
crypto
.
subtle
.
digest
(
"SHA-256"
,
textAsBuffer
);
const
hashBuffer
=
await
subtle
.
digest
(
"SHA-256"
,
textAsBuffer
);
const
hashArray
=
Array
.
from
(
new
Uint8Array
(
hashBuffer
));
const
hash
=
hashArray
.
map
((
item
)
=>
item
.
toString
(
16
).
padStart
(
2
,
"0"
))
...
...
src/Gargantext/Utils/Crypto.purs
View file @
d8717503
module Gargantext.Utils.Crypto where
import Control.Promise (Promise, toAffE)
import Data.Array as Array
import Data.Set (Set)
import Data.Set as Set
import Data.
Array as Array
import Data.
String (joinWith)
import Effect (Effect)
import Effect.Aff (Aff)
...
...
@@ -39,7 +40,7 @@ instance IsHashable (Array String) where
hash = hash <<< concat
where
concat :: Array Hash -> String
concat =
Array.foldl (<>) ""
concat =
joinWith "" <<< Array.sort
instance IsHashable (Set String) where
...
...
src/external-deps/crypto.js
0 → 100644
View file @
d8717503
// https://siteultra.com/blog/using-subtle-in-a-javascript-module-from-both-the-browser-and-nodejs
let
subtle
=
undefined
;
if
(
typeof
window
!==
'undefined'
&&
window
.
crypto
&&
window
.
crypto
.
subtle
)
{
subtle
=
window
.
crypto
.
subtle
;
}
else
{
// Import 'crypto' module in Node.js environment
subtle
=
require
(
'crypto'
).
subtle
;
}
exports
.
subtle
=
subtle
;
test/Test/Gargantext/Utils/Spec.purs
View file @
d8717503
...
...
@@ -124,7 +124,7 @@ spec =
it "Hash List with backend works" do
let list = ["a","b"]
let hashed = "
ab19ec537f09499b26f0f62eed7aefad46ab9f498e06a7328ce8e8ef90da6d86
"
let hashed = "
fb8e20fc2e4c3f248c60c39bd652f3c1347298bb977b8b4d5903b85055620603
"
-- ^ hash from backend with text above
h <- Crypto.hash list
h`shouldEqual` hashed
...
...
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