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
7366fd67
Verified
Commit
7366fd67
authored
Aug 01, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-websockets
parents
b27e06f5
409ace3a
Pipeline
#6495
passed with stages
in 20 minutes and 42 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
20 deletions
+109
-20
package.json
package.json
+1
-1
App.purs
src/Gargantext/Components/App/App.purs
+11
-0
DocList.purs
src/Gargantext/Components/GraphExplorer/Sidebar/DocList.purs
+28
-7
DocList.purs
src/Gargantext/Components/PhyloExplorer/Sidebar/DocList.purs
+28
-6
Router.purs
src/Gargantext/Components/Router.purs
+13
-6
Trace.js
src/Gargantext/Utils/Trace.js
+11
-0
Trace.purs
src/Gargantext/Utils/Trace.purs
+17
-0
No files found.
package.json
View file @
7366fd67
{
"name"
:
"Gargantext"
,
"version"
:
"0.0.7.1.1
4
"
,
"version"
:
"0.0.7.1.1
6
"
,
"scripts"
:
{
"build"
:
"spago build"
,
"bundle"
:
"spago bundle --module Main --outfile dist/bundle.min.js --minify --source-maps"
,
...
...
src/Gargantext/Components/App/App.purs
View file @
7366fd67
...
...
@@ -9,6 +9,7 @@ import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Notifications.Types as NotificationsT
import Gargantext.Components.Router (router)
import Gargantext.Config as Config
import Gargantext.Hooks (useHashRouter)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Router as Router
...
...
@@ -100,6 +101,8 @@ mainAppCpt = here.component "main" cpt where
R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen
-- | Websockets
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
...
...
@@ -112,5 +115,13 @@ mainAppCpt = here.component "main" cpt where
-- NOTE: Dummy subscription
-- let action = NotificationsT.InsertCallback (NotificationsT.UpdateTree (-1)) "some-uuid" (\_ -> here.log "callback!")
-- Notifications.performAction ws action
-- Store in the box the current backend, as
-- derived from the href, before the window gets
-- injected with the router.
R.useEffectOnce' $ do
mLoc <- Config.matchCurrentLocation
T.write_ mLoc boxes.backend
useHashRouter Router.router boxes.route -- Install router to window
pure $ router { boxes } -- Render router component
src/Gargantext/Components/GraphExplorer/Sidebar/DocList.purs
View file @
7366fd67
...
...
@@ -4,7 +4,7 @@ module Gargantext.Components.GraphExplorer.Sidebar.DocList
import Gargantext.Prelude
import Data.Array (catMaybes, head)
import Data.Array (catMaybes,
foldl,
head)
import Data.Array as A
import Data.Foldable (intercalate)
import Data.Map as Map
...
...
@@ -22,6 +22,7 @@ import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Config (defaultFrontends)
import Gargantext.Config.REST (RESTError(..))
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.Types as SigmaxT
...
...
@@ -172,6 +173,8 @@ docListCpt = here.component "main" cpt where
, path: path'
, state
}
{ goToURL } <- useLinkHandler
-- | Effects
-- |
...
...
@@ -234,6 +237,16 @@ docListCpt = here.component "main" cpt where
_
= false
webSearch :: Array String -> (String -> Effect Unit) -> Effect Unit
webSearch q f = do
let url = foldl (\acc elem -> acc <> (elem <> "+")) "https://duckduckgo.com/?q=" q
f url
wikipediaSearch :: Array String -> (String -> Effect Unit) -> Effect Unit
wikipediaSearch q f = do
let url = foldl (\acc elem -> acc <> (elem <> "+")) "https://en.wikipedia.org/w/index.php?search=" q
f url
-- | Render
-- |
pure $
...
...
@@ -243,11 +256,19 @@ docListCpt = here.component "main" cpt where
R.fragment
[
R2.when (results == Seq.empty) $
B.caveat
{}
H.div {}
[
H.text "Searching relevant document(s)"
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text "No related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ -> webSearch (A.fromFoldable selectedNgramsTerms') goToURL } ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ -> wikipediaSearch (A.fromFoldable selectedNgramsTerms') goToURL } ]
]
, B.caveat
{}
[
H.text "No document found in your corpus for your selected terms"
]
]
,
R2.when (not $ eq results Seq.empty) $
...
...
@@ -257,8 +278,8 @@ docListCpt = here.component "main" cpt where
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text $ show (Seq.length results) <> " related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ ->
pure unit
} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ ->
pure unit
} ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ ->
webSearch (A.fromFoldable selectedNgramsTerms') goToURL
} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ ->
wikipediaSearch (A.fromFoldable selectedNgramsTerms') goToURL
} ]
]
, H.ul
{ className: intercalate " "
...
...
src/Gargantext/Components/PhyloExplorer/Sidebar/DocList.purs
View file @
7366fd67
...
...
@@ -4,6 +4,7 @@ module Gargantext.Components.PhyloExplorer.Sidebar.DocList
import Gargantext.Prelude
import Data.Array (foldl)
import Data.Array as A
import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..))
...
...
@@ -19,6 +20,7 @@ import Gargantext.Components.Search (SearchQuery(..), SearchType(..))
import Gargantext.Config (defaultFrontends)
import Gargantext.Config.REST (RESTError(..))
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1')
...
...
@@ -162,6 +164,8 @@ docListCpt = here.component "main" cpt where
, path: path'
}
{ goToURL } <- useLinkHandler
-- | Effects
-- |
...
...
@@ -220,6 +224,16 @@ docListCpt = here.component "main" cpt where
_
= false
webSearch :: Array String -> (String -> Effect Unit) -> Effect Unit
webSearch q f = do
let url = foldl (\acc elem -> acc <> (elem <> "+")) "https://duckduckgo.com/?q=" q
f url
wikipediaSearch :: Array String -> (String -> Effect Unit) -> Effect Unit
wikipediaSearch q f = do
let url = foldl (\acc elem -> acc <> (elem <> "+")) "https://en.wikipedia.org/w/index.php?search=" q
f url
-- | Render
-- |
pure $
...
...
@@ -229,11 +243,19 @@ docListCpt = here.component "main" cpt where
R.fragment
[
R2.when (results == Seq.empty) $
B.caveat
{}
H.div {}
[
H.text "No document found in your corpus for your selected terms"
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text "No related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ -> webSearch q' goToURL} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ -> wikipediaSearch q' goToURL} ]
]
, B.caveat
{}
[
H.text "No document found in your corpus for your selected terms"
]
]
,
R2.when (not $ eq results Seq.empty) $
...
...
@@ -242,8 +264,8 @@ docListCpt = here.component "main" cpt where
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text $ show (Seq.length results) <> " related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ ->
pure unit
} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ ->
pure unit
} ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ ->
webSearch q' goToURL
} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ ->
wikipediaSearch q' goToURL
} ]
]
,
H.ul
...
...
src/Gargantext/Components/Router.purs
View file @
7366fd67
...
...
@@ -12,6 +12,7 @@ import Data.Array as A
import Data.Foldable (intercalate)
import Data.Map as M
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.String (contains, Pattern(..))
import Data.Tuple (Tuple(..))
import Data.UUID (UUID)
import Data.UUID as UUID
...
...
@@ -39,15 +40,15 @@ import Gargantext.Components.Nodes.Texts as Texts
import Gargantext.Components.Tile (tileBlock)
import Gargantext.Components.TopBar as TopBar
import Gargantext.Components.TreeSearch (treeSearch)
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config (defaultFrontends, defaultBackends
, matchCurrentLocation
)
import Gargantext.Context.Session as SessionContext
import Gargantext.Ends (Backend)
import Gargantext.Ends (Backend
(..)
)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Resize (ResizeType(..), useResizeHandler)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (AppRoute(..), Tile)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, sessionId, unSessions)
import Gargantext.Sessions (Session, sessionId, unSessions
, sessionUrl
)
import Gargantext.Sessions as Sessions
import Gargantext.Types (CorpusId, Handed(..), ListId, NodeID, NodeType(..), SessionId, SidePanelState(..), ID)
import Gargantext.Utils ((?))
...
...
@@ -779,19 +780,25 @@ type ShareProps = (nodeType :: String, nodeId :: ID | Props)
share :: R2.Component ShareProps
share = R.createElement shareCpt
-- | Ensures that we rewrite the Share URL into something that points
-- to the correct user in the correct session, see Gargantext#357.
findSuitableSession :: Maybe Backend -> Session -> Boolean
findSuitableSession Nothing _ = false
findSuitableSession (Just (Backend be)) s = (Pattern $ be.baseUrl) `contains` sessionUrl s ""
shareCpt :: R.Component ShareProps
shareCpt = here.component "share" cpt where
cpt { nodeType, nodeId, boxes} _ = do
{ goToRoute } <- useLinkHandler
sessions' <- T.useLive T.unequal boxes.sessions
backend <- T.useLive T.unequal boxes.backend
case unSessions sessions' of
[] -> do
[] -> do
R.useEffect' $ T.write_ true boxes.showLogin
R.useEffect' $ T.write_ (Just (Tuple nodeType nodeId)) boxes.loginRedirect
R.useEffect' $ goToRoute Login
pure $ H.text "no session"
s -> case
head
s of
s -> case
A.findIndex (findSuitableSession backend) s >>= A.index
s of
Just s' -> do
R.useEffect' $ goToRoute $ fromMaybe Login $ GR.nodeTypeAppRoute (fromMaybe Node $ read nodeType) (sessionId s') nodeId
pure $ H.text $ "session route: " <> (show $ fromMaybe Login $ GR.nodeTypeAppRoute (fromMaybe Node $ read nodeType) (sessionId s') nodeId)
...
...
src/Gargantext/Utils/Trace.js
0 → 100644
View file @
7366fd67
"use strict"
;
export
function
_traceAnythingId
(
a
)
{
console
.
log
(
a
);
return
a
;
}
export
function
_traceAnything
(
a
,
b
)
{
console
.
log
(
a
);
return
b
;
}
src/Gargantext/Utils/Trace.purs
0 → 100644
View file @
7366fd67
module Gargantext.Utils.Trace (
traceAnythingId
, traceAnything
) where
import Gargantext.Prelude
import Data.Function.Uncurried (Fn1, runFn1, Fn2, runFn2)
foreign import _traceAnythingId :: forall a. Fn1 a a
foreign import _traceAnything :: forall a b. Fn2 a b b
traceAnythingId :: forall a. a -> a
traceAnythingId a = runFn1 _traceAnythingId a
traceAnything :: forall a b. a -> b -> b
traceAnything a b = runFn2 _traceAnything a b
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