Commit 6ad8d99d authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev' into testing

parents c979e19b 7f7ac4ad
Pipeline #4032 failed with stage
dist/images/logo.png

19.8 KB | W: | H:

dist/images/logo.png

17.1 KB | W: | H:

dist/images/logo.png
dist/images/logo.png
dist/images/logo.png
dist/images/logo.png
  • 2-up
  • Swipe
  • Onion skin
{ {
"name": "Gargantext", "name": "Gargantext",
"version": "0.0.6.9.9.3.3", "version": "0.0.6.9.9.5",
"scripts": { "scripts": {
"generate-purs-packages-nix": "./nix/generate-purs-packages.nix", "generate-purs-packages-nix": "./nix/generate-purs-packages.nix",
"generate-psc-packages-nix": "./nix/generate-packages-json.bash", "generate-psc-packages-nix": "./nix/generate-packages-json.bash",
......
...@@ -33,6 +33,7 @@ to generate this file without the comments in this block. ...@@ -33,6 +33,7 @@ to generate this file without the comments in this block.
, "dom-simple" , "dom-simple"
, "effect" , "effect"
, "either" , "either"
, "enums"
, "exceptions" , "exceptions"
, "ffi-simple" , "ffi-simple"
, "foldable-traversable" , "foldable-traversable"
......
...@@ -13,18 +13,18 @@ module Gargantext.Components.Annotation.Field where ...@@ -13,18 +13,18 @@ module Gargantext.Components.Annotation.Field where
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple.Event as DE
import Data.Array as A import Data.Array as A
import Data.List (List(..), (:)) import Data.List (List(..), (:))
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.String.Common (joinWith) import Data.String.Common (joinWith)
import Data.Tuple (Tuple(..), snd) import Data.Tuple (Tuple(..), snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect) import Effect (Effect)
import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu) import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu)
import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass) import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass)
import Gargantext.Core.NgramsTable.Functions (findNgramTermList, highlightNgrams, normNgram) import Gargantext.Core.NgramsTable.Functions (findNgramTermList, highlightNgrams, normNgram)
import Gargantext.Core.NgramsTable.Types (NgramsTable, NgramsTerm) import Gargantext.Core.NgramsTable.Types (NgramsTable, NgramsTerm(..))
import Gargantext.Types (CTabNgramType(..), TermList) import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Selection as Sel import Gargantext.Utils.Selection as Sel
...@@ -35,7 +35,7 @@ import Record as Record ...@@ -35,7 +35,7 @@ import Record as Record
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Annotation.AnnotatedField" here = R2.here "Gargantext.Components.Annotation.Field"
-- @NOTE #386: add parameter "type" ("Authors", "Terms") -- @NOTE #386: add parameter "type" ("Authors", "Terms")
type Props = type Props =
...@@ -52,7 +52,6 @@ type MouseEvent = E.SyntheticEvent DE.MouseEvent ...@@ -52,7 +52,6 @@ type MouseEvent = E.SyntheticEvent DE.MouseEvent
annotatedField :: R2.Leaf Props annotatedField :: R2.Leaf Props
annotatedField = R2.leaf annotatedFieldCpt annotatedField = R2.leaf annotatedFieldCpt
annotatedFieldCpt :: R.Component Props annotatedFieldCpt :: R.Component Props
annotatedFieldCpt = here.component "annotatedField" cpt where annotatedFieldCpt = here.component "annotatedField" cpt where
cpt props _ = do cpt props _ = do
...@@ -71,7 +70,6 @@ type InnerProps = ...@@ -71,7 +70,6 @@ type InnerProps =
annotatedFieldInner :: R2.Leaf InnerProps annotatedFieldInner :: R2.Leaf InnerProps
annotatedFieldInner = R2.leaf annotatedFieldInnerCpt annotatedFieldInner = R2.leaf annotatedFieldInnerCpt
annotatedFieldInnerCpt :: R.Component InnerProps annotatedFieldInnerCpt :: R.Component InnerProps
annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
cpt { menuRef cpt { menuRef
...@@ -159,16 +157,16 @@ onAnnotationSelect ...@@ -159,16 +157,16 @@ onAnnotationSelect
s <- Sel.getSelection s <- Sel.getSelection
case s of case s of
Just sel -> do Just sel -> do
case Sel.selectionToString sel of case (normNgram CTabTerms $ Sel.selectionToString sel) of
"" -> hideMenu { menuRef, redrawMenu } NormNgramsTerm "" -> hideMenu { menuRef, redrawMenu }
sel' -> do sel' -> do
showMenu { event showMenu { event
, getList: findNgramTermList ngrams , getList: findNgramTermList ngrams
, menuRef , menuRef
, menuType: NewNgram , menuType: NewNgram
, ngram: normNgram CTabTerms sel' , ngram: sel' -- normNgram CTabTerms sel'
, redrawMenu , redrawMenu
, setTermList } , setTermList }
Nothing -> hideMenu { menuRef, redrawMenu } Nothing -> hideMenu { menuRef, redrawMenu }
onAnnotationSelect onAnnotationSelect
...@@ -241,7 +239,6 @@ type RunProps = ...@@ -241,7 +239,6 @@ type RunProps =
annotateRun :: R2.Leaf RunProps annotateRun :: R2.Leaf RunProps
annotateRun = R2.leaf annotatedRunCpt annotateRun = R2.leaf annotatedRunCpt
annotatedRunCpt :: R.Component RunProps annotatedRunCpt :: R.Component RunProps
annotatedRunCpt = here.component "annotatedRun" cpt where annotatedRunCpt = here.component "annotatedRun" cpt where
cpt { list, onSelect, text } _ = pure $ case list of cpt { list, onSelect, text } _ = pure $ case list of
......
...@@ -36,7 +36,6 @@ type AnnotationMenu = ...@@ -36,7 +36,6 @@ type AnnotationMenu =
annotationMenu :: R2.Leaf Props annotationMenu :: R2.Leaf Props
annotationMenu = R2.leaf annotationMenuCpt annotationMenu = R2.leaf annotationMenuCpt
annotationMenuCpt :: R.Component Props annotationMenuCpt :: R.Component Props
annotationMenuCpt = here.component "main" cpt where annotationMenuCpt = here.component "main" cpt where
cpt { menuRef } _ = do cpt { menuRef } _ = do
......
...@@ -4,6 +4,7 @@ module Gargantext.Components.Category where ...@@ -4,6 +4,7 @@ module Gargantext.Components.Category where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Enum (fromEnum)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
...@@ -12,8 +13,8 @@ import Effect.Aff (launchAff_) ...@@ -12,8 +13,8 @@ import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Variant(..)) import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.Category.Types (Category(..), Star(..), cat2score, categories, clickAgain, decodeStar, star2score, stars) import Gargantext.Components.Category.Types (Category(..), Star(..), cat2score, cat2star, categories, categoryNextState, decodeCategory, stars)
import Gargantext.Components.DocsTable.Types (DocumentsView(..), LocalCategories, LocalUserScore) import Gargantext.Components.DocsTable.Types (DocumentsView(..), LocalCategories)
import Gargantext.Components.GraphQL.Context (NodeContext) import Gargantext.Components.GraphQL.Context (NodeContext)
import Gargantext.Components.GraphQL.Endpoints (getNodeContext, updateNodeContextCategory) import Gargantext.Components.GraphQL.Endpoints (getNodeContext, updateNodeContextCategory)
import Gargantext.Config.REST (AffRESTError, RESTError(..)) import Gargantext.Config.REST (AffRESTError, RESTError(..))
...@@ -36,9 +37,9 @@ type RatingProps = ...@@ -36,9 +37,9 @@ type RatingProps =
( chartReload :: T2.ReloadS ( chartReload :: T2.ReloadS
, nodeId :: NodeID , nodeId :: NodeID
, row :: DocumentsView , row :: DocumentsView
, score :: Star , score :: Category
, session :: Session , session :: Session
, setLocalCategories :: R.Setter LocalUserScore -- , setLocalCategories :: R.Setter LocalCategories
) )
rating :: R2.Component RatingProps rating :: R2.Component RatingProps
...@@ -50,11 +51,11 @@ ratingCpt = here.component "rating" cpt where ...@@ -50,11 +51,11 @@ ratingCpt = here.component "rating" cpt where
, row: DocumentsView r , row: DocumentsView r
, score , score
, session , session
, setLocalCategories -- , setLocalCategories
} _ = do } _ = do
pure $ renderRatingSimple { docId: r._id pure $ renderRatingSimple { docId: r._id
, corpusId: nodeId , corpusId: nodeId
, category: star2score score , category: score
, session } [] , session } []
-- -- | Behaviors -- -- | Behaviors
...@@ -86,14 +87,17 @@ ratingCpt = here.component "rating" cpt where ...@@ -86,14 +87,17 @@ ratingCpt = here.component "rating" cpt where
-- , className: ratingClassName score s -- , className: ratingClassName score s
-- } -- }
ratingIcon Star_0 Star_0 = "recycle" ratingIcon :: Category -> Star -> String
ratingIcon Trash Star_0 = "recycle"
ratingIcon _ Star_0 = "trash" ratingIcon _ Star_0 = "trash"
ratingIcon c s = star2score c < star2score s ? "star-o" $ "star" ratingIcon c s = fromEnum (cat2star c) < fromEnum s ? "star-o" $ "star"
ratingVariant :: Star -> Star -> Variant
ratingVariant Star_0 Star_0 = Dark ratingVariant Star_0 Star_0 = Dark
ratingVariant _ Star_0 = Dark ratingVariant _ Star_0 = Dark
ratingVariant _ _ = Dark ratingVariant _ _ = Dark
ratingClassName :: Star -> Star -> String
ratingClassName Star_0 Star_0 = "rating-group__action" ratingClassName Star_0 Star_0 = "rating-group__action"
ratingClassName _ Star_0 = "rating-group__action" ratingClassName _ Star_0 = "rating-group__action"
ratingClassName _ _ = "rating-group__star" ratingClassName _ _ = "rating-group__star"
...@@ -118,10 +122,12 @@ ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where ...@@ -118,10 +122,12 @@ ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where
useLoader { errorHandler useLoader { errorHandler
, loader: loadDocumentContext session , loader: loadDocumentContext session
, path: { docId, corpusId } , path: { docId, corpusId }
, render: \{ nc_category } -> renderRatingSimple { docId , render: \{ nc_category } -> do
, corpusId let category = fromMaybe UnRead $ decodeCategory <$> nc_category
, category: fromMaybe 0 nc_category renderRatingSimple { docId
, session } [] } , corpusId
, category
, session } [] }
where where
errorHandler err = do errorHandler err = do
here.warn2 "[pageLayout] RESTError" err here.warn2 "[pageLayout] RESTError" err
...@@ -139,7 +145,7 @@ loadDocumentContext session { docId, corpusId } = getNodeContext session docId c ...@@ -139,7 +145,7 @@ loadDocumentContext session { docId, corpusId } = getNodeContext session docId c
type RenderRatingSimpleProps = type RenderRatingSimpleProps =
( docId :: NodeID ( docId :: NodeID
, corpusId :: NodeID , corpusId :: NodeID
, category :: Int , category :: Category
, session :: Session ) , session :: Session )
renderRatingSimple :: R2.Component RenderRatingSimpleProps renderRatingSimple :: R2.Component RenderRatingSimpleProps
...@@ -151,17 +157,17 @@ renderRatingSimpleCpt = here.component "renderRatingSimple" cpt where ...@@ -151,17 +157,17 @@ renderRatingSimpleCpt = here.component "renderRatingSimple" cpt where
, category , category
, session , session
} _ = do } _ = do
score <- T.useBox $ decodeStar category categoryS <- T.useBox category
pure $ ratingSimple { docId pure $ ratingSimple { docId
, corpusId , corpusId
, score , category: categoryS
, session } [] , session } []
type RatingSimpleProps = type RatingSimpleProps =
( docId :: NodeID ( docId :: NodeID
, corpusId :: NodeID , corpusId :: NodeID
, score :: T.Box Star , category :: T.Box Category
, session :: Session ) , session :: Session )
ratingSimple :: R2.Component RatingSimpleProps ratingSimple :: R2.Component RatingSimpleProps
...@@ -170,19 +176,21 @@ ratingSimpleCpt :: R.Component RatingSimpleProps ...@@ -170,19 +176,21 @@ ratingSimpleCpt :: R.Component RatingSimpleProps
ratingSimpleCpt = here.component "ratingSimple" cpt where ratingSimpleCpt = here.component "ratingSimple" cpt where
cpt { docId cpt { docId
, corpusId , corpusId
, score , category
, session , session
} _ = do } _ = do
score' <- T.useLive T.unequal score category' <- T.useLive T.unequal category
let star' = cat2star category'
let let
onClick c _ = do onClick c _ = do
let c' = score' == c ? clickAgain c $ c -- let c' = score' == c ? clickAgain c $ c
let c' = categoryNextState category' c
-- setLocalCategories $ Map.insert r._id c' -- setLocalCategories $ Map.insert r._id c'
launchAff_ do launchAff_ do
_ <- updateNodeContextCategory session docId corpusId $ star2score c' _ <- updateNodeContextCategory session docId corpusId $ cat2score c'
liftEffect $ T.write_ c' score liftEffect $ T.write_ c' category
pure unit pure unit
pure $ pure $
...@@ -190,17 +198,17 @@ ratingSimpleCpt = here.component "ratingSimple" cpt where ...@@ -190,17 +198,17 @@ ratingSimpleCpt = here.component "ratingSimple" cpt where
{ className: "rating-group" } $ { className: "rating-group" } $
stars <#> \s -> stars <#> \s ->
B.iconButton B.iconButton
{ name: ratingIcon score' s { name: ratingIcon category' s
, callback: onClick s , callback: onClick s
, overlay: false , overlay: false
, variant: ratingVariant score' s , variant: ratingVariant star' s
, className: ratingClassName score' s , className: ratingClassName star' s
} }
newtype RatingQuery = newtype RatingQuery =
RatingQuery { nodeIds :: Array Int RatingQuery { nodeIds :: Array Int
, rating :: Star , rating :: Category
} }
derive instance Generic RatingQuery _ derive instance Generic RatingQuery _
instance JSON.WriteForeign RatingQuery where instance JSON.WriteForeign RatingQuery where
...@@ -267,6 +275,9 @@ icon cat b = btn b $ "fa fa-" <> (color $ size b $ icon' cat b) ...@@ -267,6 +275,9 @@ icon cat b = btn b $ "fa fa-" <> (color $ size b $ icon' cat b)
icon' Favorite false = "heart-o" icon' Favorite false = "heart-o"
icon' Favorite true = "heart" icon' Favorite true = "heart"
icon' ToCite false = "quote-left-o"
icon' ToCite true = "quote-left"
size :: Boolean -> String -> String size :: Boolean -> String -> String
size true s = s <> " btn-lg" size true s = s <> " btn-lg"
size false s = s <> " btn-sm" size false s = s <> " btn-sm"
......
module Gargantext.Components.Category.Types where module Gargantext.Components.Category.Types where
import Data.Generic.Rep (class Generic) import Data.Bounded.Generic (genericTop, genericBottom)
import Data.Enum (class Enum, class BoundedEnum, succ, pred, fromEnum, toEnumWithDefaults)
import Data.Enum.Generic (genericPred, genericSucc, genericCardinality, genericFromEnum, genericToEnum)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (fromMaybe)
import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Simple.JSON as JSON import Simple.JSON as JSON
import Gargantext.Prelude import Gargantext.Prelude
------------------------------------------------------------------------ ------------------------------------------------------------------------
data Star = Star_0 | Star_1 | Star_2 | Star_3 | Star_4 data Category = Trash | UnRead | Checked | Topic | Favorite | ToCite
{-
stars :: Array Star - `UnRead` is assigned initially for new docs
stars = [Star_0, Star_1, Star_2, Star_3, Star_4] - After reading a doc, `Checked` should be assigned automatically
- Both `Trash` and `UnRead` map to 0 stars in the doc list
derive instance Generic Star _ -}
instance Show Star where show = genericShow
instance Eq Star where eq = genericEq
instance JSON.ReadForeign Star where
readImpl f = do
inst <- JSON.readImpl f
pure $ decodeStar inst
instance JSON.WriteForeign Star where writeImpl = JSON.writeImpl <<< star2score
decodeStar :: Int -> Star
decodeStar 0 = Star_0
decodeStar 1 = Star_1
decodeStar 2 = Star_2
decodeStar 3 = Star_3
decodeStar 4 = Star_4
decodeStar _ = Star_4
star2score :: Star -> Int
star2score Star_0 = 0
star2score Star_1 = 1
star2score Star_2 = 2
star2score Star_3 = 3
star2score Star_4 = 4
clickAgain :: Star -> Star
clickAgain Star_0 = Star_1
clickAgain s = decodeStar (star2score s - 1)
------------------------------------------------------------------------
data Category = Trash | UnRead | Checked | Topic | Favorite
categories :: Array Category categories :: Array Category
categories = [Trash, UnRead, Checked, Topic, Favorite] categories = [Trash, UnRead, Checked, Topic, Favorite, ToCite]
derive instance Generic Category _ derive instance Generic Category _
instance Ord Category where compare = genericCompare
instance Enum Category where
pred = genericPred
succ = genericSucc
instance Bounded Category where
bottom = genericBottom
top = genericTop
instance BoundedEnum Category where
cardinality = genericCardinality
fromEnum = genericFromEnum
toEnum = genericToEnum
instance Show Category where show = genericShow instance Show Category where show = genericShow
instance Eq Category where eq = genericEq instance Eq Category where eq = genericEq
instance JSON.ReadForeign Category where instance JSON.ReadForeign Category where
...@@ -58,26 +43,79 @@ instance JSON.ReadForeign Category where ...@@ -58,26 +43,79 @@ instance JSON.ReadForeign Category where
pure $ decodeCategory inst pure $ decodeCategory inst
instance JSON.WriteForeign Category where writeImpl = JSON.writeImpl <<< cat2score instance JSON.WriteForeign Category where writeImpl = JSON.writeImpl <<< cat2score
catSucc :: Category -> Category
catSucc c = fromMaybe ToCite $ succ c
catPred :: Category -> Category
catPred c = fromMaybe Trash $ pred c
clickAgain :: Category -> Category
clickAgain _ = UnRead
-- | `categoryNextState :: current -> clicked -> new State`
categoryNextState :: Category -> Star -> Category
categoryNextState Trash Star_0 = UnRead
categoryNextState _ Star_0 = Trash
categoryNextState current clicked =
if (cat2star current) == clicked then
clickAgain current
else
star2catSimple clicked
favCategory :: Category -> Category favCategory :: Category -> Category
favCategory Favorite = Topic favCategory Favorite = Topic
favCategory _ = Favorite favCategory _ = Favorite
trashCategory :: Category -> Category trashCategory :: Category -> Category
trashCategory _ = Trash trashCategory = const Trash
-- TODO: ?
--trashCategory Trash = UnRead
decodeCategory :: Int -> Category decodeCategory :: Int -> Category
decodeCategory 0 = Trash decodeCategory = toEnumWithDefaults UnRead UnRead
decodeCategory 1 = UnRead
decodeCategory 2 = Checked
decodeCategory 3 = Topic
decodeCategory 4 = Favorite
decodeCategory _ = UnRead
cat2score :: Category -> Int cat2score :: Category -> Int
cat2score Trash = 0 cat2score = fromEnum
cat2score UnRead = 1
cat2score Checked = 2 ------------------------------------------------------------------------
cat2score Topic = 3 -- | This is just a helper to visualize categories.
cat2score Favorite = 4 data Star = Star_0 | Star_1 | Star_2 | Star_3 | Star_4
stars :: Array Star
stars = [Star_0, Star_1, Star_2, Star_3, Star_4]
derive instance Generic Star _
instance Show Star where show = genericShow
instance Eq Star where eq = genericEq
instance Ord Star where compare = genericCompare
instance Enum Star where
pred = genericPred
succ = genericSucc
instance Bounded Star where
bottom = genericBottom
top = genericTop
instance BoundedEnum Star where
cardinality = genericCardinality
fromEnum = genericFromEnum
toEnum = genericToEnum
cat2star :: Category -> Star
cat2star Trash = Star_0
cat2star UnRead = Star_0
cat2star Checked = Star_1
cat2star Topic = Star_2
cat2star Favorite = Star_3
cat2star ToCite = Star_4
-- | This is a "reverse" of `cat2star`
star2catSimple :: Star -> Category
star2catSimple Star_0 = UnRead
star2catSimple Star_1 = Checked
star2catSimple Star_2 = Topic
star2catSimple Star_3 = Favorite
star2catSimple Star_4 = ToCite
markCategoryChecked :: Category -> Category
markCategoryChecked UnRead = Checked
markCategoryChecked s = s
This diff is collapsed.
...@@ -7,14 +7,14 @@ import Data.Generic.Rep (class Generic) ...@@ -7,14 +7,14 @@ import Data.Generic.Rep (class Generic)
import Data.Map (Map) import Data.Map (Map)
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Components.Category.Types (Category, Star(..), decodeStar) import Gargantext.Components.Category.Types (Category(..), Star(..), decodeCategory)
import Simple.JSON as JSON import Simple.JSON as JSON
data Action data Action
= MarkCategory Int Category = MarkCategory Int Category
type DocumentsViewT = type DocumentsViewT =
( category :: Star ( category :: Category
, date :: Int , date :: Int
, ngramCount :: Maybe Int , ngramCount :: Maybe Int
, score :: Maybe Int , score :: Maybe Int
...@@ -65,8 +65,8 @@ type ResponseT = ...@@ -65,8 +65,8 @@ type ResponseT =
, score :: Maybe Int , score :: Maybe Int
, title :: String ) , title :: String )
newtype Response = Response newtype Response = Response
{ cid :: Int { cid :: Int
, category :: Star , category :: Category
| ResponseT | ResponseT
} }
...@@ -74,7 +74,7 @@ instance JSON.ReadForeign Response where ...@@ -74,7 +74,7 @@ instance JSON.ReadForeign Response where
readImpl f = do readImpl f = do
{ category, id, hyperdata, ngramCount, score, title } :: { category :: Int, id :: Int | ResponseT } <- JSON.readImpl f { category, id, hyperdata, ngramCount, score, title } :: { category :: Int, id :: Int | ResponseT } <- JSON.readImpl f
--pure $ Response { category: decodeCategory category, cid, hyperdata, ngramCount, score, title } --pure $ Response { category: decodeCategory category, cid, hyperdata, ngramCount, score, title }
pure $ Response { category: decodeStar category pure $ Response { category: decodeCategory category
, cid: id , cid: id
, hyperdata , hyperdata
, ngramCount , ngramCount
...@@ -110,7 +110,7 @@ sampleData' = DocumentsView { _id : 1 ...@@ -110,7 +110,7 @@ sampleData' = DocumentsView { _id : 1
, date : 2010 , date : 2010
, title : "title" , title : "title"
, source : Just "source" , source : Just "source"
, category : Star_1 , category : UnRead
, ngramCount : Just 1 , ngramCount : Just 1
, score: Just 1 } , score: Just 1 }
...@@ -121,7 +121,7 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1 ...@@ -121,7 +121,7 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1
, date : 2017 , date : 2017
, title: t , title: t
, source: Just s , source: Just s
, category : Star_1 , category : UnRead
, ngramCount : Just 10 , ngramCount : Just 10
, score: Just 1 }) sampleDocuments , score: Just 1 }) sampleDocuments
......
...@@ -16,7 +16,6 @@ import Gargantext.Components.AutoUpdate (autoUpdate) ...@@ -16,7 +16,6 @@ import Gargantext.Components.AutoUpdate (autoUpdate)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), SpinnerTheme(..)) import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), SpinnerTheme(..))
import Gargantext.Components.Category (ratingSimpleLoader) import Gargantext.Components.Category (ratingSimpleLoader)
import Gargantext.Components.Category.Types (decodeStar)
import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState) import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState)
import Gargantext.Components.NgramsTable.AutoSync (useAutoSync) import Gargantext.Components.NgramsTable.AutoSync (useAutoSync)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
......
...@@ -395,6 +395,7 @@ pageCpt = here.component "page" cpt ...@@ -395,6 +395,7 @@ pageCpt = here.component "page" cpt
wrapColElts = const identity wrapColElts = const identity
-- TODO: how to interprete other scores? -- TODO: how to interprete other scores?
gi Trash = "fa fa-star-empty" gi Trash = "fa fa-star-empty"
gi UnRead = "fa fa-star-empty"
gi _ = "fa fa-star" gi _ = "fa fa-star"
documentUrl id { listId, nodeId } = documentUrl id { listId, nodeId } =
......
...@@ -8,7 +8,6 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe) ...@@ -8,7 +8,6 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Set (Set) import Data.Set (Set)
import Data.Set as Set import Data.Set as Set
import Data.String as String
import Data.Tuple (Tuple) import Data.Tuple (Tuple)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Gargantext.Components.GraphQL.IMT as GQLIMT import Gargantext.Components.GraphQL.IMT as GQLIMT
...@@ -23,21 +22,18 @@ import Simple.JSON as JSON ...@@ -23,21 +22,18 @@ import Simple.JSON as JSON
import URI.Extra.QueryPairs as QP import URI.Extra.QueryPairs as QP
import URI.Query as Q import URI.Query as Q
type Search = { databases :: Database type Search = { databases :: Database
, datafield :: Maybe DataField , datafield :: Maybe DataField
, url :: String , url :: String
, lang :: Maybe Lang , lang :: Maybe Lang
, node_id :: Maybe Int , node_id :: Maybe Int
, term :: String , term :: String
, years :: Array String , years :: Array String
} }
isIsTex_Advanced :: Maybe DataField -> Boolean isIsTex_Advanced :: Maybe DataField -> Boolean
isIsTex_Advanced ( Just isIsTex_Advanced ( Just
( External ( External ( IsTex_Advanced) )
( Just ( IsTex_Advanced)
)
)
) = true ) = true
isIsTex_Advanced _ = false isIsTex_Advanced _ = false
...@@ -51,13 +47,13 @@ class Doc a where ...@@ -51,13 +47,13 @@ class Doc a where
dataFields :: Array DataField dataFields :: Array DataField
dataFields = [ {- Gargantext dataFields = [ {- Gargantext
, -} External Nothing , -} External Empty
, Web , Web
-- , Files -- , Files
] ]
data DataField = Gargantext data DataField = Gargantext
| External (Maybe Database) | External Database
| Web | Web
| Files | Files
...@@ -74,9 +70,9 @@ instance Doc DataField where ...@@ -74,9 +70,9 @@ instance Doc DataField where
doc Files = "Zip files with formats.." doc Files = "Zip files with formats.."
derive instance Eq DataField derive instance Eq DataField
instance JSON.WriteForeign DataField where instance JSON.WriteForeign DataField where
writeImpl (External (Just db)) = JSON.writeImpl $ "External " <> show db writeImpl (External db) = JSON.writeImpl { tag: "External"
writeImpl Web = JSON.writeImpl $ "Web" , contents: JSON.writeImpl db }
writeImpl f = JSON.writeImpl $ show f writeImpl f = JSON.writeImpl $ JSON.writeImpl { tag: show f }
---------------------------------------- ----------------------------------------
data DataOriginApi = InternalOrigin { api :: Database } data DataOriginApi = InternalOrigin { api :: Database }
...@@ -91,23 +87,23 @@ instance JSON.WriteForeign DataOriginApi where ...@@ -91,23 +87,23 @@ instance JSON.WriteForeign DataOriginApi where
writeImpl (ExternalOrigin { api }) = JSON.writeImpl { api } writeImpl (ExternalOrigin { api }) = JSON.writeImpl { api }
datafield2dataOriginApi :: DataField -> DataOriginApi datafield2dataOriginApi :: DataField -> DataOriginApi
datafield2dataOriginApi (External (Just a)) = ExternalOrigin { api : a } datafield2dataOriginApi (External a) = ExternalOrigin { api : a }
datafield2dataOriginApi _ = InternalOrigin { api : IsTex } -- TODO fixme datafield2dataOriginApi _ = InternalOrigin { api : IsTex } -- TODO fixme
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Database search specifications -- | Database search specifications
datafield2database :: DataField -> Database datafield2database :: DataField -> Database
datafield2database (External (Just x)) = x datafield2database (External x) = x
datafield2database _ = Empty datafield2database _ = Empty
allDatabases :: Array Database allDatabases :: Array Database
allDatabases = [ Empty allDatabases = [ Empty
, PubMed , PubMed { api_key: Nothing }
, Arxiv -- , Arxiv
, HAL Nothing , HAL Nothing
, IsTex , IsTex
, IsTex_Advanced -- , IsTex_Advanced
-- , Isidore -- , Isidore
--, Web --, Web
--, News --, News
...@@ -116,7 +112,7 @@ allDatabases = [ Empty ...@@ -116,7 +112,7 @@ allDatabases = [ Empty
data Database = All_Databases data Database = All_Databases
| Empty | Empty
| PubMed | PubMed { api_key :: Maybe String }
| Arxiv | Arxiv
| HAL (Maybe Org) | HAL (Maybe Org)
| IsTex | IsTex
...@@ -127,7 +123,7 @@ data Database = All_Databases ...@@ -127,7 +123,7 @@ data Database = All_Databases
derive instance Generic Database _ derive instance Generic Database _
instance Show Database where instance Show Database where
show All_Databases = "All Databases" show All_Databases = "All Databases"
show PubMed = "PubMed" show (PubMed _) = "PubMed"
show Arxiv = "Arxiv" show Arxiv = "Arxiv"
show (HAL _) = "HAL" show (HAL _) = "HAL"
show IsTex = "IsTex" show IsTex = "IsTex"
...@@ -139,7 +135,7 @@ instance Show Database where ...@@ -139,7 +135,7 @@ instance Show Database where
instance Doc Database where instance Doc Database where
doc All_Databases = "All databases" doc All_Databases = "All databases"
doc PubMed = "All Medical publications" doc (PubMed _) = "All Medical publications"
doc Arxiv = "Arxiv" doc Arxiv = "Arxiv"
doc (HAL _) = "All open science (archives ouvertes)" doc (HAL _) = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST" doc IsTex = "All Elsevier enriched by CNRS/INIST"
...@@ -149,22 +145,46 @@ instance Doc Database where ...@@ -149,22 +145,46 @@ instance Doc Database where
-- doc News = "Web filtered by News" -- doc News = "Web filtered by News"
-- doc SocialNetworks = "Web filtered by MicroBlogs" -- doc SocialNetworks = "Web filtered by MicroBlogs"
instance Read Database where -- instance Read Database where
read :: String -> Maybe Database -- read :: String -> Maybe Database
read "All Databases" = Just All_Databases -- read "All Databases" = Just All_Databases
read "PubMed" = Just PubMed -- read "PubMed" = Just PubMed
read "Arxiv" = Just Arxiv -- read "Arxiv" = Just Arxiv
read "HAL" = Just $ HAL Nothing -- read "HAL" = Just $ HAL Nothing
read "Isidore" = Just Isidore -- read "Isidore" = Just Isidore
read "IsTex" = Just IsTex -- read "IsTex" = Just IsTex
read "IsTex_Advanced" = Just IsTex_Advanced -- read "IsTex_Advanced" = Just IsTex_Advanced
-- read "Web" = Just Web -- -- read "Web" = Just Web
-- read "News" = Just News -- -- read "News" = Just News
-- read "Social Networks" = Just SocialNetworks -- -- read "Social Networks" = Just SocialNetworks
read _ = Nothing -- read _ = Nothing
dbToInputValue :: Database -> String
dbToInputValue All_Databases = "all_databases"
dbToInputValue (PubMed _) = "pubmed"
dbToInputValue Arxiv = "arxiv"
dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex"
dbToInputValue IsTex_Advanced = "istex_advanced"
dbToInputValue Isidore = "isidore"
dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database
dbFromInputValue "all_databases" = Just All_Databases
dbFromInputValue "pubmed" = Just (PubMed { api_key: Nothing})
dbFromInputValue "arxiv" = Just Arxiv
dbFromInputValue "hal" = Just (HAL Nothing)
dbFromInputValue "istex" = Just IsTex
dbFromInputValue "istex_advanced" = Just IsTex_Advanced
dbFromInputValue "isidore" = Just Isidore
dbFromInputValue "empty" = Just Empty
dbFromInputValue _ = Nothing
derive instance Eq Database derive instance Eq Database
instance JSON.WriteForeign Database where writeImpl = JSON.writeImpl <<< show instance JSON.WriteForeign Database where
writeImpl (PubMed { api_key }) = JSON.writeImpl { tag: "PubMed"
, _api_key: api_key }
writeImpl f = JSON.writeImpl { tag: show f }
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Organization specifications -- | Organization specifications
...@@ -234,16 +254,17 @@ instance Show SearchOrder where ...@@ -234,16 +254,17 @@ instance Show SearchOrder where
------------------------------------------------------------------------ ------------------------------------------------------------------------
newtype SearchQuery = SearchQuery newtype SearchQuery = SearchQuery
{ query :: String { query :: String
, databases :: Database , databases :: Database
, datafield :: Maybe DataField , datafield :: Maybe DataField
, files_id :: Array String , files_id :: Array String
, lang :: Maybe Lang , lang :: Maybe Lang
, limit :: Maybe Int , limit :: Maybe Int
, node_id :: Maybe Int , node_id :: Maybe Int
, offset :: Maybe Int , offset :: Maybe Int
, order :: Maybe SearchOrder , order :: Maybe SearchOrder
, selection :: ListSelection.Selection , pubmedAPIKey :: Maybe String
, selection :: ListSelection.Selection
} }
derive instance Generic SearchQuery _ derive instance Generic SearchQuery _
derive instance Newtype SearchQuery _ derive instance Newtype SearchQuery _
...@@ -260,27 +281,29 @@ instance GT.ToQuery SearchQuery where ...@@ -260,27 +281,29 @@ instance GT.ToQuery SearchQuery where
pair k = maybe [] $ \v -> pair k = maybe [] $ \v ->
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ] [ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance JSON.WriteForeign SearchQuery where instance JSON.WriteForeign SearchQuery where
writeImpl (SearchQuery { databases, datafield, lang, node_id, query, selection }) = writeImpl (SearchQuery { databases, datafield, lang, node_id, pubmedAPIKey, query, selection }) =
JSON.writeImpl { query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query JSON.writeImpl { query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query
, databases , databases
, datafield , datafield
, lang: maybe "EN" show lang , lang: maybe "EN" show lang
, node_id: fromMaybe 0 node_id , node_id: fromMaybe 0 node_id
, flowListWith: selection , flowListWith: selection
, pubmedAPIKey
} }
defaultSearchQuery :: SearchQuery defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery defaultSearchQuery = SearchQuery
{ query : "" { query : ""
, databases : Empty , databases : Empty
, datafield : Nothing , datafield : Nothing
, files_id : [] , files_id : []
, lang : Nothing , lang : Nothing
, limit : Nothing , limit : Nothing
, node_id : Nothing , node_id : Nothing
, offset : Nothing , offset : Nothing
, order : Nothing , order : Nothing
, selection : ListSelection.NoList -- MyListsFirst , pubmedAPIKey : Nothing
, selection : ListSelection.NoList -- MyListsFirst
} }
performSearch :: Session -> Int -> SearchQuery -> AffRESTError GT.AsyncTaskWithType performSearch :: Session -> Int -> SearchQuery -> AffRESTError GT.AsyncTaskWithType
......
...@@ -156,6 +156,7 @@ uploadFileViewWithLangsCpt = here.component "uploadFileViewWithLangs" cpt ...@@ -156,6 +156,7 @@ uploadFileViewWithLangsCpt = here.component "uploadFileViewWithLangs" cpt
[ formChoiceSafe { items: [ CSV [ formChoiceSafe { items: [ CSV
, CSV_HAL , CSV_HAL
, WOS , WOS
, JSON
-- , Iramuteq -- , Iramuteq
] ]
, default: CSV , default: CSV
...@@ -585,7 +586,7 @@ uploadFile { contents, fileFormat, lang, fileType, id, nodeType, mName, selectio ...@@ -585,7 +586,7 @@ uploadFile { contents, fileFormat, lang, fileType, id, nodeType, mName, selectio
, Tuple "_wjf_name" mName , Tuple "_wjf_name" mName
] ]
csvBodyParams = [ Tuple "_wtf_data" (Just contents) csvBodyParams = [ Tuple "_wtf_data" (Just contents)
, Tuple "_wtf_filetype" (Just $ show NodeList) , Tuple "_wtf_filetype" (Just $ show fileType)
, Tuple "_wtf_fileformat" (Just $ show fileFormat) , Tuple "_wtf_fileformat" (Just $ show fileFormat)
, Tuple "_wf_lang" (Just $ show lang) , Tuple "_wf_lang" (Just $ show lang)
, Tuple "_wtf_name" mName , Tuple "_wtf_name" mName
......
...@@ -14,7 +14,7 @@ import Gargantext.Components.GraphQL.Contact (AnnuaireContact) ...@@ -14,7 +14,7 @@ import Gargantext.Components.GraphQL.Contact (AnnuaireContact)
import Gargantext.Components.GraphQL.Context as GQLCTX import Gargantext.Components.GraphQL.Context as GQLCTX
import Gargantext.Components.GraphQL.IMT as GQLIMT import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.NLP as GQLNLP import Gargantext.Components.GraphQL.NLP as GQLNLP
import Gargantext.Components.GraphQL.Node (Node) import Gargantext.Components.GraphQL.Node as GQLNode
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel) import Gargantext.Components.GraphQL.Tree (TreeFirstLevel)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM) import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Components.GraphQL.Team (Team, TeamDeleteM) import Gargantext.Components.GraphQL.Team (Team, TeamDeleteM)
...@@ -78,8 +78,9 @@ type Schema ...@@ -78,8 +78,9 @@ type Schema
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String } ==> Array GQLCTX.Context , contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String } ==> Array GQLCTX.Context
, imt_schools :: {} ==> Array GQLIMT.School , imt_schools :: {} ==> Array GQLIMT.School
, languages :: {} ==> Array GQLNLP.Language , languages :: {} ==> Array GQLNLP.Language
, node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType , node_parent :: { node_id :: Int, parent_type :: String } ==> Array GQLNode.Node -- TODO: parent_type :: NodeType
, nodes :: { node_id :: Int } ==> Array Node , nodes :: { node_id :: Int } ==> Array GQLNode.Node
, nodes_corpus :: { corpus_id :: Int } ==> Array GQLNode.Corpus
, user_infos :: { user_id :: Int } ==> Array UserInfo , user_infos :: { user_id :: Int } ==> Array UserInfo
, users :: { user_id :: Int } ==> Array User , users :: { user_id :: Int } ==> Array User
, team :: { team_node_id :: Int } ==> Team , team :: { team_node_id :: Int } ==> Team
......
...@@ -14,7 +14,7 @@ import Gargantext.Components.GraphQL.Contact (AnnuaireContact, annuaireContactQu ...@@ -14,7 +14,7 @@ import Gargantext.Components.GraphQL.Contact (AnnuaireContact, annuaireContactQu
import Gargantext.Components.GraphQL.Context as GQLCTX import Gargantext.Components.GraphQL.Context as GQLCTX
import Gargantext.Components.GraphQL.IMT as GQLIMT import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.NLP as GQLNLP import Gargantext.Components.GraphQL.NLP as GQLNLP
import Gargantext.Components.GraphQL.Node (Node, nodeParentQuery, nodesQuery) import Gargantext.Components.GraphQL.Node (Corpus, Node, nodeParentQuery, nodesQuery, nodesCorpusQuery)
import Gargantext.Components.GraphQL.Team (Team, teamQuery) import Gargantext.Components.GraphQL.Team (Team, teamQuery)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, treeFirstLevelQuery) import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, treeFirstLevelQuery)
import Gargantext.Components.GraphQL.User (UserInfo, userInfoQuery) import Gargantext.Components.GraphQL.User (UserInfo, userInfoQuery)
...@@ -46,6 +46,15 @@ getNode session nodeId = do ...@@ -46,6 +46,15 @@ getNode session nodeId = do
Nothing -> Left (CustomError $ "node with id" <> show nodeId <>" not found") Nothing -> Left (CustomError $ "node with id" <> show nodeId <>" not found")
Just node -> Right node Just node -> Right node
getNodeCorpus :: Session -> Int -> AffRESTError Corpus
getNodeCorpus session corpusId = do
{ nodes_corpus } <- queryGql session "get nodes corpus" $
nodesCorpusQuery `withVars` { id: corpusId }
liftEffect $ here.log2 "[getNodesCorpus] nodes_corpus" nodes_corpus
pure $ case A.head nodes_corpus of
Nothing -> Left (CustomError $ "corpus with id" <> show corpusId <>" not found")
Just corpus -> Right corpus
getNodeParent :: Session -> Int -> NodeType -> Aff (Array Node) getNodeParent :: Session -> Int -> NodeType -> Aff (Array Node)
getNodeParent session nodeId parentType = do getNodeParent session nodeId parentType = do
{ node_parent } <- queryGql session "get node parent" $ { node_parent } <- queryGql session "get node parent" $
......
...@@ -2,18 +2,35 @@ module Gargantext.Components.GraphQL.Node where ...@@ -2,18 +2,35 @@ module Gargantext.Components.GraphQL.Node where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Maybe (Maybe)
import GraphQL.Client.Args (Args, (=>>)) import GraphQL.Client.Args (Args, (=>>))
import GraphQL.Client.Variable (Var(..)) import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..)) import Type.Proxy (Proxy(..))
type Corpus
= { id :: Int
, name :: String
, parent_id :: Int
, pubmedAPIKey :: Maybe String
, type_id :: Int }
type Node type Node
= { id :: Int = { id :: Int
, name :: String , name :: String
, parent_id :: Int , parent_id :: Int
, type_id :: Int } , type_id :: Int }
type NodesCorpusQuery =
{ nodes_corpus :: Args
{ corpus_id :: Var "id" Int }
{ id :: Unit
, name :: Unit
, parent_id :: Unit
, pubmedAPIKey :: Unit
, type_id :: Unit } }
type NodesQuery = type NodesQuery =
{ nodes :: Args { nodes :: Args
{ node_id :: Var "id" Int } { node_id :: Var "id" Int }
...@@ -27,6 +44,11 @@ nodesQuery = { nodes: { node_id: Var :: _ "id" Int } =>> ...@@ -27,6 +44,11 @@ nodesQuery = { nodes: { node_id: Var :: _ "id" Int } =>>
GGQL.getFieldsStandard (Proxy :: _ Node) GGQL.getFieldsStandard (Proxy :: _ Node)
} }
nodesCorpusQuery :: NodesCorpusQuery
nodesCorpusQuery = { nodes_corpus: { corpus_id: Var :: _ "id" Int } =>>
GGQL.getFieldsStandard (Proxy :: _ Corpus)
}
nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
, parent_type: Var :: _ "parent_type" String } =>> -- TODO parent_type :: NodeType , parent_type: Var :: _ "parent_type" String } =>> -- TODO parent_type :: NodeType
GGQL.getFieldsStandard (Proxy :: _ Node) GGQL.getFieldsStandard (Proxy :: _ Node)
......
...@@ -13,6 +13,7 @@ import Gargantext.Prelude ...@@ -13,6 +13,7 @@ import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Array as Array import Data.Array as Array
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (any)
import Data.FunctorWithIndex (mapWithIndex) import Data.FunctorWithIndex (mapWithIndex)
import Data.Lens (to, view, (.~), (^.), (^?)) import Data.Lens (to, view, (.~), (^.), (^?))
import Data.Lens.At (at) import Data.Lens.At (at)
...@@ -47,7 +48,7 @@ import Gargantext.Components.Table.Types (Params, orderByToGTOrderBy) ...@@ -47,7 +48,7 @@ import Gargantext.Components.Table.Types (Params, orderByToGTOrderBy)
import Gargantext.Components.Table.Types as TT import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError)
import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned) import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned)
import Gargantext.Core.NgramsTable.Types (Action(..), CoreAction(..), State, Dispatch, NgramsActionRef, NgramsClick, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTablePatch(..), NgramsTerm(..), PageParams, PatchMap(..), Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, applyPatchSet, ngramsTermText, replace) import Gargantext.Core.NgramsTable.Types (Action(..), CoreAction(..), State, Dispatch, NgramsActionRef, NgramsClick, NgramsElement(..), NgramsPatch(..), NgramsRepoElement(..), NgramsTable, NgramsTablePatch(..), NgramsTerm(..), PageParams, PatchMap(..), Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, applyPatchSet, ngramsTermText, replace)
import Gargantext.Hooks.Loader (useLoaderBox) import Gargantext.Hooks.Loader (useLoaderBox)
import Gargantext.Routes (SessionRoute(..)) as Routes import Gargantext.Routes (SessionRoute(..)) as Routes
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
...@@ -525,7 +526,11 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -525,7 +526,11 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
exactMatches :: Boolean exactMatches :: Boolean
exactMatches = not $ Seq.null $ Seq.filter fltr nres exactMatches = not $ Seq.null $ Seq.filter fltr nres
where where
fltr (Tuple ng _) = queryExactMatchesLabel searchQuery (ngramsTermText ng) -- | Match either ngrams term or its children with the
-- | `queryExactMatchesLabel` function.
fltr :: Tuple NgramsTerm NgramsRepoElement -> Boolean
fltr (Tuple ng (NgramsRepoElement { children })) =
any (queryExactMatchesLabel searchQuery) $ (Set.map ngramsTermText $ Set.insert ng children)
rowsFilter :: NgramsElement -> Maybe NgramsElement rowsFilter :: NgramsElement -> Maybe NgramsElement
rowsFilter ngramsElement = rowsFilter ngramsElement =
if displayRow { ngramsElement if displayRow { ngramsElement
......
...@@ -177,7 +177,7 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt ...@@ -177,7 +177,7 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt
] ]
, ----------------------------------------------------------- , -----------------------------------------------------------
[ LiNav { title : "Chat" [ LiNav { title : "Chat"
, href : "https://chat.iscpif.fr/channel/gargantext" , href : "https://webchat.oftc.net/?channels=#gargantext"
, icon : "fa fa-rocket" , icon : "fa fa-rocket"
, text : "Chat" , text : "Chat"
} }
......
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