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
ed4f4b47
Commit
ed4f4b47
authored
May 27, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-node-async
parents
ec7165a2
eb6aacde
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
11 deletions
+72
-11
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+33
-7
SearchBar.purs
src/Gargantext/Components/Search/SearchBar.purs
+5
-0
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+7
-2
Reactix.js
src/Gargantext/Utils/Reactix.js
+5
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+22
-2
No files found.
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
ed4f4b47
...
...
@@ -7,6 +7,8 @@ import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Tuple (fst, Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable, null)
import DOM.Simple as DOM
import Effect (Effect)
import Effect.Aff (Aff, launchAff, launchAff_)
import Effect.Class (liftEffect)
...
...
@@ -40,6 +42,11 @@ import URI.Extra.QueryPairs as NQP
import URI.Query as Query
import Web.File.FileReader.Aff (readAsText)
import DOM.Simple.Types
import DOM.Simple.Window
import DOM.Simple.EventListener
import DOM.Simple.Event
import Effect.Console
type Dispatch = Action -> Aff Unit
...
...
@@ -324,6 +331,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
where
cpt p _ = do
renameBoxOpen <- R.useState' false
iframeRef <- R.useRef null
nodePopupState@(nodePopup /\ setNodePopup) <- R.useState' {action: Nothing, id: p.id, name: p.name, nodeType: p.nodeType}
search <- R.useState' $ defaultSearch { node_id = Just p.id }
pure $ H.div tooltipProps $
...
...
@@ -343,7 +351,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, if nodePopup.action == Just SearchBox then
H.div {}
[
searchIsTexIframe p search
searchIsTexIframe p search
iframeRef
]
else
H.div {} []
...
...
@@ -418,20 +426,38 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, session : p.session
}
searchIsTexIframe {nodeType} search@(search' /\ _) =
searchIsTexIframe {nodeType} search@(search' /\ _)
iframeRef
=
if isIsTex search'.datafield then
H.div { className: "istex-search panel panel-default" }
[
H.h3 { className: GT.fldr nodeType true} []
, componentIsTex search
, componentIsTex search
iframeRef
]
else
H.div {} []
componentIsTex (search /\ setSearch) =
H.iframe { src: isTexTermUrl search.term , width: "100%", height: "100%"} []
isTexUrl = "https://istex.gargantext.org"
isTexLocalUrl = "http://localhost:8083"
componentIsTex (search /\ setSearch) iframeRef =
H.iframe { src: isTexTermUrl search.term
,width: "100%"
,height: "100%"
,ref: iframeRef
,on: {
load: \_ -> do
addEventListener window "message" changeSearchOnMessage
R2.postMessage iframeRef search.term
}
} []
where
changeSearchOnMessage :: Callback MessageEvent
changeSearchOnMessage = callback $ \m -> if R2.getMessageOrigin m == isTexUrl
then do
let {url, term} = R2.getMessageData m
setSearch $ _ {url = url, term = term}
else
pure unit
--isTexUrl = "http://0.0.0.0:8080"--"https://istex.gargantext.org"
isTexUrl = "https://istex.gargantext.org"
-- isTexLocalUrl = "http://localhost:8083"
isTexTermUrl term = isTexUrl <> query
where
query = Query.print $ NQP.print identity identity qp
...
...
src/Gargantext/Components/Search/SearchBar.purs
View file @
ed4f4b47
...
...
@@ -3,6 +3,11 @@ module Gargantext.Components.Search.SearchBar
) where
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Search.Types -- (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..))
import Effect (Effect)
import Gargantext.Components.Lang (Lang)
import Gargantext.Components.Search.SearchField (Search, searchField)
...
...
src/Gargantext/Components/Search/SearchField.purs
View file @
ed4f4b47
module Gargantext.Components.Search.SearchField
( Search, Props, defaultSearch, searchField, searchFieldComponent, isIsTex) where
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Maybe (Maybe(..), maybe, fromMaybe
, isJust
)
import Data.Newtype (over)
import Data.String (length)
import Data.Set as Set
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable, toMaybe)
import Effect.Console (logShow)
import DOM.Simple.Console (log, log2)
import Effect.Aff (launchAff_)
import Effect.Aff (
Aff,
launchAff_)
import Effect.Class (liftEffect)
import Effect (Effect)
import Reactix as R
...
...
@@ -32,6 +34,7 @@ select = R.createElement "select"
type Search = { databases :: Database
, datafield :: Maybe DataField
, url :: String
, lang :: Maybe Lang
, node_id :: Maybe Int
, term :: String
...
...
@@ -50,6 +53,7 @@ defaultSearch = { databases: Empty
, node_id : Nothing
, lang : Nothing
, term : ""
, url: ""
}
type Props =
...
...
@@ -364,6 +368,7 @@ searchInputComponent = R.hooksComponent "G.C.S.SearchInput" cpt
pure $
H.div { className : "" }
[ H.input { defaultValue: search.term
, value: search.term
, className: "form-control"
, type: "text"
, on: { change : onChange setSearch }
...
...
src/Gargantext/Utils/Reactix.js
View file @
ed4f4b47
...
...
@@ -15,6 +15,10 @@ function stringify(j, indent) {
return
JSON
.
stringify
(
j
,
null
,
indent
);
}
function
postMessage
(
obj
,
msg
,
src
)
{
obj
.
contentWindow
.
postMessage
(
msg
,
src
);
}
function
setCookie
(
c
)
{
document
.
cookie
=
c
;
}
...
...
@@ -22,4 +26,5 @@ function setCookie(c) {
exports
.
_addRootElement
=
addRootElement
;
exports
.
_getSelection
=
getSelection
;
exports
.
_stringify
=
stringify
;
exports
.
_postMessage
=
postMessage
;
exports
.
_setCookie
=
setCookie
;
src/Gargantext/Utils/Reactix.purs
View file @
ed4f4b47
...
...
@@ -13,15 +13,16 @@ import Data.Argonaut as Json
import Data.Argonaut.Core (Json)
import Data.Either (hush)
import Data.Function.Uncurried (Fn2, runFn2)
import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Maybe (Maybe(..), fromJust, fromMaybe
, isJust
)
import Data.Nullable (Nullable, null, toMaybe)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Console (logShow)
import Effect.Aff (Aff, launchAff, launchAff_, killFiber)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Effect.Uncurried (EffectFn1, EffectFn2,
mkEffectFn1, mkEffectFn2, runEffectFn1, runEffectFn2
)
import Effect.Uncurried (EffectFn1, EffectFn2,
EffectFn3, mkEffectFn1, mkEffectFn2, runEffectFn1, runEffectFn2, runEffectFn3
)
import Effect.Unsafe (unsafePerformEffect)
import FFI.Simple ((..), (...), (.=), defineProperty, delay, args2, args3)
import Partial.Unsafe (unsafePartial)
...
...
@@ -296,6 +297,25 @@ useLocalStorageState key s = do
pure (Tuple state setState)
getMessageDataStr :: DE.MessageEvent -> String
getMessageDataStr = getMessageData
getMessageOrigin :: DE.MessageEvent -> String
getMessageOrigin me = me .. "origin"
getMessageData :: forall o. DE.MessageEvent -> o
getMessageData me = me .. "data"
foreign import _postMessage
:: forall r. EffectFn3 r String String Unit
postMessage :: forall r. R.Ref (Nullable r) -> String -> Effect Unit
postMessage ref msg = do
case (R.readNullableRef ref) of
(Just ifr) -> do
runEffectFn3 _postMessage ifr msg (ifr .. "src")
(Nothing) -> pure unit
foreign import _setCookie :: EffectFn1 String Unit
setCookie :: String -> Effect Unit
...
...
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