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
7c068c4c
Unverified
Commit
7c068c4c
authored
May 16, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS] refactoring some routes and adding POST for new ngrams
parent
bd8a048d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+11
-1
Config.purs
src/Gargantext/Config.purs
+4
-14
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
7c068c4c
...
...
@@ -74,7 +74,7 @@ import Partial.Unsafe (unsafePartial)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Types (TermList(..), TermSize, readTermList, readTermSize, termLists, termSizes)
import Gargantext.Config (toUrl, End(..), Path(..), TabType(..), OrderBy(..), NodeType(..))
import Gargantext.Config.REST (get, put)
import Gargantext.Config.REST (get, put
, post
)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Table as T
import Gargantext.Prelude
...
...
@@ -515,6 +515,7 @@ data Action
-- applied to `initTable`.
-- TODO more docs
| Refresh
| AddNewNgram NgramsTerm
type Dispatch = Action -> Effect Unit
...
...
@@ -607,6 +608,13 @@ tableContainer { pageParams
, button [className "btn btn-primary", onClick $ const $ dispatch $ AddTermChildren] [text "Save"]
, button [className "btn btn-secondary", onClick $ const $ dispatch $ SetParentResetChildren Nothing] [text "Cancel"]
]) ngramsParent)
, div [] (
if A.null props.tableBody && pageParams.searchQuery /= "" then [
button [ className "btn btn-primary"
, onClick $ const $ dispatch $ AddNewNgram pageParams.searchQuery
] [text $ "Add " <> pageParams.searchQuery]
] else []
)
, div [ _id "terms_table", className "panel-body" ]
[ table [ className "table able" ]
[ thead [ className "tableHeader"] [props.tableHead]
...
...
@@ -678,6 +686,8 @@ ngramsTableSpec = simpleSpec performAction render
pt = PatchMap $ Map.fromFoldable [Tuple parent pe]
-- TODO ROOT-UPDATE
-- patch the root of the child to be equal to the root of the parent.
performAction (AddNewNgram ngram) {path: {nodeId, listIds, tabType}} _ =
lift $ post (toUrl Back (PutNgrams tabType (head listIds)) $ Just nodeId) [ngram]
render :: Render State Props' Action
render dispatch { path: pageParams
...
...
src/Gargantext/Config.purs
View file @
7c068c4c
...
...
@@ -128,16 +128,6 @@ showTabType' (TabCorpus t) = show t
showTabType' (TabDocument t) = show t
showTabType' (TabPairing t) = show t
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabDocument t) = "ngrams?ngramsType=" <> show t
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsPut :: TabType -> UrlPath
tabTypeNgramsPut (TabCorpus t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabDocument t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabPairing t) = "list?ngramsType=" <> show t -- TODO
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl c (Tab t o l s) i =
pathUrl c (NodeAPI Node) i <>
...
...
@@ -156,8 +146,7 @@ pathUrl c (GetNgrams
, searchQuery: q
}) i =
base
<> "/"
<> tabTypeNgramsGet t
<> "/ngrams?ngramsType=" <> showTabType' t
<> offsetUrl o <> limitUrl l
<> orderByUrl orderBy
<> foldMap (\x -> "&list=" <> show x) listIds
...
...
@@ -174,7 +163,7 @@ pathUrl c (GetNgrams
pathUrl c (PutNgrams t listid) i =
pathUrl c (NodeAPI Node) i <> "/
" <> tabTypeNgramsPut
t <> listid'
pathUrl c (NodeAPI Node) i <> "/
ngrams?ngramsType=" <> showTabType'
t <> listid'
where
listid' = maybe "" (\x -> "&list=" <> show x) listid
pathUrl c Auth Nothing = c.prePath <> "auth"
...
...
@@ -185,7 +174,7 @@ pathUrl c (Search {limit,offset,orderBy}) _TODO =
<> offsetUrl offset <> limitUrl limit <> orderUrl orderBy
pathUrl c (CorpusMetrics {tabType, listId, limit}) i =
pathUrl c (NodeAPI Corpus) i <> "/metrics"
<> "?
list
=" <> show listId
<> "?
ngrams
=" <> show listId
<> "&ngramsType=" <> showTabType' tabType
<> maybe "" (\x -> "&limit=" <> show x) limit
-- TODO fix this url path
...
...
@@ -282,6 +271,7 @@ data Path
, searchQuery :: String
}
| PutNgrams TabType (Maybe ListId)
-- ^ The name is not good. In particular this URL is used both in PUT and POST.
| NodeAPI NodeType
| Search { {-id :: Int
, query :: Array String
...
...
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