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
81ad30d2
Verified
Commit
81ad30d2
authored
Jan 11, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refactor] support for more REST errors
Also, refactored node/settings as there were lots of duplications.
parent
f3532d2b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
366 additions
and
430 deletions
+366
-430
packages.dhall
packages.dhall
+39
-33
spago.dhall
spago.dhall
+1
-0
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+32
-30
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+21
-13
Settings.purs
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
+244
-340
REST.purs
src/Gargantext/Config/REST.purs
+29
-14
No files found.
packages.dhall
View file @
81ad30d2
...
@@ -104,7 +104,23 @@ let overrides =
...
@@ -104,7 +104,23 @@ let overrides =
}
}
let additions =
let additions =
{ sequences =
{ convertable-options =
{ dependencies = [ "console", "effect", "maybe", "record" ]
, repo = "https://github.com/natefaubion/purescript-convertable-options"
, version = "v1.0.0"
}
, data-default =
{ dependencies =
[ "assert", "lists", "maybe", "record", "effect", "prelude" ]
, repo = "https://github.com/thought2/purescript-data-default"
, version = "350e600a5a022c9599865a2dd14196b442f59bcc"
}
, dom-filereader =
{ dependencies = [ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, sequences =
{ dependencies =
{ dependencies =
[ "arrays"
[ "arrays"
, "assert"
, "assert"
...
@@ -126,6 +142,28 @@ let additions =
...
@@ -126,6 +142,28 @@ let additions =
, repo = "https://github.com/garganscript/purescript-sequences.git"
, repo = "https://github.com/garganscript/purescript-sequences.git"
, version = "recursion-fix"
, version = "recursion-fix"
}
}
, read =
{ dependencies = [ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, simple-json-generics =
{ dependencies =
[ "assert"
, "control"
, "effect"
, "either"
, "foreign"
, "partial"
, "prelude"
, "simple-json"
, "transformers"
, "typelevel-prelude"
]
, repo =
"https://github.com/garganscript/purescript-simple-json-generics"
, version = "master"
}
, spec-discovery =
, spec-discovery =
{ dependencies = [ "prelude", "effect", "arrays", "spec", "node-fs" ]
{ dependencies = [ "prelude", "effect", "arrays", "spec", "node-fs" ]
, repo = "https://github.com/purescript-spec/purescript-spec-discovery"
, repo = "https://github.com/purescript-spec/purescript-spec-discovery"
...
@@ -156,28 +194,6 @@ let additions =
...
@@ -156,28 +194,6 @@ let additions =
"https://gitlab.iscpif.fr/gargantext/purescript-string-search.git"
"https://gitlab.iscpif.fr/gargantext/purescript-string-search.git"
, version = "v0.1.6"
, version = "v0.1.6"
}
}
, dom-filereader =
{ dependencies = [ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, simple-json-generics =
{ dependencies =
[ "assert"
, "control"
, "effect"
, "either"
, "foreign"
, "partial"
, "prelude"
, "simple-json"
, "transformers"
, "typelevel-prelude"
]
, repo =
"https://github.com/garganscript/purescript-simple-json-generics"
, version = "master"
}
, tuples-native =
, tuples-native =
{ dependencies =
{ dependencies =
[ "console"
[ "console"
...
@@ -191,11 +207,6 @@ let additions =
...
@@ -191,11 +207,6 @@ let additions =
, repo = "https://github.com/garganscript/purescript-tuples-native"
, repo = "https://github.com/garganscript/purescript-tuples-native"
, version = "v2.3.0"
, version = "v2.3.0"
}
}
, read =
{ dependencies = [ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, versions =
, versions =
{ dependencies = [ "prelude" ]
{ dependencies = [ "prelude" ]
, repo = "https://github.com/hdgarrood/purescript-versions.git"
, repo = "https://github.com/hdgarrood/purescript-versions.git"
...
@@ -206,11 +217,6 @@ let additions =
...
@@ -206,11 +217,6 @@ let additions =
, repo = "https://github.com/mjepronk/purescript-web-url"
, repo = "https://github.com/mjepronk/purescript-web-url"
, version = "v2.0.0"
, version = "v2.0.0"
}
}
, convertable-options =
{ dependencies = [ "console", "effect", "maybe", "record" ]
, repo = "https://github.com/natefaubion/purescript-convertable-options"
, version = "v1.0.0"
}
}
}
in upstream // overrides // additions
in upstream // overrides // additions
spago.dhall
View file @
81ad30d2
...
@@ -28,6 +28,7 @@ to generate this file without the comments in this block.
...
@@ -28,6 +28,7 @@ to generate this file without the comments in this block.
, "convertable-options"
, "convertable-options"
, "css"
, "css"
, "d3"
, "d3"
, "data-default"
, "datetime"
, "datetime"
, "debug"
, "debug"
, "dom-filereader"
, "dom-filereader"
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
81ad30d2
...
@@ -43,9 +43,7 @@ addNodeAsync :: Session
...
@@ -43,9 +43,7 @@ addNodeAsync :: Session
-> AffRESTError GT.AsyncTaskWithType
-> AffRESTError GT.AsyncTaskWithType
addNodeAsync session parentId q = do
addNodeAsync session parentId q = do
eTask :: Either RESTError GT.AsyncTask <- post session p q
eTask :: Either RESTError GT.AsyncTask <- post session p q
case eTask of
pure $ (\task -> GT.AsyncTaskWithType { task, typ: GT.AddNode }) <$> eTask
Left err -> pure $ Left err
Right task -> pure $ Right $ GT.AsyncTaskWithType { task, typ: GT.AddNode }
where
where
p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.AddNode)
p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.AddNode)
...
@@ -91,20 +89,24 @@ addNodeViewCpt = here.component "addNodeView" cpt where
...
@@ -91,20 +89,24 @@ addNodeViewCpt = here.component "addNodeView" cpt where
setNodeType' nt = do
setNodeType' nt = do
T.write_ (GT.prettyNodeType nt) nodeName
T.write_ (GT.prettyNodeType nt) nodeName
T.write_ nt nodeType
T.write_ nt nodeType
(maybeChoose /\ nt') = if length nodeTypes > 1
(maybeChoose /\ nt') =
then ([ Tools.formChoice { items: nodeTypes
if length nodeTypes > 1 then
[ Tools.formChoice { items: nodeTypes
, default: nodeType'
, default: nodeType'
, callback: setNodeType'
, callback: setNodeType'
, print: print hasChromeAgent' } [] ] /\ nodeType')
, print: print hasChromeAgent' } []
else ([H.div {} [H.text $ "Creating a node of type "
] /\ nodeType'
else
[ H.div {}
[H.text $ "Creating a node of type "
<> show defaultNt
<> show defaultNt
<> " with name:"
<> " with name:"
]
]
] /\ defaultNt
] /\ defaultNt
)
where
where
defaultNt = (fromMaybe Error $ head nodeTypes)
defaultNt = fromMaybe Error $ head nodeTypes
maybeEdit = if edit then
maybeEdit =
if edit then
[ inputWithEnterWithKey {
[ inputWithEnterWithKey {
onBlur: \val -> T.write_ val nodeName
onBlur: \val -> T.write_ val nodeName
, onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt')
, onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt')
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
81ad30d2
...
@@ -332,31 +332,39 @@ panelAction = R2.leaf panelActionCpt
...
@@ -332,31 +332,39 @@ panelAction = R2.leaf panelActionCpt
panelActionCpt :: R.Component PanelActionProps
panelActionCpt :: R.Component PanelActionProps
panelActionCpt = here.component "panelAction" cpt
panelActionCpt = here.component "panelAction" cpt
where
where
cpt { action: Documentation nodeType} _ = pure $ actionDoc { nodeType } []
cpt { action: Download, id, nodeType, session} _ = pure $ actionDownload { id, nodeType, session } []
cpt { action: Upload, dispatch, id, nodeType, session} _ = pure $ actionUpload { dispatch, id, nodeType, session } []
cpt { action: Delete, nodeType, dispatch} _ = pure $ actionDelete { dispatch, nodeType } []
cpt { action: ManageTeam, nodeType, id, session} _ = pure $ actionManageTeam { id, nodeType, session } []
cpt { action: Add xs, dispatch, id, name, nodeType} _ =
cpt { action: Add xs, dispatch, id, name, nodeType} _ =
pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} []
pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} []
cpt { action
: Refresh , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } []
cpt { action
: AddingContact, dispatch, id } _ =
cpt { action: ReloadWithSettings , dispatch, nodeType } _ = pure $ update { dispatch, nodeType
} []
pure $ Contact.actionAddContact { dispatch, id
} []
cpt { action: Config, nodeType } _ =
cpt { action: Config, nodeType } _ =
pure $ fragmentPT $ "Config " <> show nodeType
pure $ fragmentPT $ "Config " <> show nodeType
-- Functions using SubTree
cpt { action: Delete, nodeType, dispatch} _ =
cpt { action: Reconstruct , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } []
pure $ actionDelete { dispatch, nodeType } []
cpt { action: Documentation nodeType} _ =
pure $ actionDoc { nodeType } []
cpt { action: Download, id, nodeType, session} _ =
pure $ actionDownload { id, nodeType, session } []
cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: ManageTeam, nodeType, id, session} _ =
pure $ actionManageTeam { id, nodeType, session } []
cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ mergeNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
pure $ mergeNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ moveNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
pure $ moveNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action : Share, id, session } _ = pure $ Share.shareNode { id, session } []
cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } []
cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ Share.publishNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
pure $ Share.publishNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Reconstruct , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: Refresh , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: ReloadWithSettings , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: SearchBox, boxes, dispatch, id, session } _ =
cpt { action: SearchBox, boxes, dispatch, id, session } _ =
pure $ actionSearch { boxes, dispatch, id: Just id, session } []
pure $ actionSearch { boxes, dispatch, id: Just id, session } []
cpt { action : Share, id, session } _ = pure $ Share.shareNode { id, session } []
cpt { action: Upload, dispatch, id, nodeType, session} _ =
pure $ actionUpload { dispatch, id, nodeType, session } []
cpt { action: WriteNodesDocuments, boxes, dispatch, id, session } _ =
cpt { action: WriteNodesDocuments, boxes, dispatch, id, session } _ =
pure $ actionWriteNodesDocuments { boxes, dispatch, id, session } []
pure $ actionWriteNodesDocuments { boxes, dispatch, id, session } []
cpt _ _ = pure $ H.div {} []
cpt _ _ = pure $ H.div {} []
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
View file @
81ad30d2
module Gargantext.Components.Forest.Tree.Node.Settings where
module Gargantext.Components.Forest.Tree.Node.Settings where
import Gargantext.Prelude (class Eq, class Show, show, (&&), (<>), (==))
import Data.Default (class Default, def)
import Data.Lens (Lens', lens, (.~))
import Data.Lens.Record (prop)
import Gargantext.Prelude (class Eq, class Show, show, (&&), (<>), (==), ($), (<<<))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..))
import Gargantext.Types
import Gargantext.Types
import Type.Proxy (Proxy(..))
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -11,92 +15,89 @@ import Gargantext.Types
...
@@ -11,92 +15,89 @@ import Gargantext.Types
if user has access to node then he can do all his related actions
if user has access to node then he can do all his related actions
-}
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
data NodeAction = Documentation NodeType
data NodeAction = Add (Array NodeType)
| SearchBox
| AddingContact
| Download
| CloseNodePopover
| Upload
| Refresh
| ReloadWithSettings
| Config
| Config
| Reconstruct
| Delete
| Delete
| Share
| Documentation NodeType
| Download
| Link { subTreeParams :: SubTreeParams }
| ManageTeam
| ManageTeam
| Publish { subTreeParams :: SubTreeParams }
| Add (Array NodeType)
| Merge { subTreeParams :: SubTreeParams }
| Merge { subTreeParams :: SubTreeParams }
| Move { subTreeParams :: SubTreeParams }
| Move { subTreeParams :: SubTreeParams }
| Link { subTreeParams :: SubTreeParams }
| Publish { subTreeParams :: SubTreeParams }
| Clone
| Refresh
| AddingContact
| ReloadWithSettings
| CloseNodePopover
| Reconstruct
| SearchBox
| Share
| Upload
| WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
| WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
------------------------------------------------------------------------
------------------------------------------------------------------------
instance Eq NodeAction where
instance Eq NodeAction where
eq (Add x) (Add y) = x == y
eq AddingContact AddingContact = true
eq CloseNodePopover CloseNodePopover = true
eq Config Config = true
eq Delete Delete = true
eq (Documentation x) (Documentation y) = true && (x == y)
eq (Documentation x) (Documentation y) = true && (x == y)
eq SearchBox SearchBox = true
eq Download Download = true
eq Download Download = true
eq Upload Upload = true
eq Refresh Refresh = true
eq ReloadWithSettings ReloadWithSettings = true
eq (Move x) (Move y) = x == y
eq Clone Clone = true
eq Delete Delete = true
eq Share Share = true
eq ManageTeam ManageTeam = true
eq (Link x) (Link y) = x == y
eq (Link x) (Link y) = x == y
eq
(Add x) (Add y) = x == y
eq
ManageTeam ManageTeam = true
eq (Merge x) (Merge y) = x == y
eq (Merge x) (Merge y) = x == y
eq Config Config = true
eq (Move x) (Move y) = x == y
eq Reconstruct Reconstruct = true
eq (Publish x) (Publish y) = x == y
eq (Publish x) (Publish y) = x == y
eq AddingContact AddingContact = true
eq Reconstruct Reconstruct = true
eq CloseNodePopover CloseNodePopover = true
eq Refresh Refresh = true
eq ReloadWithSettings ReloadWithSettings = true
eq SearchBox SearchBox = true
eq Share Share = true
eq Upload Upload = true
eq WriteNodesDocuments WriteNodesDocuments = true
eq WriteNodesDocuments WriteNodesDocuments = true
eq _ _ = false
eq _ _ = false
instance Show NodeAction where
instance Show NodeAction where
show (Add _) = "Add Child" -- foldl (\a b -> a <> show b) "Add " xs
show AddingContact = "AddingContact"
show CloseNodePopover = "CloseNodePopover"
show Config = "Config"
show Delete = "Delete"
show (Documentation x) = "Documentation of " <> show x
show (Documentation x) = "Documentation of " <> show x
show SearchBox = "SearchBox"
show Download = "Download"
show Download = "Download"
show Upload = "Upload"
show Refresh = "Refresh"
show ReloadWithSettings = "Reload (with settings)"
show (Move _) = "Move with subtree params" -- <> show t
show Clone = "Clone"
show Delete = "Delete"
show Share = "Share"
show ManageTeam = "Team"
show Config = "Config"
show Reconstruct = "Reconstruct"
show (Link _) = "Link to " -- <> show x
show (Link _) = "Link to " -- <> show x
show
(Add _) = "Add Child" -- foldl (\a b -> a <> show b) "Add " xs
show
ManageTeam = "Team"
show (Merge _) = "Merge with subtree" -- <> show t
show (Merge _) = "Merge with subtree" -- <> show t
show (Move _) = "Move with subtree params" -- <> show t
show (Publish _) = "Publish" -- <> show x
show (Publish _) = "Publish" -- <> show x
show AddingContact = "AddingContact"
show Reconstruct = "Reconstruct"
show CloseNodePopover = "CloseNodePopover"
show Refresh = "Refresh"
show ReloadWithSettings = "Reload (with settings)"
show SearchBox = "SearchBox"
show Share = "Share"
show Upload = "Upload"
show WriteNodesDocuments = "WriteNodesDocuments"
show WriteNodesDocuments = "WriteNodesDocuments"
glyphiconNodeAction :: NodeAction -> String
glyphiconNodeAction :: NodeAction -> String
glyphiconNodeAction (Documentation _) = "question-circle"
glyphiconNodeAction Delete = "trash"
glyphiconNodeAction (Add _) = "plus"
glyphiconNodeAction (Add _) = "plus"
glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction AddingContact = "user-plus"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction CloseNodePopover = "close"
glyphiconNodeAction (Link _) = "arrows-h"
glyphiconNodeAction Config = "wrench"
glyphiconNodeAction Delete = "trash"
glyphiconNodeAction (Documentation _) = "question-circle"
glyphiconNodeAction Download = "download"
glyphiconNodeAction Download = "download"
glyphiconNodeAction (Link _) = "arrows-h"
glyphiconNodeAction ManageTeam = "users"
glyphiconNodeAction (Merge _) = "random"
glyphiconNodeAction (Merge _) = "random"
glyphiconNodeAction (Move _) = "share-square-o"
glyphiconNodeAction (Publish _) = fldr FolderPublic true
glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction ReloadWithSettings = "reload-with-settings"
glyphiconNodeAction ReloadWithSettings = "reload-with-settings"
glyphiconNodeAction Config = "wrench"
glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction ManageTeam = "users"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction AddingContact = "user-plus"
glyphiconNodeAction (Move _) = "share-square-o"
glyphiconNodeAction (Publish _) = fldr FolderPublic true
glyphiconNodeAction CloseNodePopover = "close"
glyphiconNodeAction WriteNodesDocuments = "bars"
glyphiconNodeAction WriteNodesDocuments = "bars"
glyphiconNodeAction _ = ""
glyphiconNodeAction _ = ""
...
@@ -107,88 +108,48 @@ data SettingsBox =
...
@@ -107,88 +108,48 @@ data SettingsBox =
, doc :: NodeAction
, doc :: NodeAction
, buttons :: Array NodeAction
, buttons :: Array NodeAction
}
}
------------------------------------------------------------------------
instance Default SettingsBox where
def = SettingsBox { show: true
settingsBox :: NodeType -> SettingsBox
, edit: true
settingsBox NodeUser =
, doc: Documentation Annuaire
SettingsBox { show : true
, buttons: []
, edit : false
, doc : Documentation NodeUser
, buttons : [ Delete
]
}
}
settingsBox FolderPrivate =
defNt :: NodeType -> SettingsBox
SettingsBox { show : true
defNt nt = (_doc .~ Documentation nt) def
, edit : false
, doc : Documentation FolderPrivate
, buttons : [ Add [ Notes
, Corpus
, Calc
, Folder
, Annuaire
-- , NodeFrameNotebook
]
]
}
settingsBox Team =
_show :: Lens' SettingsBox Boolean
SettingsBox { show : true
_show = lens (\(SettingsBox { show }) -> show) (\(SettingsBox sb) val -> SettingsBox (sb { show = val }))
, edit : true
, doc : Documentation Team
, buttons : [ Add [ Notes
, Corpus
, Calc
, Folder
, Team
, Annuaire
-- , NodeFrameNotebook
-- , FolderShared
, NodeFrameVisio
]
, Share
, ManageTeam
, Delete
]
}
settingsBox FolderShared =
_edit :: Lens' SettingsBox Boolean
SettingsBox { show : true
_edit = lens (\(SettingsBox { edit }) -> edit) (\(SettingsBox sb) val -> SettingsBox (sb { edit = val }))
, edit : true
, doc : Documentation FolderShared
, buttons : [ Add [Team, FolderShared]
]
}
settingsBox FolderPublic =
_doc :: Lens' SettingsBox NodeAction
SettingsBox { show : true
_doc = lens (\(SettingsBox { doc }) -> doc) (\(SettingsBox sb) val -> SettingsBox (sb { doc = val }))
, edit : true
, doc : Documentation FolderPublic
, buttons : [ Add [ FolderPublic ]
]
}
settingsBox Folder =
_buttons :: Lens' SettingsBox (Array NodeAction)
SettingsBox { show : true
_buttons = lens (\(SettingsBox { buttons }) -> buttons)
, edit : true
(\(SettingsBox sb) val -> SettingsBox (sb { buttons = val }))
, doc : Documentation Folder
------------------------------------------------------------------------
, buttons : [ Add [ Notes
, Corpus
settingsBox :: NodeType -> SettingsBox
, Calc
settingsBox p = (settingsBoxLens p) $ defNt p
, Folder
, Annuaire
-- , NodeFrameNotebook
]
, Move moveParameters
, Delete
]
}
settingsBox Corpus =
settingsBoxLens :: NodeType -> (SettingsBox -> SettingsBox)
SettingsBox { show : true
settingsBoxLens Annuaire =
, edit : true
_buttons .~ [ Upload
, doc : Documentation Corpus
, AddingContact
, buttons : [ Add [ Graph
, Move moveParameters
, Link (linkParams Corpus)
, Delete ]
settingsBoxLens Calc =
_buttons .~ [ Upload
, Add [ Calc
, Notes ]
, Move moveFrameParameters
, Delete ]
settingsBoxLens Corpus =
_buttons .~ [ Add [ Graph
, Notes
, Notes
, Calc
, Calc
, NodeTexts
, NodeTexts
...
@@ -206,84 +167,66 @@ settingsBox Corpus =
...
@@ -206,84 +167,66 @@ settingsBox Corpus =
, Link (linkParams Annuaire)
, Link (linkParams Annuaire)
, Delete
, Delete
]
]
}
settingsBoxLens Dashboard =
(_edit .~ false) <<<
settingsBox NodeTexts =
(_buttons .~ [ ReloadWithSettings
SettingsBox { show : true
, Publish publishParams
, edit : true
, doc : Documentation NodeTexts
, buttons : [ ReloadWithSettings
, Upload
, Download
, Delete
, Delete
])
settingsBoxLens Folder =
_buttons .~ [ Add [ Notes
, Corpus
, Calc
, Folder
, Annuaire
-- , NodeFrameNotebook
]
]
}
, Move moveParameters
, Delete
settingsBox Graph =
]
SettingsBox { show : true
settingsBoxLens FolderPrivate =
, edit : true
(_edit .~ false) <<<
, doc : Documentation Graph
(_buttons .~ [ Add [ Notes
, buttons : [ ReloadWithSettings
, Corpus
, Calc
, Folder
, Annuaire
-- , NodeFrameNotebook
]
])
settingsBoxLens FolderPublic =
_buttons .~ [ Add [ FolderPublic ]
]
settingsBoxLens FolderShared =
_buttons .~ [ Add [Team, FolderShared]
]
settingsBoxLens Graph =
_buttons .~ [ ReloadWithSettings
, Config
, Config
, Download -- TODO as GEXF or JSON
, Download -- TODO as GEXF or JSON
-- , Publish publishParams
-- , Publish publishParams
, Delete
, Delete
]
]
}
settingsBoxLens NodeFile =
_buttons .~ [ Publish publishParams
settingsBox Phylo =
, Delete ]
SettingsBox { show : true
settingsBoxLens NodeFrameNotebook =
, edit : true
_buttons .~ [ Add [ Calc
, doc : Documentation Phylo
, Notes
, buttons : [ Reconstruct
-- , NodeFrameNotebook
, Delete
]
]
}
, Move moveFrameParameters
settingsBox (NodePublic Graph) =
SettingsBox { show : true
, edit : true
, doc : Documentation Graph
, buttons : [ Download -- TODO as GEXF or JSON
, Delete
, Delete
]
]
}
settingsBoxLens NodeFrameVisio =
_buttons .~ [ Add [ NodeFrameVisio
settingsBox (NodePublic Dashboard) =
, Notes
SettingsBox { show : true
, Calc
, edit : true
, doc : Documentation Dashboard
, buttons : [ Delete
]
}
settingsBox (NodePublic NodeFile) =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFile
, buttons : [ Delete
]
]
}
settingsBox (NodePublic FolderPublic) =
SettingsBox { show : true
, edit : true
, doc : Documentation FolderPublic
, buttons : [ Add [FolderPublic]
, Delete
, Delete
]
]
}
settingsBoxLens NodeList =
_buttons .~ [ ReloadWithSettings
settingsBox NodeList =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeList
, buttons : [ ReloadWithSettings
, Config
, Config
, Upload
, Upload
, Download
, Download
...
@@ -300,102 +243,63 @@ settingsBox NodeList =
...
@@ -300,102 +243,63 @@ settingsBox NodeList =
}
}
, Delete
, Delete
]
]
}
settingsBoxLens (NodePublic Dashboard) =
_buttons .~ [ Delete
settingsBox Dashboard =
]
SettingsBox { show : true
settingsBoxLens (NodePublic FolderPublic) =
, edit : false
_buttons .~ [ Add [FolderPublic]
, doc : Documentation Dashboard
, buttons : [ ReloadWithSettings
, Publish publishParams
, Delete
, Delete
]
]
}
settingsBoxLens (NodePublic Graph) =
_buttons .~ [ Download -- TODO as GEXF or JSON
settingsBox Annuaire =
SettingsBox { show : true
, edit : true
, doc : Documentation Annuaire
, buttons : [ Upload
, AddingContact
, Move moveParameters
, Link (linkParams Corpus)
, Delete
, Delete
]
]
}
settingsBoxLens (NodePublic NodeFile) =
_buttons .~ [ Delete
settingsBox Notes =
SettingsBox { show : true
, edit : true
, doc : Documentation Notes
, buttons : [ Add [ Notes
, Calc
, Folder
, Corpus
]
]
, Move moveFrameParameters
settingsBoxLens NodeTexts =
_buttons .~ [ ReloadWithSettings
, Upload
, Download
, Delete
, Delete
]
]
}
settingsBoxLens NodeUser =
(_edit .~ false) <<<
(_buttons .~ [ Delete
settingsBox Calc =
])
SettingsBox { show : true
settingsBoxLens Notes =
, edit : true
_buttons .~ [ Add [ Notes
, doc : Documentation Calc
, Calc
, buttons : [ Upload
, Folder
, Add [ Calc
, Corpus
, Notes
]
]
, Move moveFrameParameters
, Move moveFrameParameters
, Delete
, Delete
]
]
}
settingsBoxLens Phylo =
_buttons .~ [ Reconstruct
settingsBox NodeFrameNotebook =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameNotebook
, buttons : [ Add [ Calc
, Notes
-- , NodeFrameNotebook
]
, Move moveFrameParameters
, Delete
, Delete
]
]
}
settingsBoxLens Team =
_buttons .~ [ Add [ Notes
, Corpus
settingsBox NodeFrameVisio =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameVisio
, buttons : [ Add [ NodeFrameVisio
, Notes
, Calc
, Calc
, Folder
, Team
, Annuaire
-- , NodeFrameNotebook
-- , FolderShared
, NodeFrameVisio
]
]
, Share
, ManageTeam
, Delete
, Delete
]
]
}
settingsBoxLens _ =
(_show .~ false) <<<
(_edit .~ false)
settingsBox NodeFile =
SettingsBox { show: true
, edit: true
, doc: Documentation NodeFile
, buttons: [ Publish publishParams
, Delete ]
}
settingsBox _ =
SettingsBox { show : false
, edit : false
, doc : Documentation NodeUser
, buttons : []
}
-- | SubTree Parameters
-- | SubTree Parameters
moveParameters = { subTreeParams : SubTreeParams
moveParameters = { subTreeParams : SubTreeParams
...
...
src/Gargantext/Config/REST.purs
View file @
81ad30d2
...
@@ -79,9 +79,35 @@ data FrontendError =
...
@@ -79,9 +79,35 @@ data FrontendError =
| EC_500__node_not_implemented_yet
| EC_500__node_not_implemented_yet
derive instance Generic FrontendError _
derive instance Generic FrontendError _
instance Show FrontendError where
instance Show FrontendError where
show EC_403__login_failed_invalid_username_or_password = "Invalid username or password"
show (EC_400__node_creation_failed_insert_node { user_id, parent_id }) =
show (EC_404__node_lookup_failed_username_not_found { username }) = "User '" <> username <> "' not found"
"Failed to insert node for user " <> show user_id <> ", parent " <> show parent_id
show a = genericShow a
show (EC_400__node_creation_failed_no_parent { user_id }) =
"Failed to insert node for user " <> show user_id <> ": no parent"
show (EC_400__node_creation_failed_parent_exists { user_id, parent_id }) =
"Failed to insert node for user " <> show user_id <> ", parent " <> show parent_id <> " exists"
show (EC_400__node_creation_failed_user_negative_id { user_id }) =
"Failed to insert node for use " <> show user_id <> " (negative user_id)"
show (EC_400__node_lookup_failed_user_too_many_roots { user_id, roots }) =
"Failed to lookup node for user " <> show user_id <> ": too many roots (" <> show roots <> ")"
show EC_400__node_needs_configuration = "Node needs configuration"
show (EC_403__login_failed_error { node_id, user_id }) =
"Login failed for node_id " <> show node_id <> ", user id " <> show user_id
show EC_403__login_failed_invalid_username_or_password =
"Invalid username or password"
show (EC_404__node_context_not_found { context_id }) =
"Context not found with id " <> show context_id
show (EC_404__node_lookup_failed_not_found { node_id }) =
"Node not found with id " <> show node_id
show (EC_404__node_lookup_failed_parent_not_found { node_id }) =
"Node parent not found for id " <> show node_id
show (EC_404__node_lookup_failed_username_not_found { username }) =
"User '" <> username <> "' not found"
show (EC_404__node_list_not_found { list_id }) =
"Node list not found for id " <> show list_id
show EC_404__node_root_not_found = "Node root not found"
show (EC_500__node_generic_exception { error }) =
"Node exception: " <> error
show EC_500__node_not_implemented_yet = "Node not implemented yet"
instance JSON.ReadForeign FrontendError where
instance JSON.ReadForeign FrontendError where
readImpl f = do
readImpl f = do
{ type: type_ } <- JSON.readImpl f :: Foreign.F { type :: String }
{ type: type_ } <- JSON.readImpl f :: Foreign.F { type :: String }
...
@@ -167,17 +193,6 @@ readJSON affResp =
...
@@ -167,17 +193,6 @@ readJSON affResp =
_ -> case (JSON.readJSON $ AC.stringify resp.body :: JSON.E FrontendError) of
_ -> case (JSON.readJSON $ AC.stringify resp.body :: JSON.E FrontendError) of
Right err -> Left $ FE err
Right err -> Left $ FE err
Left _ -> Left $ UnknownServerError $ AC.stringify resp.body
Left _ -> Left $ UnknownServerError $ AC.stringify resp.body
-- _ -> Left $ parseServerError resp
parseServerError :: Affjax.Response AC.Json -> RESTError
parseServerError { body } =
case (JSON.readJSON $ AC.stringify body :: JSON.E { type :: String }) of
Right { type: "EC_404__node_lookup_failed_username_not_found" } ->
ServerError "username not found"
-- TODO Add more errors for the frontend
Right { type: type_ } ->
UnknownServerError $ "Server error of type '" <> type_ <> "' not supported"
Left _ -> UnknownServerError $ AC.stringify body
-- TODO too much duplicate code in `postWwwUrlencoded`
-- TODO too much duplicate code in `postWwwUrlencoded`
...
...
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