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
43495ef8
Commit
43495ef8
authored
Jul 30, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-doc-table-columns' into dev-merge
parents
d775f14c
9221aec4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
82 deletions
+75
-82
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+1
-45
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+20
-33
Types.purs
src/Gargantext/Components/Search/Types.purs
+54
-2
Tabs.purs
src/Gargantext/Pages/Corpus/Graph/Tabs.purs
+0
-1
Layout.purs
src/Gargantext/Pages/Layout.purs
+0
-1
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
43495ef8
...
...
@@ -10,7 +10,6 @@ import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson
import Data.Array (drop, take, (:), filter)
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.HTTP.Method (Method(..))
import Data.Lens
...
...
@@ -41,6 +40,7 @@ import Gargantext.Config (End(..), NodeType(..), OrderBy(..), Path(..), TabType,
import Gargantext.Config.REST (get, put, post, deleteWithBody, delete)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, trashCategory, decodeCategory, putCategories)
import Gargantext.Components.Table as T
import Gargantext.Utils.DecodeMaybe ((.|))
import Gargantext.Utils.Reactix as R2
...
...
@@ -50,26 +50,6 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_
type NodeID = Int
type TotalRecords = Int
data Category = Trash | Normal | Favorite
derive instance genericFavorite :: Generic Category _
instance showCategory :: Show Category where
show = genericShow
instance eqCategory :: Eq Category where
eq = genericEq
instance encodeJsonCategory :: EncodeJson Category where
encodeJson Trash = encodeJson 0
encodeJson Normal = encodeJson 1
encodeJson Favorite = encodeJson 2
favCategory :: Category -> Category
favCategory Normal = Favorite
favCategory Trash = Favorite
favCategory Favorite = Normal
trashCategory :: Category -> Category
trashCategory Normal = Trash
trashCategory Trash = Normal
trashCategory Favorite = Trash
type Props =
{ nodeId :: Int
...
...
@@ -143,12 +123,6 @@ instance decodeHyperdata :: DecodeJson Hyperdata where
pub_year <- obj .? "publication_year"
pure $ Hyperdata { title,source, pub_year}
decodeCategory :: Int -> Category
decodeCategory 0 = Trash
decodeCategory 1 = Normal
decodeCategory 2 = Favorite
decodeCategory _ = Normal
instance decodeResponse :: DecodeJson Response where
decodeJson json = do
obj <- decodeJson json
...
...
@@ -397,24 +371,6 @@ searchResults :: SearchQuery -> Aff Int
searchResults squery = post "http://localhost:8008/count" unit
-- TODO
newtype CategoryQuery = CategoryQuery {
nodeIds :: Array Int
, category :: Category
}
instance encodeJsonCategoryQuery :: EncodeJson CategoryQuery where
encodeJson (CategoryQuery post) =
"ntc_nodesId" := post.nodeIds
~> "ntc_category" := encodeJson post.category
~> jsonEmptyObject
categoryUrl :: Int -> String
categoryUrl nodeId = toUrl Back Node (Just nodeId) <> "/category"
putCategories :: Int -> CategoryQuery -> Aff (Array Int)
putCategories nodeId = put $ categoryUrl nodeId
documentsUrl :: Int -> String
documentsUrl nodeId = toUrl Back Node (Just nodeId) <> "/documents"
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
43495ef8
...
...
@@ -29,6 +29,7 @@ import Gargantext.Prelude
import Gargantext.Config (End(..), NodeType(..), OrderBy(..), Path(..), TabType, toUrl)
import Gargantext.Config.REST (put, post, deleteWithBody)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, trashCategory, decodeCategory, putCategories)
import Gargantext.Components.Table as T
import Gargantext.Utils (toggleSet)
import Gargantext.Utils.DecodeMaybe ((.|))
...
...
@@ -83,9 +84,9 @@ initialState =
}
data Action
= Mark
Favorites
(Array Int)
= Mark
Category Category
(Array Int)
| ToggleDocumentToDelete Int
| Trash
| Trash
Documents
newtype Pair = Pair
{ id :: Int
...
...
@@ -106,9 +107,9 @@ newtype DocumentsView
, score :: Int
, pairs :: Array Pair
, delete :: Boolean
, category :: Category
}
derive instance genericDocumentsView :: Generic DocumentsView _
instance showDocumentsView :: Show DocumentsView where
...
...
@@ -118,7 +119,7 @@ newtype Response = Response
{ id :: Int
, created :: String
, hyperdata :: Hyperdata
,
favorite :: Boolean
,
category :: Category
, ngramCount :: Int
-- , date :: String
-- , score :: Int
...
...
@@ -174,7 +175,7 @@ instance decodeResponse :: DecodeJson Response where
hyperdata <- obj .? "hyperdata"
favorite <- obj .? "favorite"
ngramCount <- obj .? "ngramCount"
pure $ Response { id, created, hyperdata, favorite, ngramCount }
pure $ Response { id, created, hyperdata,
category: decodeCategory
favorite, ngramCount }
-- | Filter
-- TODO: unused
...
...
@@ -194,12 +195,12 @@ layoutDocview :: Spec State Props Action
layoutDocview = simpleSpec performAction render
where
performAction :: PerformAction State Props Action
performAction (Mark
Favorites
nids) {nodeId} _ =
void $ lift $ put
Favorites nodeId (FavoriteQuery {favorites: nids})
performAction (Mark
Category category
nids) {nodeId} _ =
void $ lift $ put
Categories nodeId $ CategoryQuery {nodeIds: nids, category: favCategory category}
--TODO add array of delete rows here
performAction (ToggleDocumentToDelete nid) _ _ =
modifyState_ \state -> state {documentIdsToDelete = toggleSet nid state.documentIdsToDelete}
performAction Trash {nodeId} {documentIdsToDelete} = do
performAction Trash
Documents
{nodeId} {documentIdsToDelete} = do
void $ lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents: Set.toUnfoldable documentIdsToDelete})
modifyState_ \{documentIdsToDelete, documentIdsDeleted} ->
{ documentIdsToDelete: mempty
...
...
@@ -229,7 +230,7 @@ layoutDocview = simpleSpec performAction render
]
, div [className "col-md-12"]
[ button [ style {backgroundColor: "peru", padding : "9px", color : "white", border : "white", float: "right"}
, onClick $ (\_ -> dispatch Trash)
, onClick $ (\_ -> dispatch Trash
Documents
)
]
[ i [className "glyphitem glyphicon glyphicon-trash", style {marginRight : "9px"}] []
, text "Trash it !"
...
...
@@ -245,12 +246,12 @@ layoutDocviewGraph :: Spec State Props Action
layoutDocviewGraph = simpleSpec performAction render
where
performAction :: PerformAction State Props Action
performAction (Mark
Favorites
nids) {nodeId} _ =
void $ lift $ put
Favorites nodeId (FavoriteQuery {favorites: nids})
performAction (Mark
Category category
nids) {nodeId} _ =
void $ lift $ put
Categories nodeId $ CategoryQuery {nodeIds: nids, category: favCategory category}
--TODO add array of delete rows here
performAction (ToggleDocumentToDelete nid) _ _ =
modifyState_ \state -> state {documentIdsToDelete = toggleSet nid state.documentIdsToDelete}
performAction Trash {nodeId} {documentIdsToDelete} = do
performAction Trash
Documents
{nodeId} {documentIdsToDelete} = do
void $ lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents: Set.toUnfoldable documentIdsToDelete})
modifyState_ \{documentIdsToDelete, documentIdsDeleted} ->
{ documentIdsToDelete: mempty
...
...
@@ -275,7 +276,7 @@ layoutDocviewGraph = simpleSpec performAction render
, container
}
, button [ style {backgroundColor: "peru", padding : "9px", color : "white", border : "white", float: "right"}
, onClick $ (\_ -> dispatch Trash)
, onClick $ (\_ -> dispatch Trash
Documents
)
]
[ i [className "glyphitem glyphicon glyphicon-trash", style {marginRight : "9px"}] []
, text "Trash it !"
...
...
@@ -303,7 +304,7 @@ loadPage {nodeId, listId, query, params: {limit, offset, orderBy}} = do
res2corpus :: Response -> DocumentsView
res2corpus (Response { id, created: date, ngramCount: score
, hyperdata: Hyperdata {title, source}
-- favorite TODO
, category
}) =
DocumentsView
{ id
...
...
@@ -313,6 +314,7 @@ loadPage {nodeId, listId, query, params: {limit, offset, orderBy}} = do
, score
, pairs: []
, delete: false
, category
}
convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc
convOrderBy (T.DESC (T.ColumnName "Date")) = DateDesc
...
...
@@ -363,7 +365,7 @@ renderPage loaderDispatch { totalRecords, dispatch, container
]
where
-- TODO: how to interprete other scores?
gi
0
= "glyphicon glyphicon-star-empty"
gi
Favorite
= "glyphicon glyphicon-star-empty"
gi _ = "glyphicon glyphicon-star"
isChecked id = Set.member id documentIdsToDelete
isDeleted (DocumentsView {id}) = Set.member id documentIdsDeleted
...
...
@@ -371,7 +373,7 @@ renderPage loaderDispatch { totalRecords, dispatch, container
| id > 1 = [a [href (toUrl Front NodeContact (Just id)), target "blank"] [text label]]
| otherwise = [text label]
comma = span [] [text ", "]
rows = (\(DocumentsView {id,score,title,source,date,pairs,delete}) ->
rows = (\(DocumentsView {id,score,title,source,date,pairs,delete
,category
}) ->
let
strikeIfDeleted
| delete = [style {textDecoration : "line-through"}]
...
...
@@ -379,8 +381,8 @@ renderPage loaderDispatch { totalRecords, dispatch, container
in
{ row:
[ div []
[ a [ className $ gi
score
, onClick $ const $ dispatch $ Mark
Favorites
[id]
[ a [ className $ gi
category
, onClick $ const $ dispatch $ Mark
Category category
[id]
] []
]
-- TODO show date: Year-Month-Day only
...
...
@@ -405,15 +407,6 @@ pageLoader props = React.createElement pageLoaderClass props []
---------------------------------------------------------
newtype FavoriteQuery = FavoriteQuery
{ favorites :: Array Int
}
instance encodeJsonFQuery :: EncodeJson FavoriteQuery where
encodeJson (FavoriteQuery post)
= "favorites" := post.favorites
~> jsonEmptyObject
newtype DeleteDocumentQuery = DeleteDocumentQuery
{
documents :: Array Int
...
...
@@ -425,11 +418,5 @@ instance encodeJsonDDQuery :: EncodeJson DeleteDocumentQuery where
= "documents" := post.documents
~> jsonEmptyObject
putFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
putFavorites nodeId = put (toUrl Back Node (Just nodeId) <> "/favorites")
deleteFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
deleteFavorites nodeId = deleteWithBody (toUrl Back Node (Just nodeId) <> "/favorites")
deleteDocuments :: Int -> DeleteDocumentQuery -> Aff (Array Int)
deleteDocuments nodeId = deleteWithBody (toUrl Back Node (Just nodeId) <> "/documents")
src/Gargantext/Components/Search/Types.purs
View file @
43495ef8
...
...
@@ -2,8 +2,11 @@ module Gargantext.Components.Search.Types where
import Control.Monad.Cont.Trans (lift)
import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>), encodeJson)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Array (head)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (class Newtype)
import Data.Tuple (Tuple)
import Data.Tuple.Nested ((/\))
...
...
@@ -14,7 +17,8 @@ import Thermite (PerformAction, modifyState)
import Gargantext.Prelude
import Gargantext.Types (class ToQuery)
import Gargantext.Config.REST (post)
import Gargantext.Config (End(..), NodeType(..), Path(..), toUrl)
import Gargantext.Config.REST (post, put)
import Gargantext.Components.Modals.Modal (modalHide)
import Gargantext.Pages.Layout.Specs.AddCorpus.States (Response, State)
import Gargantext.Utils (id)
...
...
@@ -96,3 +100,51 @@ instance encodeJsonSearchQuery :: EncodeJson SearchQuery where
~> "corpus_id" := fromMaybe 0 corpus_id
~> "files_id" := files_id
~> jsonEmptyObject
data Category = Trash | Normal | Favorite
derive instance genericFavorite :: Generic Category _
instance showCategory :: Show Category where
show = genericShow
instance eqCategory :: Eq Category where
eq = genericEq
instance encodeJsonCategory :: EncodeJson Category where
encodeJson Trash = encodeJson 0
encodeJson Normal = encodeJson 1
encodeJson Favorite = encodeJson 2
favCategory :: Category -> Category
favCategory Normal = Favorite
favCategory Trash = Favorite
favCategory Favorite = Normal
trashCategory :: Category -> Category
trashCategory Normal = Trash
trashCategory Trash = Normal
trashCategory Favorite = Trash
decodeCategory :: Int -> Category
decodeCategory 0 = Trash
decodeCategory 1 = Normal
decodeCategory 2 = Favorite
decodeCategory _ = Normal
newtype CategoryQuery = CategoryQuery {
nodeIds :: Array Int
, category :: Category
}
instance encodeJsonCategoryQuery :: EncodeJson CategoryQuery where
encodeJson (CategoryQuery post) =
"ntc_nodesId" := post.nodeIds
~> "ntc_category" := encodeJson post.category
~> jsonEmptyObject
categoryUrl :: Int -> String
categoryUrl nodeId = toUrl Back Node (Just nodeId) <> "/category"
putCategories :: Int -> CategoryQuery -> Aff (Array Int)
putCategories nodeId = put $ categoryUrl nodeId
src/Gargantext/Pages/Corpus/Graph/Tabs.purs
View file @
43495ef8
...
...
@@ -4,7 +4,6 @@ import Prelude hiding (div)
import Data.Lens (view)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..))
import Gargantext.Components.FacetsTable (TextQuery, docViewSpec)
import Gargantext.Components.Table as T
...
...
src/Gargantext/Pages/Layout.purs
View file @
43495ef8
...
...
@@ -10,7 +10,6 @@ import Gargantext.Pages.Corpus.Graph as GE
-- import Gargantext.Pages.Corpus.Tabs.Terms.NgramsTable as NG
-- import Gargantext.Pages.Home as L
-- import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..))
dispatchAction :: forall ignored m.
...
...
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