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
03f40a8a
Commit
03f40a8a
authored
May 06, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ANNOTATION] connecting backend WIP (needs listId of corpus view).
parent
2e58c066
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
33 deletions
+66
-33
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+11
-5
Config.purs
src/Gargantext/Config.purs
+20
-9
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+24
-8
Router.purs
src/Gargantext/Router.purs
+11
-11
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
03f40a8a
...
@@ -14,6 +14,9 @@ module Gargantext.Components.NgramsTable
...
@@ -14,6 +14,9 @@ module Gargantext.Components.NgramsTable
, initialPageParams
, initialPageParams
, initialState
, initialState
, mainNgramsTableSpec
, mainNgramsTableSpec
, loadNgramsTable
, ngramsTableSpec
, ngramsLoaderClass
, ngramsLoader
, ngramsLoader
, ngramsLoaderClass
, ngramsLoaderClass
, ngramsTableClass
, ngramsTableClass
...
@@ -68,7 +71,7 @@ import Partial.Unsafe (unsafePartial)
...
@@ -68,7 +71,7 @@ import Partial.Unsafe (unsafePartial)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Types (TermList(..), TermSize, readTermList, readTermSize, termLists, termSizes)
import Gargantext.Types (TermList(..), TermSize, readTermList, readTermSize, termLists, termSizes)
import Gargantext.Config (toUrl, End(..), Path(..), TabType(..), OrderBy(..))
import Gargantext.Config (toUrl, End(..), Path(..), TabType(..), OrderBy(..)
, NodeType(..)
)
import Gargantext.Config.REST (get, put)
import Gargantext.Config.REST (get, put)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
...
@@ -115,12 +118,15 @@ derive instance eqNgramsTable :: Eq NgramsTable
...
@@ -115,12 +118,15 @@ derive instance eqNgramsTable :: Eq NgramsTable
_parent = prop (SProxy :: SProxy "parent")
_parent = prop (SProxy :: SProxy "parent")
_root = prop (SProxy :: SProxy "root")
_root
= prop (SProxy :: SProxy "root")
_ngrams = prop (SProxy :: SProxy "ngrams")
_ngrams = prop (SProxy :: SProxy "ngrams")
_children :: forall row. Lens' { children :: Set NgramsTerm | row } (Set NgramsTerm)
_children :: forall row. Lens' { children :: Set NgramsTerm | row } (Set NgramsTerm)
_children = prop (SProxy :: SProxy "children")
_children = prop (SProxy :: SProxy "children")
_occurrences :: forall row. Lens' { occurrences :: Int | row } Int
_occurrences :: forall row. Lens' { occurrences :: Int | row } Int
_occurrences = prop (SProxy :: SProxy "occurrences")
_occurrences = prop (SProxy :: SProxy "occurrences")
_list :: forall a row. Lens' { list :: a | row } a
_list :: forall a row. Lens' { list :: a | row } a
_list = prop (SProxy :: SProxy "list")
_list = prop (SProxy :: SProxy "list")
...
@@ -702,8 +708,8 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -702,8 +708,8 @@ ngramsTableSpec = simpleSpec performAction render
, delete: false
, delete: false
}
}
load
Pag
e :: PageParams -> Aff VersionedNgramsTable
load
NgramsTabl
e :: PageParams -> Aff VersionedNgramsTable
load
Pag
e { nodeId, listIds, termListFilter, termSizeFilter
load
NgramsTabl
e { nodeId, listIds, termListFilter, termSizeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
(GetNgrams { tabType, offset, limit, listIds
...
@@ -716,7 +722,7 @@ loadPage { nodeId, listIds, termListFilter, termSizeFilter
...
@@ -716,7 +722,7 @@ loadPage { nodeId, listIds, termListFilter, termSizeFilter
convOrderBy _ = DateAsc -- TODO
convOrderBy _ = DateAsc -- TODO
ngramsLoaderClass :: Loader.LoaderClass PageParams VersionedNgramsTable
ngramsLoaderClass :: Loader.LoaderClass PageParams VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "NgramsTableLoader" load
Pag
e
ngramsLoaderClass = Loader.createLoaderClass "NgramsTableLoader" load
NgramsTabl
e
ngramsLoader :: Loader.Props' PageParams VersionedNgramsTable -> ReactElement
ngramsLoader :: Loader.Props' PageParams VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsLoader props = React.createElement ngramsLoaderClass props []
...
...
src/Gargantext/Config.purs
View file @
03f40a8a
...
@@ -107,6 +107,7 @@ endPathUrl end = pathUrl <<< endOf end
...
@@ -107,6 +107,7 @@ endPathUrl end = pathUrl <<< endOf end
tabTypeDocs :: TabType -> UrlPath
tabTypeDocs :: TabType -> UrlPath
tabTypeDocs (TabCorpus t) = "table?view=" <> show t
tabTypeDocs (TabCorpus t) = "table?view=" <> show t
tabTypeDocs (TabDocument t)= "table?view=" <> show t
tabTypeDocs (TabPairing t) = "pairing?view=" <> show t
tabTypeDocs (TabPairing t) = "pairing?view=" <> show t
limitUrl :: Limit -> UrlPath
limitUrl :: Limit -> UrlPath
...
@@ -119,15 +120,18 @@ orderUrl :: forall a. Show a => Maybe a -> UrlPath
...
@@ -119,15 +120,18 @@ orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
orderUrl = maybe "" (\x -> "&order=" <> show x)
showTabType' :: TabType -> String
showTabType' :: TabType -> String
showTabType' (TabCorpus t) = show t
showTabType' (TabCorpus t) = show t
showTabType' (TabDocument t) = show t
showTabType' (TabPairing t) = show t
showTabType' (TabPairing t) = show t
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabDocument t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsPut :: TabType -> UrlPath
tabTypeNgramsPut :: TabType -> UrlPath
tabTypeNgramsPut (TabCorpus t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabCorpus t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabDocument t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabPairing t) = "list?ngramsType=" <> show t -- TODO
tabTypeNgramsPut (TabPairing t) = "list?ngramsType=" <> show t -- TODO
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
...
@@ -146,7 +150,9 @@ pathUrl c (GetNgrams
...
@@ -146,7 +150,9 @@ pathUrl c (GetNgrams
, termSizeFilter: tsf
, termSizeFilter: tsf
, searchQuery: q
, searchQuery: q
}) i =
}) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsGet t
base
<> "/"
<> tabTypeNgramsGet t
<> offsetUrl o <> limitUrl l
<> offsetUrl o <> limitUrl l
<> foldMap (\x -> "&list=" <> show x) listIds
<> foldMap (\x -> "&list=" <> show x) listIds
<> foldMap (\x -> "&listType=" <> show x) tlf
<> foldMap (\x -> "&listType=" <> show x) tlf
...
@@ -155,6 +161,12 @@ pathUrl c (GetNgrams
...
@@ -155,6 +161,12 @@ pathUrl c (GetNgrams
MultiTerm -> "&minTermSize=2"
MultiTerm -> "&minTermSize=2"
) tsf
) tsf
<> if q == "" then "" else ("&search=" <> q)
<> if q == "" then "" else ("&search=" <> q)
where
base = case t of
TabCorpus _ -> pathUrl c (NodeAPI Node) i
_ -> pathUrl c (NodeAPI Url_Document) i
pathUrl c (PutNgrams t listid) i =
pathUrl c (PutNgrams t listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsPut t <> listid'
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsPut t <> listid'
where
where
...
@@ -198,10 +210,9 @@ data NodeType = NodeUser
...
@@ -198,10 +210,9 @@ data NodeType = NodeUser
| Annuaire
| Annuaire
| NodeContact
| NodeContact
| Corpus
| Corpus
-- | Node
Document
| Url_
Document
| CorpusV3
| CorpusV3
| Dashboard
| Dashboard
| Url_Document
| Error
| Error
| Folder
| Folder
| Graph
| Graph
...
@@ -220,7 +231,6 @@ instance showNodeType :: Show NodeType where
...
@@ -220,7 +231,6 @@ instance showNodeType :: Show NodeType where
show CorpusV3 = "NodeCorpusV3"
show CorpusV3 = "NodeCorpusV3"
show Dashboard = "NodeDashboard"
show Dashboard = "NodeDashboard"
show Url_Document = "NodeDocument"
show Url_Document = "NodeDocument"
--show NodeDocument = "NodeDocument"
show Error = "NodeError"
show Error = "NodeError"
show Folder = "NodeFolder"
show Folder = "NodeFolder"
show Graph = "NodeGraph"
show Graph = "NodeGraph"
...
@@ -323,8 +333,9 @@ instance showTabSubType :: Show a => Show (TabSubType a) where
...
@@ -323,8 +333,9 @@ instance showTabSubType :: Show a => Show (TabSubType a) where
show TabTrash = "Trash"
show TabTrash = "Trash"
data TabType
data TabType
= TabCorpus (TabSubType CTabNgramType)
= TabCorpus (TabSubType CTabNgramType)
| TabPairing (TabSubType PTabNgramType)
| TabPairing (TabSubType PTabNgramType)
| TabDocument (TabSubType CTabNgramType)
derive instance eqTabType :: Eq TabType
derive instance eqTabType :: Eq TabType
...
...
src/Gargantext/Pages/Corpus/Document.purs
View file @
03f40a8a
...
@@ -18,10 +18,10 @@ import Unsafe.Coerce (unsafeCoerce)
...
@@ -18,10 +18,10 @@ import Unsafe.Coerce (unsafeCoerce)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Class (lift)
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config (toUrl, NodeType(..), End(..)
, TabSubType(..), TabType(..), CTabNgramType(..)
)
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable (NgramsTable(..), NgramsElement(..))
import Gargantext.Components.NgramsTable (NgramsTable(..), NgramsElement(..)
, loadNgramsTable, Versioned(..)
)
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Types (TermList(..))
import Gargantext.Types (TermList(..))
import Gargantext.Utils.Reactix ( scuff )
import Gargantext.Utils.Reactix ( scuff )
...
@@ -38,15 +38,15 @@ testTable = NgramsTable $ Map.fromFoldable $ nge <$> words
...
@@ -38,15 +38,15 @@ testTable = NgramsTable $ Map.fromFoldable $ nge <$> words
where words = [ "the", "quick", "brown", "fox", "jumped", "over", "lazy", "dog" ]
where words = [ "the", "quick", "brown", "fox", "jumped", "over", "lazy", "dog" ]
type State =
type State =
{ document :: Maybe (NodePoly Document)
{ document
:: Maybe (NodePoly Document)
, ngramsTable :: NgramsTable
, ngramsTable ::
Maybe
NgramsTable
, inputValue :: String
, inputValue
:: String
}
}
initialState :: {} -> State
initialState :: {} -> State
initialState {} =
initialState {} =
{ document: Nothing
{ document: Nothing
, ngramsTable:
testTable
, ngramsTable:
(Just testTable)
, inputValue: ""
, inputValue: ""
}
}
...
@@ -281,7 +281,18 @@ instance decodeDocument :: DecodeJson Document
...
@@ -281,7 +281,18 @@ instance decodeDocument :: DecodeJson Document
performAction :: PerformAction State {} Action
performAction :: PerformAction State {} Action
performAction (Load nId) _ _ = do
performAction (Load nId) _ _ = do
node <- lift $ getNode (Just nId)
node <- lift $ getNode (Just nId)
void $ modifyState $ _document ?~ node
let listIds = [1]
(Versioned {version:_version, data:table}) <- lift $ loadNgramsTable {nodeId : nId
, listIds : listIds
, params : { offset : 0, limit : 100, orderBy: Nothing}
, tabType : (TabDocument (TabNgramType CTabTerms))
, searchQuery : ""
, termListFilter : Nothing
, termSizeFilter : Nothing
}
void $ modifyState $ _document ?~ node
void $ modifyState $ _ngramsTable ?~ table
logs $ "Node Document " <> show nId <> " fetched."
logs $ "Node Document " <> show nId <> " fetched."
performAction (ChangeString ps) _ _ = pure unit
performAction (ChangeString ps) _ _ = pure unit
performAction (SetInput ps) _ _ = void <$> modifyState $ _ { inputValue = ps }
performAction (SetInput ps) _ _ = void <$> modifyState $ _ { inputValue = ps }
...
@@ -292,6 +303,11 @@ getNode = get <<< toUrl Back Node
...
@@ -292,6 +303,11 @@ getNode = get <<< toUrl Back Node
_document :: Lens' State (Maybe (NodePoly Document))
_document :: Lens' State (Maybe (NodePoly Document))
_document = lens (\s -> s.document) (\s ss -> s{document = ss})
_document = lens (\s -> s.document) (\s ss -> s{document = ss})
_ngramsTable :: Lens' State (Maybe NgramsTable)
_ngramsTable = lens (\s -> s.ngramsTable) (\s ss -> s{ngramsTable = ss})
------------------------------------------------------------------------
------------------------------------------------------------------------
docview :: Spec State {} Action
docview :: Spec State {} Action
...
@@ -330,7 +346,7 @@ docview = simpleSpec performAction render
...
@@ -330,7 +346,7 @@ docview = simpleSpec performAction render
]
]
]
]
where
where
annotate t = scuff $ AnnotatedField.annotatedField { ngrams: state.ngramsTable, text: t }
annotate t = scuff $ AnnotatedField.annotatedField { ngrams:
maybe (NgramsTable Map.empty) identity
state.ngramsTable, text: t }
li' = li [className "list-group-item justify-content-between"]
li' = li [className "list-group-item justify-content-between"]
text' x = text $ maybe "Nothing" identity x
text' x = text $ maybe "Nothing" identity x
badge s = span [className "badge badge-default badge-pill"] [text s]
badge s = span [className "badge badge-default badge-pill"] [text s]
...
...
src/Gargantext/Router.purs
View file @
03f40a8a
...
@@ -31,14 +31,14 @@ routing =
...
@@ -31,14 +31,14 @@ routing =
Login <$ route "login"
Login <$ route "login"
<|> SearchView <$ route "search"
<|> SearchView <$ route "search"
<|> AddCorpus <$ route "addCorpus"
<|> AddCorpus <$ route "addCorpus"
<|> Folder <$> (route "folder" *> int)
<|> Folder <$> (route "folder"
*> int)
<|> Corpus <$> (route "corpus" *> int)
<|> Corpus <$> (route "corpus"
*> int)
<|> Document
<$> (route "document"
*> int)
<|> Document
<$> (route "document"
*> int)
<|> Dashboard <$ route "dashboard"
<|> Dashboard <$ route "dashboard"
<|> PGraphExplorer <$>
(route "graph" *> int
)
<|> PGraphExplorer <$>
(route "graph" *> int
)
<|> Annuaire <$> (route "annuaire" *> int)
<|> Annuaire <$> (route "annuaire"
*> int)
<|> UserPage
<$> (route "user"
*> int)
<|> UserPage
<$> (route "user"
*> int)
<|> ContactPage <$> (route "contact"
*> int)
<|> ContactPage <$> (route "contact" *> int)
<|> Home <$ lit ""
<|> Home <$ lit ""
where
where
...
@@ -51,12 +51,12 @@ instance showRoutes :: Show Routes where
...
@@ -51,12 +51,12 @@ instance showRoutes :: Show Routes where
show Login = "Login"
show Login = "Login"
show AddCorpus = "AddCorpus"
show AddCorpus = "AddCorpus"
show SearchView = "Search"
show SearchView = "Search"
show (UserPage i) = "User" <> show i
show (UserPage i) = "User"
<> show i
show (ContactPage i)
= "Contact"
<> show i
show (ContactPage i)
= "Contact"
<> show i
show (Document i) = "Document"
show (Document i) = "Document"
show (Corpus i) = "Corpus" <> show i
show (Corpus i) = "Corpus"
<> show i
show (Annuaire i) = "Annuaire" <> show i
show (Annuaire i) = "Annuaire" <> show i
show (Folder i) = "Folder" <> show i
show (Folder i) = "Folder" <> show i
show Dashboard = "Dashboard"
show Dashboard = "Dashboard"
show (PGraphExplorer i)
= "graphExplorer" <> show i
show (PGraphExplorer i) = "graphExplorer" <> show i
show Home = "Home"
show Home = "Home"
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