Commit cae0c4bc authored by Alexandre Delanoë's avatar Alexandre Delanoë

[NGRAMS][Table] needs to adapt the type of tab for the loader.

parent 0f076527
...@@ -31,7 +31,7 @@ endConfig' v = { front : frontCaddy ...@@ -31,7 +31,7 @@ endConfig' v = { front : frontCaddy
-- until authentication implementation -- until authentication implementation
-- (Default Root will be given after authentication) -- (Default Root will be given after authentication)
defaultRoot :: Int defaultRoot :: Int
defaultRoot = 943779 defaultRoot = 950094
------------------------------------------------------------------------ ------------------------------------------------------------------------
frontCaddy :: Config frontCaddy :: Config
frontCaddy = { proto : "http://" frontCaddy = { proto : "http://"
...@@ -149,14 +149,15 @@ instance showApiVersion :: Show ApiVersion where ...@@ -149,14 +149,15 @@ instance showApiVersion :: Show ApiVersion where
show V11 = "v1.1" show V11 = "v1.1"
------------------------------------------------------------ ------------------------------------------------------------
data TabType = TabDocs | TabTerms | TabSources | TabAuthors | TabTrash data TabType = TabDocs | TabTerms | TabSources | TabAuthors | TabInstitutes | TabTrash
instance showTabType :: Show TabType where instance showTabType :: Show TabType where
show TabDocs = "Docs" show TabDocs = "Docs"
show TabTerms = "Terms" show TabTerms = "Terms"
show TabSources = "Sources" show TabSources = "Sources"
show TabAuthors = "Authors" show TabAuthors = "Authors"
show TabTrash = "Trash" show TabInstitutes = "Institutes"
show TabTrash = "Trash"
------------------------------------------------------------ ------------------------------------------------------------
urlConfig :: NodeType -> Url urlConfig :: NodeType -> Url
......
...@@ -80,12 +80,12 @@ _NgramsElement = _Newtype ...@@ -80,12 +80,12 @@ _NgramsElement = _Newtype
instance decodeJsonNgramsElement :: DecodeJson NgramsElement where instance decodeJsonNgramsElement :: DecodeJson NgramsElement where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
ngrams <- obj .? "ngrams" ngrams <- obj .? "ngrams"
list <- obj .? "list" list <- obj .? "list"
occurrences <- obj .? "occurrences" occurrences <- obj .? "occurrences"
parent <- obj .?? "parent" parent <- obj .?? "parent"
children' <- obj .? "children" children' <- obj .? "children"
let children = Set.fromFoldable (children' :: Array NgramsTerm) let children = Set.fromFoldable (children' :: Array NgramsTerm)
pure $ NgramsElement {ngrams, list, occurrences, parent, children} pure $ NgramsElement {ngrams, list, occurrences, parent, children}
...@@ -297,7 +297,7 @@ data Action ...@@ -297,7 +297,7 @@ data Action
| SetTermTypeFilter (Maybe TermType) | SetTermTypeFilter (Maybe TermType)
| SetSearchQuery String | SetSearchQuery String
data Mode = Authors | Sources | Terms | Trash data Mode = Authors | Sources | Institutes | Terms
type Dispatch = Action -> Effect Unit type Dispatch = Action -> Effect Unit
...@@ -488,11 +488,12 @@ type PageLoaderProps = ...@@ -488,11 +488,12 @@ type PageLoaderProps =
--, corpusInfo :: Maybe (NodePoly CorpusInfo) --, corpusInfo :: Maybe (NodePoly CorpusInfo)
} }
getNgramsTable :: Maybe Int -> Aff NgramsTable getTable :: TabType -> Maybe Int -> Aff NgramsTable
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing) getTable tab = get <<< toUrl Back (Ngrams tab Nothing)
-- TODO TabTerms or TabAuthors ...
loadPage :: PageParams -> Aff NgramsTable loadPage :: PageParams -> Aff NgramsTable
loadPage {nodeId} = getNgramsTable (Just nodeId) -- TODO this ignores params loadPage {nodeId} = getTable TabTerms (Just nodeId) -- TODO this ignores params
ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable) ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable)
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage
......
...@@ -23,6 +23,7 @@ statefulTabs = ...@@ -23,6 +23,7 @@ statefulTabs =
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Documents" docPageSpec Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Documents" docPageSpec
, Tuple "Authors" authorPageSpec , Tuple "Authors" authorPageSpec
, Tuple "Sources" sourcePageSpec , Tuple "Sources" sourcePageSpec
, Tuple "Institutes" institutesPageSpec
, Tuple "Terms" termsPageSpec , Tuple "Terms" termsPageSpec
, Tuple "Trash" trashPageSpec , Tuple "Trash" trashPageSpec
] ]
...@@ -41,8 +42,13 @@ authorPageSpec = ngramsViewSpec {mode: NV.Authors} ...@@ -41,8 +42,13 @@ authorPageSpec = ngramsViewSpec {mode: NV.Authors}
sourcePageSpec :: Spec State Props Action sourcePageSpec :: Spec State Props Action
sourcePageSpec = ngramsViewSpec {mode: NV.Sources} sourcePageSpec = ngramsViewSpec {mode: NV.Sources}
institutesPageSpec :: Spec State Props Action
institutesPageSpec = ngramsViewSpec {mode: NV.Institutes}
termsPageSpec :: Spec State Props Action termsPageSpec :: Spec State Props Action
termsPageSpec = ngramsViewSpec {mode: NV.Terms} termsPageSpec = ngramsViewSpec {mode: NV.Terms}
trashPageSpec :: Spec State Props Action trashPageSpec :: Spec State Props Action
trashPageSpec = ngramsViewSpec {mode: NV.Trash} trashPageSpec = focus _doclens _docAction DV.layoutDocview
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