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
1d0b9f16
Commit
1d0b9f16
authored
May 30, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] UpdateNode type and json instance
parent
1aded978
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
29 deletions
+52
-29
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+2
-2
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+39
-14
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+3
-5
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+2
-2
Types.purs
src/Gargantext/Types.purs
+6
-6
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
1d0b9f16
...
@@ -13,7 +13,7 @@ import Reactix.DOM.HTML as H
...
@@ -13,7 +13,7 @@ import Reactix.DOM.HTML as H
import Record as Record
import Record as Record
import Record.Extra as RecordE
import Record.Extra as RecordE
import Gargantext.Components.Forest.Tree.Node.Action (Action(..),
CreateValue(..), FTree, ID, LNode(..), NTree(..), Reload, RenameValue(..), Tree, create
Node, deleteNode, loadNode, renameNode)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..),
AddNodeValue(..), FTree, ID, LNode(..), NTree(..), Reload, RenameValue(..), Tree, add
Node, deleteNode, loadNode, renameNode)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile)
import Gargantext.Components.Forest.Tree.Node.Box (nodeMainSpan)
import Gargantext.Components.Forest.Tree.Node.Box (nodeMainSpan)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
...
@@ -209,7 +209,7 @@ performAction p@{ openNodes: (_ /\ setOpenNodes)
...
@@ -209,7 +209,7 @@ performAction p@{ openNodes: (_ /\ setOpenNodes)
, session
, session
, tree: (NTree (LNode {id}) _) } (CreateSubmit name nodeType) = do
, tree: (NTree (LNode {id}) _) } (CreateSubmit name nodeType) = do
-- task <- createNodeAsync session id $ CreateValue {name, nodeType}
-- task <- createNodeAsync session id $ CreateValue {name, nodeType}
task <-
createNode session id $ Creat
eValue {name, nodeType}
task <-
addNode session id $ AddNod
eValue {name, nodeType}
-- liftEffect $ setAsyncTasks $ A.cons task
-- liftEffect $ setAsyncTasks $ A.cons task
liftEffect do
liftEffect do
setOpenNodes (Set.insert (mkNodeId session id))
setOpenNodes (Set.insert (mkNodeId session id))
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
1d0b9f16
...
@@ -60,18 +60,18 @@ type UploadFile =
...
@@ -60,18 +60,18 @@ type UploadFile =
, name :: String
, name :: String
}
}
createNode :: Session -> ID -> Creat
eValue -> Aff (Array ID)
addNode :: Session -> ID -> AddNod
eValue -> Aff (Array ID)
create
Node session parentId = post session $ NodeAPI GT.Node (Just parentId) ""
add
Node session parentId = post session $ NodeAPI GT.Node (Just parentId) ""
create
NodeAsync :: Session
add
NodeAsync :: Session
-> ID
-> ID
->
Creat
eValue
->
AddNod
eValue
-> Aff GT.AsyncTaskWithType
-> Aff GT.AsyncTaskWithType
create
NodeAsync session parentId q = do
add
NodeAsync session parentId q = do
task <- post session p q
task <- post session p q
pure $ GT.AsyncTaskWithType {task, typ: GT.
Create
Node}
pure $ GT.AsyncTaskWithType {task, typ: GT.
Add
Node}
where
where
p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.
Create
Node)
p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.
Add
Node)
renameNode :: Session -> ID -> RenameValue -> Aff (Array ID)
renameNode :: Session -> ID -> RenameValue -> Aff (Array ID)
renameNode session renameNodeId = put session $ NodeAPI GT.Node (Just renameNodeId) "rename"
renameNode session renameNodeId = put session $ NodeAPI GT.Node (Just renameNodeId) "rename"
...
@@ -87,29 +87,53 @@ updateNode :: Session -> ID -> Aff ID
...
@@ -87,29 +87,53 @@ updateNode :: Session -> ID -> Aff ID
updateNode session nodeId = post session
updateNode session nodeId = post session
-}
-}
-----------------------------------------------------------------------
newtype RenameValue = RenameValue
newtype RenameValue = RenameValue
{ name :: Name
{ name :: Name }
}
instance encodeJsonRenameValue :: EncodeJson RenameValue where
instance encodeJsonRenameValue :: EncodeJson RenameValue where
encodeJson (RenameValue {name})
encodeJson (RenameValue {name})
= "r_name" := name
= "r_name" := name
~> jsonEmptyObject
~> jsonEmptyObject
newtype CreateValue = CreateValue
-----------------------------------------------------------------------
newtype AddNodeValue = AddNodeValue
{ name :: Name
{ name :: Name
, nodeType :: GT.NodeType
, nodeType :: GT.NodeType
}
}
instance encodeJsonCreateValue :: EncodeJson
Creat
eValue where
instance encodeJsonCreateValue :: EncodeJson
AddNod
eValue where
encodeJson (
Creat
eValue {name, nodeType})
encodeJson (
AddNod
eValue {name, nodeType})
= "pn_name" := name
= "pn_name" := name
~> "pn_typename" := nodeType
~> "pn_typename" := nodeType
~> jsonEmptyObject
~> jsonEmptyObject
-----------------------------------------------------------------------
data UpdateNodeParams = UpdateNodeParamsList { method :: Int }
| UpdateNodeParamsGraph { method :: String }
| UpdateNodeParamsTexts { method :: Int }
instance encodeJsonUpdateNodeParams :: EncodeJson UpdateNodeParams
where
encodeJson (UpdateNodeParamsList { method })
= "method" := method
~> jsonEmptyObject
encodeJson (UpdateNodeParamsGraph { method })
= "method" := method
~> jsonEmptyObject
encodeJson (UpdateNodeParamsTexts { method })
= "method" := method
~> jsonEmptyObject
-----------------------------------------------------------------------
data NTree a = NTree a (Array (NTree a))
data NTree a = NTree a (Array (NTree a))
type FTree = NTree LNode
type FTree = NTree LNode
type Tree = { tree :: FTree, asyncTasks :: Array GT.AsyncTaskWithType }
type Tree = { tree :: FTree
, asyncTasks :: Array GT.AsyncTaskWithType
}
instance ntreeFunctor :: Functor NTree where
instance ntreeFunctor :: Functor NTree where
map f (NTree x ary) = NTree (f x) (map (map f) ary)
map f (NTree x ary) = NTree (f x) (map (map f) ary)
...
@@ -129,7 +153,8 @@ instance decodeJsonLNode :: DecodeJson LNode where
...
@@ -129,7 +153,8 @@ instance decodeJsonLNode :: DecodeJson LNode where
nodeType <- obj .: "type"
nodeType <- obj .: "type"
pure $ LNode { id : id_
pure $ LNode { id : id_
, name
, name
, nodeType}
, nodeType
}
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
decodeJson json = do
decodeJson json = do
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
1d0b9f16
...
@@ -28,11 +28,11 @@ type CreateNodeProps =
...
@@ -28,11 +28,11 @@ type CreateNodeProps =
, nodeTypes :: Array NodeType
, nodeTypes :: Array NodeType
)
)
create
NodeView :: Record CreateNodeProps
add
NodeView :: Record CreateNodeProps
-> R.Element
-> R.Element
create
NodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
add
NodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
where
where
el = R.hooksComponent "
Create
NodeView" cpt
el = R.hooksComponent "
Add
NodeView" cpt
cpt {id, name} _ = do
cpt {id, name} _ = do
nodeName <- R.useState' "Name"
nodeName <- R.useState' "Name"
nodeType' <- R.useState' $ fromMaybe NodeUser $ head nodeTypes
nodeType' <- R.useState' $ fromMaybe NodeUser $ head nodeTypes
...
@@ -103,7 +103,6 @@ createNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
...
@@ -103,7 +103,6 @@ createNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
-- END Create Node
-- END Create Node
showConfig :: NodeType -> R.Element
showConfig :: NodeType -> R.Element
showConfig NodeUser = H.div {} []
showConfig NodeUser = H.div {} []
showConfig FolderPrivate = H.div {} [H.text "This folder will be private only"]
showConfig FolderPrivate = H.div {} [H.text "This folder will be private only"]
...
@@ -111,4 +110,3 @@ showConfig FolderShared = H.div {} [H.text "This folder will be shared"]
...
@@ -111,4 +110,3 @@ showConfig FolderShared = H.div {} [H.text "This folder will be shared"]
showConfig FolderPublic = H.div {} [H.text "This folder will be public"]
showConfig FolderPublic = H.div {} [H.text "This folder will be public"]
showConfig nt = H.div {} [H.h4 {} [H.text $ "Config of " <> show nt ]]
showConfig nt = H.div {} [H.h4 {} [H.text $ "Config of " <> show nt ]]
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
1d0b9f16
...
@@ -18,7 +18,7 @@ import Effect.Console
...
@@ -18,7 +18,7 @@ import Effect.Console
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), DroppedFile(..), FileType(..), ID, Name, UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), DroppedFile(..), FileType(..), ID, Name, UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..),
create
NodeView)
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..),
add
NodeView)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView, uploadTermListView, copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView, uploadTermListView, copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
...
@@ -542,7 +542,7 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
...
@@ -542,7 +542,7 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
cpt {action: Delete, nodeType, dispatch} _ = actionDelete nodeType dispatch
cpt {action: Delete, nodeType, dispatch} _ = actionDelete nodeType dispatch
cpt {action: Add xs, dispatch, id, name, nodePopup: p, nodeType} _ = do
cpt {action: Add xs, dispatch, id, name, nodePopup: p, nodeType} _ = do
pure $
create
NodeView {dispatch, id, name, nodeType, nodeTypes: xs}
pure $
add
NodeView {dispatch, id, name, nodeType, nodeTypes: xs}
cpt {action: CopyFromCorpus, dispatch, id, nodeType, session} _ = do
cpt {action: CopyFromCorpus, dispatch, id, nodeType, session} _ = do
pure $ copyFromCorpusView {dispatch, id, nodeType, session}
pure $ copyFromCorpusView {dispatch, id, nodeType, session}
...
...
src/Gargantext/Types.purs
View file @
1d0b9f16
...
@@ -457,11 +457,11 @@ modeTabType Institutes = CTabInstitutes
...
@@ -457,11 +457,11 @@ modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
modeTabType Terms = CTabTerms
modeFromString :: String -> Maybe Mode
modeFromString :: String -> Maybe Mode
modeFromString "Authors" = Just Authors
modeFromString "Authors"
= Just Authors
modeFromString "Sources" = Just Sources
modeFromString "Sources"
= Just Sources
modeFromString "Institutes" = Just Institutes
modeFromString "Institutes" = Just Institutes
modeFromString "Terms" = Just Terms
modeFromString "Terms"
= Just Terms
modeFromString _ = Nothing
modeFromString _
= Nothing
-- | Async tasks
-- | Async tasks
...
@@ -469,7 +469,7 @@ modeFromString _ = Nothing
...
@@ -469,7 +469,7 @@ modeFromString _ = Nothing
data AsyncTaskType = Form
data AsyncTaskType = Form
| GraphT
| GraphT
| Query
| Query
|
Create
Node
|
Add
Node
| UpdateNode
| UpdateNode
derive instance genericAsyncTaskType :: Generic AsyncTaskType _
derive instance genericAsyncTaskType :: Generic AsyncTaskType _
...
@@ -477,7 +477,7 @@ asyncTaskTypePath :: AsyncTaskType -> String
...
@@ -477,7 +477,7 @@ asyncTaskTypePath :: AsyncTaskType -> String
asyncTaskTypePath Form = "add/form/async/"
asyncTaskTypePath Form = "add/form/async/"
asyncTaskTypePath Query = "query/"
asyncTaskTypePath Query = "query/"
asyncTaskTypePath GraphT = "async/"
asyncTaskTypePath GraphT = "async/"
asyncTaskTypePath
Create
Node = "async/nobody/"
asyncTaskTypePath
Add
Node = "async/nobody/"
asyncTaskTypePath UpdateNode = "async/"
asyncTaskTypePath UpdateNode = "async/"
type AsyncTaskID = String
type AsyncTaskID = 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