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
01136431
Commit
01136431
authored
Nov 22, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] [node] node palc parser work
parent
003e3880
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
31 deletions
+41
-31
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+4
-1
User.purs
src/Gargantext/Components/GraphQL/User.purs
+2
-3
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+4
-14
Frame.purs
src/Gargantext/Components/Nodes/Frame.purs
+26
-13
Types.purs
src/Gargantext/Types.purs
+5
-0
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
01136431
...
...
@@ -10,8 +10,10 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Sessions (Session(..))
import Gargantext.Types (NodeType)
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (type (==>))
import GraphQL.Client.BaseClients.Urql (UrqlClient, createClient)
...
...
@@ -65,7 +67,8 @@ queryGql session name q = do
-- Schema
type Schema
= { user_infos :: { user_id :: Int } ==> Array UserInfo
= { node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType
, user_infos :: { user_id :: Int } ==> Array UserInfo
, users :: { user_id :: Int } ==> Array User
}
...
...
src/Gargantext/Components/GraphQL/User.purs
View file @
01136431
...
...
@@ -5,10 +5,8 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import GraphQL.Client.Args (NotNull
(..)
, (=>>))
import GraphQL.Client.Args (NotNull, (=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variables (withVars)
import Type.Proxy (Proxy(..))
type UserInfo
...
...
@@ -144,3 +142,4 @@ showUser { u_id
, u_username
, u_email } = "[" <> show u_id <> "] " <> u_username <> " :: " <> u_email
showMUser u = maybe "" showUser u
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
01136431
...
...
@@ -2,15 +2,11 @@ module Gargantext.Components.Nodes.Annuaire.User.Contact
( module Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
, contactInfos
, contactLayout
, getUserInfo
, getUserInfoWithReload
, saveContactHyperdata
, saveUserInfo
) where
import Gargantext.Components.GraphQL.User
import Gargantext.Prelude
import Affjax.RequestBody (RequestBody(..))
import Data.Array as A
import Data.Either (Either(..))
...
...
@@ -21,6 +17,8 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphQL (getClient, queryGql)
import Gargantext.Components.GraphQL.Endpoints (getUserInfo)
import Gargantext.Components.GraphQL.User
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData', HyperdataContact(..))
...
...
@@ -28,12 +26,13 @@ import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Config.REST (RESTError(..), logRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (
type (==>), IgnoreArg(..), OrArg(..), onlyArgs, (=>>)
)
import GraphQL.Client.Args (
IgnoreArg(..), OrArg(..), onlyArgs
)
import GraphQL.Client.Query (mutationOpts, mutation)
import GraphQL.Client.Variables (withVars)
import Reactix as R
...
...
@@ -290,12 +289,3 @@ getUserInfoWithReload :: { nodeId :: Int
, reload :: T2.Reload
, session :: Session} -> Aff (Either RESTError UserInfo)
getUserInfoWithReload {nodeId, session} = getUserInfo session nodeId -- getContact session nodeId
getUserInfo :: Session -> Int -> Aff (Either RESTError UserInfo)
getUserInfo session id = do
{ user_infos } <- queryGql session "get user infos" $ userInfoQuery `withVars` { id }
liftEffect $ here.log2 "[getUserInfo] user infos" user_infos
pure $ case A.head user_infos of
Nothing -> Left (CustomError $ "user with id " <> show id <> " not found")
-- NOTE Contact is at G.C.N.A.U.C.Types
Just ui -> Right ui
src/Gargantext/Components/Nodes/Frame.purs
View file @
01136431
...
...
@@ -2,8 +2,9 @@ module Gargantext.Components.Nodes.Frame where
import Gargantext.Prelude
import Data.Array as A
import DOM.Simple as DOM
import Data.Either (Either)
import Data.Either (Either
(..)
)
import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
...
...
@@ -13,12 +14,13 @@ import Data.Show.Generic (genericShow)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.FolderView as FV
import Gargantext.Components.GraphQL.Endpoints (getNodeParent)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Sessions (Session, get,
postWwwUrlencoded,
sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT
import Gargantext.Utils.EtherCalc as EC
...
...
@@ -80,8 +82,8 @@ type ViewProps =
( frame :: NodePoly Hyperdata
, reload :: T2.ReloadS
, nodeId :: Int
, session :: Session
, nodeType :: NodeType
, session :: Session
)
type Base = String
...
...
@@ -102,7 +104,8 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
cpt { frame: NodePoly { hyperdata: h@(Hyperdata { base, frame_id }) }
, nodeId
, nodeType
, reload } _ = do
, reload
, session } _ = do
case nodeType of
NodeFrameVisio ->
case WURL.fromAbsolute base of
...
...
@@ -111,7 +114,7 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
_ ->
pure $ H.div{}
[ FV.backButton {} []
, importIntoListButton { hyperdata: h, nodeId } []
, importIntoListButton { hyperdata: h, nodeId
, session
} []
, H.div { className : "frame"
, rows: "100%,*" }
[ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [],
...
...
@@ -124,14 +127,16 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
type ImportIntoListButtonProps =
( hyperdata :: Hyperdata
, nodeId :: Int )
, nodeId :: Int
, session :: Session )
importIntoListButton :: R2.Component ImportIntoListButtonProps
importIntoListButton = R.createElement importIntoListButtonCpt
importIntoListButtonCpt :: R.Component ImportIntoListButtonProps
importIntoListButtonCpt = here.component "importIntoListButton" cpt where
cpt { hyperdata: Hyperdata { base, frame_id }
, nodeId } _ = do
, nodeId
, session } _ = do
pure $ H.div { className: "btn btn-default"
, on: { click: onClick } }
[ H.text $ "Import into list" ]
...
...
@@ -139,13 +144,21 @@ importIntoListButtonCpt = here.component "importIntoListButton" cpt where
onClick _ = do
let url = base <> "/" <> frame_id
--task = GT.AsyncTaskWithType { task, typ: GT.ListCSVUpload }
uploadPath = GR.NodeAPI NodeList (Just id) $ GT.asyncTaskTypePath GT.ListCSVUpload
launchAff_ $ do
-- TODO Get corpus_id
csv <- EC.downloadCSV base frame_id
liftEffect $ here.log2 "[importIntoListButton] CSV: " csv
--eTask <- postWwwUrlencoded session uploadPath body
pure unit
-- Get corpus_id
eCorpusNodes <- getNodeParent session nodeId Corpus
case eCorpusNodes of
Left err -> liftEffect $ here.log2 "[importIntoListButton] error parsing corpus" err
Right corpusNodes -> do
case A.uncons corpusNodes of
Nothing -> liftEffect $ here.log2 "[importIntoListButton] corpusNodes empty" corpusNodes
Just { head: corpusNode } -> do
-- Use that corpus id
csv <- EC.downloadCSV base frame_id
liftEffect $ here.log2 "[importIntoListButton] CSV: " csv
let uploadPath = GR.NodeAPI NodeList (Just corpusNode.id) $ GT.asyncTaskTypePath GT.ListCSVUpload
eTask <- postWwwUrlencoded session uploadPath csv
pure unit
type NodeFrameVisioProps =
( frame_id :: String
...
...
src/Gargantext/Types.purs
View file @
01136431
...
...
@@ -17,6 +17,8 @@ import Foreign as F
import Gargantext.Components.Lang (class Translate, Lang(..))
import Gargantext.Config.REST (RESTError)
import Gargantext.Utils.Glyphicon (classNamePrefix, glyphiconToCharCode)
import GraphQL.Client.Args (class ArgGql)
import GraphQL.Client.Variables.TypeName (class VarTypeName)
import Prim.Row (class Union)
import Reactix as R
import Simple.JSON as JSON
...
...
@@ -167,6 +169,9 @@ instance JSON.ReadForeign NodeType where
Nothing -> F.fail $ F.ErrorAtProperty s $ F.ForeignError "unknown property"
Just nt -> pure nt
instance JSON.WriteForeign NodeType where writeImpl = JSON.writeImpl <<< show
instance ArgGql NodeType NodeType
instance VarTypeName NodeType where
varTypeName _ = "NodeType!"
instance Show NodeType where
show NodeUser = "NodeUser"
...
...
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