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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
4856c644
Verified
Commit
4856c644
authored
1 year ago
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ws] first implementation of websocket notifications
parent
4af8b5e7
Changes
6
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:
- uri: ">=9.0.0 <10.0.0"
- uuid: ">=9.0.0 <10.0.0"
- validation: ">=6.0.0 <7.0.0"
- var
- web-file: ">=4.0.0 <5.0.0"
- web-html: ">=4.1.0 <5.0.0"
- web-socket
- web-storage: ">=5.0.0 <6.0.0"
- web-url: ">=2.0.0 <3.0.0"
- web-xhr: ">=5.0.1 <6.0.0"
- websocket-simple
test_dependencies:
- spec
- spec-discovery
...
...
@@ -226,14 +229,17 @@ workspace:
- uri
- uuid
- validation
- var
- variant
- web-dom
- web-events
- web-file
- web-html
- web-socket
- web-storage
- web-url
- web-xhr
- websocket-simple
package_set:
address:
registry: 50.13.1
...
...
@@ -753,6 +759,11 @@ workspace:
tuples-native:
git: https://github.com/garganscript/purescript-tuples-native.git
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:
aff:
type: registry
...
...
@@ -2296,6 +2307,14 @@ packages:
- foldable-traversable
- newtype
- prelude
var:
type: local
path: /data/git-work/github/PURESCRIPT/purescript-var
dependencies:
- contravariant
- effect
- invariant
- prelude
variant:
type: registry
version: 8.0.0
...
...
@@ -2341,6 +2360,13 @@ packages:
- web-dom
- web-file
- web-storage
web-socket:
type: registry
version: 4.0.0
integrity: sha256-xz46Q/rdJPNdLhq8QsyfxBoc2CTRXzgbwAj8oqV//C4=
dependencies:
- arraybuffer-types
- web-file
web-storage:
type: registry
version: 5.0.0
...
...
@@ -2371,3 +2397,15 @@ packages:
- web-dom
- web-file
- 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
This diff is collapsed.
Click to expand it.
spago.yaml
View file @
4856c644
...
...
@@ -29,6 +29,13 @@ workspace:
tuples-native
:
git
:
https://github.com/garganscript/purescript-tuples-native.git
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
spec-discovery
:
...
...
@@ -121,9 +128,12 @@ package:
-
validation
:
"
>=6.0.0
<7.0.0"
-
web-file
:
"
>=4.0.0
<5.0.0"
-
web-html
:
"
>=4.1.0
<5.0.0"
-
web-socket
-
web-storage
:
"
>=5.0.0
<6.0.0"
-
web-url
:
"
>=2.0.0
<3.0.0"
-
web-xhr
:
"
>=5.0.1
<6.0.0"
-
websocket-simple
-
var
build
:
# Be strict about missing packages
...
...
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/App/App.purs
View file @
4856c644
...
...
@@ -2,9 +2,11 @@ module Gargantext.Components.App (app) where
import Gargantext.Prelude
import Data.Sequence as Seq
import Data.Tuple.Nested ((/\))
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
...
...
@@ -99,5 +101,15 @@ mainAppCpt = here.component "main" cpt where
R.useEffectOnce' $ do
R2.loadLocalStorageState 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
pure $ router { boxes } -- Render router component
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/App/Store.purs
View file @
4856c644
...
...
@@ -21,6 +21,7 @@ import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Lang as Lang
import Gargantext.Components.Nodes.Lists.SidePanel as ListsSP
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Themes as Themes
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(Home), Tile)
...
...
@@ -66,6 +67,7 @@ type Store =
, theme :: T.Box Themes.Theme
, tileAxisXList :: T.Box (Array (Record Tile))
, tileAxisYList :: T.Box (Array (Record Tile))
, wsNotification :: T.Box Notifications.WSNotification
)
type State =
...
...
@@ -95,6 +97,7 @@ type State =
, theme :: Themes.Theme
, tileAxisXList :: Array (Record Tile)
, tileAxisYList :: Array (Record Tile)
, wsNotification :: Notifications.WSNotification
)
options :: Record State
...
...
@@ -125,6 +128,7 @@ options =
, theme : Themes.defaultTheme
, tileAxisXList : mempty
, tileAxisYList : mempty
, wsNotification : Notifications.emptyWSNotification
}
context :: R.Context (Record Store)
...
...
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Forest/Tree.purs
View file @
4856c644
...
...
@@ -10,6 +10,7 @@ import Data.Traversable (intercalate, traverse, traverse_)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Timer (setTimeout)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
...
...
@@ -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.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
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.Utils (handleRESTError)
import Gargantext.Ends (Frontends)
...
...
@@ -109,7 +111,6 @@ type PerformActionProps =
-- | Loads and renders the tree starting at the given root node id.
treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
-- treeLoaderCpt :: R.Memo LoaderProps
...
...
@@ -281,6 +282,17 @@ childLoaderCpt = R2.hereComponent here "childLoader" hCpt where
, 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
pure $
...
...
This diff is collapsed.
Click to expand it.
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