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
138
Issues
138
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
b82e5d28
Commit
b82e5d28
authored
Mar 05, 2020
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Need to find a way to not re render at every change
parent
5d5d668f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
13 deletions
+62
-13
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+27
-10
SearchBar.purs
src/Gargantext/Components/Search/SearchBar.purs
+1
-0
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+6
-1
Reactix.js
src/Gargantext/Utils/Reactix.js
+6
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+22
-2
No files found.
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
b82e5d28
...
...
@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node.Box where
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable, null)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
...
...
@@ -34,10 +35,10 @@ import Gargantext.Types (AsyncTask, NodePath(..), NodeType(..), fldr)
import Gargantext.Utils (glyphicon, glyphiconActive)
import Gargantext.Utils.Reactix as R2
import DOM.Simple.Types
import DOM.Simple.Window
import DOM.Simple.EventListener
import DOM.Simple.Event
import Effect.Console
-- Main Node
...
...
@@ -162,7 +163,7 @@ fldr nt open = if open
-- START node text
type NodeTextProps =
( isSelected :: Boolean
, name :: Name
, name :: Name
)
nodeText :: Record NodeTextProps -> R.Element
...
...
@@ -206,6 +207,7 @@ nodePopupView d p mPop@(Just NodePopup /\ setPopupOpen) = R.createElement el p [
el = R.hooksComponent "NodePopupView" cpt
cpt {id, action, name, nodeType, position, session} _ = do
renameBoxOpen <- R.useState' false
iframeRef <- R.useRef null
nodePopupState@(nodePopup /\ setNodePopup) <- R.useState' {id, name, nodeType, action}
search <- R.useState' $ defaultSearch { node_id = Just id }
pure $ H.div (tooltipProps position) $
...
...
@@ -225,7 +227,7 @@ nodePopupView d p mPop@(Just NodePopup /\ setPopupOpen) = R.createElement el p [
, if nodePopup.action == Just SearchBox then
H.div {}
[
searchIsTexIframe id session search
searchIsTexIframe id session search
iframeRef
]
else
H.div {} []
...
...
@@ -288,19 +290,36 @@ nodePopupView d p mPop@(Just NodePopup /\ setPopupOpen) = R.createElement el p [
$ map (buttonClick nodePopupState d') buttons
]
searchIsTexIframe _id _session search@(search' /\ _) =
searchIsTexIframe _id _session search@(search' /\ _)
iframeRef
=
if isIsTex search'.datafield then
H.div { className: "istex-search panel panel-default" }
[
H.h3 { className: 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 = "http://0.0.0.0:8080/"--"https://istex.gargantext.org"
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"
isTexLocalUrl = "http://localhost:8083"
isTexTermUrl term = isTexUrl <> query
where
...
...
@@ -406,5 +425,3 @@ reallyDelete d = H.div {className: "panel-footer"}
, onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode}
[H.text " Yes, delete!"]
]
windowCallBack = addEventListener window "message" (callback errorShow)
src/Gargantext/Components/Search/SearchBar.purs
View file @
b82e5d28
...
...
@@ -4,6 +4,7 @@ module Gargantext.Components.Search.SearchBar
import Prelude (pure, ($))
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable)
import Reactix as R
import Reactix.DOM.HTML as H
...
...
src/Gargantext/Components/Search/SearchField.purs
View file @
b82e5d28
...
...
@@ -2,12 +2,14 @@ module Gargantext.Components.Search.SearchField
( Search, Props, defaultSearch, searchField, searchFieldComponent, isIsTex) where
import Prelude (const, map, pure, show, discard, ($), (&&), (<), (<$>), (<>), (==), (<<<), Unit, bind)
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe
, 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 (log2)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
...
...
@@ -29,6 +31,7 @@ select = R.createElement "select"
type Search = { datafield :: Maybe DataField
, term :: String
, url :: String
, lang :: Maybe Lang
, node_id :: Maybe Int
}
...
...
@@ -42,6 +45,7 @@ eqSearch s s' = (s.datafield == s'.datafield)
defaultSearch :: Search
defaultSearch = { datafield: Nothing
, term: ""
, url: ""
, lang: Nothing
, node_id: Nothing
}
...
...
@@ -318,6 +322,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 @
b82e5d28
...
...
@@ -15,6 +15,12 @@ function stringify(j, indent) {
return
JSON
.
stringify
(
j
,
null
,
indent
);
}
function
postMessage
(
obj
,
msg
,
src
)
{
obj
.
contentWindow
.
postMessage
(
msg
,
src
);
}
exports
.
_addRootElement
=
addRootElement
;
exports
.
_getSelection
=
getSelection
;
exports
.
_stringify
=
stringify
;
exports
.
_postMessage
=
postMessage
;
src/Gargantext/Utils/Reactix.purs
View file @
b82e5d28
...
...
@@ -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,
mkEffectFn1, mkEffectFn2, runEffectFn1
)
import Effect.Uncurried (EffectFn1,
EffectFn3, mkEffectFn1, mkEffectFn2, runEffectFn1, runEffectFn3
)
import Effect.Unsafe (unsafePerformEffect)
import FFI.Simple ((..), (...), defineProperty, delay, args2, args3)
import Partial.Unsafe (unsafePartial)
...
...
@@ -283,3 +284,22 @@ useLocalStorageState key s = do
setItem key json storage
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
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