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
132
Issues
132
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
3a73ed0b
Commit
3a73ed0b
authored
Feb 15, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] score sorting work
parent
69038bce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
9 deletions
+97
-9
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+11
-9
Score.purs
src/Gargantext/Components/Score.purs
+86
-0
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
3a73ed0b
...
...
@@ -30,6 +30,7 @@ import Gargantext.Components.DocsTable.Types
import Gargantext.Components.Table.Types as T
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types (SidePanelTriggers)
import Gargantext.Components.Score as GCS
import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
...
...
@@ -360,7 +361,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
, localCategories
, params } _ = do
reload <-
R.useState' 0
reload <-
GUR.new
pure $ T.table
{ syncResetButton : [ H.div {} [] ]
...
...
@@ -389,21 +390,22 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
row dv@(DocumentsView r) =
{ row:
T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" }
[ docChooser { listId, mCorpusId, nodeId: r._id, selected, sidePanelTriggers, tableReload: reload } []
]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" }
[ rating { score: cat, nodeId, row: dv, session, setLocalCategories } [] ]
H.div { className: "" }
[ docChooser { listId, mCorpusId, nodeId: r._id, selected, sidePanelTriggers, tableReload: reload } []
]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" }
[ rating { score: cat, nodeId, row: dv, session, setLocalCategories } [] ]
--, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only
, H.div { className: tClassName } [ R2.showText r.date ]
, H.div { className: tClassName }
[ H.a { href: url frontends $ corpusDocument r._id, target: "_blank"}
[ H.a { href: url frontends $ corpusDocument r._id, target: "_blank"
}
[ H.text r.title ]
]
, H.div { className: tClassName } [ H.text $ if r.source == "" then "Source" else r.source ]
, H.div {} [ H.text $ maybe "-" show r.ngramCount ]
-- , H.div {} [ H.text $ maybe "-" show r.score ]
, H.div { className: tClassName } [ GCS.scoreEl { docId: r._id, nodeId, score: r.score, session, tableReload: reload } [] ]
]
, delete: true }
where
...
...
src/Gargantext/Components/Score.purs
0 → 100644
View file @
3a73ed0b
module Gargantext.Components.Score where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>), encodeJson)
import Data.Int (fromString)
import Data.Maybe (Maybe(..), maybe)
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
type Score = Int
type DocID = Int
thisModule :: String
thisModule = "Gargantext.Components.Score"
type Props = (
docId ::DocID
, nodeId :: GT.NodeID
, score :: Maybe Score
, session :: Session
, tableReload :: GUR.ReloadS
)
type Choice = Maybe Score
scoreEl :: R2.Component Props
scoreEl = R.createElement scoreElCpt
scoreElCpt :: R.Component Props
scoreElCpt = R.hooksComponentWithModule thisModule "scoreEl" cpt
where
cpt { docId, nodeId, score, session, tableReload } _ = do
pure $ R2.select { className: "form-control"
, defaultValue: showChoice score
, on: { change: onChange session nodeId docId tableReload }
} (map option choices)
onChange session nodeId docId reloadS e = do
-- TODO change score via api
let query = ScoreQuery { nodeIds: [ docId ]
, score: readChoice $ R.unsafeEventValue e }
launchAff_ $ do
_ <- putScore session nodeId query
liftEffect $ GUR.bump reloadS
option :: Choice -> R.Element
option c = H.option { value: showChoice c } [ H.text $ showChoice c ]
choices = [ Nothing
, Just 5
, Just 10
, Just 15 ]
showChoice :: Choice -> String
showChoice Nothing = "-"
showChoice (Just c) = show c
readChoice = fromString
newtype ScoreQuery =
ScoreQuery { nodeIds :: Array DocID
, score :: Choice
}
instance encodeJsonScoreQuery :: EncodeJson ScoreQuery where
encodeJson (ScoreQuery post) =
"nts_nodesId" := post.nodeIds
~> "nts_score" := encodeJson post.score
~> jsonEmptyObject
putScore :: Session -> GT.NodeID -> ScoreQuery -> Aff (Array Int)
putScore session nodeId = put session $ scoreRoute nodeId
where
scoreRoute :: GT.NodeID -> SessionRoute
scoreRoute nodeId = NodeAPI GT.Node (Just nodeId) "score"
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