Commit 214da83f authored by arturo's avatar arturo

>>> continue

parent 9cc0bffb
Pipeline #2116 canceled with stage
......@@ -6,7 +6,7 @@ import Gargantext.Prelude
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either)
import Data.Generic.Rep (class Generic)
import Data.Lens ((^.))
import Data.Lens.At (at)
......@@ -36,12 +36,13 @@ import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get, delete)
import Gargantext.Types (FrontendError(..), ListId, NodeID, NodeType(..), OrderBy(..), SidePanelState(..), TabSubType, TabType, TableResult, showTabType')
import Gargantext.Types (ListId, NodeID, NodeType(..), OrderBy(..), SidePanelState(..), TabSubType, TabType, TableResult, showTabType')
import Gargantext.Utils (sortWith, (?))
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParam, mQueryParamS, queryParam, queryParamS)
......@@ -151,15 +152,11 @@ docViewCpt = here.component "docView" cpt where
liftEffect $
T.write_ true onDocumentCreationPendingBox
res <- DFC.create session nodeId fdata
eTask <- DFC.create session nodeId fdata
liftEffect $ case res of
Left err -> do
err' <- pure (FRESTError { error: err })
log2 "createDocumentCallback error" err
T.modify_ (A.cons $ err') boxes.errors
T.write_ false onDocumentCreationPendingBox
Right _ -> pure unit -- @WIP reload page
handleRESTError boxes.errors eTask
\t -> liftEffect do
here.log2 "[nodeDocument] NodeDocument task:" t
-- Render
pure $
......
......@@ -9,6 +9,7 @@ import Gargantext.Prelude
import DOM.Simple.Console (log3)
import Data.Either (Either(..))
import Data.Foldable (foldl, intercalate)
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Aff (Aff)
import Gargantext.Components.Bootstrap as B
......@@ -24,7 +25,7 @@ import Gargantext.Utils (nbsp, (?))
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record (merge, rename)
import Record as Record
import Record.Extra (pick)
import Type.Proxy (Proxy(..))
......@@ -37,7 +38,7 @@ type Props =
type Options = ( | FormData )
options :: Record Options
options = merge {} defaultData
options = Record.merge {} defaultData
documentFormCreation :: forall r. R2.OptLeaf Options Props r
documentFormCreation = R2.optLeaf component options
......@@ -135,7 +136,7 @@ component = R.hooksComponent "documentFormCreation" cpt where
[
B.formInput $
{ placeholder: "ex: author1, author2, …"
} `merge` bindStateKey "authors"
} `Record.merge` bindStateKey "authors"
,
R2.if' (fv.hasError' "authors") $
H.div { className: "form-group__error" }
......@@ -163,7 +164,7 @@ component = R.hooksComponent "documentFormCreation" cpt where
[
B.formTextarea $
{ rows: 5
} `merge` bindStateKey "abstract"
} `Record.merge` bindStateKey "abstract"
]
]
,
......@@ -208,12 +209,36 @@ documentFormValidation r = foldl append mempty rules
---------------------------------------------------
-- create ::
-- Session
-- -> GT.ID
-- -> Record FormData
-- -> Aff (Either RESTError GT.ID)
-- create session id = post session (GR.NodeDocument id) <<< r
-- where
-- r = rename (Proxy :: Proxy "source")
-- (Proxy :: Proxy "sources")
create ::
Session
-> GT.ID
-> Record FormData
-> Aff (Either RESTError GT.ID)
create session id = post session (GR.NodeDocument id) <<< r
-> Aff (Either RESTError GT.AsyncTaskWithType)
create session id =
rename
>>> post session request
>=> case _ of
Left err -> pure $ Left err
Right task -> pure $ Right $ GT.AsyncTaskWithType
{ task
, typ: GT.NodeDocument
}
where
r = rename (Proxy :: Proxy "source")
(Proxy :: Proxy "sources")
request = GR.NodeAPI GT.Node (Just id)
(GT.asyncTaskTypePath GT.NodeDocument)
rename = Record.rename
(Proxy :: Proxy "source")
(Proxy :: Proxy "sources")
......@@ -196,7 +196,6 @@ sessionPath (R.ChartHash { chartType, listId, tabType } i) =
<> defaultListAddMaybe listId
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ fromMaybe 0 pId) <> p
sessionPath (R.NodeDocument id) = "node/" <> (show id) <> "/document/upload/async"
------- misc routing stuff
......
......@@ -57,7 +57,6 @@ data SessionRoute
| CorpusMetricsHash { listId :: ListId, tabType :: TabType } (Maybe Id)
| Chart ChartOpts (Maybe Id)
| ChartHash { chartType :: ChartType, listId :: Maybe ListId, tabType :: TabType } (Maybe Id)
| NodeDocument Id
-- | AnnuaireContact AnnuaireId DocId
instance Show AppRoute where
......
......@@ -659,6 +659,7 @@ data AsyncTaskType = AddNode
| GraphRecompute
| ListUpload
| ListCSVUpload -- legacy v3 CSV upload for lists
| NodeDocument
| Query
| UpdateNgramsCharts
| UpdateNode
......@@ -679,6 +680,7 @@ asyncTaskTypePath CorpusFormUpload = "add/form/async/"
asyncTaskTypePath GraphRecompute = "async/recompute/"
asyncTaskTypePath ListUpload = "add/form/async/"
asyncTaskTypePath ListCSVUpload = "csv/add/form/async/"
asyncTaskTypePath NodeDocument = "document/upload/async"
asyncTaskTypePath Query = "query/"
asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/"
asyncTaskTypePath UpdateNode = "update/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment