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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
388f48fc
Commit
388f48fc
authored
Feb 27, 2022
by
arturo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
>>> continue
parent
51b679f0
Pipeline
#2516
failed with stage
in 0 seconds
Changes
7
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
976 additions
and
34 deletions
+976
-34
Update.purs
...Gargantext/Components/Forest/Tree/Node/Action/Update.purs
+38
-3
Types.purs
...text/Components/Forest/Tree/Node/Action/Update/Types.purs
+14
-9
Settings.purs
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
+6
-7
API.purs
src/Gargantext/Components/PhyloExplorer/API.purs
+286
-15
ConfigForm.purs
src/Gargantext/Components/PhyloExplorer/ConfigForm.purs
+628
-0
Reload.purs
src/Gargantext/Components/Reload.purs
+2
-0
Unboxed.purs
src/Gargantext/Hooks/StateRecord/Unboxed.purs
+2
-0
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Update.purs
View file @
388f48fc
...
...
@@ -3,11 +3,17 @@ module Gargantext.Components.Forest.Tree.Node.Action.Update where
import Gargantext.Components.Forest.Tree.Node.Action.Update.Types
import Gargantext.Prelude
import DOM.Simple.Console (log)
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Aff (Aff, launchAff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe, submitButton, panel)
import Gargantext.Components.PhyloExplorer.API (Clique(..), CliqueFilter(..), TimeUnit(..), TimeUnitCriteria(..))
import Gargantext.Components.PhyloExplorer.API as Phylo
import Gargantext.Components.PhyloExplorer.ConfigForm (configForm)
import Gargantext.Config.REST (RESTError, AffRESTError)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post)
...
...
@@ -17,6 +23,7 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Unsafe.Coerce (unsafeCoerce)
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Update"
...
...
@@ -83,8 +90,36 @@ updatePhylo = R2.leaf updatePhyloCpt
updatePhyloCpt :: R.Component UpdateProps
updatePhyloCpt = here.component "updatePhylo" cpt where
cpt { dispatch } _ = do
-- @WIP: no `update/` async route created for phylo update in backend
pure $ H.div {} [ H.text "hello" ]
-- Behavior
let
params :: Action
params
= UpdateNode $ UpdateNodeParamsPhylo
{ methodPhylo: paramsValue
}
paramsValue :: Phylo.UpdateData
paramsValue = Phylo.UpdateData
{ proximity: 0.1
, synchrony: 0.1
, quality: 0.1
, exportFilter: 0.1
, timeUnit: Year $ TimeUnitCriteria
{ period: 3
, step: 1
, matchingFrame: 5
}
, clique: FIS
{ support: 1
, size: 1
}
}
-- Render
pure $
configForm
{ callback: \_ -> launchAff_ $ dispatch $ params
, status: Enabled
}
updateNodeList :: R2.Component UpdateProps
updateNodeList = R.createElement updateNodeListCpt
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Update/Types.purs
View file @
388f48fc
module Gargantext.Components.Forest.Tree.Node.Action.Update.Types where
import Gargantext.Prelude
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Gargantext.Components.PhyloExplorer.API as Phylo
import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG
import Gargantext.Prelude
data UpdateNodeParams = UpdateNodeParamsList { methodList :: Method }
| UpdateNodeParamsGraph { methodGraph :: GraphMetric }
| UpdateNodeParamsTexts { methodTexts :: Granularity }
| UpdateNodeParamsBoard { methodBoard :: Charts }
data UpdateNodeParams
= UpdateNodeParamsList { methodList :: Method }
| UpdateNodeParamsGraph { methodGraph :: GraphMetric }
| UpdateNodeParamsTexts { methodTexts :: Granularity }
| UpdateNodeParamsBoard { methodBoard :: Charts }
| UpdateNodeParamsPhylo { methodPhylo :: Phylo.UpdateData }
derive instance Eq UpdateNodeParams
derive instance Generic UpdateNodeParams _
instance Show UpdateNodeParams where show = genericShow
...
...
@@ -30,6 +33,9 @@ instance JSON.WriteForeign UpdateNodeParams where
writeImpl (UpdateNodeParamsBoard { methodBoard }) =
JSON.writeImpl { type: "UpdateNodeParamsBoard"
, methodBoard }
writeImpl (UpdateNodeParamsPhylo { methodPhylo }) =
JSON.writeImpl { type: "UpdateNodePhylo"
, config: methodPhylo }
----------------------------------------------------------------------
data Method = Basic | Advanced | WithModel
...
...
@@ -55,7 +61,7 @@ instance Read GraphMetric where
read _ = Nothing
instance JSON.ReadForeign GraphMetric where readImpl = JSONG.enumSumRep
instance JSON.WriteForeign GraphMetric where writeImpl = JSON.writeImpl <<< show
----------------------------------------------------------------------
data Granularity = NewNgrams | NewTexts | Both
...
...
@@ -86,4 +92,3 @@ instance JSON.ReadForeign Charts where readImpl = JSONG.enumSumRep
instance JSON.WriteForeign Charts where
writeImpl All = JSON.writeImpl $ "AllCharts"
writeImpl f = JSON.writeImpl $ show f
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
View file @
388f48fc
...
...
@@ -24,7 +24,7 @@ data NodeAction = Documentation NodeType
| Clone
| AddingContact
| CloseNodePopover
| WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
| WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
------------------------------------------------------------------------
instance Eq NodeAction where
...
...
@@ -223,7 +223,8 @@ settingsBox Phylo =
SettingsBox { show : true
, edit : true
, doc : Documentation Phylo
, buttons : [ Delete
, buttons : [ Refresh
, Delete
]
}
...
...
@@ -383,7 +384,7 @@ settingsBox _ =
-- | SubTree Parameters
moveParameters = { subTreeParams : SubTreeParams
moveParameters = { subTreeParams : SubTreeParams
{ showtypes: [ FolderPrivate
, FolderShared
, Team
...
...
@@ -399,7 +400,7 @@ moveParameters = { subTreeParams : SubTreeParams
}
moveFrameParameters = { subTreeParams : SubTreeParams
moveFrameParameters = { subTreeParams : SubTreeParams
{ showtypes: [ FolderPrivate
, FolderShared
, Team
...
...
@@ -422,7 +423,7 @@ moveFrameParameters = { subTreeParams : SubTreeParams
linkParams :: NodeType -> {subTreeParams :: SubTreeParams}
linkParams nodeType = { subTreeParams : SubTreeParams
linkParams nodeType = { subTreeParams : SubTreeParams
{ showtypes: [ FolderPrivate
, FolderShared
, Team
...
...
@@ -444,5 +445,3 @@ publishParams = { subTreeParams : SubTreeParams
]
}
}
src/Gargantext/Components/PhyloExplorer/API.purs
View file @
388f48fc
module Gargantext.Components.PhyloExplorer.API
( get, update) where
( get
, UpdateData(..)
, TimeUnit(..), ReflexiveTimeUnit(..), TimeUnitCriteria(..)
, Clique(..), ReflexiveClique(..), CliqueFilter(..)
, update, updateProgress
) where
import Gargantext.Prelude
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.Symbol (SProxy(..))
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSONSet)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet, parsePhyloJSONSet)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes as GR
import Gargantext.Sessions (Session)
import Gargantext.Sessions as S
import Gargantext.Types (NodeID)
import Gargantext.Types as GT
import Record as Record
import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG
get :: S.Session -> NodeID -> AffRESTError (PhyloDataSet)
...
...
@@ -17,18 +33,273 @@ get session nodeId = request >>= (_ <#> parsePhyloJSONSet) >>> pure
request :: AffRESTError (PhyloJSONSet)
request = S.get session $ PhyloAPI nodeId
-- @WIP: change `Unit` to actual Record of options
update :: S.Session -> NodeID -> Unit -> AffRESTError (PhyloDataSet)
update session nodeId _ = request >>= (_ <#> parsePhyloJSONSet) >>> pure
where
request :: AffRESTError (PhyloJSONSet)
request = S.post session (PhyloAPI nodeId) options
options =
{ phyloProximity: 0.5
, phyloSynchrony: 0.5
, phyloQuality: 0.5
, timeUnit: 3
, clique: 5
, exportFilter: [ 3 ]
----------------------------------------------------------
newtype UpdateData = UpdateData
{ proximity :: Number
, synchrony :: Number
, quality :: Number
, timeUnit :: TimeUnit
, clique :: Clique
, exportFilter :: Number
}
derive instance Generic UpdateData _
derive instance Eq UpdateData
instance Show UpdateData where show = genericShow
derive newtype instance JSON.ReadForeign UpdateData
instance JSON.WriteForeign UpdateData where
writeImpl (UpdateData o) = (JSON.writeImpl <<< rename) o
where
rename
= Record.rename
(SProxy :: SProxy "proximity")
(SProxy :: SProxy "_sc_phyloProximity")
>>> Record.rename
(SProxy :: SProxy "synchrony")
(SProxy :: SProxy "_sc_phyloSynchrony")
>>> Record.rename
(SProxy :: SProxy "quality")
(SProxy :: SProxy "_sc_phyloQuality")
>>> Record.rename
(SProxy :: SProxy "timeUnit")
(SProxy :: SProxy "_sc_timeUnit")
>>> Record.rename
(SProxy :: SProxy "clique")
(SProxy :: SProxy "_sc_clique")
>>> Record.rename
(SProxy :: SProxy "exportFilter")
(SProxy :: SProxy "_sc_exportFilter")
data TimeUnit
= Epoch TimeUnitCriteria
| Year TimeUnitCriteria
| Month TimeUnitCriteria
| Week TimeUnitCriteria
| Day TimeUnitCriteria
derive instance Generic TimeUnit _
derive instance Eq TimeUnit
instance Show TimeUnit where show = genericShow
instance JSON.ReadForeign TimeUnit where readImpl = JSONG.untaggedSumRep
instance JSON.WriteForeign TimeUnit where
writeImpl = case _ of
Epoch (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseEpoch) o
Year (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseYear) o
Month (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseMonth) o
Week (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseWeek) o
Day (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseDay) o
where
parseEpoch
= Record.rename
(SProxy :: SProxy "period")
(SProxy :: SProxy "_epoch_period")
>>> Record.rename
(SProxy :: SProxy "step")
(SProxy :: SProxy "_epoch_step")
>>> Record.rename
(SProxy :: SProxy "matchingFrame")
(SProxy :: SProxy "_epoch_matchingFrame")
>>> Record.insert
(SProxy :: SProxy "tag")
"Epoch"
parseYear
= Record.rename
(SProxy :: SProxy "period")
(SProxy :: SProxy "_year_period")
>>> Record.rename
(SProxy :: SProxy "step")
(SProxy :: SProxy "_year_step")
>>> Record.rename
(SProxy :: SProxy "matchingFrame")
(SProxy :: SProxy "_year_matchingFrame")
>>> Record.insert
(SProxy :: SProxy "tag")
"Year"
parseMonth
= Record.rename
(SProxy :: SProxy "period")
(SProxy :: SProxy "_month_period")
>>> Record.rename
(SProxy :: SProxy "step")
(SProxy :: SProxy "_month_step")
>>> Record.rename
(SProxy :: SProxy "matchingFrame")
(SProxy :: SProxy "_month_matchingFrame")
>>> Record.insert
(SProxy :: SProxy "tag")
"Month"
parseWeek
= Record.rename
(SProxy :: SProxy "period")
(SProxy :: SProxy "_week_period")
>>> Record.rename
(SProxy :: SProxy "step")
(SProxy :: SProxy "_week_step")
>>> Record.rename
(SProxy :: SProxy "matchingFrame")
(SProxy :: SProxy "_week_matchingFrame")
>>> Record.insert
(SProxy :: SProxy "tag")
"Week"
parseDay
= Record.rename
(SProxy :: SProxy "period")
(SProxy :: SProxy "_day_period")
>>> Record.rename
(SProxy :: SProxy "step")
(SProxy :: SProxy "_day_step")
>>> Record.rename
(SProxy :: SProxy "matchingFrame")
(SProxy :: SProxy "_day_matchingFrame")
>>> Record.insert
(SProxy :: SProxy "tag")
"Day"
data ReflexiveTimeUnit
= Epoch_
| Year_
| Month_
| Week_
| Day_
derive instance Generic ReflexiveTimeUnit _
derive instance Eq ReflexiveTimeUnit
instance Show ReflexiveTimeUnit where show = genericShow
instance Read ReflexiveTimeUnit where
read :: String -> Maybe ReflexiveTimeUnit
read = case _ of
"Epoch" -> Just Epoch_
"Year" -> Just Year_
"Month" -> Just Month_
"Week" -> Just Week_
"Day" -> Just Day_
_ -> Nothing
newtype TimeUnitCriteria = TimeUnitCriteria
{ period :: Int
, step :: Int
, matchingFrame :: Int
}
derive instance Generic TimeUnitCriteria _
derive instance Eq TimeUnitCriteria
instance Show TimeUnitCriteria where show = genericShow
derive newtype instance JSON.ReadForeign TimeUnitCriteria
data Clique
= FIS
{ support :: Int
, size :: Int
}
| MaxClique
{ size :: Int
, threshold :: Number
, filter :: CliqueFilter
}
derive instance Eq Clique
derive instance Generic Clique _
instance Show Clique where show = genericShow
instance JSON.ReadForeign Clique where readImpl = JSONG.untaggedSumRep
instance JSON.WriteForeign Clique where
writeImpl = case _ of
FIS o -> (JSON.writeImpl <<< parseFIS) o
MaxClique o -> (JSON.writeImpl <<< parseMaxClique) o
where
parseFIS
= Record.insert
(SProxy :: SProxy "tag")
"Fis"
>>> Record.rename
(SProxy :: SProxy "support")
(SProxy :: SProxy "_fis_support")
>>> Record.rename
(SProxy :: SProxy "size")
(SProxy :: SProxy "_fis_size")
parseMaxClique
= Record.insert
(SProxy :: SProxy "tag")
"MaxClique"
>>> Record.rename
(SProxy :: SProxy "size")
(SProxy :: SProxy "_mcl_size")
>>> Record.rename
(SProxy :: SProxy "threshold")
(SProxy :: SProxy "_mcl_threshold")
>>> Record.rename
(SProxy :: SProxy "filter")
(SProxy :: SProxy "_mcl_filter")
data ReflexiveClique
= FIS_
| MaxClique_
derive instance Generic ReflexiveClique _
derive instance Eq ReflexiveClique
instance Show ReflexiveClique where show = genericShow
instance Read ReflexiveClique where
read :: String -> Maybe ReflexiveClique
read = case _ of
"FIS" -> Just FIS_
"MaxClique" -> Just MaxClique_
_ -> Nothing
data CliqueFilter = ByThreshold | ByNeighbours
derive instance Eq CliqueFilter
derive instance Generic CliqueFilter _
instance Show CliqueFilter where show = genericShow
instance JSON.ReadForeign CliqueFilter where readImpl = JSONG.enumSumRep
instance JSON.WriteForeign CliqueFilter where writeImpl = JSON.writeImpl <<< show
instance Read CliqueFilter where
read :: String -> Maybe CliqueFilter
read = case _ of
"ByTreshold" -> Just ByThreshold
"ByNeighbours" -> Just ByNeighbours
_ -> Nothing
update ::
Session
-> NodeID
-> Unit
-> AffRESTError GT.AsyncTaskWithType
update session nodeId _
= S.post session request {}
>>= case _ of
Left err -> pure $ Left err
Right task -> pure $ Right $ GT.AsyncTaskWithType
{ task
, typ: GT.UpdateNode
}
where
request = GR.NodeAPI GT.Node (Just nodeId)
(GT.asyncTaskTypePath GT.UpdateNode)
updateProgress ::
Session
-> NodeID
-> GT.AsyncTaskWithType
-> AffRESTError GT.AsyncProgress
updateProgress
session
nodeId
(GT.AsyncTaskWithType { task: GT.AsyncTask { id } })
=
S.get session request
where
request = GR.NodeAPI GT.Node (Just nodeId)
(GT.asyncTaskTypePath GT.UpdateNode <> pollParams)
pollParams = "/" <> id <> "/poll?limit1"
src/Gargantext/Components/PhyloExplorer/ConfigForm.purs
0 → 100644
View file @
388f48fc
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Reload.purs
View file @
388f48fc
...
...
@@ -7,6 +7,8 @@ import Gargantext.Utils.Toestand as T2
import Reactix as R
import Toestand as T
-- @TODO: use typing
-- | Reload Context
-- |
-- | Use with `R.provideContext` as a (nested) context
...
...
src/Gargantext/Hooks/StateRecord/Unboxed.purs
View file @
388f48fc
...
...
@@ -13,6 +13,8 @@ import Prim.RowList (class RowToList)
import Reactix as R
import Toestand as T
-- @TODO: /!\ `bindStateKey` + `setStateKey` not working together
type Methods r a =
-- | Every provided props will be available within the `formFields` proxy
( state :: Record r
...
...
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