Commit 162c3a5a authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into 395-dev-ps-0.15-update

parents 563cd937 61422c57
# Contributor Covenant Code of Conduct # GarganText "Code of Conduct"
## Our Pledge The GarganText Project, the contributors of the GarganText eco-system,
have adopted a code of conduct for participants to any modes of
In the interest of fostering an open and welcoming environment, we as communication within the project.
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body ## Be respectful
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and In a project the size of GarganText, inevitably there will be people
orientation. with whom you may disagree, or find it difficult to cooperate. Accept
that, but even so, remain respectful. Disagreement is no excuse for poor
## Our Standards behaviour or personal attacks, and a community in which people feel
threatened is not a healthy community.
Examples of behavior that contributes to creating a positive environment
include: ## Assume good faith
* Using welcoming and inclusive language GarganText Contributors have many ways of reaching our common goal of
* Being respectful of differing viewpoints and experiences a free digital ecosystem which may differ from your ways. Assume that
* Gracefully accepting constructive criticism other people are working towards this goal.
* Focusing on what is best for the community
* Showing empathy towards other community members Note that many of our Contributors are not native English speakers
or may have different cultural backgrounds.
Examples of unacceptable behavior by participants include:
## Be collaborative
* The use of sexualized language or imagery and unwelcome sexual attention or
advances GarganText is a large and complex project; there is always more to
* Trolling, insulting/derogatory comments, and personal or political attacks learn within GarganText. It's good to ask for help when you need it.
* Public or private harassment Similarly, offers for help should be seen in the context of our shared
* Publishing others' private information, such as a physical or electronic goal of improving GarganText.
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a When you make something for the benefit of the project, be willing
professional setting to explain to others how it works, so that they can build on your work
to make it even better.
## Our Responsibilities
## Try to be concise
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in Keep in mind that what you write once will be read by many others
response to any instances of unacceptable behavior. persons. Writing a short email means people can understand the
conversation as efficiently as possible. When a long explanation is
Project maintainers have the right and responsibility to remove, edit, or necessary, consider adding a summary.
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or Try to bring new arguments to a conversation so that each comment
permanently any contributor for other behaviors that they deem inappropriate, adds something unique to the thread, keeping in mind that the rest of
threatening, offensive, or harmful. the thread still contains the other messages with arguments that have
already been made.
## Scope
Try to stay on topic, especially in discussions that are already
This Code of Conduct applies both within project spaces and in public spaces fairly large.
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail ## Be open
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be Most ways of communication used within GarganText allow for public and
further defined and clarified by project maintainers. private communication. You should preferably use public methods of
communication for GarganText-related messages, unless posting something
## Enforcement sensitive.
Instances of abusive, harassing, or otherwise unacceptable behavior may be This applies to messages for help or GarganText-related support,
reported by contacting the project team at [sos AT gargantext DOT org]. All too; not only is a public support request much more likely to
complaints will be reviewed and investigated and will result in a response that result in an answer to your question, it also makes sure that any
is deemed necessary and appropriate to the circumstances. The project team is inadvertent mistakes made by people answering your question will be
obligated to maintain confidentiality with regard to the reporter of an incident. more easily detected and corrected.
Further details of specific enforcement policies may be posted separately.
While this code of conduct should be adhered to by participants,
Project maintainers who do not follow or enforce the Code of Conduct in good we recognize that sometimes people may have a bad day, or be unaware
faith may face temporary or permanent repercussions as determined by other of some of the guidelines in this code of conduct. When that happens,
members of the project's leadership. you may reply to them and point out this code of conduct. Such messages
may be in public or in private, whatever is most appropriate. However,
## Attribution regardless of whether the message is public or not, it should still
adhere to the relevant parts of this code of conduct; in particular, it
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, should not be abusive or disrespectful. Assume good faith; it is more
available at [http://contributor-covenant.org/version/1/4][version] likely that participants are unaware of their bad behaviour than that
they intentionally try to degrade the quality of the discussion.
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/ Serious or persistent offenders will be temporarily or permanently
banned from communicating through GarganText's ecosystem. Complaints
should be made (in private) to the administrators of the GarganText
communication forum in question. To find contact information for these
administrators, please see the page on GarganText's organizational
structure.
...@@ -9463,6 +9463,11 @@ select.form-control { ...@@ -9463,6 +9463,11 @@ select.form-control {
.phylo-selection-tab__counter__value { .phylo-selection-tab__counter__value {
color: #0F81C7; color: #0F81C7;
} }
.phylo-selection-tab__counter__expand {
position: absolute;
right: 1.25rem;
bottom: 1rem;
}
.phylo-selection-tab__nil { .phylo-selection-tab__nil {
margin: 16px 20px; margin: 16px 20px;
} }
......
...@@ -9416,6 +9416,11 @@ select.form-control { ...@@ -9416,6 +9416,11 @@ select.form-control {
.phylo-selection-tab__counter__value { .phylo-selection-tab__counter__value {
color: #17a2b8; color: #17a2b8;
} }
.phylo-selection-tab__counter__expand {
position: absolute;
right: 1.25rem;
bottom: 1rem;
}
.phylo-selection-tab__nil { .phylo-selection-tab__nil {
margin: 16px 20px; margin: 16px 20px;
} }
......
...@@ -9172,6 +9172,11 @@ select.form-control { ...@@ -9172,6 +9172,11 @@ select.form-control {
.phylo-selection-tab__counter__value { .phylo-selection-tab__counter__value {
color: #5c8f94; color: #5c8f94;
} }
.phylo-selection-tab__counter__expand {
position: absolute;
right: 1.25rem;
bottom: 1rem;
}
.phylo-selection-tab__nil { .phylo-selection-tab__nil {
margin: 16px 20px; margin: 16px 20px;
} }
......
...@@ -9420,6 +9420,11 @@ select.form-control { ...@@ -9420,6 +9420,11 @@ select.form-control {
.phylo-selection-tab__counter__value { .phylo-selection-tab__counter__value {
color: #74DBEF; color: #74DBEF;
} }
.phylo-selection-tab__counter__expand {
position: absolute;
right: 1.25rem;
bottom: 1rem;
}
.phylo-selection-tab__nil { .phylo-selection-tab__nil {
margin: 16px 20px; margin: 16px 20px;
} }
......
...@@ -9421,6 +9421,11 @@ select.form-control { ...@@ -9421,6 +9421,11 @@ select.form-control {
.phylo-selection-tab__counter__value { .phylo-selection-tab__counter__value {
color: #515151; color: #515151;
} }
.phylo-selection-tab__counter__expand {
position: absolute;
right: 1.25rem;
bottom: 1rem;
}
.phylo-selection-tab__nil { .phylo-selection-tab__nil {
margin: 16px 20px; margin: 16px 20px;
} }
......
{ {
"name": "Gargantext", "name": "Gargantext",
"version": "0.0.5.8.9.2", "version": "0.0.5.8.9.3",
"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",
......
...@@ -61,12 +61,15 @@ forestLayoutCpt = here.component "forest" cpt where ...@@ -61,12 +61,15 @@ forestLayoutCpt = here.component "forest" cpt where
H.div H.div
{ className: "forest-layout__tree" } { className: "forest-layout__tree" }
[ [
treeLoader { boxes treeLoader
{ boxes
, frontends , frontends
, handed: handed' , handed: handed'
, reload: reloadForest , reload: reloadForest
, root: treeId , root: treeId
, session: s } [] , session: s
, key: "tree-" <> (show treeId)
}
] ]
type Plus = ( boxes :: Boxes ) type Plus = ( boxes :: Boxes )
......
...@@ -106,9 +106,10 @@ type PerformActionProps = ...@@ -106,9 +106,10 @@ type PerformActionProps =
| PACommon ) | PACommon )
-- | Loads and renders the tree starting at the given root node id. -- | Loads and renders the tree starting at the given root node id.
treeLoader :: R2.Component LoaderProps treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R.createElement treeLoaderCpt treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component LoaderProps
treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = here.component "treeLoader" cpt where treeLoaderCpt = here.component "treeLoader" cpt where
-- treeLoaderCpt :: R.Memo LoaderProps -- treeLoaderCpt :: R.Memo LoaderProps
-- treeLoaderCpt = R.memo (here.component "treeLoader" cpt) memoCmp where -- treeLoaderCpt = R.memo (here.component "treeLoader" cpt) memoCmp where
......
...@@ -33,10 +33,11 @@ import Gargantext.Components.NgramsTable.Core as NTC ...@@ -33,10 +33,11 @@ import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Config.REST (AffRESTError) import Gargantext.Config.REST (AffRESTError)
import Gargantext.Data.Array (mapMaybe) import Gargantext.Data.Array (mapMaybe)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType) import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Utils (nbsp, (?)) import Gargantext.Utils (nbsp, setter, (?))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
...@@ -258,23 +259,33 @@ selectedNodes = R2.leaf selectedNodesCpt ...@@ -258,23 +259,33 @@ selectedNodes = R2.leaf selectedNodesCpt
selectedNodesCpt :: R.Component SelectedNodesProps selectedNodesCpt :: R.Component SelectedNodesProps
selectedNodesCpt = here.component "selectedNodes" cpt where selectedNodesCpt = here.component "selectedNodes" cpt where
cpt props _ = do cpt props _ = do
-- States -- | States
-- |
{ selectedNodeIds { selectedNodeIds
, graph , graph
, showNGramsActions , expandSelection
} <- GraphStore.use } <- GraphStore.use
showNGramsActions' <- R2.useLive' showNGramsActions
selectedNodeIds' <- R2.useLive' selectedNodeIds selectedNodeIds' <- R2.useLive' selectedNodeIds
graph' <- R2.useLive' graph graph' <- R2.useLive' graph
expandSelection' <- R2.useLive' expandSelection
-- Behaviors -- | Effects
-- |
-- transfer local Component change to Local Storage cache
useFirstEffect' $
flip T.listen expandSelection onExpandSelectionChange
-- | Behaviors
-- |
let let
onBadgeClick id _ = T.write_ (Set.singleton id) selectedNodeIds onBadgeClick id _ = T.write_ (Set.singleton id) selectedNodeIds
onExpandClick _ = T.modify_ (not) showNGramsActions onExpandClick _ = T.modify_ (not) expandSelection
-- Render -- | Render
-- |
pure $ pure $
H.ul H.ul
...@@ -308,7 +319,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt where ...@@ -308,7 +319,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt where
, ,
-- Expand NGrams actions -- Expand NGrams actions
B.iconButton B.iconButton
{ name: showNGramsActions' ? { name: expandSelection' ?
"caret-up" $ "caret-up" $
"caret-down" "caret-down"
, className: "graph-selected-nodes__expand" , className: "graph-selected-nodes__expand"
...@@ -317,7 +328,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt where ...@@ -317,7 +328,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt where
] ]
, ,
-- NGrams actions -- NGrams actions
R2.when showNGramsActions' $ R2.when expandSelection' $
H.li H.li
{ className: intercalate " " { className: intercalate " "
...@@ -362,6 +373,12 @@ selectedNodesCpt = here.component "selectedNodes" cpt where ...@@ -362,6 +373,12 @@ selectedNodesCpt = here.component "selectedNodes" cpt where
] ]
] ]
onExpandSelectionChange :: T.Change Boolean -> Effect Unit
onExpandSelectionChange { new } = do
cache <- R2.loadLocalStorageState' R2.graphParamsKey GET.defaultCacheParams
let update = setter (_ { expandSelection = new }) cache
R2.setLocalStorageState R2.graphParamsKey update
--------------------------------------------------------- ---------------------------------------------------------
neighborhood :: R2.Leaf () neighborhood :: R2.Leaf ()
...@@ -370,17 +387,18 @@ neighborhood = R2.leaf neighborhoodCpt ...@@ -370,17 +387,18 @@ neighborhood = R2.leaf neighborhoodCpt
neighborhoodCpt :: R.Memo () neighborhoodCpt :: R.Memo ()
neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
cpt _ _ = do cpt _ _ = do
-- States -- | States
-- |
{ selectedNodeIds { selectedNodeIds
, graph , graph
, showWordCloud , expandNeighborhood
} <- GraphStore.use } <- GraphStore.use
selectedNodeIds' <- selectedNodeIds' <-
R2.useLive' selectedNodeIds R2.useLive' selectedNodeIds
showWordCloud' <- expandNeighborhood' <-
R2.useLive' showWordCloud R2.useLive' expandNeighborhood
graph' <- graph' <-
R2.useLive' graph R2.useLive' graph
...@@ -394,7 +412,8 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -394,7 +412,8 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
termCount /\ termCountBox <- termCount /\ termCountBox <-
R2.useBox' 0 R2.useBox' 0
-- Computed -- | Computed
-- |
let let
minSize = F.foldl DN.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph')) minSize = F.foldl DN.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph'))
...@@ -405,13 +424,20 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -405,13 +424,20 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
withTruncateResults = (termCount > maxTruncateResult) && (not showMore) withTruncateResults = (termCount > maxTruncateResult) && (not showMore)
-- Behaviors -- | Behaviors
-- |
let let
onBadgeClick id _ = T.write_ (Set.singleton id) selectedNodeIds onBadgeClick id _ = T.write_ (Set.singleton id) selectedNodeIds
onExpandClick _ = T.modify_ (not) showWordCloud onExpandClick _ = T.modify_ (not) expandNeighborhood
-- | Effects
-- |
-- transfer local Component change to Local Storage cache
useFirstEffect' $
flip T.listen expandNeighborhood onExpandNeighborhoodChange
-- Effects
R.useEffect1' selectedNodeIds' do R.useEffect1' selectedNodeIds' do
let refreshed = neighbourBadges graph' selectedNodeIds' let refreshed = neighbourBadges graph' selectedNodeIds'
let count = Seq.length refreshed let count = Seq.length refreshed
...@@ -420,7 +446,8 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -420,7 +446,8 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
T.write_ ordered termListBox T.write_ ordered termListBox
T.write_ false showMoreBox T.write_ false showMoreBox
-- Render -- | Render
-- |
pure $ pure $
H.ul H.ul
...@@ -446,7 +473,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -446,7 +473,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
, ,
-- Expand word cloud -- Expand word cloud
B.iconButton B.iconButton
{ name: showWordCloud' ? { name: expandNeighborhood' ?
"caret-up" $ "caret-up" $
"caret-down" "caret-down"
, className: "graph-neighborhood__expand" , className: "graph-neighborhood__expand"
...@@ -456,7 +483,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -456,7 +483,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
] ]
, ,
-- Word cloud -- Word cloud
R2.when showWordCloud' $ R2.when expandNeighborhood' $
H.li H.li
{ className: "list-group-item"} { className: "list-group-item"}
...@@ -505,6 +532,12 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -505,6 +532,12 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
] ]
] ]
onExpandNeighborhoodChange :: T.Change Boolean -> Effect Unit
onExpandNeighborhoodChange { new } = do
cache <- R2.loadLocalStorageState' R2.graphParamsKey GET.defaultCacheParams
let update = setter (_ { expandNeighborhood = new }) cache
R2.setLocalStorageState R2.graphParamsKey update
--------------------------------------------------------- ---------------------------------------------------------
type UpdateTermButtonProps = type UpdateTermButtonProps =
......
...@@ -14,6 +14,7 @@ import Data.Set as Set ...@@ -14,6 +14,7 @@ import Data.Set as Set
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils (getter)
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Stores as Stores import Gargantext.Utils.Stores as Stores
...@@ -35,8 +36,8 @@ type Store = ...@@ -35,8 +36,8 @@ type Store =
, sideTab :: T.Box GET.SideTab , sideTab :: T.Box GET.SideTab
, showSidebar :: T.Box GT.SidePanelState , showSidebar :: T.Box GT.SidePanelState
, showDoc :: T.Box (Maybe GET.GraphSideDoc) , showDoc :: T.Box (Maybe GET.GraphSideDoc)
, showWordCloud :: T.Box Boolean , expandSelection :: T.Box Boolean
, showNGramsActions :: T.Box Boolean , expandNeighborhood :: T.Box Boolean
-- Controls -- Controls
, multiSelectEnabled :: T.Box Boolean , multiSelectEnabled :: T.Box Boolean
, edgeConfluence :: T.Box Range.NumberRange , edgeConfluence :: T.Box Range.NumberRange
...@@ -65,8 +66,8 @@ type State = ...@@ -65,8 +66,8 @@ type State =
, sideTab :: GET.SideTab , sideTab :: GET.SideTab
, showSidebar :: GT.SidePanelState , showSidebar :: GT.SidePanelState
, showDoc :: Maybe GET.GraphSideDoc , showDoc :: Maybe GET.GraphSideDoc
, showWordCloud :: Boolean , expandSelection :: Boolean
, showNGramsActions :: Boolean , expandNeighborhood :: Boolean
-- Controls -- Controls
, multiSelectEnabled :: Boolean , multiSelectEnabled :: Boolean
, edgeConfluence :: Range.NumberRange , edgeConfluence :: Range.NumberRange
...@@ -90,8 +91,8 @@ options :: ...@@ -90,8 +91,8 @@ options ::
, showDoc :: Maybe GET.GraphSideDoc , showDoc :: Maybe GET.GraphSideDoc
, showSidebar :: GT.SidePanelState , showSidebar :: GT.SidePanelState
, sideTab :: GET.SideTab , sideTab :: GET.SideTab
, showWordCloud :: Boolean , expandSelection :: Boolean
, showNGramsActions :: Boolean , expandNeighborhood :: Boolean
-- Controls -- Controls
, labelSize :: Number , labelSize :: Number
, mouseSelectorSize :: Number , mouseSelectorSize :: Number
...@@ -111,8 +112,8 @@ options = ...@@ -111,8 +112,8 @@ options =
, sideTab : GET.SideTabLegend , sideTab : GET.SideTabLegend
, showSidebar : GT.InitialClosed , showSidebar : GT.InitialClosed
, showDoc : Nothing , showDoc : Nothing
, showWordCloud : true , expandSelection : getter _.expandSelection GET.defaultCacheParams
, showNGramsActions : true , expandNeighborhood : getter _.expandNeighborhood GET.defaultCacheParams
-- Controls -- Controls
, multiSelectEnabled : false , multiSelectEnabled : false
, labelSize : 14.0 , labelSize : 14.0
......
...@@ -3,11 +3,12 @@ module Gargantext.Components.GraphExplorer.Types where ...@@ -3,11 +3,12 @@ module Gargantext.Components.GraphExplorer.Types where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array ((!!), length) import Data.Array ((!!), length)
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), fromJust) import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Ord.Generic (genericCompare) import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow)
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Record as Record import Record as Record
...@@ -267,3 +268,26 @@ instance JSON.WriteForeign HyperdataGraph where ...@@ -267,3 +268,26 @@ instance JSON.WriteForeign HyperdataGraph where
data Stage = Init | Ready | Cleanup data Stage = Init | Ready | Cleanup
derive instance Generic Stage _ derive instance Generic Stage _
derive instance Eq Stage derive instance Eq Stage
-----------------------------------------------------------------------
newtype CacheParams = CacheParams
{ expandSelection :: Boolean
, expandNeighborhood :: 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
{ expandSelection : true
, expandNeighborhood: true
}
...@@ -32,7 +32,7 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where ...@@ -32,7 +32,7 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where
email <- T.useBox "" email <- T.useBox ""
pure $ H.div { className: "row" } pure $ H.div { className: "row" }
[ H.form { className: "col-md-12" } [ H.form { className: "text-center col-md-12" }
[ H.h4 {} [ H.text "Forgot password" ] [ H.h4 {} [ H.text "Forgot password" ]
, formGroup , formGroup
[ emailInput email ] [ emailInput email ]
...@@ -60,7 +60,7 @@ submitButtonCpt = here.component "submitButton" cpt where ...@@ -60,7 +60,7 @@ submitButtonCpt = here.component "submitButton" cpt where
cpt { backend, email, sessions } _ = do cpt { backend, email, sessions } _ = do
email' <- T.useLive T.unequal email email' <- T.useLive T.unequal email
pure $ formGroup pure $ H.div {className: "form-group text-center"}
[ H.button { className: "btn btn-primary" [ H.button { className: "btn btn-primary"
, on: { click: click email' }} , on: { click: click email' }}
[ H.text "Submit" ] [ H.text "Submit" ]
......
...@@ -71,8 +71,8 @@ formCpt = here.component "form" cpt where ...@@ -71,8 +71,8 @@ formCpt = here.component "form" cpt where
[ passwordInput cursors.password [ passwordInput cursors.password
, clearfix ] , clearfix ]
, termsCheckbox cursors.agreed , termsCheckbox cursors.agreed
, forgotPassword { formType }
, submitButton { backend, formType, sessions, visible, cell } , submitButton { backend, formType, sessions, visible, cell }
, forgotPassword { formType }
]] ]]
-- might be wrong, all we care about is preventDefault -- might be wrong, all we care about is preventDefault
...@@ -175,9 +175,9 @@ forgotPassword = R2.leaf forgotPasswordCpt ...@@ -175,9 +175,9 @@ forgotPassword = R2.leaf forgotPasswordCpt
forgotPasswordCpt :: R.Component ForgotPasswordProps forgotPasswordCpt :: R.Component ForgotPasswordProps
forgotPasswordCpt = here.component "forgotPassword" cpt where forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { formType } _ = do cpt { formType } _ = do
pure $ H.div { className: "form-group text-center" } pure $ H.div { className: "" }
[ H.button { className: "btn btn-danger" [ H.a { className: "",
, on: { click } } [ H.text "Forgot password" ] on: { click } } [ H.text "Forgot password?" ]
] ]
where where
click _ = T.write_ ForgotPassword formType click _ = T.write_ ForgotPassword formType
...@@ -11,11 +11,13 @@ import Gargantext.Components.Bootstrap as B ...@@ -11,11 +11,13 @@ import Gargantext.Components.Bootstrap as B
import Gargantext.Components.PhyloExplorer.API (get) import Gargantext.Components.PhyloExplorer.API (get)
import Gargantext.Components.PhyloExplorer.Layout (layout) import Gargantext.Components.PhyloExplorer.Layout (layout)
import Gargantext.Components.PhyloExplorer.Store as PhyloStore import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet) import Gargantext.Components.PhyloExplorer.Types (CacheParams, PhyloDataSet, defaultCacheParams)
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Types (NodeID) import Gargantext.Types (NodeID)
import Gargantext.Utils (getter)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -38,7 +40,8 @@ nodeCpt = here.component "node" cpt where ...@@ -38,7 +40,8 @@ nodeCpt = here.component "node" cpt where
-- | -- |
session <- useSession session <- useSession
state' /\ state <- R2.useBox' Nothing state' /\ state <- R2.useBox' (Nothing :: Maybe PhyloDataSet)
cache' /\ cache <- R2.useBox' (defaultCacheParams :: CacheParams)
-- | Computed -- | Computed
-- | -- |
...@@ -47,6 +50,10 @@ nodeCpt = here.component "node" cpt where ...@@ -47,6 +50,10 @@ nodeCpt = here.component "node" cpt where
-- | Hooks -- | Hooks
-- | -- |
-- load Local Storage cache (if exists)
useFirstEffect' $
R2.loadLocalStorageState R2.phyloParamsKey cache
useLoaderEffect useLoaderEffect
{ errorHandler { errorHandler
, loader: get session , loader: get session
...@@ -93,6 +100,9 @@ nodeCpt = here.component "node" cpt where ...@@ -93,6 +100,9 @@ nodeCpt = here.component "node" cpt where
-- Data -- Data
{ phyloDataSet { phyloDataSet
, phyloId: nodeId , phyloId: nodeId
-- (cache params)
, expandSelection: getter _.expandSelection cache'
, expandNeighborhood: getter _.expandNeighborhood cache'
-- (default options) -- (default options)
} `Record.merge` PhyloStore.options } `Record.merge` PhyloStore.options
......
...@@ -17,10 +17,12 @@ import Gargantext.Components.GraphExplorer.Layout (convert, layout) ...@@ -17,10 +17,12 @@ import Gargantext.Components.GraphExplorer.Layout (convert, layout)
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Utils (getter)
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
...@@ -48,9 +50,19 @@ nodeCpt = here.component "node" cpt where ...@@ -48,9 +50,19 @@ nodeCpt = here.component "node" cpt where
graphVersion' <- R2.useLive' graphVersion graphVersion' <- R2.useLive' graphVersion
state' /\ state <- R2.useBox' Nothing state' /\ state <- R2.useBox' Nothing
cache' /\ cache <- R2.useBox' (GET.defaultCacheParams :: GET.CacheParams)
-- | Computed
-- |
let errorHandler = logRESTError here "[explorerLayout]"
-- | Hooks -- | Hooks
-- | -- |
-- load Local Storage cache (if exists)
useFirstEffect' $
R2.loadLocalStorageState R2.graphParamsKey cache
useLoaderEffect useLoaderEffect
{ errorHandler { errorHandler
, loader: GraphAPI.getNodes session graphVersion' , loader: GraphAPI.getNodes session graphVersion'
...@@ -80,20 +92,19 @@ nodeCpt = here.component "node" cpt where ...@@ -80,20 +92,19 @@ nodeCpt = here.component "node" cpt where
{} {}
, defaultSlot: , defaultSlot:
R2.fromMaybe state' handler R2.fromMaybe state' \loaded ->
} let
GET.HyperdataGraph { graph: hyperdataGraph } = loaded
where Tuple mMetaData graph = convert hyperdataGraph
errorHandler = logRESTError here "[explorerLayout]" in
handler loaded@(GET.HyperdataGraph { graph: hyperdataGraph }) =
hydrateStore hydrateStore
{ graph { graph
, hyperdataGraph: loaded , hyperdataGraph: loaded
, mMetaData , mMetaData
, graphId , graphId
, cacheParams: cache'
}
} }
where
Tuple mMetaData graph = convert hyperdataGraph
-------------------------------------------------------- --------------------------------------------------------
...@@ -102,6 +113,7 @@ type HydrateStoreProps = ...@@ -102,6 +113,7 @@ type HydrateStoreProps =
, graph :: SigmaxT.SGraph , graph :: SigmaxT.SGraph
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, graphId :: GET.GraphId , graphId :: GET.GraphId
, cacheParams :: GET.CacheParams
) )
hydrateStore:: R2.Leaf HydrateStoreProps hydrateStore:: R2.Leaf HydrateStoreProps
...@@ -113,6 +125,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -113,6 +125,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
, graph , graph
, graphId , graphId
, hyperdataGraph , hyperdataGraph
, cacheParams
} _ = do } _ = do
-- | Computed -- | Computed
-- | -- |
...@@ -144,6 +157,9 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where ...@@ -144,6 +157,9 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
{ min: 0.0 { min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph , max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
} }
-- (cache options)
, expandSelection: getter _.expandSelection cacheParams
, expandNeighborhood: getter _.expandNeighborhood cacheParams
-- (default options) -- (default options)
} `Record.merge` GraphStore.options } `Record.merge` GraphStore.options
......
...@@ -13,8 +13,9 @@ import Effect (Effect) ...@@ -13,8 +13,9 @@ import Effect (Effect)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.PhyloExplorer.Store as PhyloStore import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (ExtractedCount(..), ExtractedTerm(..)) import Gargantext.Components.PhyloExplorer.Types (ExtractedCount(..), ExtractedTerm(..), defaultCacheParams)
import Gargantext.Utils (nbsp, (?)) import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Utils (nbsp, setter, (?))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -28,11 +29,11 @@ type Props = ...@@ -28,11 +29,11 @@ type Props =
selectionTab :: R2.Leaf Props selectionTab :: R2.Leaf Props
selectionTab = R2.leaf component selectionTab = R2.leaf component
componentName :: String here :: R2.Here
componentName = "Gargantext.Components.PhyloExplorer.SideBar.SelectionTab" here = R2.here "Gargantext.Components.PhyloExplorer.SideBar.SelectionTab"
component :: R.Component Props component :: R.Component Props
component = R.hooksComponent componentName cpt where component = here.component "main" cpt where
cpt { selectTermCallback cpt { selectTermCallback
} _ = do } _ = do
-- | State -- | State
...@@ -44,6 +45,7 @@ component = R.hooksComponent componentName cpt where ...@@ -44,6 +45,7 @@ component = R.hooksComponent componentName cpt where
selectedTerm <- R2.useLive' store.selectedTerm selectedTerm <- R2.useLive' store.selectedTerm
selectedBranch <- R2.useLive' store.selectedBranch selectedBranch <- R2.useLive' store.selectedBranch
selectedSource <- R2.useLive' store.selectedSource selectedSource <- R2.useLive' store.selectedSource
expandNeighborhood <- R2.useLive' store.expandNeighborhood
showMore' /\ showMore <- R2.useBox' false showMore' /\ showMore <- R2.useBox' false
...@@ -68,6 +70,17 @@ component = R.hooksComponent componentName cpt where ...@@ -68,6 +70,17 @@ component = R.hooksComponent componentName cpt where
R.useEffect1' extractedTerms $ R.useEffect1' extractedTerms $
T.write_ false showMore T.write_ false showMore
-- transfer local Component change to Local Storage cache
useFirstEffect' $
flip T.listen store.expandNeighborhood onExpandNeighborhoodChange
-- | Behaviors
-- |
let
onExpandClick _ = T.modify_ (not) store.expandNeighborhood
-- | Render -- | Render
-- | -- |
pure $ pure $
...@@ -249,9 +262,20 @@ component = R.hooksComponent componentName cpt where ...@@ -249,9 +262,20 @@ component = R.hooksComponent componentName cpt where
, ,
detailsCount count.branchCount "branches" false detailsCount count.branchCount "branches" false
] ]
,
-- Expand word cloud
B.iconButton
{ name: expandNeighborhood ?
"caret-up" $
"caret-down"
, className: "phylo-selection-tab__counter__expand"
, callback: onExpandClick
}
] ]
, ,
-- Term word cloud -- Term word cloud
R2.when expandNeighborhood $
H.li H.li
{ className: "list-group-item" } { className: "list-group-item" }
[ [
...@@ -346,3 +370,9 @@ detailsCount value label weighty = ...@@ -346,3 +370,9 @@ detailsCount value label weighty =
H.text $ nbsp 1 <> label H.text $ nbsp 1 <> label
] ]
] ]
onExpandNeighborhoodChange :: T.Change Boolean -> Effect Unit
onExpandNeighborhoodChange { new } = do
cache <- R2.loadLocalStorageState' R2.phyloParamsKey defaultCacheParams
let update = setter (_ { expandNeighborhood = new }) cache
R2.setLocalStorageState R2.phyloParamsKey update
...@@ -11,8 +11,9 @@ module Gargantext.Components.PhyloExplorer.Store ...@@ -11,8 +11,9 @@ module Gargantext.Components.PhyloExplorer.Store
import Gargantext.Prelude import Gargantext.Prelude
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Gargantext.Components.PhyloExplorer.Types (DisplayView(..), ExtractedCount, ExtractedTerm, FrameDoc, PhyloDataSet, Source, TabView(..), Term) import Gargantext.Components.PhyloExplorer.Types (DisplayView(..), ExtractedCount, ExtractedTerm, FrameDoc, PhyloDataSet, Source, TabView(..), Term, defaultCacheParams)
import Gargantext.Types (NodeID, SidePanelState(..)) import Gargantext.Types (NodeID, SidePanelState(..))
import Gargantext.Utils (getter)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Stores as Stores import Gargantext.Utils.Stores as Stores
import Reactix as R import Reactix as R
...@@ -33,6 +34,8 @@ type Store = ...@@ -33,6 +34,8 @@ type Store =
, sideBarDisplayed :: T.Box SidePanelState , sideBarDisplayed :: T.Box SidePanelState
, sideBarTabView :: T.Box TabView , sideBarTabView :: T.Box TabView
, frameDoc :: T.Box (Maybe FrameDoc) , frameDoc :: T.Box (Maybe FrameDoc)
, expandSelection :: T.Box Boolean
, expandNeighborhood :: T.Box Boolean
-- Topbar -- Topbar
, source :: T.Box String , source :: T.Box String
, sources :: T.Box (Array Source) , sources :: T.Box (Array Source)
...@@ -60,6 +63,8 @@ type State = ...@@ -60,6 +63,8 @@ type State =
, sideBarDisplayed :: SidePanelState , sideBarDisplayed :: SidePanelState
, sideBarTabView :: TabView , sideBarTabView :: TabView
, frameDoc :: Maybe FrameDoc , frameDoc :: Maybe FrameDoc
, expandSelection :: Boolean
, expandNeighborhood :: Boolean
-- Topbar -- Topbar
, source :: String , source :: String
, sources :: Array Source , sources :: Array Source
...@@ -84,6 +89,8 @@ options :: ...@@ -84,6 +89,8 @@ options ::
, sideBarDisplayed :: SidePanelState , sideBarDisplayed :: SidePanelState
, sideBarTabView :: TabView , sideBarTabView :: TabView
, frameDoc :: Maybe FrameDoc , frameDoc :: Maybe FrameDoc
, expandSelection :: Boolean
, expandNeighborhood :: Boolean
-- Topbar -- Topbar
, source :: String , source :: String
, sources :: Array Source , sources :: Array Source
...@@ -108,6 +115,8 @@ options = ...@@ -108,6 +115,8 @@ options =
, sideBarDisplayed : InitialClosed , sideBarDisplayed : InitialClosed
, sideBarTabView : DetailsTab , sideBarTabView : DetailsTab
, frameDoc : Nothing , frameDoc : Nothing
, expandSelection : getter _.expandSelection defaultCacheParams
, expandNeighborhood : getter _.expandNeighborhood defaultCacheParams
-- Topbar -- Topbar
, source : "" , source : ""
, sources : mempty , sources : mempty
......
...@@ -11,6 +11,7 @@ module Gargantext.Components.PhyloExplorer.Types ...@@ -11,6 +11,7 @@ module Gargantext.Components.PhyloExplorer.Types
, ExtractedTerm(..) , ExtractedTerm(..)
, ExtractedCount(..) , ExtractedCount(..)
, FrameDoc(..) , FrameDoc(..)
, CacheParams(..), defaultCacheParams
) where ) where
import Gargantext.Prelude import Gargantext.Prelude
...@@ -498,3 +499,26 @@ newtype FrameDoc = FrameDoc ...@@ -498,3 +499,26 @@ newtype FrameDoc = FrameDoc
derive instance Generic FrameDoc _ derive instance Generic FrameDoc _
derive instance Eq FrameDoc derive instance Eq FrameDoc
----------------------------------------------------------------
newtype CacheParams = CacheParams
{ expandSelection :: Boolean
, expandNeighborhood :: 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
{ expandSelection : true
, expandNeighborhood: true
}
...@@ -12,8 +12,8 @@ import DOM.Simple.Types (class IsNode, class IsElement, DOMRect) ...@@ -12,8 +12,8 @@ import DOM.Simple.Types (class IsNode, class IsElement, DOMRect)
import Data.Array as A import Data.Array as A
import Data.Either (hush) import Data.Either (hush)
import Data.Function.Uncurried (Fn1, runFn1, Fn2, runFn2) import Data.Function.Uncurried (Fn1, runFn1, Fn2, runFn2)
import Data.Maybe as Maybe
import Data.Maybe (Maybe(..), fromJust, fromMaybe) import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Maybe as Maybe
import Data.Nullable (Nullable, null, toMaybe) import Data.Nullable (Nullable, null, toMaybe)
import Data.Tuple (Tuple) import Data.Tuple (Tuple)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
...@@ -397,6 +397,12 @@ getls = window >>= localStorage ...@@ -397,6 +397,12 @@ getls = window >>= localStorage
openNodesKey :: LocalStorageKey openNodesKey :: LocalStorageKey
openNodesKey = "garg-open-nodes" openNodesKey = "garg-open-nodes"
graphParamsKey :: LocalStorageKey
graphParamsKey = "garg-graph-params"
phyloParamsKey :: LocalStorageKey
phyloParamsKey = "garg-phylo-params"
type LocalStorageKey = String type LocalStorageKey = String
loadLocalStorageState :: forall s. JSON.ReadForeign s => LocalStorageKey -> T.Box s -> Effect Unit loadLocalStorageState :: forall s. JSON.ReadForeign s => LocalStorageKey -> T.Box s -> Effect Unit
...@@ -410,6 +416,16 @@ loadLocalStorageState key cell = do ...@@ -410,6 +416,16 @@ loadLocalStorageState key cell = do
Nothing -> pure unit Nothing -> pure unit
Just p -> void $ T.write p cell Just p -> void $ T.write p cell
loadLocalStorageState' :: forall s.
JSON.ReadForeign s
=> LocalStorageKey
-> s
-> Effect s
loadLocalStorageState' key default = do
(item :: Maybe String) <- getls >>= getItem key
let parsed = hush <<< JSON.readJSON $ Maybe.fromMaybe "" item
pure $ Maybe.fromMaybe default parsed
listenLocalStorageState :: forall s. JSON.WriteForeign s => LocalStorageKey -> T.Change s -> Effect Unit listenLocalStorageState :: forall s. JSON.WriteForeign s => LocalStorageKey -> T.Change s -> Effect Unit
listenLocalStorageState key { old, new } = do listenLocalStorageState key { old, new } = do
--let json = Json.stringify $ Argonaut.encodeJson new --let json = Json.stringify $ Argonaut.encodeJson new
...@@ -417,6 +433,15 @@ listenLocalStorageState key { old, new } = do ...@@ -417,6 +433,15 @@ listenLocalStorageState key { old, new } = do
storage <- getls storage <- getls
setItem key json storage setItem key json storage
setLocalStorageState :: forall s.
JSON.WriteForeign s
=> LocalStorageKey
-> s
-> Effect Unit
setLocalStorageState key s =
let json = JSON.writeJSON s
in getls >>= setItem key json
getMessageDataStr :: DE.MessageEvent -> String getMessageDataStr :: DE.MessageEvent -> String
getMessageDataStr = getMessageData getMessageDataStr = getMessageData
......
...@@ -590,6 +590,17 @@ $decreasing-color: #11638F; ...@@ -590,6 +590,17 @@ $decreasing-color: #11638F;
&__value { &__value {
color: $info; color: $info;
} }
&__expand {
// Following <list-group-item> spacing
$position-x: $list-group-item-padding-x;
// Empirical: fit well with icon overlay
$position-y: 1rem;
position: absolute;
right: $position-x;
bottom: $position-y;
}
} }
&__nil { &__nil {
......
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