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
131
Issues
131
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
4856c644
Verified
Commit
4856c644
authored
May 27, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ws] first implementation of websocket notifications
parent
4af8b5e7
Pipeline
#6143
failed with stages
in 11 minutes and 29 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
342 additions
and
1 deletion
+342
-1
spago.lock
spago.lock
+38
-0
spago.yaml
spago.yaml
+10
-0
App.purs
src/Gargantext/Components/App/App.purs
+12
-0
Store.purs
src/Gargantext/Components/App/Store.purs
+4
-0
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+13
-1
Notifications.purs
src/Gargantext/Components/Notifications.purs
+265
-0
No files found.
spago.lock
View file @
4856c644
...
@@ -83,11 +83,14 @@ workspace:
...
@@ -83,11 +83,14 @@ workspace:
- uri: ">=9.0.0 <10.0.0"
- uri: ">=9.0.0 <10.0.0"
- uuid: ">=9.0.0 <10.0.0"
- uuid: ">=9.0.0 <10.0.0"
- validation: ">=6.0.0 <7.0.0"
- validation: ">=6.0.0 <7.0.0"
- var
- web-file: ">=4.0.0 <5.0.0"
- web-file: ">=4.0.0 <5.0.0"
- web-html: ">=4.1.0 <5.0.0"
- web-html: ">=4.1.0 <5.0.0"
- web-socket
- web-storage: ">=5.0.0 <6.0.0"
- web-storage: ">=5.0.0 <6.0.0"
- web-url: ">=2.0.0 <3.0.0"
- web-url: ">=2.0.0 <3.0.0"
- web-xhr: ">=5.0.1 <6.0.0"
- web-xhr: ">=5.0.1 <6.0.0"
- websocket-simple
test_dependencies:
test_dependencies:
- spec
- spec
- spec-discovery
- spec-discovery
...
@@ -226,14 +229,17 @@ workspace:
...
@@ -226,14 +229,17 @@ workspace:
- uri
- uri
- uuid
- uuid
- validation
- validation
- var
- variant
- variant
- web-dom
- web-dom
- web-events
- web-events
- web-file
- web-file
- web-html
- web-html
- web-socket
- web-storage
- web-storage
- web-url
- web-url
- web-xhr
- web-xhr
- websocket-simple
package_set:
package_set:
address:
address:
registry: 50.13.1
registry: 50.13.1
...
@@ -753,6 +759,11 @@ workspace:
...
@@ -753,6 +759,11 @@ workspace:
tuples-native:
tuples-native:
git: https://github.com/garganscript/purescript-tuples-native.git
git: https://github.com/garganscript/purescript-tuples-native.git
ref: v2.3.0-spago-next
ref: v2.3.0-spago-next
var:
path: /data/git-work/github/PURESCRIPT/purescript-var
websocket-simple:
git: https://github.com/garganscript/purescript-websocket-simple
ref: v3.0.2-spago-next
packages:
packages:
aff:
aff:
type: registry
type: registry
...
@@ -2296,6 +2307,14 @@ packages:
...
@@ -2296,6 +2307,14 @@ packages:
- foldable-traversable
- foldable-traversable
- newtype
- newtype
- prelude
- prelude
var:
type: local
path: /data/git-work/github/PURESCRIPT/purescript-var
dependencies:
- contravariant
- effect
- invariant
- prelude
variant:
variant:
type: registry
type: registry
version: 8.0.0
version: 8.0.0
...
@@ -2341,6 +2360,13 @@ packages:
...
@@ -2341,6 +2360,13 @@ packages:
- web-dom
- web-dom
- web-file
- web-file
- web-storage
- web-storage
web-socket:
type: registry
version: 4.0.0
integrity: sha256-xz46Q/rdJPNdLhq8QsyfxBoc2CTRXzgbwAj8oqV//C4=
dependencies:
- arraybuffer-types
- web-file
web-storage:
web-storage:
type: registry
type: registry
version: 5.0.0
version: 5.0.0
...
@@ -2371,3 +2397,15 @@ packages:
...
@@ -2371,3 +2397,15 @@ packages:
- web-dom
- web-dom
- web-file
- web-file
- web-html
- web-html
websocket-simple:
type: git
url: https://github.com/garganscript/purescript-websocket-simple
rev: e852afaa13ba406155e5097d56b5d2772f68496b
dependencies:
- effect
- nullable
- partial
- prelude
- unsafe-coerce
- var
- web-socket
spago.yaml
View file @
4856c644
...
@@ -29,6 +29,13 @@ workspace:
...
@@ -29,6 +29,13 @@ workspace:
tuples-native
:
tuples-native
:
git
:
https://github.com/garganscript/purescript-tuples-native.git
git
:
https://github.com/garganscript/purescript-tuples-native.git
ref
:
v2.3.0-spago-next
ref
:
v2.3.0-spago-next
var
:
git
:
https://github.com/zudov/purescript-var
ref
:
v3.0.1-spago-next
path
:
/data/git-work/github/PURESCRIPT/purescript-var
websocket-simple
:
git
:
https://github.com/garganscript/purescript-websocket-simple
ref
:
v3.0.2-spago-next
# for tests
# for tests
spec-discovery
:
spec-discovery
:
...
@@ -121,9 +128,12 @@ package:
...
@@ -121,9 +128,12 @@ package:
-
validation
:
"
>=6.0.0
<7.0.0"
-
validation
:
"
>=6.0.0
<7.0.0"
-
web-file
:
"
>=4.0.0
<5.0.0"
-
web-file
:
"
>=4.0.0
<5.0.0"
-
web-html
:
"
>=4.1.0
<5.0.0"
-
web-html
:
"
>=4.1.0
<5.0.0"
-
web-socket
-
web-storage
:
"
>=5.0.0
<6.0.0"
-
web-storage
:
"
>=5.0.0
<6.0.0"
-
web-url
:
"
>=2.0.0
<3.0.0"
-
web-url
:
"
>=2.0.0
<3.0.0"
-
web-xhr
:
"
>=5.0.1
<6.0.0"
-
web-xhr
:
"
>=5.0.1
<6.0.0"
-
websocket-simple
-
var
build
:
build
:
# Be strict about missing packages
# Be strict about missing packages
...
...
src/Gargantext/Components/App/App.purs
View file @
4856c644
...
@@ -2,9 +2,11 @@ module Gargantext.Components.App (app) where
...
@@ -2,9 +2,11 @@ module Gargantext.Components.App (app) where
import Gargantext.Prelude
import Gargantext.Prelude
import Data.Sequence as Seq
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Router (router)
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.FirstEffect (useFirstEffect')
...
@@ -99,5 +101,15 @@ mainAppCpt = here.component "main" cpt where
...
@@ -99,5 +101,15 @@ mainAppCpt = here.component "main" cpt where
R.useEffectOnce' $ do
R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen
R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen
R.useEffectOnce' $ do
ws' <- T.read boxes.wsNotification
-- TODO See G.C.Forest: we need a WS connection for every backend we're connected to
(Sessions.Sessions { sessions }) <- T.read boxes.sessions
let session = Seq.head sessions
-- here.log2 "[mainApp] sessions" sessions'
ws <- Notifications.connect ws' "ws://localhost:8008/ws" session
T.write_ ws boxes.wsNotification
let action = Notifications.InsertCallback (Notifications.UpdateTree (-1)) "some-uuid" (\_ -> here.log "callback!")
Notifications.performAction ws action
useHashRouter Router.router boxes.route -- Install router to window
useHashRouter Router.router boxes.route -- Install router to window
pure $ router { boxes } -- Render router component
pure $ router { boxes } -- Render router component
src/Gargantext/Components/App/Store.purs
View file @
4856c644
...
@@ -21,6 +21,7 @@ import Gargantext.AsyncTasks as GAT
...
@@ -21,6 +21,7 @@ import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Lang as Lang
import Gargantext.Components.Lang as Lang
import Gargantext.Components.Nodes.Lists.SidePanel as ListsSP
import Gargantext.Components.Nodes.Lists.SidePanel as ListsSP
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Themes as Themes
import Gargantext.Components.Themes as Themes
import Gargantext.Ends (Backend)
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(Home), Tile)
import Gargantext.Routes (AppRoute(Home), Tile)
...
@@ -66,6 +67,7 @@ type Store =
...
@@ -66,6 +67,7 @@ type Store =
, theme :: T.Box Themes.Theme
, theme :: T.Box Themes.Theme
, tileAxisXList :: T.Box (Array (Record Tile))
, tileAxisXList :: T.Box (Array (Record Tile))
, tileAxisYList :: T.Box (Array (Record Tile))
, tileAxisYList :: T.Box (Array (Record Tile))
, wsNotification :: T.Box Notifications.WSNotification
)
)
type State =
type State =
...
@@ -95,6 +97,7 @@ type State =
...
@@ -95,6 +97,7 @@ type State =
, theme :: Themes.Theme
, theme :: Themes.Theme
, tileAxisXList :: Array (Record Tile)
, tileAxisXList :: Array (Record Tile)
, tileAxisYList :: Array (Record Tile)
, tileAxisYList :: Array (Record Tile)
, wsNotification :: Notifications.WSNotification
)
)
options :: Record State
options :: Record State
...
@@ -125,6 +128,7 @@ options =
...
@@ -125,6 +128,7 @@ options =
, theme : Themes.defaultTheme
, theme : Themes.defaultTheme
, tileAxisXList : mempty
, tileAxisXList : mempty
, tileAxisYList : mempty
, tileAxisYList : mempty
, wsNotification : Notifications.emptyWSNotification
}
}
context :: R.Context (Record Store)
context :: R.Context (Record Store)
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
4856c644
...
@@ -10,6 +10,7 @@ import Data.Traversable (intercalate, traverse, traverse_)
...
@@ -10,6 +10,7 @@ import Data.Traversable (intercalate, traverse, traverse_)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Timer (setTimeout)
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as Store
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap as B
...
@@ -28,6 +29,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile, uploadA
...
@@ -28,6 +29,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile, uploadA
import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (documentsFromWriteNodesReq)
import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (documentsFromWriteNodesReq)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Components.Notifications as Notifications
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
...
@@ -109,7 +111,6 @@ type PerformActionProps =
...
@@ -109,7 +111,6 @@ type PerformActionProps =
-- | Loads and renders the tree starting at the given root node id.
-- | Loads and renders the tree starting at the given root node id.
treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R2.leaf treeLoaderCpt
treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
-- treeLoaderCpt :: R.Memo LoaderProps
-- treeLoaderCpt :: R.Memo LoaderProps
...
@@ -281,6 +282,17 @@ childLoaderCpt = R2.hereComponent here "childLoader" hCpt where
...
@@ -281,6 +282,17 @@ childLoaderCpt = R2.hereComponent here "childLoader" hCpt where
, state: stateBox
, state: stateBox
}
}
boxes <- Store.use
R.useEffectOnce' $ do
let cb _ = do
here.log2 "callback!" p.id
-- The modal window has some problems closing when we refresh too early. This is a HACK
void $ setTimeout 400 $ T2.reload reload
let action = Notifications.InsertCallback (Notifications.UpdateTree p.id) ("tree-" <> show p.id) cb
here.log2 "[childLoader] action" action
ws <- T.read boxes.wsNotification
Notifications.performAction ws action
-- Render
-- Render
pure $
pure $
...
...
src/Gargantext/Components/Notifications.purs
0 → 100644
View file @
4856c644
This diff is collapsed.
Click to expand it.
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