Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
fbaa56ac
Commit
fbaa56ac
authored
Oct 26, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev-doc-table-cache-issue' into dev
parents
d8913830
68ac4a8b
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
678 additions
and
462 deletions
+678
-462
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+140
-76
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+58
-14
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+2
-1
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+10
-4
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+2
-2
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+4
-266
Types.purs
src/Gargantext/Components/Nodes/Corpus/Document/Types.purs
+280
-0
Types.purs
src/Gargantext/Components/Nodes/Corpus/Types.purs
+1
-0
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+7
-3
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+7
-2
Types.purs
src/Gargantext/Components/Nodes/Lists/Types.purs
+3
-0
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+106
-78
Tab.purs
src/Gargantext/Components/Tab.purs
+5
-1
Table.purs
src/Gargantext/Components/Table.purs
+21
-15
QueryString.purs
src/Gargantext/Utils/QueryString.purs
+32
-0
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
fbaa56ac
...
@@ -11,7 +11,7 @@ import Data.Lens.At (at)
...
@@ -11,7 +11,7 @@ import Data.Lens.At (at)
import Data.Lens.Record (prop)
import Data.Lens.Record (prop)
import Data.Map (Map)
import Data.Map (Map)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe, isJust)
import Data.Maybe (Maybe(..), fromMaybe, isJust
, maybe
)
import Data.Ord.Down (Down(..))
import Data.Ord.Down (Down(..))
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
...
@@ -29,46 +29,63 @@ import Reactix.DOM.HTML as H
...
@@ -29,46 +29,63 @@ import Reactix.DOM.HTML as H
------------------------------------------------------------------------
------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.Category
import Gargantext.Components.Category
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Hooks.Loader (useLoader
, useLoader
WithCacheAPI, HashedResponse(..))
import Gargantext.Utils (sortWith)
import Gargantext.Utils (sortWith)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, TabType, showTabType')
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, Tab
SubType(..), Tab
Type, showTabType')
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.DocsTable"
thisModule = "Gargantext.Components.DocsTable"
------------------------------------------------------------------------
------------------------------------------------------------------------
type TotalRecords = Int
type TotalRecords = Int
type LayoutProps =
type Path a = (
( nodeId :: Int
corpusId :: Int
, totalRecords :: Int
, listId :: Int
, frontends :: Frontends
, session :: Session
, tabType :: TabSubType a
)
type LayoutProps = (
cacheState :: R.State NT.CacheState
, corpusId :: Maybe Int
, frontends :: Frontends
, chart :: R.Element
, chart :: R.Element
, tabType :: TabType
, listId :: Int
, listId :: Int
, corpusId :: Maybe Int
, nodeId :: Int
-- , path :: Record (Path a)
, session :: Session
, showSearch :: Boolean
, showSearch :: Boolean
, frontends :: Frontends
, tabType :: TabType
, session :: Session )
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. )
-- ngramtable. Let's see how this evolves. )
type PageLayoutProps =
( nodeId :: Int
, totalRecords :: Int
, totalRecords :: Int
, tabType :: TabType
)
, listId :: Int
type PageLayoutProps = (
cacheState :: R.State NT.CacheState
, corpusId :: Maybe Int
, corpusId :: Maybe Int
, frontends :: Frontends
, key :: String -- NOTE Necessary to clear the component when cache state changes
, listId :: Int
, nodeId :: Int
, params :: T.Params
, query :: Query
, query :: Query
, session :: Session
, session :: Session
, frontends :: Frontends
, tabType :: TabType
, params :: T.Params )
, totalRecords :: Int
)
type LocalCategories = Map Int Category
type LocalCategories = Map Int Category
type Query = String
type Query = String
...
@@ -150,14 +167,13 @@ instance decodeHyperdata :: DecodeJson Hyperdata where
...
@@ -150,14 +167,13 @@ instance decodeHyperdata :: DecodeJson Hyperdata where
instance decodeResponse :: DecodeJson Response where
instance decodeResponse :: DecodeJson Response where
decodeJson json = do
decodeJson json = do
obj <- decodeJson json
obj <- decodeJson json
cid <- obj .: "id"
category <- obj .: "category"
category <- obj .: "category"
ngramCount <- obj .: "id"
cid <- obj .: "id"
title <- obj .: "title"
hyperdata <- obj .: "hyperdata"
hyperdata <- obj .: "hyperdata"
ngramCount <- obj .: "id"
title <- obj .: "title"
pure $ Response { cid, title, category: decodeCategory category, ngramCount, hyperdata }
pure $ Response { cid, title, category: decodeCategory category, ngramCount, hyperdata }
docViewLayout :: Record LayoutProps -> R.Element
docViewLayout :: Record LayoutProps -> R.Element
docViewLayout props = R.createElement docViewLayoutCpt props []
docViewLayout props = R.createElement docViewLayoutCpt props []
...
@@ -167,7 +183,7 @@ docViewLayoutCpt = R.hooksComponentWithModule thisModule "docViewLayout" cpt
...
@@ -167,7 +183,7 @@ docViewLayoutCpt = R.hooksComponentWithModule thisModule "docViewLayout" cpt
cpt layout _children = do
cpt layout _children = do
query <- R.useState' ""
query <- R.useState' ""
let params = T.initialParams
let params = T.initialParams
pure $ docView {
query, params, layout
}
pure $ docView {
layout, params, query
}
type Props = (
type Props = (
layout :: Record LayoutProps
layout :: Record LayoutProps
...
@@ -180,16 +196,29 @@ docView props = R.createElement docViewCpt props []
...
@@ -180,16 +196,29 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: R.Component Props
docViewCpt :: R.Component Props
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
cpt { query, params
cpt { layout: { cacheState
, layout: { frontends, session, nodeId, tabType, listId
, chart
, corpusId, totalRecords, chart, showSearch } } _ = do
, corpusId
, frontends
, listId
, nodeId
, session
, showSearch
, tabType
, totalRecords
}
, params
, query
} _ = do
pure $ H.div {className: "container1"}
pure $ H.div {className: "container1"}
[ R2.row
[ R2.row
[ chart
[ chart
, if showSearch then searchBar query else H.div {} []
, if showSearch then searchBar query else H.div {} []
, H.div {className: "col-md-12"}
, H.div {className: "col-md-12"}
[ pageLayout { corpusId
[ pageLayout { cacheState
, corpusId
, frontends
, frontends
, key: "docView-" <> (show $ fst cacheState)
, listId
, listId
, nodeId
, nodeId
, params
, params
...
@@ -198,20 +227,6 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
...
@@ -198,20 +227,6 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
, tabType
, tabType
, totalRecords
, totalRecords
} ] ] ]
} ] ] ]
-- onClickTrashAll nodeId _ = do
-- launchAff $ deleteAllDocuments p.session nodeId
{-, H.div {className: "col-md-1 col-md-offset-11"}
[ pageLayout p.session params {nodeId, totalRecords, tabType, listId, corpusId, query: fst query} ]
, H.div {className: "col-md-1 col-md-offset-11"}
[ H.button { className: "btn"
, style: {backgroundColor: "peru", color : "white", border : "white"}
, on: { click: onClickTrashAll nodeId } }
[ H.i {className: "glyphitem glyphicon glyphicon-trash"} []
, H.text "Trash all"
]
]
-}
searchBar :: R.State Query -> R.Element
searchBar :: R.State Query -> R.Element
searchBar (query /\ setQuery) = R.createElement el {} []
searchBar (query /\ setQuery) = R.createElement el {} []
...
@@ -302,30 +317,43 @@ pageLayout props = R.createElement pageLayoutCpt props []
...
@@ -302,30 +317,43 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
cpt props@{ corpusId, frontends, listId, nodeId, params, query, session, tabType } _ =
cpt props@{ cacheState, corpusId, frontends, listId, nodeId, params, query, session, tabType } _ = do
useLoaderWithCacheAPI {
let path = { corpusId, listId, nodeId, params, query, tabType }
cacheEndpoint: getPageHash session
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
, handleResponse
handleResponse (HashedResponse { hash, value: res }) = ret
, mkRequest
where
, path
docs = res2corpus <$> filterDocs query res.docs
, renderer: paint
ret = if mock then
}
--Tuple 0 (take limit $ drop offset sampleData)
where
Tuple 0 sampleData
path = { corpusId, listId, nodeId, params, query, tabType }
else
paint (Tuple count docs) = page params (props { totalRecords = count }) docs
Tuple res.count docs
case cacheState of
mkRequest :: PageParams -> GUC.Request
(NT.CacheOn /\ _) -> do
mkRequest p@{ listId, nodeId, tabType } =
let paint (Tuple count docs) = page params (props { totalRecords = count }) docs
GUC.makeGetRequest session $ tableRoute nodeId tabType listId
mkRequest :: PageParams -> GUC.Request
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
mkRequest p@{ listId, nodeId, tabType } =
handleResponse (HashedResponse { hash, value: res }) = ret
GUC.makeGetRequest session $ tableRoute nodeId tabType listId
where
docs = res2corpus <$> filterDocs query res.docs
useLoaderWithCacheAPI {
ret = if mock then
cacheEndpoint: getPageHash session
--Tuple 0 (take limit $ drop offset sampleData)
, handleResponse
Tuple 0 sampleData
, mkRequest
else
, path
Tuple (A.length docs) docs
, renderer: paint
}
(NT.CacheOff /\ _) -> do
localCategories <- R.useState' (mempty :: LocalCategories)
paramsS <- R.useState' params
let loader p@{ listId, nodeId, tabType } = do
res <- get session $ tableRouteWithPage { listId, nodeId, params: fst paramsS, query, tabType }
pure $ handleResponse res
render (Tuple count documents) = pagePaintRaw { documents
, layout: props { params = fst paramsS
, totalRecords = count }
, localCategories
, params: paramsS }
useLoader (path { params = fst paramsS }) loader render
type PageProps = (
type PageProps = (
documents :: Array DocumentsView
documents :: Array DocumentsView
...
@@ -353,8 +381,38 @@ pagePaint props = R.createElement pagePaintCpt props []
...
@@ -353,8 +381,38 @@ pagePaint props = R.createElement pagePaintCpt props []
pagePaintCpt :: R.Component PagePaintProps
pagePaintCpt :: R.Component PagePaintProps
pagePaintCpt = R.hooksComponentWithModule thisModule "pagePaintCpt" cpt where
pagePaintCpt = R.hooksComponentWithModule thisModule "pagePaintCpt" cpt where
cpt {
layout: { corpusId, frontends, listId, nodeId, session, totalRecords }, documents
, params } _ = do
cpt {
documents, layout
, params } _ = do
localCategories <- R.useState' (mempty :: LocalCategories)
localCategories <- R.useState' (mempty :: LocalCategories)
pure $ pagePaintRaw { documents: A.fromFoldable filteredRows, layout, localCategories, params }
where
orderWith =
case convOrderBy (fst params).orderBy of
Just DateAsc -> sortWith \(DocumentsView { date }) -> date
Just DateDesc -> sortWith \(DocumentsView { date }) -> Down date
Just SourceAsc -> sortWith \(DocumentsView { source }) -> Str.toLower source
Just SourceDesc -> sortWith \(DocumentsView { source }) -> Down $ Str.toLower source
Just TitleAsc -> sortWith \(DocumentsView { title }) -> Str.toLower title
Just TitleDesc -> sortWith \(DocumentsView { title }) -> Down $ Str.toLower title
_ -> identity -- the server ordering is enough here
filteredRows = T.filterRows { params: fst params } $ orderWith $ A.toUnfoldable documents
type PagePaintRawProps = (
documents :: Array DocumentsView
, layout :: Record PageLayoutProps
, localCategories :: R.State LocalCategories
, params :: R.State T.Params
)
pagePaintRaw :: Record PagePaintRawProps -> R.Element
pagePaintRaw props = R.createElement pagePaintRawCpt props []
pagePaintRawCpt :: R.Component PagePaintRawProps
pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt where
cpt { documents
, layout: { corpusId, frontends, listId, nodeId, session, totalRecords }
, localCategories
, params } _ = do
pure $ T.table
pure $ T.table
{ colNames
{ colNames
, container: T.defaultContainer { title: "Documents" }
, container: T.defaultContainer { title: "Documents" }
...
@@ -375,17 +433,7 @@ pagePaintCpt = R.hooksComponentWithModule thisModule "pagePaintCpt" cpt where
...
@@ -375,17 +433,7 @@ pagePaintCpt = R.hooksComponentWithModule thisModule "pagePaintCpt" cpt where
colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"]
colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"]
wrapColElts = const identity
wrapColElts = const identity
getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id)
getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id)
orderWith =
rows localCategories = row <$> A.toUnfoldable documents
case convOrderBy (fst params).orderBy of
Just DateAsc -> sortWith \(DocumentsView { date }) -> date
Just DateDesc -> sortWith \(DocumentsView { date }) -> Down date
Just SourceAsc -> sortWith \(DocumentsView { source }) -> Str.toLower source
Just SourceDesc -> sortWith \(DocumentsView { source }) -> Down $ Str.toLower source
Just TitleAsc -> sortWith \(DocumentsView { title }) -> Str.toLower title
Just TitleDesc -> sortWith \(DocumentsView { title }) -> Down $ Str.toLower title
_ -> identity -- the server ordering is enough here
filteredRows = T.filterRows { params: fst params } $ orderWith $ A.toUnfoldable documents
rows localCategories = row <$> filteredRows
where
where
row (DocumentsView r) =
row (DocumentsView r) =
{ row:
{ row:
...
@@ -451,6 +499,22 @@ tableRoute nodeId tabType listId = NodeAPI Node (Just nodeId) $ "table" <> "?tab
...
@@ -451,6 +499,22 @@ tableRoute nodeId tabType listId = NodeAPI Node (Just nodeId) $ "table" <> "?tab
tableHashRoute :: Int -> TabType -> SessionRoute
tableHashRoute :: Int -> TabType -> SessionRoute
tableHashRoute nodeId tabType = NodeAPI Node (Just nodeId) $ "table/hash" <> "?tabType=" <> (showTabType' tabType)
tableHashRoute nodeId tabType = NodeAPI Node (Just nodeId) $ "table/hash" <> "?tabType=" <> (showTabType' tabType)
tableRouteWithPage :: { listId :: Int
, nodeId :: Int
, params :: T.Params
, query :: Query
, tabType :: TabType } -> SessionRoute
tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchType }, query, tabType } =
NodeAPI Node (Just nodeId) $ "table" <> joinQueryStrings [tt, lst, lmt, odb, ofs, st, q]
where
lmt = queryParam "limit" limit
lst = queryParam "list" listId
ofs = queryParam "offset" offset
odb = mQueryParamS "orderBy" T.orderByToForm orderBy
st = queryParam "searchType" searchType
tt = queryParamS "tabType" (showTabType' tabType)
q = queryParamS "query" query
deleteAllDocuments :: Session -> Int -> Aff (Array Int)
deleteAllDocuments :: Session -> Int -> Aff (Array Int)
deleteAllDocuments session = delete session <<< documentsRoute
deleteAllDocuments session = delete session <<< documentsRoute
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
fbaa56ac
...
@@ -20,7 +20,7 @@ import Data.Sequence as Seq
...
@@ -20,7 +20,7 @@ import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..)
, fst
)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log)
import DOM.Simple.Console (log)
import Effect (Effect)
import Effect (Effect)
...
@@ -544,12 +544,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
...
@@ -544,12 +544,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, tabNgramType
, tabNgramType
, tabType
, tabType
, withAutoUpdate } _ = do
, withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync, path, tabNgramType, versioned, withAutoUpdate }
case cacheState of
case cacheState of
(NT.CacheOn /\ _) ->
(NT.CacheOn /\ _) -> do
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync, path, tabNgramType, versioned, withAutoUpdate }
useLoaderWithCacheAPI {
useLoaderWithCacheAPI {
cacheEndpoint: versionEndpoint props
cacheEndpoint: versionEndpoint props
, handleResponse
, handleResponse
...
@@ -557,16 +556,39 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
...
@@ -557,16 +556,39 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, path
, path
, renderer: render
, renderer: render
}
}
(NT.CacheOff /\ _) ->
(NT.CacheOff /\ _) -> do
useLoader path loader render
path <- R.useState' $ initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaintWithState { afterSync, path, tabNgramType, versioned, withAutoUpdate }
useLoader (fst path) loader render
versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
-- NOTE With cache off
loader :: PageParams -> Aff VersionedNgramsTable
loader :: PageParams -> Aff VersionedNgramsTable
loader path@{ listIds, nodeId, session, tabType } =
loader path@{ listIds
get session $ R.GetNgramsTableAll { listIds, tabType } (Just nodeId)
, nodeId
, params: { limit, offset, orderBy }
, searchQuery
, session
, tabType
, termListFilter
, termSizeFilter
} =
get session $ R.GetNgrams params (Just nodeId)
where
params = { limit
, listIds
, offset: Just offset
, orderBy: Nothing -- TODO
, searchQuery
, tabType
, termListFilter
, termSizeFilter
}
-- NOTE With cache on
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
...
@@ -584,10 +606,6 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
...
@@ -584,10 +606,6 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
handleResponse v = v
handleResponse v = v
pathNoLimit :: PageParams -> PageParams
pathNoLimit path@{ params } = path { params = params { limit = 100000 }
, termListFilter = Nothing }
type MainNgramsTablePaintProps =
type MainNgramsTablePaintProps =
( afterSync :: Unit -> Aff Unit
( afterSync :: Unit -> Aff Unit
, path :: PageParams
, path :: PageParams
...
@@ -615,6 +633,32 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
...
@@ -615,6 +633,32 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
, withAutoUpdate
, withAutoUpdate
}
}
type MainNgramsTablePaintWithStateProps =
( afterSync :: Unit -> Aff Unit
, path :: R.State PageParams
, tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element
mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p []
mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
where
cpt { afterSync, path, tabNgramType, versioned, withAutoUpdate } _ = do
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
afterSync
, path
, state
, tabNgramType
, versioned
, withAutoUpdate
}
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
ngramsElementToNgramsOcc :: NgramsElement -> NgramsOcc
ngramsElementToNgramsOcc :: NgramsElement -> NgramsOcc
...
...
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
fbaa56ac
...
@@ -91,13 +91,14 @@ annuaireCpt = R.hooksComponentWithModule thisModule "annuaire" cpt
...
@@ -91,13 +91,14 @@ annuaireCpt = R.hooksComponentWithModule thisModule "annuaire" cpt
cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ = do
cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ = do
pagePath <- R.useState' $ initialPagePath (fst path)
pagePath <- R.useState' $ initialPagePath (fst path)
cacheState <- R.useState' NT.CacheO
n
cacheState <- R.useState' NT.CacheO
ff
pure $ R.fragment
pure $ R.fragment
[ T.tableHeaderLayout { afterCacheStateChange: \_ -> launchAff_ $ clearCache unit
[ T.tableHeaderLayout { afterCacheStateChange: \_ -> launchAff_ $ clearCache unit
, cacheState
, cacheState
, date
, date
, desc: name
, desc: name
, key: "annuaire-" <> (show $ fst cacheState)
, query: ""
, query: ""
, title: name
, title: name
, user: "" }
, user: "" }
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
fbaa56ac
...
@@ -76,11 +76,17 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
...
@@ -76,11 +76,17 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
chart = mempty
chart = mempty
totalRecords = 4736 -- TODO
totalRecords = 4736 -- TODO
docs = DT.docViewLayout
docs = DT.docViewLayout
{ frontends, session, nodeId, chart, totalRecords
{ cacheState
, tabType: TabPairing TabDocs
, chart
, listId: defaultListId
, corpusId: Nothing
, corpusId: Nothing
, showSearch: true }
, frontends
, listId: defaultListId
, nodeId
, session
, showSearch: true
, tabType: TabPairing TabDocs
, totalRecords
}
type NgramsViewTabsProps =
type NgramsViewTabsProps =
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
fbaa56ac
...
@@ -427,7 +427,7 @@ loadCorpus {nodeId, session} = do
...
@@ -427,7 +427,7 @@ loadCorpus {nodeId, session} = do
loadCorpusWithChild :: Record LoadProps -> Aff CorpusData
loadCorpusWithChild :: Record LoadProps -> Aff CorpusData
loadCorpusWithChild {
nodeId:childId, session
} = do
loadCorpusWithChild {
nodeId: childId, session
} = do
-- fetch corpus via lists parentId
-- fetch corpus via lists parentId
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session $ listNodeRoute childId ""
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session $ listNodeRoute childId ""
corpusNode <- get session $ corpusNodeRoute corpusId ""
corpusNode <- get session $ corpusNodeRoute corpusId ""
...
@@ -435,7 +435,7 @@ loadCorpusWithChild {nodeId:childId, session} = do
...
@@ -435,7 +435,7 @@ loadCorpusWithChild {nodeId:childId, session} = do
:: forall a. DecodeJson a => AffTableResult (NodePoly a)
:: forall a. DecodeJson a => AffTableResult (NodePoly a)
case (A.head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
case (A.head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
Just (NodePoly { id: defaultListId }) ->
pure {
corpusId, corpusNode, defaultListId
}
pure {
corpusId, corpusNode, defaultListId
}
Nothing ->
Nothing ->
throwError $ error "Missing default list"
throwError $ error "Missing default list"
where
where
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
fbaa56ac
...
@@ -13,9 +13,10 @@ import Reactix.DOM.HTML as H
...
@@ -13,9 +13,10 @@ import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.AutoUpdate (
autoUpdate)
import Gargantext.Components.AutoUpdate (autoUpdate)
import Gargantext.Components.Search (SearchType(..))
import Gargantext.Components.Search (SearchType(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus.Document.Types
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Core
( CoreState, NgramsPatch(..), NgramsTerm, Replace, Versioned(..)
( CoreState, NgramsPatch(..), NgramsTerm, Replace, Versioned(..)
, VersionedNgramsTable, addNewNgram, applyNgramsPatches, commitPatch
, VersionedNgramsTable, addNewNgram, applyNgramsPatches, commitPatch
...
@@ -24,282 +25,19 @@ import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
...
@@ -24,282 +25,19 @@ import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (CTabNgramType(..), NodeType(..), TabSubType(..), TabType(..),
TermList,
ScoreType(..))
import Gargantext.Types (CTabNgramType(..), 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
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus.Document"
thisModule = "Gargantext.Components.Nodes.Corpus.Document"
type DocPath =
{
corpusId :: Maybe Int
, listIds :: Array Int
, nodeId :: Int
, session :: Session
, tabType :: TabType
}
type NodeDocument = NodePoly Document
type LoadedData =
{ document :: NodeDocument
, ngramsTable :: VersionedNgramsTable
}
type Props = (
loaded :: LoadedData
, path :: DocPath
)
-- This is a subpart of NgramsTable.State.
type State = CoreState ()
initialState
:: forall props others
. { loaded :: { ngramsTable :: VersionedNgramsTable | others }
| props }
-> State
initialState {loaded: {ngramsTable: Versioned {version}}} =
{ ngramsLocalPatch: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: version
}
-- This is a subset of NgramsTable.Action.
data Action
= SetTermListItem NgramsTerm (Replace TermList)
| AddNewNgram NgramsTerm TermList
| Synchronize
newtype Status = Status { failed :: Int
, succeeded :: Int
, remaining :: Int
}
newtype DocumentV3 =
DocumentV3 { abstract :: Maybe String
, authors :: Maybe String
--, error :: Maybe String
, language_iso2 :: Maybe String
, language_iso3 :: Maybe String
, language_name :: Maybe String
, publication_date :: Maybe String
, publication_day :: Maybe Int
, publication_hour :: Maybe Int
, publication_minute :: Maybe Int
, publication_month :: Maybe Int
, publication_second :: Maybe Int
, publication_year :: Maybe Int
, realdate_full_ :: Maybe String
, source :: Maybe String
, statuses :: Maybe (Array Status)
, title :: Maybe String
}
defaultNodeDocumentV3 :: NodePoly DocumentV3
defaultNodeDocumentV3 =
NodePoly { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : "Default name"
, date : "Default date"
, hyperdata : defaultDocumentV3
}
defaultDocumentV3 :: DocumentV3
defaultDocumentV3 =
DocumentV3 { abstract : Nothing
, authors : Nothing
--, error : Nothing
, language_iso2 : Nothing
, language_iso3 : Nothing
, language_name : Nothing
, publication_date : Nothing
, publication_day : Nothing
, publication_hour : Nothing
, publication_minute : Nothing
, publication_month : Nothing
, publication_second : Nothing
, publication_year : Nothing
, realdate_full_ : Nothing
, source : Nothing
, statuses : Nothing
, title : Nothing
}
data Document
= Document
{ abstract :: Maybe String
, authors :: Maybe String
, bdd :: Maybe String
, doi :: Maybe String
, language_iso2 :: Maybe String
-- , page :: Maybe Int
, publication_date :: Maybe String
--, publication_second :: Maybe Int
--, publication_minute :: Maybe Int
--, publication_hour :: Maybe Int
, publication_day :: Maybe Int
, publication_month :: Maybe Int
, publication_year :: Maybe Int
, source :: Maybe String
, institutes :: Maybe String
, title :: Maybe String
, uniqId :: Maybe String
--, url :: Maybe String
--, text :: Maybe String
}
publicationDate :: Document -> String
publicationDate :: Document -> String
publicationDate (Document doc@{publication_year: Nothing}) = ""
publicationDate (Document doc@{publication_year: Nothing}) = ""
publicationDate (Document doc@{publication_year: Just py, publication_month: Nothing}) = U.zeroPad 2 py
publicationDate (Document doc@{publication_year: Just py, publication_month: Nothing}) = U.zeroPad 2 py
publicationDate (Document doc@{publication_year: Just py, publication_month: Just pm, publication_day: Nothing}) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm)
publicationDate (Document doc@{publication_year: Just py, publication_month: Just pm, publication_day: Nothing}) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm)
publicationDate (Document doc@{publication_year: Just py, publication_month: Just pm, publication_day: Just pd}) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm) <> "-" <> (U.zeroPad 2 pd)
publicationDate (Document doc@{publication_year: Just py, publication_month: Just pm, publication_day: Just pd}) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm) <> "-" <> (U.zeroPad 2 pd)
defaultNodeDocument :: NodeDocument
defaultNodeDocument =
NodePoly { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : "Default name"
, date : "Default date"
, hyperdata : defaultDocument
}
-- TODO: BUG if DOI does not exist, page is not shown
defaultDocument :: Document
defaultDocument =
Document { abstract : Nothing
, authors : Nothing
, bdd : Nothing
, doi : Nothing
, language_iso2 : Nothing
--, page : Nothing
, publication_date : Nothing
--, publication_second : Nothing
--, publication_minute : Nothing
--, publication_hour : Nothing
, publication_day : Nothing
, publication_month : Nothing
, publication_year : Nothing
, source : Nothing
, institutes : Nothing
, title : Nothing
, uniqId : Nothing
--, url : Nothing
--, text : Nothing
}
derive instance genericDocument :: Generic Document _
derive instance genericDocumentV3 :: Generic DocumentV3 _
derive instance genericStatus :: Generic Status _
instance showDocument :: Show Document where
show = genericShow
instance showDocumentV3 :: Show DocumentV3 where
show = genericShow
instance showStatus :: Show Status where
show = genericShow
instance decodeStatus :: DecodeJson Status
where
decodeJson json = do
obj <- decodeJson json
failed <- obj .: "failed"
succeeded <- obj .: "succeeded"
remaining <- obj .: "remaining"
pure $ Status {failed, succeeded, remaining}
instance decodeDocumentV3 :: DecodeJson DocumentV3
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .:? "abstract"
authors <- obj .: "authors"
--error <- obj .: "error"
language_iso2 <- obj .: "language_iso2"
language_iso3 <- obj .: "language_iso3"
language_name <- obj .: "language_name"
publication_date <- obj .: "publication_date"
publication_day <- obj .: "publication_day"
publication_hour <- obj .: "publication_hour"
publication_minute <- obj .: "publication_minute"
publication_month <- obj .: "publication_month"
publication_second <- obj .: "publication_second"
publication_year <- obj .: "publication_year"
realdate_full_ <- obj .: "realdate_full_"
source <- obj .: "source"
statuses <- obj .: "statuses"
title <- obj .: "title"
pure $ DocumentV3 { abstract
, authors
--, error
, language_iso2
, language_iso3
, language_name
, publication_date
, publication_day
, publication_hour
, publication_minute
, publication_month
, publication_second
, publication_year
, realdate_full_
, source
, statuses
, title
}
instance decodeDocument :: DecodeJson Document
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .:? "abstract"
authors <- obj .:? "authors"
bdd <- obj .:? "bdd"
doi <- obj .:? "doi"
language_iso2 <- obj .:? "language_iso2"
-- page <- obj .:? "page"
publication_date <- obj .:? "publication_date"
--publication_second <- obj .:? "publication_second"
--publication_minute <- obj .:? "publication_minute"
--publication_hour <- obj .:? "publication_hour"
publication_day <- obj .:? "publication_day"
publication_month <- obj .:? "publication_month"
publication_year <- obj .:? "publication_year"
source <- obj .:? "sources"
institutes <- obj .:? "institutes"
title <- obj .:? "title"
uniqId <- obj .:? "uniqId"
--url <- obj .: "url"
--text <- obj .: "text"
pure $ Document { abstract
, authors
, bdd
, doi
, language_iso2
-- , page
, publication_date
--, publication_second
--, publication_minute
--, publication_hour
, publication_day
, publication_month
, publication_year
, source
, institutes
, title
, uniqId
--, url
--, text
}
docViewWrapper :: Record Props -> R.Element
docViewWrapper :: Record Props -> R.Element
docViewWrapper props = R.createElement docViewWrapperCpt props []
docViewWrapper props = R.createElement docViewWrapperCpt props []
...
...
src/Gargantext/Components/Nodes/Corpus/Document/Types.purs
0 → 100644
View file @
fbaa56ac
module Gargantext.Components.Nodes.Corpus.Document.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable.Core
(CoreState, NgramsTerm, Replace, Versioned(..) , VersionedNgramsTable)
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType, TermList)
type DocPath =
{
corpusId :: Maybe Int
, listIds :: Array Int
, nodeId :: Int
, session :: Session
, tabType :: TabType
}
type NodeDocument = NodePoly Document
type LoadedData =
{ document :: NodeDocument
, ngramsTable :: VersionedNgramsTable
}
type Props = (
loaded :: LoadedData
, path :: DocPath
)
-- This is a subpart of NgramsTable.State.
type State = CoreState ()
initialState
:: forall props others
. { loaded :: { ngramsTable :: VersionedNgramsTable | others }
| props }
-> State
initialState {loaded: {ngramsTable: Versioned {version}}} =
{ ngramsLocalPatch: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: version
}
-- This is a subset of NgramsTable.Action.
data Action
= SetTermListItem NgramsTerm (Replace TermList)
| AddNewNgram NgramsTerm TermList
| Synchronize
newtype Status = Status { failed :: Int
, succeeded :: Int
, remaining :: Int
}
newtype DocumentV3 =
DocumentV3 { abstract :: Maybe String
, authors :: Maybe String
--, error :: Maybe String
, language_iso2 :: Maybe String
, language_iso3 :: Maybe String
, language_name :: Maybe String
, publication_date :: Maybe String
, publication_day :: Maybe Int
, publication_hour :: Maybe Int
, publication_minute :: Maybe Int
, publication_month :: Maybe Int
, publication_second :: Maybe Int
, publication_year :: Maybe Int
, realdate_full_ :: Maybe String
, source :: Maybe String
, statuses :: Maybe (Array Status)
, title :: Maybe String
}
defaultNodeDocumentV3 :: NodePoly DocumentV3
defaultNodeDocumentV3 =
NodePoly { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : "Default name"
, date : "Default date"
, hyperdata : defaultDocumentV3
}
defaultDocumentV3 :: DocumentV3
defaultDocumentV3 =
DocumentV3 { abstract : Nothing
, authors : Nothing
--, error : Nothing
, language_iso2 : Nothing
, language_iso3 : Nothing
, language_name : Nothing
, publication_date : Nothing
, publication_day : Nothing
, publication_hour : Nothing
, publication_minute : Nothing
, publication_month : Nothing
, publication_second : Nothing
, publication_year : Nothing
, realdate_full_ : Nothing
, source : Nothing
, statuses : Nothing
, title : Nothing
}
data Document
= Document
{ abstract :: Maybe String
, authors :: Maybe String
, bdd :: Maybe String
, doi :: Maybe String
, language_iso2 :: Maybe String
-- , page :: Maybe Int
, publication_date :: Maybe String
--, publication_second :: Maybe Int
--, publication_minute :: Maybe Int
--, publication_hour :: Maybe Int
, publication_day :: Maybe Int
, publication_month :: Maybe Int
, publication_year :: Maybe Int
, source :: Maybe String
, institutes :: Maybe String
, title :: Maybe String
, uniqId :: Maybe String
--, url :: Maybe String
--, text :: Maybe String
}
defaultNodeDocument :: NodeDocument
defaultNodeDocument =
NodePoly { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : "Default name"
, date : "Default date"
, hyperdata : defaultDocument
}
-- TODO: BUG if DOI does not exist, page is not shown
defaultDocument :: Document
defaultDocument =
Document { abstract : Nothing
, authors : Nothing
, bdd : Nothing
, doi : Nothing
, language_iso2 : Nothing
--, page : Nothing
, publication_date : Nothing
--, publication_second : Nothing
--, publication_minute : Nothing
--, publication_hour : Nothing
, publication_day : Nothing
, publication_month : Nothing
, publication_year : Nothing
, source : Nothing
, institutes : Nothing
, title : Nothing
, uniqId : Nothing
--, url : Nothing
--, text : Nothing
}
derive instance genericDocument :: Generic Document _
derive instance genericDocumentV3 :: Generic DocumentV3 _
derive instance genericStatus :: Generic Status _
instance showDocument :: Show Document where
show = genericShow
instance showDocumentV3 :: Show DocumentV3 where
show = genericShow
instance showStatus :: Show Status where
show = genericShow
instance decodeStatus :: DecodeJson Status
where
decodeJson json = do
obj <- decodeJson json
failed <- obj .: "failed"
succeeded <- obj .: "succeeded"
remaining <- obj .: "remaining"
pure $ Status {failed, succeeded, remaining}
instance decodeDocumentV3 :: DecodeJson DocumentV3
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .:? "abstract"
authors <- obj .: "authors"
--error <- obj .: "error"
language_iso2 <- obj .: "language_iso2"
language_iso3 <- obj .: "language_iso3"
language_name <- obj .: "language_name"
publication_date <- obj .: "publication_date"
publication_day <- obj .: "publication_day"
publication_hour <- obj .: "publication_hour"
publication_minute <- obj .: "publication_minute"
publication_month <- obj .: "publication_month"
publication_second <- obj .: "publication_second"
publication_year <- obj .: "publication_year"
realdate_full_ <- obj .: "realdate_full_"
source <- obj .: "source"
statuses <- obj .: "statuses"
title <- obj .: "title"
pure $ DocumentV3 { abstract
, authors
--, error
, language_iso2
, language_iso3
, language_name
, publication_date
, publication_day
, publication_hour
, publication_minute
, publication_month
, publication_second
, publication_year
, realdate_full_
, source
, statuses
, title
}
instance decodeDocument :: DecodeJson Document
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .:? "abstract"
authors <- obj .:? "authors"
bdd <- obj .:? "bdd"
doi <- obj .:? "doi"
language_iso2 <- obj .:? "language_iso2"
-- page <- obj .:? "page"
publication_date <- obj .:? "publication_date"
--publication_second <- obj .:? "publication_second"
--publication_minute <- obj .:? "publication_minute"
--publication_hour <- obj .:? "publication_hour"
publication_day <- obj .:? "publication_day"
publication_month <- obj .:? "publication_month"
publication_year <- obj .:? "publication_year"
source <- obj .:? "sources"
institutes <- obj .:? "institutes"
title <- obj .:? "title"
uniqId <- obj .:? "uniqId"
--url <- obj .: "url"
--text <- obj .: "text"
pure $ Document { abstract
, authors
, bdd
, doi
, language_iso2
-- , page
, publication_date
--, publication_second
--, publication_minute
--, publication_hour
, publication_day
, publication_month
, publication_year
, source
, institutes
, title
, uniqId
--, url
--, text
}
src/Gargantext/Components/Nodes/Corpus/Types.purs
View file @
fbaa56ac
...
@@ -8,6 +8,7 @@ import Data.Generic.Rep (class Generic)
...
@@ -8,6 +8,7 @@ import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.Node (NodePoly)
import Gargantext.Prelude
import Gargantext.Prelude
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
fbaa56ac
module Gargantext.Components.Nodes.Lists where
module Gargantext.Components.Nodes.Lists where
import Data.Tuple (fst)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Reactix as R
import Reactix as R
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -15,6 +16,7 @@ import Gargantext.Prelude
...
@@ -15,6 +16,7 @@ import Gargantext.Prelude
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists"
thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -53,15 +55,16 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
...
@@ -53,15 +55,16 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
useLoader path loadCorpusWithChild $
useLoader path loadCorpusWithChild $
\corpusData@{ corpusId, corpusNode: NodePoly poly, defaultListId } ->
\corpusData@{ corpusId, corpusNode: NodePoly poly, defaultListId } ->
let { date, hyperdata : Hyperdata h, name } = poly
let { date, hyperdata : Hyperdata h, name } = poly
CorpusInfo {desc,query,authors
} = getCorpusInfo h.fields
CorpusInfo { authors, desc, query
} = getCorpusInfo h.fields
in
in
R.fragment [
R.fragment [
Table.tableHeaderLayout {
Table.tableHeaderLayout {
afterCacheStateChange: \_ -> launchAff_ $ clearCache unit
afterCacheStateChange: \_ -> launchAff_ $ clearCache unit
, cacheState
, cacheState
, date
, date
, desc
, desc
, key: "listsLayoutWithKey-header-" <> (show $ fst cacheState)
, query
, query
, title: "Corpus " <> name
, title: "Corpus " <> name
, user: authors }
, user: authors }
...
@@ -69,6 +72,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
...
@@ -69,6 +72,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
cacheState
cacheState
, corpusData
, corpusData
, corpusId
, corpusId
, key: "listsLayoutWithKey-tabs-" <> (show $ fst cacheState)
, session }
, session }
]
]
------------------------------------------------------------------------
------------------------------------------------------------------------
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
fbaa56ac
...
@@ -33,10 +33,15 @@ type Props = ( cacheState :: R.State NTypes.CacheState
...
@@ -33,10 +33,15 @@ type Props = ( cacheState :: R.State NTypes.CacheState
, session :: Session
, session :: Session
)
)
tabs :: Record Props -> R.Element
type PropsWithKey = (
key :: String
| Props
)
tabs :: Record PropsWithKey -> R.Element
tabs props = R.createElement tabsCpt props []
tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component Props
tabsCpt :: R.Component Props
WithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
where
cpt { cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do
cpt { cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do
...
...
src/Gargantext/Components/Nodes/Lists/Types.purs
View file @
fbaa56ac
...
@@ -2,6 +2,7 @@ module Gargantext.Components.Nodes.Lists.Types where
...
@@ -2,6 +2,7 @@ module Gargantext.Components.Nodes.Lists.Types where
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Gargantext.Prelude
import Gargantext.Prelude
...
@@ -12,3 +13,5 @@ data CacheState = CacheOn | CacheOff
...
@@ -12,3 +13,5 @@ data CacheState = CacheOn | CacheOff
derive instance genericCacheState :: Generic CacheState _
derive instance genericCacheState :: Generic CacheState _
instance eqCacheState :: Eq CacheState where
instance eqCacheState :: Eq CacheState where
eq = genericEq
eq = genericEq
instance showCacheState :: Show CacheState where
show = genericShow
src/Gargantext/Components/Nodes/Texts.purs
View file @
fbaa56ac
...
@@ -4,6 +4,7 @@ import Prelude
...
@@ -4,6 +4,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Reactix as R
import Reactix as R
...
@@ -56,13 +57,12 @@ textsLayoutWithKeyCpt :: R.Component KeyProps
...
@@ -56,13 +57,12 @@ textsLayoutWithKeyCpt :: R.Component KeyProps
textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKey" cpt
textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKey" cpt
where
where
cpt { frontends, nodeId, session } _ = do
cpt { frontends, nodeId, session } _ = do
cacheState <- R.useState' NT.CacheO
n
cacheState <- R.useState' NT.CacheO
ff
pure $ loader {session, nodeId} loadCorpusWithChild $
pure $ loader {session, nodeId} loadCorpusWithChild $
\corpusData@{ corpusId, corpusNode, defaultListId } -> do
\corpusData@{ corpusId, corpusNode, defaultListId } -> do
let NodePoly {
name, date, hyperdata: Hyperdata h
} = corpusNode
let NodePoly {
date, hyperdata: Hyperdata h, name
} = corpusNode
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
tabs' = tabs { corpusData, corpusId, frontends, session }
title = "Corpus " <> name
title = "Corpus " <> name
R.fragment [
R.fragment [
...
@@ -70,10 +70,11 @@ textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKe
...
@@ -70,10 +70,11 @@ textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKe
, cacheState
, cacheState
, date
, date
, desc
, desc
, key: "textsLayoutWithKey-" <> (show $ fst cacheState)
, query
, query
, title
, title
, user: authors }
, user: authors }
, tabs
'
, tabs
{ cacheState, corpusData, corpusId, frontends, session }
]
]
data Mode = MoreLikeFav | MoreLikeTrash
data Mode = MoreLikeFav | MoreLikeTrash
...
@@ -89,7 +90,13 @@ modeTabType :: Mode -> CTabNgramType
...
@@ -89,7 +90,13 @@ modeTabType :: Mode -> CTabNgramType
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
type TabsProps = ( frontends :: Frontends, session :: Session, corpusId :: Int, corpusData :: CorpusData )
type TabsProps = (
cacheState :: R.State NT.CacheState
, corpusData :: CorpusData
, corpusId :: Int
, frontends :: Frontends
, session :: Session
)
tabs :: Record TabsProps -> R.Element
tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props []
tabs props = R.createElement tabsCpt props []
...
@@ -97,27 +104,43 @@ tabs props = R.createElement tabsCpt props []
...
@@ -97,27 +104,43 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
where
cpt {
frontends, session, corpusId, corpusData
} _ = do
cpt {
cacheState, corpusId, corpusData, frontends, session
} _ = do
(selected /\ setSelected) <- R.useState' 0
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { tabs: tabs', selected }
let path = initialPath
pure $ Tab.tabs {
selected
, tabs: [
"Documents" /\ R.fragment [
histo { path, session }
, docView' path TabDocs
]
, "Trash" /\ docView' path TabTrash
, "More like fav" /\ docView' path TabMoreLikeFav
, "More like trash" /\ docView' path TabMoreLikeTrash
]
}
where
where
tabs' = [ "Documents" /\ docs, "Trash" /\ trash
initialPath = { corpusId, listId: 0, limit: Nothing, tabType: TabCorpus TabDocs }
, "More like fav" /\ moreLikeFav, "More like trash" /\ moreLikeTrash ]
docView' path tabType = docView { cacheState
docView' tabType = docView { frontends, session, corpusId, corpusData, tabType }
, corpusData
docs = R.fragment [ docsHisto, docView' TabDocs ]
, corpusId
docsHisto = histo { path, session }
, frontends
where
-- , path
path = { corpusId, listId: 0, limit: Nothing, tabType: TabCorpus TabDocs }
, session
moreLikeFav = docView' TabMoreLikeFav
, tabType }
moreLikeTrash = docView' TabMoreLikeTrash
trash = docView' TabTrash
type DocViewProps a = (
cacheState :: R.State NT.CacheState
type DocViewProps a =
( frontends :: Frontends
, session :: Session
, corpusId :: Int
, corpusData :: CorpusData
, corpusData :: CorpusData
, tabType :: TabSubType a )
, corpusId :: Int
, frontends :: Frontends
-- , path :: Record DT.Path
, session :: Session
, tabType :: TabSubType a
)
docView :: forall a. Record (DocViewProps a) -> R.Element
docView :: forall a. Record (DocViewProps a) -> R.Element
docView props = R.createElement docViewCpt props []
docView props = R.createElement docViewCpt props []
...
@@ -125,58 +148,63 @@ docView props = R.createElement docViewCpt props []
...
@@ -125,58 +148,63 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: forall a. R.Component (DocViewProps a)
docViewCpt :: forall a. R.Component (DocViewProps a)
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
where
where
cpt {frontends, session, corpusId, corpusData: {defaultListId}, tabType} _children = do
cpt props _children = do
pure $ DT.docViewLayout $ params tabType
pure $ DT.docViewLayout $ docViewLayoutRec props
where
params :: forall b. TabSubType b -> Record DT.LayoutProps
-- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps
params TabDocs =
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } =
{ nodeId: corpusId
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, cacheState
, tabType: TabCorpus TabDocs
, chart : H.div {} []
, totalRecords: 4737
, tabType: TabCorpus TabDocs
, listId: defaultListId
, totalRecords: 4737
, corpusId: Just corpusId
, listId: defaultListId
, showSearch: true
, corpusId: Just corpusId
, frontends, session }
, showSearch: true
params TabMoreLikeFav =
, frontends, session }
{ nodeId: corpusId
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } =
-- ^ TODO merge nodeId and corpusId in DT
{ nodeId: corpusId
, chart : H.div {} []
-- ^ TODO merge nodeId and corpusId in DT
, tabType: TabCorpus TabMoreLikeFav
, cacheState
, totalRecords: 4737
, chart : H.div {} []
, listId: defaultListId
, tabType: TabCorpus TabMoreLikeFav
, corpusId: Just corpusId
, totalRecords: 4737
, showSearch: false
, listId: defaultListId
, frontends, session }
, corpusId: Just corpusId
params TabMoreLikeTrash =
, showSearch: false
{ nodeId: corpusId
, frontends, session }
-- ^ TODO merge nodeId and corpusId in DT
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } =
, chart : H.div {} []
{ nodeId: corpusId
, tabType: TabCorpus TabMoreLikeTrash
-- ^ TODO merge nodeId and corpusId in DT
, totalRecords: 4737
, cacheState
, listId: defaultListId
, chart : H.div {} []
, corpusId: Just corpusId
, tabType: TabCorpus TabMoreLikeTrash
, showSearch: false
, totalRecords: 4737
, frontends, session }
, listId: defaultListId
params TabTrash =
, corpusId: Just corpusId
{ nodeId: corpusId
, showSearch: false
-- ^ TODO merge nodeId and corpusId in DT
, frontends, session }
, chart : H.div {} []
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } =
, tabType: TabCorpus TabTrash
{ nodeId: corpusId
, totalRecords: 4737
-- ^ TODO merge nodeId and corpusId in DT
, listId: defaultListId
, cacheState
, corpusId: Nothing
, chart : H.div {} []
, showSearch: true
, tabType: TabCorpus TabTrash
, frontends, session }
, totalRecords: 4737
-- DUMMY
, listId: defaultListId
params _ =
, corpusId: Nothing
{ nodeId: corpusId
, showSearch: true
-- ^ TODO merge nodeId and corpusId in DT
, frontends, session }
, chart : H.div {} []
-- DUMMY
, tabType: TabCorpus TabTrash
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } =
, totalRecords: 4737
{ nodeId: corpusId
, listId: defaultListId
-- ^ TODO merge nodeId and corpusId in DT
, corpusId: Nothing
, cacheState
, showSearch: true
, chart : H.div {} []
, frontends, session }
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, frontends, session }
src/Gargantext/Components/Tab.purs
View file @
fbaa56ac
...
@@ -9,9 +9,13 @@ import Reactix.DOM.HTML as H
...
@@ -9,9 +9,13 @@ import Reactix.DOM.HTML as H
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Tab"
thisModule = "Gargantext.Components.Tab"
type TabsProps = ( tabs :: Array (Tuple String R.Element), selected :: Int )
type TabsProps = (
selected :: Int
, tabs :: Array (Tuple String R.Element)
)
tabs :: Record TabsProps -> R.Element
tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props []
tabs props = R.createElement tabsCpt props []
...
...
src/Gargantext/Components/Table.purs
View file @
fbaa56ac
...
@@ -18,6 +18,7 @@ import Gargantext.Components.Search
...
@@ -18,6 +18,7 @@ import Gargantext.Components.Search
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix (effectLink)
import Gargantext.Utils.Reactix (effectLink)
thisModule :: String
thisModule = "Gargantext.Components.Table"
thisModule = "Gargantext.Components.Table"
type TableContainerProps =
type TableContainerProps =
...
@@ -33,9 +34,9 @@ type Rows = Seq.Seq Row
...
@@ -33,9 +34,9 @@ type Rows = Seq.Seq Row
type OrderBy = Maybe (OrderByDirection ColumnName)
type OrderBy = Maybe (OrderByDirection ColumnName)
type Params = {
offset
:: Int
type Params = {
limit
:: Int
,
limit
:: Int
,
offset
:: Int
, orderBy :: OrderBy
, orderBy
:: OrderBy
, searchType :: SearchType
, searchType :: SearchType
}
}
...
@@ -60,20 +61,24 @@ instance showOrderByDirection :: Show a => Show (OrderByDirection a) where
...
@@ -60,20 +61,24 @@ instance showOrderByDirection :: Show a => Show (OrderByDirection a) where
derive instance eqOrderByDirection :: Eq a => Eq (OrderByDirection a)
derive instance eqOrderByDirection :: Eq a => Eq (OrderByDirection a)
orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc"
orderByToForm (DESC (ColumnName x)) = x <> "Desc"
type Props =
type Props =
( colNames :: Array ColumnName
( colNames :: Array ColumnName
, wrapColElts :: ColumnName -> Array R.Element -> Array R.Element
, container :: Record TableContainerProps -> R.Element
-- ^ Use `const identity` as a default behavior.
, totalRecords :: Int
, params :: R.State Params
, params :: R.State Params
, rows :: Rows
, rows :: Rows
, container :: Record TableContainerProps -> R.Element
, totalRecords :: Int
, wrapColElts :: ColumnName -> Array R.Element -> Array R.Element
-- ^ Use `const identity` as a default behavior.
)
)
type State =
type State =
{ page :: Int
{ page
:: Int
, pageSize :: PageSizes
, pageSize
:: PageSizes
, orderBy :: OrderBy
, orderBy
:: OrderBy
, searchType :: SearchType
, searchType :: SearchType
}
}
...
@@ -94,6 +99,7 @@ type TableHeaderLayoutProps =
...
@@ -94,6 +99,7 @@ type TableHeaderLayoutProps =
, cacheState :: R.State NT.CacheState
, cacheState :: R.State NT.CacheState
, date :: String
, date :: String
, desc :: String
, desc :: String
, key :: String
, query :: String
, query :: String
, title :: String
, title :: String
, user :: String
, user :: String
...
@@ -120,26 +126,26 @@ tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout"
...
@@ -120,26 +126,26 @@ tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout"
[ H.div {className: "jumbotron1", style: {padding: "12px 0px 20px 12px"}}
[ H.div {className: "jumbotron1", style: {padding: "12px 0px 20px 12px"}}
[ H.div {className: "col-md-8 content"}
[ H.div {className: "col-md-8 content"}
[ H.p {}
[ H.p {}
[ H.
i
{className: "fa fa-globe"} []
[ H.
span
{className: "fa fa-globe"} []
, H.text $ " " <> desc
, H.text $ " " <> desc
]
]
, H.p {}
, H.p {}
[ H.
i
{className: "fa fa-search-plus"} []
[ H.
span
{className: "fa fa-search-plus"} []
, H.text $ " " <> query
, H.text $ " " <> query
]
]
, H.p { className: "cache-toggle"
, H.p { className: "cache-toggle"
, on: { click: cacheClick cacheState afterCacheStateChange } }
, on: { click: cacheClick cacheState afterCacheStateChange } }
[ H.
i {className: "fa " <> (cacheToggle cacheState)
} []
[ H.
span { className: "fa " <> (cacheToggle cacheState)
} []
, H.text $ cacheText cacheState
, H.text $ cacheText cacheState
]
]
]
]
, H.div {className: "col-md-4 content"}
, H.div {className: "col-md-4 content"}
[ H.p {}
[ H.p {}
[ H.
i
{className: "fa fa-calendar"} []
[ H.
span
{className: "fa fa-calendar"} []
, H.text $ " " <> date
, H.text $ " " <> date
]
]
, H.p {}
, H.p {}
[ H.
i
{className: "fa fa-user"} []
[ H.
span
{className: "fa fa-user"} []
, H.text $ " " <> user
, H.text $ " " <> user
]
]
]
]
...
...
src/Gargantext/Utils/QueryString.purs
0 → 100644
View file @
fbaa56ac
module Gargantext.Utils.QueryString where
import Data.Array
import Data.Maybe
import Data.String.Common (joinWith)
import Gargantext.Prelude
queryParam :: forall a. Show a => String -> a -> String
queryParam key value = key <> "=" <> show value
queryParamS :: String -> String -> String
queryParamS key value = key <> "=" <> value
mQueryParam :: forall a. Show a => String -> Maybe a -> String
mQueryParam _ Nothing = ""
mQueryParam key (Just v) = queryParam key v
mQueryParamS :: forall a. String -> (a -> String) -> Maybe a -> String
mQueryParamS _ _ Nothing = ""
mQueryParamS key mFunc (Just v) = queryParamS key $ mFunc v
joinQueryStrings :: Array String -> String
joinQueryStrings qs =
case uncons qs of
Nothing -> ""
Just { head, tail } -> "?" <> head <> (joinQS tail)
where
joinQS ys =
case uncons ys of
Nothing -> ""
Just { tail: ys } -> "&" <> (joinWith "&" ys)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment