Commit e3eb2757 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[rest, search] resterror handler, search fixes

parent 41ecf1e2
Pipeline #1931 failed with stage
...@@ -25,12 +25,12 @@ import Effect.Class (liftEffect) ...@@ -25,12 +25,12 @@ import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Category (rating) import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..)) import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData) import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData, showSource)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types as TextsT import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Table as TT import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..)) import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
...@@ -324,7 +324,7 @@ pageLayoutCpt = here.component "pageLayout" cpt where ...@@ -324,7 +324,7 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, totalRecords = count } , totalRecords = count }
, localCategories , localCategories
, params: paramsS } [] , params: paramsS } []
let errorHandler err = here.log2 "[pageLayout] RESTError" err let errorHandler = logRESTError here "[pageLayout]"
useLoader { errorHandler useLoader { errorHandler
, path: path { params = paramsS' } , path: path { params = paramsS' }
, loader , loader
...@@ -370,8 +370,8 @@ pagePaintCpt = here.component "pagePaintCpt" cpt ...@@ -370,8 +370,8 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
case convOrderBy orderBy of case convOrderBy orderBy of
Just DateAsc -> sortWith \(DocumentsView { date }) -> date Just DateAsc -> sortWith \(DocumentsView { date }) -> date
Just DateDesc -> sortWith \(DocumentsView { date }) -> Down date Just DateDesc -> sortWith \(DocumentsView { date }) -> Down date
Just SourceAsc -> sortWith \(DocumentsView { source }) -> Str.toLower source Just SourceAsc -> sortWith \(DocumentsView { source }) -> Str.toLower $ fromMaybe "" source
Just SourceDesc -> sortWith \(DocumentsView { source }) -> Down $ Str.toLower source Just SourceDesc -> sortWith \(DocumentsView { source }) -> Down $ Str.toLower $ fromMaybe "" source
Just TitleAsc -> sortWith \(DocumentsView { title }) -> Str.toLower title Just TitleAsc -> sortWith \(DocumentsView { title }) -> Str.toLower title
Just TitleDesc -> sortWith \(DocumentsView { title }) -> Down $ Str.toLower title Just TitleDesc -> sortWith \(DocumentsView { title }) -> Down $ Str.toLower title
_ -> identity -- the server ordering is enough here _ -> identity -- the server ordering is enough here
...@@ -452,7 +452,7 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -452,7 +452,7 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
[ H.a { href: url frontends $ corpusDocument r._id, target: "_blank"} [ H.a { href: url frontends $ corpusDocument r._id, target: "_blank"}
[ H.text r.title ] [ H.text r.title ]
] ]
, H.div { className: tClassName } [ H.text $ if r.source == "" then "Source" else r.source ] , H.div { className: tClassName } [ H.text $ showSource r.source ]
, H.div {} [ H.text $ maybe "-" show r.ngramCount ] , H.div {} [ H.text $ maybe "-" show r.ngramCount ]
] ]
, delete: true } , delete: true }
......
module Gargantext.Components.DocsTable.Types where module Gargantext.Components.DocsTable.Types where
import Data.Generic.Rep (class Generic) import Gargantext.Prelude
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Map (Map) import Data.Map (Map)
import Data.Map as Map import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Components.Category.Types (Category, Star(..), decodeStar)
import Simple.JSON as JSON import Simple.JSON as JSON
import Gargantext.Prelude
import Gargantext.Components.Category.Types (Category(..), decodeCategory, Star(..), decodeStar)
data Action data Action
= MarkCategory Int Category = MarkCategory Int Category
...@@ -20,7 +18,7 @@ type DocumentsViewT = ...@@ -20,7 +18,7 @@ type DocumentsViewT =
, date :: Int , date :: Int
, ngramCount :: Maybe Int , ngramCount :: Maybe Int
, score :: Maybe Int , score :: Maybe Int
, source :: String , source :: Maybe String
, title :: String , title :: String
, url :: String , url :: String
) )
...@@ -33,15 +31,21 @@ derive instance Generic DocumentsView _ ...@@ -33,15 +31,21 @@ derive instance Generic DocumentsView _
instance Eq DocumentsView where instance Eq DocumentsView where
eq = genericEq eq = genericEq
showSource :: Maybe String -> String
showSource s = fromMaybe "NOT FOUND" s
instance JSON.ReadForeign DocumentsView where instance JSON.ReadForeign DocumentsView where
readImpl f = do readImpl f = do
{ id, category, date, ngramCount, score, source, title, url } :: { id :: Int | DocumentsViewT } <- JSON.readImpl f { id, category, date, ngramCount, score, source, title, url } :: { id :: Int | DocumentsViewT } <- JSON.readImpl f
let source' = case source of
Just "NOT FOUND" -> Nothing
s -> s
pure $ DocumentsView { _id: id pure $ DocumentsView { _id: id
, category , category
, date , date
, ngramCount , ngramCount
, score , score
, source , source: source'
, title , title
, url } , url }
instance JSON.WriteForeign DocumentsView where instance JSON.WriteForeign DocumentsView where
...@@ -80,7 +84,7 @@ instance JSON.ReadForeign Response where ...@@ -80,7 +84,7 @@ instance JSON.ReadForeign Response where
type HyperdataT = type HyperdataT =
( title :: String ( title :: String
, source :: String ) , source :: Maybe String )
newtype Hyperdata = Hyperdata newtype Hyperdata = Hyperdata
{ pub_year :: Int { pub_year :: Int
| HyperdataT | HyperdataT
...@@ -105,7 +109,7 @@ sampleData' = DocumentsView { _id : 1 ...@@ -105,7 +109,7 @@ sampleData' = DocumentsView { _id : 1
, url : "" , url : ""
, date : 2010 , date : 2010
, title : "title" , title : "title"
, source : "source" , source : Just "source"
, category : Star_1 , category : Star_1
, ngramCount : Just 1 , ngramCount : Just 1
, score: Just 1 } , score: Just 1 }
...@@ -116,7 +120,7 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1 ...@@ -116,7 +120,7 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1
, url : "" , url : ""
, date : 2017 , date : 2017
, title: t , title: t
, source: s , source: Just s
, category : Star_1 , category : Star_1
, ngramCount : Just 10 , ngramCount : Just 10
, score: Just 1 }) sampleDocuments , score: Just 1 }) sampleDocuments
......
...@@ -21,6 +21,7 @@ import Effect.Aff (Aff, launchAff_) ...@@ -21,6 +21,7 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.Category (CategoryQuery(..), putCategories) import Gargantext.Components.Category (CategoryQuery(..), putCategories)
import Gargantext.Components.Category.Types (Category(..), decodeCategory, favCategory) import Gargantext.Components.Category.Types (Category(..), decodeCategory, favCategory)
import Gargantext.Components.DocsTable.Types (showSource)
import Gargantext.Components.Search (Contact(..), Document(..), HyperdataRowContact(..), HyperdataRowDocument(..), SearchQuery, SearchResult(..), SearchResultTypes(..)) import Gargantext.Components.Search (Contact(..), Document(..), HyperdataRowContact(..), HyperdataRowDocument(..), SearchQuery, SearchResult(..), SearchResultTypes(..))
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Components.Table.Types as T import Gargantext.Components.Table.Types as T
...@@ -245,7 +246,7 @@ doc2view ( Document { id ...@@ -245,7 +246,7 @@ doc2view ( Document { id
) = DocumentsView { id ) = DocumentsView { id
, date , date
, title: title , title: title
, source: fromMaybe "Source" source , source: showSource source
, score , score
, authors: fromMaybe "Authors" authors , authors: fromMaybe "Authors" authors
, category: decodeCategory category , category: decodeCategory category
......
...@@ -8,11 +8,6 @@ import Data.Traversable (traverse_) ...@@ -8,11 +8,6 @@ import Data.Traversable (traverse_)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode) import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
...@@ -30,7 +25,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (docume ...@@ -30,7 +25,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (docume
import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView) import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), ID, fTreeID) import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), ID, fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>)) import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>))
...@@ -41,6 +36,10 @@ import Gargantext.Types as GT ...@@ -41,6 +36,10 @@ import Gargantext.Types as GT
import Gargantext.Utils.Popover as Popover import Gargantext.Utils.Popover as Popover
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
foreign import back :: Effect Unit foreign import back :: Effect Unit
foreign import link :: String -> Effect Unit foreign import link :: String -> Effect Unit
...@@ -76,7 +75,7 @@ folderViewCpt = here.component "folderViewCpt" cpt where ...@@ -76,7 +75,7 @@ folderViewCpt = here.component "folderViewCpt" cpt where
, session , session
, setPopoverRef } [] } , setPopoverRef } [] }
where where
errorHandler err = here.log2 "[folderView] RESTError" err errorHandler = logRESTError here "[folderView]"
type FolderViewProps = type FolderViewProps =
( backFolder :: Boolean ( backFolder :: Boolean
......
...@@ -26,7 +26,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile, uploadA ...@@ -26,7 +26,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile, uploadA
import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (documentsFromWriteNodesReq) import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (documentsFromWriteNodesReq)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID) import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
...@@ -122,7 +122,7 @@ treeLoaderCpt = here.component "treeLoader" cpt where ...@@ -122,7 +122,7 @@ treeLoaderCpt = here.component "treeLoader" cpt where
props = Record.merge common extra where props = Record.merge common extra where
common = RecordE.pick p :: Record Common common = RecordE.pick p :: Record Common
extra = { reloadTree: p.reload, root, session, tree: tree' } extra = { reloadTree: p.reload, root, session, tree: tree' }
errorHandler err = here.log2 "[treeLoader] RESTError" err errorHandler = logRESTError here "[treeLoader]"
getNodeTree :: Session -> ID -> Aff (Either RESTError FTree) getNodeTree :: Session -> ID -> Aff (Either RESTError FTree)
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) "" getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
...@@ -216,7 +216,7 @@ childLoaderCpt = here.component "childLoader" cpt where ...@@ -216,7 +216,7 @@ childLoaderCpt = here.component "childLoader" cpt where
, path: cache , path: cache
, render: paint reload } , render: paint reload }
where where
errorHandler err = here.log2 "[childLoader] RESTError" err errorHandler = logRESTError here "[childLoader]"
fetch _ = getNodeTreeFirstLevel p.session p.id fetch _ = getNodeTreeFirstLevel p.session p.id
paint reload tree' = render (Record.merge base extra) where paint reload tree' = render (Record.merge base extra) where
base = nodeProps { reload = reload } base = nodeProps { reload = reload }
......
...@@ -21,6 +21,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.Sync (nodeActionsGraph, node ...@@ -21,6 +21,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.Sync (nodeActionsGraph, node
import Gargantext.Components.GraphExplorer.API as GraphAPI import Gargantext.Components.GraphExplorer.API as GraphAPI
import Gargantext.Components.Lang (Lang(EN)) import Gargantext.Components.Lang (Lang(EN))
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild) import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Config.REST (logRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
...@@ -315,7 +316,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where ...@@ -315,7 +316,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where
, path: id , path: id
, render: \gv -> nodeActionsGraph { graphVersions: gv, session, id, refresh } [] } , render: \gv -> nodeActionsGraph { graphVersions: gv, session, id, refresh } [] }
graphVersions session graphId = GraphAPI.graphVersions { graphId, session } graphVersions session graphId = GraphAPI.graphVersions { graphId, session }
errorHandler err = here.log2 "[graphNodeActions] RESTError" err errorHandler = logRESTError here "[graphNodeActions]"
listNodeActions :: R2.Leaf NodeActionsCommon listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions props = R.createElement listNodeActionsCpt props [] listNodeActions props = R.createElement listNodeActionsCpt props []
...@@ -329,5 +330,5 @@ listNodeActionsCpt = here.component "listNodeActions" cpt where ...@@ -329,5 +330,5 @@ listNodeActionsCpt = here.component "listNodeActions" cpt where
{ listId: id, nodeId: corpusId, session, refresh: refresh { listId: id, nodeId: corpusId, session, refresh: refresh
, nodeType: GT.TabNgramType GT.CTabTerms } } , nodeType: GT.TabNgramType GT.CTabTerms } }
where where
errorHandler err = here.log2 "[listNodeActions] RESTError" err errorHandler = logRESTError here "[listNodeActions]"
...@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Types (Action) ...@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Types (Action)
import Gargantext.Components.Forest.Tree.Node.Tools (nodeText) import Gargantext.Components.Forest.Tree.Node.Tools (nodeText)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..)) import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..), SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..), SubTreeOut(..))
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), get) import Gargantext.Sessions (Session(..), get)
...@@ -75,7 +75,7 @@ subTreeViewCpt = here.component "subTreeView" cpt ...@@ -75,7 +75,7 @@ subTreeViewCpt = here.component "subTreeView" cpt
, tree , tree
} [] } } [] }
where where
errorHandler err = here.log2 "RESTError" err errorHandler = logRESTError here "[subTreeView]"
loadSubTree :: Array GT.NodeType -> Session -> Aff (Either RESTError FTree) loadSubTree :: Array GT.NodeType -> Session -> Aff (Either RESTError FTree)
loadSubTree nodetypes session = getSubTree session treeId nodetypes loadSubTree nodetypes session = getSubTree session treeId nodetypes
......
...@@ -2,6 +2,7 @@ module Gargantext.Components.GraphExplorer where ...@@ -2,6 +2,7 @@ module Gargantext.Components.GraphExplorer where
import Gargantext.Prelude hiding (max, min) import Gargantext.Prelude hiding (max, min)
import DOM.Simple.Types (Element)
import Data.Array as A import Data.Array as A
import Data.Either (Either) import Data.Either (Either)
import Data.FoldableWithIndex (foldMapWithIndex) import Data.FoldableWithIndex (foldMapWithIndex)
...@@ -12,22 +13,13 @@ import Data.Nullable (null, Nullable) ...@@ -12,22 +13,13 @@ import Data.Nullable (null, Nullable)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import DOM.Simple.Types (Element)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Math as Math
import Partial.Unsafe (unsafePartial)
import Reactix as R
import Reactix.DOM.HTML as RH
import Record as Record
import Record.Extra as RX
import Toestand as T
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Graph as Graph import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Controls as Controls import Gargantext.Components.GraphExplorer.Controls as Controls
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Data.Louvain as Louvain import Gargantext.Data.Louvain as Louvain
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
...@@ -37,6 +29,13 @@ import Gargantext.Types as Types ...@@ -37,6 +29,13 @@ import Gargantext.Types as Types
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Math as Math
import Partial.Unsafe (unsafePartial)
import Reactix as R
import Reactix.DOM.HTML as RH
import Record as Record
import Record.Extra as RX
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer" here = R2.here "Gargantext.Components.GraphExplorer"
...@@ -74,7 +73,7 @@ explorerLayoutCpt = here.component "explorerLayout" cpt where ...@@ -74,7 +73,7 @@ explorerLayoutCpt = here.component "explorerLayout" cpt where
, path: graphId , path: graphId
, render: handler } , render: handler }
where where
errorHandler err = here.log2 "[explorerLayout] RESTError" err errorHandler = logRESTError here "[explorerLayout]"
handler loaded@(GET.HyperdataGraph { graph: hyperdataGraph }) = handler loaded@(GET.HyperdataGraph { graph: hyperdataGraph }) =
explorerWriteGraph (Record.merge props { graph, hyperdataGraph: loaded, mMetaData' }) [] explorerWriteGraph (Record.merge props { graph, hyperdataGraph: loaded, mMetaData' }) []
where where
......
...@@ -34,7 +34,7 @@ import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI) ...@@ -34,7 +34,7 @@ import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoaderBox) import Gargantext.Hooks.Loader (useLoaderBox)
import Gargantext.Routes (SessionRoute(..)) as R import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
...@@ -582,7 +582,7 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where ...@@ -582,7 +582,7 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
, renderer: render , renderer: render
} }
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId) versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err errorHandler = logRESTError here "[mainNgramsTable]"
mkRequest :: PageParams -> GUC.Request mkRequest :: PageParams -> GUC.Request
mkRequest path@{ session } = GUC.makeGetRequest session $ url path mkRequest path@{ session } = GUC.makeGetRequest session $ url path
where where
...@@ -616,7 +616,7 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where ...@@ -616,7 +616,7 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
, path , path
, render } , render }
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err errorHandler = logRESTError here "[mainNgramsTable]"
-- NOTE With cache off -- NOTE With cache off
loader :: PageParams -> Aff (Either RESTError VersionedWithCountNgramsTable) loader :: PageParams -> Aff (Either RESTError VersionedWithCountNgramsTable)
......
...@@ -2,29 +2,23 @@ module Gargantext.Components.Nodes.Annuaire ...@@ -2,29 +2,23 @@ module Gargantext.Components.Nodes.Annuaire
-- ( annuaire ) -- ( annuaire )
where where
import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Either (Either) import Data.Either (Either)
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), maybe, fromMaybe) import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
import Gargantext.Components.NgramsTable.Loader (clearCache) import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types as CT import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types as CT
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (defaultContainer, initialParams, makeRow, table, tableHeaderLayout) as TT import Gargantext.Components.Table (defaultContainer, initialParams, makeRow, table, tableHeaderLayout) as TT
import Gargantext.Components.Table.Types (ColumnName(..), Params) as TT import Gargantext.Components.Table.Types (ColumnName(..), Params) as TT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Ends (url, Frontends) import Gargantext.Ends (url, Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
...@@ -32,6 +26,11 @@ import Gargantext.Routes as Routes ...@@ -32,6 +26,11 @@ import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get) import Gargantext.Sessions (Session, sessionId, get)
import Gargantext.Types (NodeType(..), AffETableResult, TableResult) import Gargantext.Types (NodeType(..), AffETableResult, TableResult)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Simple.JSON as JSON
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Annuaire" here = R2.here "Gargantext.Components.Nodes.Annuaire"
...@@ -84,7 +83,7 @@ annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where ...@@ -84,7 +83,7 @@ annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where
, path: path' , path: path'
, render: \info -> annuaire { frontends, info, path, session } } , render: \info -> annuaire { frontends, info, path, session } }
where where
errorHandler err = here.log2 "[annuaireLayoutWithKey] RESTError" err errorHandler = logRESTError here "[annuaireLayoutWithKey]"
type AnnuaireProps = type AnnuaireProps =
( session :: Session ( session :: Session
...@@ -151,7 +150,7 @@ pageLayoutCpt = here.component "pageLayout" cpt ...@@ -151,7 +150,7 @@ pageLayoutCpt = here.component "pageLayout" cpt
, path: pagePath' , path: pagePath'
, render: \table -> page { session, table, frontends, pagePath } } , render: \table -> page { session, table, frontends, pagePath } }
where where
errorHandler err = here.log2 "[pageLayout] RESTError" err errorHandler = logRESTError here "[pageLayout]"
type PageProps = type PageProps =
( session :: Session ( session :: Session
......
...@@ -17,7 +17,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter) ...@@ -17,7 +17,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Lists.Types as LT import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
...@@ -209,7 +209,7 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where ...@@ -209,7 +209,7 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
] ]
} }
where where
errorHandler err = here.log2 "[userLayoutWithKey] RESTError" err errorHandler = logRESTError here "[userLayoutWithKey]"
onUpdateHyperdata :: T2.ReloadS -> HyperdataUser -> Effect Unit onUpdateHyperdata :: T2.ReloadS -> HyperdataUser -> Effect Unit
onUpdateHyperdata reload hd = do onUpdateHyperdata reload hd = do
launchAff_ $ do launchAff_ $ do
......
...@@ -14,7 +14,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter) ...@@ -14,7 +14,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact'(..), ContactData', ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact'(..), ContactData', ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Lists.Types as LT import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude import Gargantext.Prelude
...@@ -191,7 +191,7 @@ contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where ...@@ -191,7 +191,7 @@ contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
, sidePanel: sidePanelTexts , sidePanel: sidePanelTexts
} ] } } ] }
where where
errorHandler err = here.log2 "[contactLayoutWithKey] RESTError" err errorHandler = logRESTError here "[contactLayoutWithKey]"
onUpdateHyperdata :: T2.ReloadS -> HyperdataContact -> Effect Unit onUpdateHyperdata :: T2.ReloadS -> HyperdataContact -> Effect Unit
onUpdateHyperdata reload hd = onUpdateHyperdata reload hd =
launchAff_ $ launchAff_ $
......
...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor, loadCorpusWithReloa ...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor, loadCorpusWithReloa
import Gargantext.Components.Nodes.Corpus.Types (Hyperdata(..)) import Gargantext.Components.Nodes.Corpus.Types (Hyperdata(..))
import Gargantext.Components.Nodes.Types (FTFieldList(..), FTFieldsWithIndex(..), defaultField) import Gargantext.Components.Nodes.Types (FTFieldList(..), FTFieldsWithIndex(..), defaultField)
import Gargantext.Components.TileMenu (tileMenu) import Gargantext.Components.TileMenu (tileMenu)
import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, pure, unit, ($), (<$>), (<>), (==), const) import Gargantext.Prelude (Unit, bind, discard, pure, unit, ($), (<$>), (<>), (==), const)
import Gargantext.Routes as GR import Gargantext.Routes as GR
...@@ -51,7 +52,7 @@ corpusCodeLayoutCpt = here.component "corpusCodeLayout" cpt where ...@@ -51,7 +52,7 @@ corpusCodeLayoutCpt = here.component "corpusCodeLayout" cpt where
, path: { nodeId, reload: reload', session } , path: { nodeId, reload: reload', session }
, render: \corpus -> corpusCodeView { corpus, nodeId, reload, session, boxes } } , render: \corpus -> corpusCodeView { corpus, nodeId, reload, session, boxes } }
where where
errorHandler err = here.log2 "[corpusLayoutWithKey] RESTError" err errorHandler = logRESTError here "[corpusLayoutWithKey]"
corpusCodeView :: Record ViewProps -> R.Element corpusCodeView :: Record ViewProps -> R.Element
corpusCodeView props = R.createElement corpusCodeViewCpt props [] corpusCodeView props = R.createElement corpusCodeViewCpt props []
......
...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor) ...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor)
import Gargantext.Components.Nodes.Corpus.Chart.Predefined as P import Gargantext.Components.Nodes.Corpus.Chart.Predefined as P
import Gargantext.Components.Nodes.Dashboard.Types as DT import Gargantext.Components.Nodes.Dashboard.Types as DT
import Gargantext.Components.Nodes.Types (FTFieldList(..), FTFieldsWithIndex(..), defaultField) import Gargantext.Components.Nodes.Types (FTFieldList(..), FTFieldsWithIndex(..), defaultField)
import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, pure, read, show, unit, ($), (<$>), (<>), (==)) import Gargantext.Prelude (Unit, bind, discard, pure, read, show, unit, ($), (<$>), (<>), (==))
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
...@@ -68,7 +69,7 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt ...@@ -68,7 +69,7 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
, onChange: onChange nodeId reload (DT.Hyperdata h) , onChange: onChange nodeId reload (DT.Hyperdata h)
, session } [] } , session } [] }
where where
errorHandler err = here.log2 "[dashboardLayoutWithKey] RESTError" err errorHandler = logRESTError here "[dashboardLayoutWithKey]"
onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart onChange :: NodeID -> T2.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
, fields :: FTFieldList } -> Effect Unit , fields :: FTFieldList } -> Effect Unit
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
......
...@@ -3,28 +3,24 @@ module Gargantext.Components.Nodes.Corpus.Document where ...@@ -3,28 +3,24 @@ module Gargantext.Components.Nodes.Corpus.Document where
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
import Gargantext.Prelude (bind, pure, show, unit, ($), (<>), (<$>), (<<<))
import Gargantext.Components.AutoUpdate (autoUpdate) import Gargantext.Components.AutoUpdate (autoUpdate)
import Gargantext.Components.Search (SearchType(..)) import Gargantext.Components.NgramsTable.Core (CoreAction(..), Versioned(..), addNewNgramA, applyNgramsPatches, coreDispatch, loadNgramsTable, replace, setTermListA, syncResetButtons, findNgramRoot)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus.Document.Types (DocPath, Document(..), LoadedData, NodeDocument, Props, State, initialState) import Gargantext.Components.Nodes.Corpus.Document.Types (DocPath, Document(..), LoadedData, NodeDocument, Props, State, initialState)
import Gargantext.Components.NgramsTable.Core import Gargantext.Components.Search (SearchType(..))
( CoreAction(..), Versioned(..), addNewNgramA, applyNgramsPatches, coreDispatch, loadNgramsTable import Gargantext.Config.REST (RESTError, logRESTError)
, replace, setTermListA, syncResetButtons, findNgramRoot )
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Config.REST (RESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (bind, pure, show, unit, ($), (<>), (<$>), (<<<))
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, NodeType(..), TabSubType(..), TabType(..), ScoreType(..)) import Gargantext.Types (CTabNgramType(..), ListId, NodeID, NodeType(..), TabSubType(..), TabType(..), ScoreType(..))
import Gargantext.Utils as U import Gargantext.Utils as U
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Document" here = R2.here "Gargantext.Components.Nodes.Corpus.Document"
...@@ -155,7 +151,7 @@ documentLayoutWithKeyCpt = here.component "documentLayoutWithKey" cpt ...@@ -155,7 +151,7 @@ documentLayoutWithKeyCpt = here.component "documentLayoutWithKey" cpt
where where
tabType = TabDocument (TabNgramType CTabTerms) tabType = TabDocument (TabNgramType CTabTerms)
path = { listIds: [listId], mCorpusId, nodeId, session, tabType } path = { listIds: [listId], mCorpusId, nodeId, session, tabType }
errorHandler err = here.log2 "[documentLayoutWithKey] RESTError" err errorHandler = logRESTError here "[documentLayoutWithKey]"
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
module Gargantext.Components.Nodes.File where module Gargantext.Components.Nodes.File where
import Data.Generic.Rep (class Generic) import Gargantext.Prelude
import Data.Either (Either) import Data.Either (Either)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R import Gargantext.Config.REST (RESTError, logRESTError)
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Gargantext.Prelude
import Gargantext.Config.REST (RESTError)
import Gargantext.Ends (toUrl) import Gargantext.Ends (toUrl)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (NodeType(..), NodeID) import Gargantext.Types (NodeType(..), NodeID)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.File" here = R2.here "Gargantext.Components.Nodes.File"
...@@ -60,7 +59,7 @@ fileLayoutCpt = here.component "fileLayout" cpt where ...@@ -60,7 +59,7 @@ fileLayoutCpt = here.component "fileLayout" cpt where
, path: nodeId , path: nodeId
, render: onLoad } , render: onLoad }
where where
errorHandler err = here.log2 "RESTError" err errorHandler = logRESTError here "[fileLayout]"
onLoad loaded = fileLayoutLoaded { loaded, nodeId, session } onLoad loaded = fileLayoutLoaded { loaded, nodeId, session }
loadFile :: Session -> NodeID -> Aff (Either RESTError File) loadFile :: Session -> NodeID -> Aff (Either RESTError File)
......
...@@ -11,15 +11,9 @@ import Data.Newtype (class Newtype) ...@@ -11,15 +11,9 @@ import Data.Newtype (class Newtype)
import Data.Nullable (Nullable, null, toMaybe) import Data.Nullable (Nullable, null, toMaybe)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Web.URL as WURL
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
...@@ -27,6 +21,11 @@ import Gargantext.Types (NodeType(..)) ...@@ -27,6 +21,11 @@ import Gargantext.Types (NodeType(..))
import Gargantext.Utils.JitsiMeet as JM import Gargantext.Utils.JitsiMeet as JM
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Web.URL as WURL
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Frame" here = R2.here "Gargantext.Components.Nodes.Frame"
...@@ -71,7 +70,7 @@ frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where ...@@ -71,7 +70,7 @@ frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where
, path: {nodeId, reload: reload', session} , path: {nodeId, reload: reload', session}
, render: \frame -> frameLayoutView {frame, nodeId, reload, session, nodeType} } , render: \frame -> frameLayoutView {frame, nodeId, reload, session, nodeType} }
where where
errorHandler err = here.log2 "[frameLayoutWithKey] RESTError" err errorHandler = logRESTError here "[frameLayoutWithKey]"
type ViewProps = type ViewProps =
( frame :: NodePoly Hyperdata ( frame :: NodePoly Hyperdata
......
module Gargantext.Components.Nodes.Home.Public where module Gargantext.Components.Nodes.Home.Public where
import Gargantext.Prelude
import Data.Either (Either) import Data.Either (Either)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.String (take) import Data.String (take)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Gargantext.Config (publicBackend) import Gargantext.Config (publicBackend)
import Gargantext.Config.REST (get, RESTError) import Gargantext.Config.REST (RESTError, get, logRESTError)
import Gargantext.Ends (backendUrl) import Gargantext.Ends (backendUrl)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.SimpleJSON as GUSJ import Gargantext.Utils.SimpleJSON as GUSJ
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Home.Public" here = R2.here "Gargantext.Components.Nodes.Home.Public"
...@@ -78,7 +78,7 @@ renderPublicCpt = here.component "renderPublic" cpt where ...@@ -78,7 +78,7 @@ renderPublicCpt = here.component "renderPublic" cpt where
, render: loaded } , render: loaded }
where where
loaded publicData = publicLayout { publicData } loaded publicData = publicLayout { publicData }
errorHandler err = here.log2 "RESTError" err errorHandler = logRESTError here "[renderPublic]"
publicLayout :: Record PublicDataProps -> R.Element publicLayout :: Record PublicDataProps -> R.Element
publicLayout props = R.createElement publicLayoutCpt props [] publicLayout props = R.createElement publicLayoutCpt props []
......
...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus.Types (getCorpusInfo, CorpusInfo(..), ...@@ -12,6 +12,7 @@ import Gargantext.Components.Nodes.Corpus.Types (getCorpusInfo, CorpusInfo(..),
import Gargantext.Components.Nodes.Lists.Tabs as Tabs import Gargantext.Components.Nodes.Lists.Tabs as Tabs
import Gargantext.Components.Nodes.Lists.Types (CacheState(..)) import Gargantext.Components.Nodes.Lists.Types (CacheState(..))
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState) import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -95,7 +96,7 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where ...@@ -95,7 +96,7 @@ listsLayoutWithKeyCpt = here.component "listsLayoutWithKey" cpt where
} }
] } ] }
where where
errorHandler err = here.log2 "[listsLayoutWithKey] RESTError" err errorHandler = logRESTError here "[listsLayoutWithKey]"
afterCacheStateChange cacheState = do afterCacheStateChange cacheState = do
launchAff_ $ clearCache unit launchAff_ $ clearCache unit
sessionUpdate $ setCacheState session nodeId cacheState sessionUpdate $ setCacheState session nodeId cacheState
......
...@@ -22,6 +22,7 @@ import Gargantext.Components.Nodes.Lists.Types as LT ...@@ -22,6 +22,7 @@ import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Components.Nodes.Texts.Types as TT import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Config.REST (logRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (WithSession, Session, getCacheState) import Gargantext.Sessions (WithSession, Session, getCacheState)
...@@ -117,7 +118,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt ...@@ -117,7 +118,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
} }
] } ] }
where where
errorHandler err = here.log2 "[textsLayoutWithKey] RESTError" err errorHandler = logRESTError here "[textsLayoutWithKey]"
afterCacheStateChange cacheState = do afterCacheStateChange cacheState = do
launchAff_ $ clearCache unit launchAff_ $ clearCache unit
-- TODO -- TODO
......
...@@ -14,6 +14,7 @@ import Data.HTTP.Method (Method(..)) ...@@ -14,6 +14,7 @@ import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData) import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData)
import Data.Tuple (Tuple) import Data.Tuple (Tuple)
import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Foreign as Foreign import Foreign as Foreign
...@@ -43,6 +44,11 @@ instance Eq RESTError where ...@@ -43,6 +44,11 @@ instance Eq RESTError where
-- this is crude but we need it only because of useLoader -- this is crude but we need it only because of useLoader
eq _ _ = false eq _ _ = false
logRESTError :: R2.Here -> String -> RESTError -> Effect Unit
logRESTError here prefix (SendResponseError e) = here.log2 (prefix <> " SendResponseError ") e -- TODO: No show
logRESTError here prefix (ReadJSONError e) = here.log2 (prefix <> " ReadJSONError ") $ show e
logRESTError here prefix (CustomError e) = here.log2 (prefix <> " CustomError ") $ e
type AffRESTError a = Aff (Either RESTError a) type AffRESTError a = Aff (Either RESTError a)
......
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