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
c86fd7e8
Commit
c86fd7e8
authored
Jun 26, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[doc] some decode/encode json types for docs table
parent
3fbee957
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
5 deletions
+67
-5
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+4
-1
Loader.purs
src/Gargantext/Components/Loader.purs
+1
-0
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+3
-0
Types.purs
src/Gargantext/Types.purs
+59
-4
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
c86fd7e8
...
...
@@ -30,6 +30,7 @@ import Reactix.DOM.HTML as H
import Gargantext.Components.Table as T
import Gargantext.Components.Loader (loader)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoaderWithCache)
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI))
...
...
@@ -372,11 +373,13 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Memo PageLayoutProps
pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where
cpt props@{frontends, session, nodeId, listId, corpusId, tabType, query, params} _ =
loader path (loadPage session) paint
--loader path (loadPage session) paint
useLoader path keyFunc (loadPage session) paint
where
path = {nodeId, listId, corpusId, tabType, query, params: fst params}
paint (Tuple count docs) = page params (newProps count) docs
newProps count = props { totalRecords = count }
keyFunc { corpusId, listId, nodeId, tabType } = "docs-table-" <> (show corpusId) <> "-" <> (show listId) <> "-" <> (show nodeId) <> "-" <> (show tabType)
type PageProps =
( params :: R.State T.Params
...
...
src/Gargantext/Components/Loader.purs
View file @
c86fd7e8
...
...
@@ -6,6 +6,7 @@ import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Reactix as R
import Gargantext.Utils.Reactix as R2
import Gargantext.Components.LoadingSpinner (loadingSpinner)
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
c86fd7e8
...
...
@@ -33,6 +33,7 @@ import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core (Action(..), CoreState, Dispatch, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTerm, PageParams, PatchMap(..), Versioned(..), VersionedNgramsTable, _NgramsElement, _NgramsTable, _children, _list, _ngrams, _occurrences, _root, addNewNgram, applyNgramsPatches, applyPatchSet, commitPatchR, convOrderBy, filterTermSize, fromNgramsPatches, initialPageParams, loadNgramsTableAll, ngramsTermText, normNgram, patchSetFromMap, replace, rootsOf, singletonNgramsTablePatch, syncPatchesR)
import Gargantext.Components.Table as T
import Gargantext.Hooks.Loader (useLoaderWithCache)
import Gargantext.Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, pure, show, unit, (#), ($), (&&), (/=), (<$>), (<<<), (<>), (=<<), (==), (||), read)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...
...
@@ -500,6 +501,8 @@ mainNgramsTableCpt = R.hooksComponent "G.C.NT.mainNgramsTable" cpt
mainNgramsTablePaint {path, tabNgramType, versioned, withAutoUpdate}
Nothing -> loadingSpinner {}
keyFunc { listIds, nodeId, tabType } = "ngrams-table-" <> (show tabType) <> "-" <> (show nodeId) <> "-" <> (show listIds)
type MainNgramsTablePaintProps =
(
path :: PageParams
...
...
src/Gargantext/Types.purs
View file @
c86fd7e8
...
...
@@ -287,9 +287,10 @@ type ListId = Int
data ScoreType = Occurrences
derive instance genericScoreType :: Generic ScoreType _
instance showScoreType :: Show ScoreType where
show = genericShow
instance eqScoreType :: Eq ScoreType where
eq = genericEq
type SearchQuery = String
...
...
@@ -425,6 +426,39 @@ data TabSubType a = TabDocs | TabNgramType a | TabTrash | TabMoreLikeFav | TabMo
derive instance eqTabSubType :: Eq a => Eq (TabSubType a)
derive instance ordTabSubType :: Ord a => Ord (TabSubType a)
{- instance encodeTabSubType a :: EncodeJson a => EncodeJson (TabSubType a) where
encodeJson TabDocs =
"type" := "TabDocs"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson (TabNgramType a) =
"type" := "TabNgramType"
~> "data" := encodeJson a
~> jsonEmptyObject
encodeJson TabTrash =
"type" := "TabTrash"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson TabMoreLikeFav =
"type" := "TabMoreLikeFav"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson TabMoreLikeTrash =
"type" := "TabMoreLikeTrash"
~> "data" := Nothing
~> jsonEmptyObject
instance decodeTabSubType a :: DecodeJson a => DecodeJson (TabSubType a) where
decodeJson j = do
obj <- decodeJson j
typ <- obj .: "type"
dat <- obj .: "data"
case typ of
"TabDocs" -> TabDocs
"TabNgramType" -> TabNgramType dat
"TabTrash" -> TabTrash
"TabMoreLikeFav" -> TabMoreLikeFav
"TabMoreLikeTrash" -> TabMoreLikeTrash
_ -> Left ("Unknown type '" <> typ <> "'") -}
instance showTabSubType :: Show a => Show (TabSubType a) where
show TabDocs = "Docs"
...
...
@@ -438,13 +472,34 @@ data TabType
| TabPairing (TabSubType PTabNgramType)
| TabDocument (TabSubType CTabNgramType)
derive instance genericTabType :: Generic TabType _
derive instance eqTabType :: Eq TabType
derive instance ordTabType :: Ord TabType
derive instance genericTabType :: Generic TabType _
instance showTabType :: Show TabType where
show = genericShow
{- instance encodeTabType :: EncodeJson TabType where
encodeJson (TabCorpus d) =
"type" := "TabCorpus"
~> "data" := encodeJson d
~> jsonEmptyObject
encodeJson (TabDocument d) =
"type" := "TabDocument"
~> "data" := encodeJson d
~> jsonEmptyObject
encodeJson (TabPairing d) =
"type" := "TabPairing"
~> "data" := encodeJson d
~> jsonEmptyObject
instance decodeTabType :: DecodeJson TabType where
decodeJson j = do
obj <- decodeJson j
typ <- obj .: "type"
dat <- obj .: "data"
case typ of
"TabCorpus" -> TabCorpus dat
"TabDocument" -> TabDocument dat
"TabPairing" -> TabPairing dat
_ -> Left ("Unknown type '" <> typ <> "'") -}
type TableResult a = {count :: Int, docs :: Array a}
type AffTableResult a = Aff (TableResult a)
...
...
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