Commit 1f854b04 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] frames div

parent 3f39fafc
...@@ -4,33 +4,56 @@ import DOM.Simple as DOM ...@@ -4,33 +4,56 @@ import DOM.Simple as DOM
import DOM.Simple.Event (MessageEvent) import DOM.Simple.Event (MessageEvent)
import DOM.Simple.EventListener (Callback, addEventListener, callback) import DOM.Simple.EventListener (Callback, addEventListener, callback)
import DOM.Simple.Window (window) import DOM.Simple.Window (window)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable) import Data.Nullable (Nullable)
import Data.String (toLower)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Search, isIsTex_Advanced) import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Search, isIsTex_Advanced)
import Gargantext.Prelude (discard, identity, pure, unit, ($), (<>), (==)) import Gargantext.Prelude (discard, identity, pure, unit, ($), (<>), (==), class Show, show)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import URI.Extra.QueryPairs as NQP import URI.Extra.QueryPairs as NQP
import URI.Query as Query import URI.Query as Query
--------------------
data FrameSource = Istex | Searx
derive instance genericFrameSource :: Generic FrameSource _
instance showFrameSource :: Show FrameSource where
show = genericShow
-------------------- --------------------
-- | Iframes -- | Iframes
searchIframes :: R.State Search searchIframes :: R.State Search
-> R.Ref (Nullable DOM.Element) -> R.Ref (Nullable DOM.Element)
-> R.Element -> R.Element
searchIframes search@(search' /\ _) iframeRef = searchIframes search@(search' /\ _) iframeRef =
if isIsTex_Advanced search'.datafield then if isIsTex_Advanced search'.datafield
H.div { className: "frame-search panel panel-default" } then divIframe Istex search iframeRef
[ iframeWith "https://istex.frame.gargantext.org" search iframeRef ]
else else
if Just Web == search'.datafield then if Just Web == search'.datafield
H.div { className: "frame-search panel panel-default" } then divIframe Searx search iframeRef
[ iframeWith "https://searx.frame.gargantext.org" search iframeRef ] else H.div {} []
else
H.div {} [] divIframe :: FrameSource
-> R.State Search
-> R.Ref (Nullable DOM.Element)
-> R.Element
divIframe frameSource search@(search' /\ _) iframeRef =
H.div { className: "frame-search panel panel-default" }
[ iframeWith (frameUrl frameSource)search iframeRef ]
frameUrl :: FrameSource -> String
frameUrl frameSource = frameUrl' (toLower $ show frameSource)
where
frameUrl' s = "https://" <> s <> ".frame.gargantext.org"
iframeWith :: String iframeWith :: String
-> R.State Search -> R.State Search
......
...@@ -51,7 +51,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt ...@@ -51,7 +51,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
where where
cpt props@{onSearch, search: search@(s /\ _)} _ = do cpt props@{onSearch, search: search@(s /\ _)} _ = do
iframeRef <- R.useRef null iframeRef <- R.useRef null
let body = let params =
[ searchInput {search} [ searchInput {search}
, if length s.term < 3 -- search with love : <3 , if length s.term < 3 -- search with love : <3
then then
...@@ -83,9 +83,9 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt ...@@ -83,9 +83,9 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
] ]
] ]
let footer = submitButton {onSearch, search, session: props.session} let button = submitButton {onSearch, search, session: props.session}
pure $ panel body footer pure $ panel params button
componentIMT (search /\ setSearch) = componentIMT (search /\ setSearch) =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment