Commit a554c2bd authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into dev-graphql

parents 6d2a6fc3 0b5b7644
Pipeline #1981 failed with stage
{ {
"name": "Gargantext", "name": "Gargantext",
"version": "0.0.4.3", "version": "0.0.4.4",
"scripts": { "scripts": {
"generate-purs-packages-nix": "./nix/generate-purs-packages.nix", "generate-purs-packages-nix": "./nix/generate-purs-packages.nix",
"generate-psc-packages-nix": "./nix/generate-packages-json.bash", "generate-psc-packages-nix": "./nix/generate-packages-json.bash",
......
...@@ -18,6 +18,7 @@ to generate this file without the comments in this block. ...@@ -18,6 +18,7 @@ to generate this file without the comments in this block.
, "argonaut" , "argonaut"
, "argonaut-codecs" , "argonaut-codecs"
, "argonaut-core" , "argonaut-core"
, "arraybuffer-types"
, "arrays" , "arrays"
, "bifunctors" , "bifunctors"
, "colors" , "colors"
......
'use strict';
exports.back = function() {
return function() {
history.back();
}
}
exports.link = function (url) {
return function() {
window.location.href = url
}
}
\ No newline at end of file
...@@ -21,15 +21,15 @@ import Gargantext.Components.Forest.Tree.Node.Action.Share as Share ...@@ -21,15 +21,15 @@ import Gargantext.Components.Forest.Tree.Node.Action.Share as Share
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest) import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryFile, uploadFile) import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryFile, uploadFile)
import Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocuments (documentsFromWriteNodesReq)
import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView) import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), ID, fTreeID) import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Config.REST (RESTError, logRESTError) import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.LinkHandler (Methods, useLinkHandler)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>)) import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>))
import Gargantext.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute) import Gargantext.Routes (AppRoute(Home), SessionRoute(..), nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -41,9 +41,6 @@ import Reactix.DOM.HTML as H ...@@ -41,9 +41,6 @@ import Reactix.DOM.HTML as H
import Record as Record import Record as Record
import Toestand as T import Toestand as T
foreign import back :: Effect Unit
foreign import link :: String -> Effect Unit
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.FolderView" here = R2.here "Gargantext.Components.FolderView"
...@@ -98,9 +95,10 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -98,9 +95,10 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, reload , reload
, session , session
, setPopoverRef } _ = do , setPopoverRef } _ = do
linkHandlers <- useLinkHandler
let foldersS = A.sortBy sortFolders folders let foldersS = A.sortBy sortFolders folders
let backHome = isBackHome nodeType let backHome = isBackHome nodeType
let parent = makeParentFolder parentId session backFolder backHome let parent = makeParentFolder linkHandlers parentId session backFolder backHome
let children = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef } let children = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
pure $ H.div {className: "fv folders"} $ parent <> children pure $ H.div {className: "fv folders"} $ parent <> children
...@@ -117,18 +115,18 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -117,18 +115,18 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, style: FolderChild , style: FolderChild
, text: node.name } [] , text: node.name } []
makeParentFolder :: Maybe Int -> Session -> Boolean -> Boolean -> Array R.Element makeParentFolder :: Record Methods -> Maybe Int -> Session -> Boolean -> Boolean -> Array R.Element
makeParentFolder (Just parentId) session _ _ = makeParentFolder _ (Just parentId) session _ _ =
-- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType -- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType
-- without performing another API call. Also parentId is never being returned by this API even when it clearly exists -- without performing another API call. Also parentId is never being returned by this API even when it clearly exists
[ folderSimple {style: FolderUp, text: "..", nodeId: parentId, nodeType: GT.FolderPrivate, session: session} [] ] [ folderSimple {style: FolderUp, text: "..", nodeId: parentId, nodeType: GT.FolderPrivate, session: session} [] ]
makeParentFolder Nothing _ _ true = [ H.a {className: "btn btn-primary", href: appPath Home} [ H.i { className: "fa fa-folder-open" } [] makeParentFolder linkHandlers Nothing _ _ true = [ H.button {className: "btn btn-primary", on: { click: \_ -> linkHandlers.goToRoute Home}} [ H.i { className: "fa fa-folder-open" } []
, H.br {} , H.br {}
, H.text ".."] ] , H.text ".."] ]
makeParentFolder Nothing _ true _ = [ H.button {className: "btn btn-primary", on: { click: back } } [ H.i { className: "fa fa-folder-open" } [] makeParentFolder linkHandlers Nothing _ true _ = [ H.button {className: "btn btn-primary", on: { click: \_ -> linkHandlers.goToPreviousPage } } [ H.i { className: "fa fa-folder-open" } []
, H.br {} , H.br {}
, H.text ".."] ] , H.text ".."] ]
makeParentFolder Nothing _ _ _ = [] makeParentFolder _ Nothing _ _ _ = []
sortFolders :: FTree -> FTree -> Ordering sortFolders :: FTree -> FTree -> Ordering
...@@ -156,9 +154,10 @@ folderSimple = R.createElement folderSimpleCpt ...@@ -156,9 +154,10 @@ folderSimple = R.createElement folderSimpleCpt
folderSimpleCpt :: R.Component FolderSimpleProps folderSimpleCpt :: R.Component FolderSimpleProps
folderSimpleCpt = here.component "folderSimpleCpt" cpt where folderSimpleCpt = here.component "folderSimpleCpt" cpt where
cpt {style, text, nodeId, session, nodeType} _ = do cpt {style, text, nodeId, session, nodeType} _ = do
{ goToRoute } <- useLinkHandler
let sid = sessionId session let sid = sessionId session
pure $ H.a { className: "btn btn-primary" pure $ H.button { className: "btn btn-primary"
, href: "/#/" <> getFolderPath nodeType sid nodeId } , on: {click: \_ -> goToRoute $ getFolderPath nodeType sid nodeId} }
[ H.i { className: icon style nodeType } [] [ H.i { className: icon style nodeType } []
, H.br {} , H.br {}
, H.text text ] , H.text text ]
...@@ -167,8 +166,8 @@ folderSimpleCpt = here.component "folderSimpleCpt" cpt where ...@@ -167,8 +166,8 @@ folderSimpleCpt = here.component "folderSimpleCpt" cpt where
icon FolderUp _ = "fa fa-folder-open" icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = GT.fldr nodeType false icon _ nodeType = GT.fldr nodeType false
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> String getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
type FolderProps = type FolderProps =
( boxes :: Boxes ( boxes :: Boxes
...@@ -194,6 +193,7 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -194,6 +193,7 @@ folderCpt = here.component "folderCpt" cpt where
let sid = sessionId session let sid = sessionId session
let dispatch a = performAction a { boxes, nodeId, parentId, reload, session, setPopoverRef } let dispatch a = performAction a { boxes, nodeId, parentId, reload, session, setPopoverRef }
popoverRef <- R.useRef null popoverRef <- R.useRef null
{ goToRoute } <- useLinkHandler
R.useEffect' $ do R.useEffect' $ do
R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef
...@@ -210,7 +210,7 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -210,7 +210,7 @@ folderCpt = here.component "folderCpt" cpt where
popOverIcon popOverIcon
, mNodePopupView (Record.merge props { dispatch }) (onPopoverClose popoverRef) , mNodePopupView (Record.merge props { dispatch }) (onPopoverClose popoverRef)
]] ]]
, H.button {on: {click: link ("/#/" <> getFolderPath nodeType sid nodeId) }, className: "btn btn-primary fv btn" } [ , H.button {on: {click: \_ -> goToRoute $ getFolderPath nodeType sid nodeId }, className: "btn btn-primary fv btn" } [
H.i {className: icon style nodeType} [] H.i {className: icon style nodeType} []
, H.br {} , H.br {}
, H.text text]] , H.text text]]
...@@ -220,8 +220,8 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -220,8 +220,8 @@ folderCpt = here.component "folderCpt" cpt where
icon FolderUp _ = "fa fa-folder-open" icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = GT.fldr nodeType false icon _ nodeType = GT.fldr nodeType false
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> String getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
...@@ -240,11 +240,17 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -240,11 +240,17 @@ folderCpt = here.component "folderCpt" cpt where
, session: props.session , session: props.session
} }
backButton :: R.Element backButton :: R2.Component ()
backButton = backButton = R.createElement backButtonCpt
backButtonCpt :: R.Component ()
backButtonCpt = R.hooksComponent "backButton" cpt where
cpt _ _ = do
{ goToPreviousPage } <- useLinkHandler
pure $
H.button { H.button {
className: "btn btn-primary" className: "btn btn-primary"
, on: {click: back} , on: { click: \_ -> goToPreviousPage }
} [ } [
H.i { className: "fa fa-arrow-left", title: "Previous view"} [] H.i { className: "fa fa-arrow-left", title: "Previous view"} []
] ]
......
...@@ -17,7 +17,7 @@ import Effect.Aff (Aff, launchAff) ...@@ -17,7 +17,7 @@ import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Action (Props) import Gargantext.Components.Forest.Tree.Node.Action (Props)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileBlob(..), readUFBAsText) import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileBlob(..), readUFBAsBase64, readUFBAsText)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, formChoiceSafe, panel) import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, formChoiceSafe, panel)
import Gargantext.Components.Lang (Lang(..)) import Gargantext.Components.Lang (Lang(..))
import Gargantext.Components.ListSelection as ListSelection import Gargantext.Components.ListSelection as ListSelection
...@@ -193,7 +193,6 @@ uploadButtonCpt = here.component "uploadButton" cpt ...@@ -193,7 +193,6 @@ uploadButtonCpt = here.component "uploadButton" cpt
let disabled = isNothing mFile' || onPending let disabled = isNothing mFile' || onPending
pure $ pure $
H.div H.div
{ className: "action-upload-button" } { className: "action-upload-button" }
[ [
...@@ -232,6 +231,11 @@ uploadButtonCpt = here.component "uploadButton" cpt ...@@ -232,6 +231,11 @@ uploadButtonCpt = here.component "uploadButton" cpt
case fileType' of case fileType' of
Arbitrary -> Arbitrary ->
dispatch $ UploadArbitraryFile (Just name) blob selection' dispatch $ UploadArbitraryFile (Just name) blob selection'
ZIP -> do
liftEffect $ here.log "[uploadButton] reading base64"
contents <- readUFBAsBase64 blob
liftEffect $ here.log "[uploadButton] base64 read"
dispatch $ UploadFile nodeType fileType' (Just name) contents selection'
_ -> do _ -> do
contents <- readUFBAsText blob contents <- readUFBAsText blob
dispatch $ UploadFile nodeType fileType' (Just name) contents selection' dispatch $ UploadFile nodeType fileType' (Just name) contents selection'
...@@ -393,14 +397,14 @@ uploadArbitraryFile :: Session ...@@ -393,14 +397,14 @@ uploadArbitraryFile :: Session
-> Aff (Either RESTError GT.AsyncTaskWithType) -> Aff (Either RESTError GT.AsyncTaskWithType)
uploadArbitraryFile session id {mName, blob: UploadFileBlob blob} selection = do uploadArbitraryFile session id {mName, blob: UploadFileBlob blob} selection = do
contents <- readAsDataURL blob contents <- readAsDataURL blob
uploadArbitraryDataURL session id mName contents uploadArbitraryData session id mName contents
uploadArbitraryDataURL :: Session uploadArbitraryData :: Session
-> ID -> ID
-> Maybe String -> Maybe String
-> String -> String
-> Aff (Either RESTError GT.AsyncTaskWithType) -> Aff (Either RESTError GT.AsyncTaskWithType)
uploadArbitraryDataURL session id mName contents' = do uploadArbitraryData session id mName contents' = do
let re = fromRight' (\_ -> unsafeCrashWith "Unexpected Left") $ DSR.regex "data:.*;base64," DSRF.noFlags let re = fromRight' (\_ -> unsafeCrashWith "Unexpected Left") $ DSR.regex "data:.*;base64," DSRF.noFlags
contents = DSR.replace re "" contents' contents = DSR.replace re "" contents'
eTask :: Either RESTError GT.AsyncTask <- postWwwUrlencoded session p (bodyParams contents) eTask :: Either RESTError GT.AsyncTask <- postWwwUrlencoded session p (bodyParams contents)
......
module Gargantext.Components.Forest.Tree.Node.Action.Upload.Types where module Gargantext.Components.Forest.Tree.Node.Action.Upload.Types where
import Data.Generic.Rep (class Generic) import Gargantext.Prelude
import Data.ArrayBuffer.Types (ArrayBuffer)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Show.Generic (genericShow) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Utils.ArrayBuffer (arrayBufferToBase64)
import Web.File.Blob (Blob, size) import Web.File.Blob (Blob, size)
import Web.File.FileReader.Aff (readAsText) import Web.File.FileReader.Aff (readAsArrayBuffer, readAsText)
import Gargantext.Prelude
data FileType = CSV | CSV_HAL | WOS | PresseRIS | Arbitrary | JSON | ZIP data FileType = CSV | CSV_HAL | WOS | PresseRIS | Arbitrary | JSON | ZIP
...@@ -33,5 +35,16 @@ derive instance Generic UploadFileBlob _ ...@@ -33,5 +35,16 @@ derive instance Generic UploadFileBlob _
instance Eq UploadFileBlob where instance Eq UploadFileBlob where
eq (UploadFileBlob b1) (UploadFileBlob b2) = eq (size b1) (size b2) eq (UploadFileBlob b1) (UploadFileBlob b2) = eq (size b1) (size b2)
readUFBAsArrayBuffer :: UploadFileBlob -> Aff ArrayBuffer
readUFBAsArrayBuffer (UploadFileBlob b) = readAsArrayBuffer b
readUFBAsBase64 :: UploadFileBlob -> Aff String
readUFBAsBase64 (UploadFileBlob b) = do
ab <- readAsArrayBuffer b
pure $ arrayBufferToBase64 ab
--pure $ Base64.runBase64 $ Base64.encodeBase64 ab
--at <- readAsText b
--pure $ SBase64.encode at
readUFBAsText :: UploadFileBlob -> Aff String readUFBAsText :: UploadFileBlob -> Aff String
readUFBAsText (UploadFileBlob b) = readAsText b readUFBAsText (UploadFileBlob b) = readAsText b
...@@ -10,7 +10,7 @@ import Effect.Aff (Aff, launchAff_) ...@@ -10,7 +10,7 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Timer (clearInterval, setInterval) import Effect.Timer (clearInterval, setInterval)
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleErrorInAsyncProgress, handleRESTError)
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
...@@ -60,6 +60,7 @@ asyncProgressBarCpt = here.component "asyncProgressBar" cpt ...@@ -60,6 +60,7 @@ asyncProgressBarCpt = here.component "asyncProgressBar" cpt
_ <- case R.readRef intervalIdRef of _ <- case R.readRef intervalIdRef of
Nothing -> pure unit Nothing -> pure unit
Just iid -> clearInterval iid Just iid -> clearInterval iid
handleErrorInAsyncProgress errors asyncProgress
onFinish unit onFinish unit
else else
pure unit pure unit
......
...@@ -363,11 +363,11 @@ forceAtlas2Settings = ...@@ -363,11 +363,11 @@ forceAtlas2Settings =
, batchEdgesDrawing : true , batchEdgesDrawing : true
, edgeWeightInfluence : 1.0 , edgeWeightInfluence : 1.0
-- fixedY : false -- fixedY : false
, gravity : 0.01 , gravity : 1.0
, hideEdgesOnMove : true , hideEdgesOnMove : true
, includeHiddenEdges : false , includeHiddenEdges : false
, includeHiddenNodes : true , includeHiddenNodes : true
, iterationsPerRender : 50.0 -- 10.0 , iterationsPerRender : 100.0 -- 10.0
, linLogMode : false -- false , linLogMode : false -- false
, outboundAttractionDistribution : false , outboundAttractionDistribution : false
, scalingRatio : 1000.0 , scalingRatio : 1000.0
......
...@@ -17,7 +17,7 @@ import Effect.Now as EN ...@@ -17,7 +17,7 @@ import Effect.Now as EN
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryDataURL) import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryData)
import Gargantext.Components.GraphExplorer.API (cloneGraph) import Gargantext.Components.GraphExplorer.API (cloneGraph)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Utils as GEU import Gargantext.Components.GraphExplorer.Utils as GEU
...@@ -99,7 +99,7 @@ cameraButton { id ...@@ -99,7 +99,7 @@ cameraButton { id
case eClonedGraphId of case eClonedGraphId of
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
Right clonedGraphId -> do Right clonedGraphId -> do
eRet <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen eRet <- uploadArbitraryData session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen
case eRet of case eRet of
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
Right _ret -> do Right _ret -> do
......
...@@ -289,8 +289,8 @@ loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps ...@@ -289,8 +289,8 @@ loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
cpt { searchQuery } _ = do cpt { searchQuery } _ = do
pure $ R.fragment pure $ R.fragment
[ H.h4 {style: {textAlign : "center"}} [ H.h4 { style: { textAlign : "center" } }
[ H.span {className: "fa fa-hand-o-down"} [] [ H.span { className: "fa fa-hand-o-down" } []
, H.text "Extracted Terms" ] , H.text "Extracted Terms" ]
, NTC.searchInput { key: "search-input" , NTC.searchInput { key: "search-input"
, searchQuery } , searchQuery }
......
...@@ -36,9 +36,9 @@ searchInputCpt :: R.Component SearchInputProps ...@@ -36,9 +36,9 @@ searchInputCpt :: R.Component SearchInputProps
searchInputCpt = here.component "searchInput" cpt searchInputCpt = here.component "searchInput" cpt
where where
cpt { searchQuery } _ = do cpt { searchQuery } _ = do
pure $ R2.row [ pure $ R2.row
H.div { className: "col-12" } [ [ H.div { className: "col-12" }
H.div { className: "input-group" } [ H.div { className: "input-group" }
[ searchButton { searchQuery } [] [ searchButton { searchQuery } []
, searchFieldInput { searchQuery } [] , searchFieldInput { searchQuery } []
] ]
......
...@@ -105,7 +105,7 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt ...@@ -105,7 +105,7 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
Just url -> pure $ nodeFrameVisio { frame_id, reload, url } Just url -> pure $ nodeFrameVisio { frame_id, reload, url }
_ -> _ ->
pure $ H.div{} [ pure $ H.div{} [
FV.backButton FV.backButton {} []
, H.div { className : "frame" , H.div { className : "frame"
, rows: "100%,*" } , rows: "100%,*" }
[ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [], [ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [],
......
...@@ -64,7 +64,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt ...@@ -64,7 +64,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
pure $ R.fragment pure $ R.fragment
[ R2.row [FV.backButton] [ R2.row [FV.backButton {} []]
, ,
R2.row R2.row
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ] [ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ]
......
...@@ -133,7 +133,7 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt ...@@ -133,7 +133,7 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt
, text : "Source Code Documentation" , text : "Source Code Documentation"
} }
, LiNav { title : "API documentation" , LiNav { title : "API documentation"
, href : "https://v4.gargantext.org/swagger-ui" , href : "https://cnrs.gargantext.org/swagger-ui"
, icon : "fa fa-code-fork" , icon : "fa fa-code-fork"
, text : "API documentation" , text : "API documentation"
} }
......
...@@ -4,10 +4,12 @@ import Gargantext.Prelude ...@@ -4,10 +4,12 @@ import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (foldl)
import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError)
import Gargantext.Types (FrontendError(..)) import Gargantext.Types (AsyncEvent(..), AsyncProgress(..), AsyncTaskLog(..), AsyncTaskStatus(..), FrontendError(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Toestand as T import Toestand as T
...@@ -22,3 +24,24 @@ handleRESTError errors (Left error) _ = liftEffect $ do ...@@ -22,3 +24,24 @@ handleRESTError errors (Left error) _ = liftEffect $ do
T.modify_ (A.cons $ FRESTError { error }) errors T.modify_ (A.cons $ FRESTError { error }) errors
here.log2 "[handleTaskError] RESTError" error here.log2 "[handleTaskError] RESTError" error
handleRESTError _ (Right task) handler = handler task handleRESTError _ (Right task) handler = handler task
handleErrorInAsyncProgress :: T.Box (Array FrontendError)
-> AsyncProgress
-> Effect Unit
handleErrorInAsyncProgress errors ap@(AsyncProgress { status: IsFailure }) = do
T.modify_ (A.cons $ FStringError { error: concatErrors ap }) errors
handleErrorInAsyncProgress errors ap@(AsyncProgress { log, status: IsFinished }) = do
if countFailed > 0 then
T.modify_ (A.cons $ FStringError { error: concatErrors ap }) errors
else
pure unit
where
countFailed = foldl (+) 0 $ (\(AsyncTaskLog { failed }) -> failed) <$> log
handleErrorInAsyncProgress _ _ = pure unit
concatErrors :: AsyncProgress -> String
concatErrors (AsyncProgress { log }) = foldl eventsErrorMessage "" log
where
eventsErrorMessage acc (AsyncTaskLog { events }) = (foldl eventErrorMessage "" events) <> "\n" <> acc
eventErrorMessage acc (AsyncEvent { level: "ERROR", message }) = message <> "\n" <> acc
eventErrorMessage acc _ = acc
module Gargantext.Hooks.LinkHandler module Gargantext.Hooks.LinkHandler
( useLinkHandler ( Methods, useLinkHandler
, goToRoute, goToURL, goToPreviousPage , goToRoute, goToURL, goToPreviousPage
) where ) where
......
...@@ -14,16 +14,15 @@ import Data.Show.Generic (genericShow) ...@@ -14,16 +14,15 @@ import Data.Show.Generic (genericShow)
import Data.String as S import Data.String as S
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Foreign as F import Foreign as F
import Gargantext.Components.Lang (class Translate, Lang(..))
import Gargantext.Config.REST (RESTError)
import Gargantext.Utils.Glyphicon (classNamePrefix, glyphiconToCharCode)
import Prim.Row (class Union) import Prim.Row (class Union)
import Reactix as R import Reactix as R
import Simple.JSON as JSON import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG import Simple.JSON.Generics as JSONG
import URI.Query (Query) import URI.Query (Query)
import Gargantext.Components.Lang (class Translate, Lang(..))
import Gargantext.Config.REST (RESTError)
import Gargantext.Utils.Glyphicon (classNamePrefix, glyphiconToCharCode)
data Handed = LeftHanded | RightHanded data Handed = LeftHanded | RightHanded
switchHanded :: forall a. a -> a -> Handed -> a switchHanded :: forall a. a -> a -> Handed -> a
...@@ -659,7 +658,6 @@ data AsyncTaskType = AddNode ...@@ -659,7 +658,6 @@ data AsyncTaskType = AddNode
| GraphRecompute | GraphRecompute
| ListUpload | ListUpload
| ListCSVUpload -- legacy v3 CSV upload for lists | ListCSVUpload -- legacy v3 CSV upload for lists
| ListZIPUpload
| Query | Query
| UpdateNgramsCharts | UpdateNgramsCharts
| UpdateNode | UpdateNode
...@@ -680,7 +678,6 @@ asyncTaskTypePath CorpusFormUpload = "add/form/async/" ...@@ -680,7 +678,6 @@ asyncTaskTypePath CorpusFormUpload = "add/form/async/"
asyncTaskTypePath GraphRecompute = "async/recompute/" asyncTaskTypePath GraphRecompute = "async/recompute/"
asyncTaskTypePath ListUpload = "add/form/async/" asyncTaskTypePath ListUpload = "add/form/async/"
asyncTaskTypePath ListCSVUpload = "csv/add/form/async/" asyncTaskTypePath ListCSVUpload = "csv/add/form/async/"
asyncTaskTypePath ListZIPUpload = "zip/add/form/async/"
asyncTaskTypePath Query = "query/" asyncTaskTypePath Query = "query/"
asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/" asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/"
asyncTaskTypePath UpdateNode = "update/" asyncTaskTypePath UpdateNode = "update/"
...@@ -723,18 +720,17 @@ derive instance Newtype AsyncTask _ ...@@ -723,18 +720,17 @@ derive instance Newtype AsyncTask _
derive newtype instance JSON.ReadForeign AsyncTask derive newtype instance JSON.ReadForeign AsyncTask
instance Eq AsyncTask where eq = genericEq instance Eq AsyncTask where eq = genericEq
newtype AsyncTaskWithType = AsyncTaskWithType { newtype AsyncTaskWithType = AsyncTaskWithType
task :: AsyncTask { task :: AsyncTask
, typ :: AsyncTaskType , typ :: AsyncTaskType
} }
derive instance Generic AsyncTaskWithType _ derive instance Generic AsyncTaskWithType _
derive instance Newtype AsyncTaskWithType _ derive instance Newtype AsyncTaskWithType _
derive newtype instance JSON.ReadForeign AsyncTaskWithType derive newtype instance JSON.ReadForeign AsyncTaskWithType
instance Eq AsyncTaskWithType where instance Eq AsyncTaskWithType where eq = genericEq
eq = genericEq
newtype AsyncProgress = AsyncProgress { newtype AsyncProgress = AsyncProgress
id :: AsyncTaskID { id :: AsyncTaskID
, log :: Array AsyncTaskLog , log :: Array AsyncTaskLog
, status :: AsyncTaskStatus , status :: AsyncTaskStatus
} }
...@@ -742,8 +738,16 @@ derive instance Generic AsyncProgress _ ...@@ -742,8 +738,16 @@ derive instance Generic AsyncProgress _
derive instance Newtype AsyncProgress _ derive instance Newtype AsyncProgress _
derive newtype instance JSON.ReadForeign AsyncProgress derive newtype instance JSON.ReadForeign AsyncProgress
newtype AsyncTaskLog = AsyncTaskLog { newtype AsyncEvent = AsyncEvent
events :: Array String { level :: String
, message :: String
}
derive instance Generic AsyncEvent _
derive instance Newtype AsyncEvent _
derive newtype instance JSON.ReadForeign AsyncEvent
newtype AsyncTaskLog = AsyncTaskLog
{ events :: Array AsyncEvent
, failed :: Int , failed :: Int
, remaining :: Int , remaining :: Int
, succeeded :: Int , succeeded :: Int
...@@ -753,7 +757,7 @@ derive instance Newtype AsyncTaskLog _ ...@@ -753,7 +757,7 @@ derive instance Newtype AsyncTaskLog _
derive newtype instance JSON.ReadForeign AsyncTaskLog derive newtype instance JSON.ReadForeign AsyncTaskLog
progressPercent :: AsyncProgress -> Number progressPercent :: AsyncProgress -> Number
progressPercent (AsyncProgress {log}) = perc progressPercent (AsyncProgress { log }) = perc
where where
perc = case A.head log of perc = case A.head log of
Nothing -> 0.0 Nothing -> 0.0
...@@ -783,10 +787,9 @@ toggleSidePanelState Opened = Closed ...@@ -783,10 +787,9 @@ toggleSidePanelState Opened = Closed
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
data FrontendError = FStringError data FrontendError =
{ error :: String FStringError { error :: String }
} | FRESTError | FRESTError { error :: RESTError }
{ error :: RESTError }
derive instance Generic FrontendError _ derive instance Generic FrontendError _
instance Eq FrontendError where eq = genericEq instance Eq FrontendError where eq = genericEq
// shameless copy from
// https://stackoverflow.com/a/9458996
// This is because base64-codec/Data.Base64.encodeBase64 was too slow
exports.arrayBufferToBase64Impl = function(buffer) {
var binary = '';
var bytes = new Uint8Array( buffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return window.btoa( binary );
}
module Gargantext.Utils.ArrayBuffer where
import Data.ArrayBuffer.Types (ArrayBuffer)
import Data.Function.Uncurried (Fn1, runFn1)
foreign import arrayBufferToBase64Impl :: Fn1 ArrayBuffer String
arrayBufferToBase64 :: ArrayBuffer -> String
arrayBufferToBase64 = runFn1 arrayBufferToBase64Impl
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