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
139
Issues
139
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
gargantext
purescript-gargantext
Commits
f4e6ba80
Commit
f4e6ba80
authored
Oct 28, 2022
by
arturo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
>>> continue
parent
7113e8a2
Pipeline
#3332
canceled with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
20 deletions
+123
-20
App.purs
src/Gargantext/Components/App/App.purs
+69
-3
Store.purs
src/Gargantext/Components/App/Store.purs
+3
-0
Table.purs
src/Gargantext/Components/Table.purs
+24
-7
Types.purs
src/Gargantext/Types.purs
+21
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+3
-0
Main.purs
src/Main.purs
+3
-10
No files found.
src/Gargantext/Components/App/App.purs
View file @
f4e6ba80
...
...
@@ -2,24 +2,90 @@ module Gargantext.Components.App (app) where
import Gargantext.Prelude
import Data.Tuple.Nested ((/\))
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Router as Router
import Gargantext.Sessions as Sessions
import Gargantext.Types (CacheParams, defaultCacheParams)
import Gargantext.Utils (getter)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Record as Record
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.App"
app :: R2.Component ()
app = R.createElement appCpt
app :: R2.Leaf ()
app = R2.leaf appCpt
appCpt :: R.Component ()
appCpt = here.component "app" cpt where
appCpt = here.component "container" cpt where
cpt _ _ = do
-- | States
-- |
cache' /\ cache <- R2.useBox' (defaultCacheParams :: CacheParams)
-- | Hooks
-- |
-- load Local Storage cache (if exists)
useFirstEffect' $
R2.loadLocalStorageState R2.appParamsKey cache
-- | Render
-- |
pure $
hydrateStore
{ cacheParams: cache'
}
--------------------------------------------------------------
type HydrateStoreProps =
( cacheParams :: CacheParams
)
hydrateStore :: R2.Leaf HydrateStoreProps
hydrateStore = R2.leaf hydrateStoreCpt
hydrateStoreCpt :: R.Component HydrateStoreProps
hydrateStoreCpt = here.component "hydrateStore" cpt where
cpt { cacheParams
} _ = do
-- | Computed
-- |
(state :: Record AppStore.State) <- pure $
-- (cache options)
{ expandTableEdition: getter _.expandTableEdition cacheParams
-- (default options)
} `Record.merge` AppStore.options
-- | Render
-- |
pure $
AppStore.provide
state
[
mainApp
{}
]
--------------------------------------------------------------
mainApp :: R2.Leaf ()
mainApp = R2.leaf mainAppCpt
mainAppCpt :: R.Component ()
mainAppCpt = here.component "main" cpt where
cpt _ _ = do
boxes <- AppStore.use
-- tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor
...
...
src/Gargantext/Components/App/Store.purs
View file @
f4e6ba80
...
...
@@ -38,6 +38,7 @@ here = R2.here "Gargantext.Components.App.Store"
type Store =
( backend :: T.Box (Maybe Backend)
, errors :: T.Box (Array FrontendError)
, expandTableEdition :: T.Box Boolean
, forestOpen :: T.Box OpenNodes
, graphVersion :: T2.ReloadS
, handed :: T.Box Handed
...
...
@@ -63,6 +64,7 @@ type Store =
type State =
( backend :: Maybe Backend
, errors :: Array FrontendError
, expandTableEdition :: Boolean
, forestOpen :: OpenNodes
, graphVersion :: T2.Reload
, handed :: Handed
...
...
@@ -89,6 +91,7 @@ options :: Record State
options =
{ backend : Nothing
, errors : []
, expandTableEdition : false
, forestOpen : OpenNodes $ Set.empty
, graphVersion : T2.newReload
, handed : RightHanded
...
...
src/Gargantext/Components/Table.purs
View file @
f4e6ba80
...
...
@@ -11,6 +11,7 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), ComponentStatus(..), Variant(..))
import Gargantext.Components.FolderView as FV
...
...
@@ -21,9 +22,10 @@ import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Types (FTFieldList)
import Gargantext.Components.Search (SearchType(..))
import Gargantext.Components.Table.Types (ColumnName(..), OrderBy, OrderByDirection(..), Params, Props, TableContainerProps, columnName)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Sessions.Types (Session)
import Gargantext.Types (NodeID)
import Gargantext.Utils ((?))
import Gargantext.Types (NodeID
, defaultCacheParams
)
import Gargantext.Utils (
setter,
(?))
import Gargantext.Utils.Reactix (effectLink)
import Gargantext.Utils.Reactix as R2
import Reactix as R
...
...
@@ -118,8 +120,10 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
cacheState' <- T.useLive T.unequal cacheState
CorpusInfo {title, desc, query, authors} <- T.read corpusInfoS
expandEditionBlock' /\ expandEditionBlock
<- R2.useBox' false
{ expandTableEdition
} <- AppStore.use
expandTableEdition' <- R2.useLive' expandTableEdition
-- | Hooks
-- |
...
...
@@ -128,10 +132,17 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
mTopBarHost <- R.unsafeHooksEffect $ R2.getElementById "portal-topbar"
-- | Effects
-- |
-- transfer local Component change to Local Storage cache
useFirstEffect' $
flip T.listen expandTableEdition onExpandTableEditionChange
-- | Behaviors
-- |
let
onExpandClick _ = T.modify_ (not) expand
EditionBlock
onExpandClick _ = T.modify_ (not) expand
TableEdition
-- | Render
-- |
...
...
@@ -171,7 +182,7 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
{ className: "table-header-rename__title__line" }
,
B.iconButton
{ name: expand
EditionBlock
' ?
{ name: expand
TableEdition
' ?
"caret-up" $
"caret-down"
, className: "table-header-rename__title__expand"
...
...
@@ -179,7 +190,7 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
}
]
,
R2.when expand
EditionBlock
' $
R2.when expand
TableEdition
' $
tableHeaderEditionBlock
{ hyperdata: p.hyperdata
...
...
@@ -205,6 +216,12 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
cacheStateToggle NT.CacheOn = NT.CacheOff
cacheStateToggle NT.CacheOff = NT.CacheOn
onExpandTableEditionChange :: T.Change Boolean -> Effect Unit
onExpandTableEditionChange { new } = do
cache <- R2.loadLocalStorageState' R2.appParamsKey defaultCacheParams
let update = setter (_ { expandTableEdition = new }) cache
R2.setLocalStorageState R2.appParamsKey update
----------------------------------------------------------
type TableHeaderEditionBlockDefaultData =
...
...
src/Gargantext/Types.purs
View file @
f4e6ba80
...
...
@@ -814,3 +814,24 @@ data FrontendError =
derive instance Generic FrontendError _
instance Eq FrontendError where eq = genericEq
-----------------------------------------------------------------------
newtype CacheParams = CacheParams
{ expandTableEdition :: Boolean
}
derive instance Newtype CacheParams _
derive instance Generic CacheParams _
derive instance Eq CacheParams
instance Show CacheParams where show = genericShow
derive newtype instance JSON.ReadForeign CacheParams
derive newtype instance JSON.WriteForeign CacheParams
-- (!) in case cache storage (ie. JavaScript Local Storage) returns an invalid
-- objects (eg. possible data migration), this will safely set new default
-- values
defaultCacheParams :: CacheParams
defaultCacheParams = CacheParams
{ expandTableEdition : false
}
src/Gargantext/Utils/Reactix.purs
View file @
f4e6ba80
...
...
@@ -397,6 +397,9 @@ getls = window >>= localStorage
openNodesKey :: LocalStorageKey
openNodesKey = "garg-open-nodes"
appParamsKey :: LocalStorageKey
appParamsKey = "garg-app-params"
graphParamsKey :: LocalStorageKey
graphParamsKey = "garg-graph-params"
...
...
src/Main.purs
View file @
f4e6ba80
...
...
@@ -6,8 +6,7 @@ import Data.Maybe (Maybe(..))
import Data.Nullable (toMaybe)
import Effect (Effect)
import FFI.Simple ((...))
import Gargantext.Components.App (app)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.App as App
import Gargantext.Utils.Reactix as R2
import Prelude (Unit, ($))
...
...
@@ -19,12 +18,6 @@ main = paint $ toMaybe (document ... "getElementById" $ [ "app" ])
paint :: Maybe Element -> Effect Unit
paint Nothing = here.error "[main] Container not found"
paint (Just c) = R2.render app
'
c
paint (Just c) = R2.render app c
where
state = AppStore.options
app' =
AppStore.provide
state
[
app {} []
]
app = App.app {}
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