Commit ef521e75 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] Framing : front + back

parent 1a198895
...@@ -20,6 +20,7 @@ import Gargantext.Components.Login (login) ...@@ -20,6 +20,7 @@ import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout) import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contacts (annuaireUserLayout, userLayout) import Gargantext.Components.Nodes.Annuaire.User.Contacts (annuaireUserLayout, userLayout)
import Gargantext.Components.Nodes.Corpus (corpusLayout) import Gargantext.Components.Nodes.Corpus (corpusLayout)
import Gargantext.Components.Nodes.Frame (frameLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout) import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
import Gargantext.Components.Nodes.Corpus.Document (documentLayout) import Gargantext.Components.Nodes.Corpus.Document (documentLayout)
import Gargantext.Components.Nodes.Home (homeLayout) import Gargantext.Components.Nodes.Home (homeLayout)
...@@ -72,20 +73,21 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -72,20 +73,21 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
Home -> forested $ homeLayout LL_EN Home -> forested $ homeLayout LL_EN
Login -> login { sessions, backends, visible: showLogin } Login -> login { sessions, backends, visible: showLogin }
--Folder sid _ -> withSession sid $ \_ -> forested (folder {}) --Folder sid _ -> withSession sid $ \_ -> forested (folder {})
Folder sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } Folder sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: show nodeId, nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends } RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: show nodeId, nodeId, session }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session } Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session } Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends }
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session } Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session } Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, frontends, nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
CorpusDocument sid corpusId listId nodeId -> UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session }
withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId } ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, frontends, nodeId, session }
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Document sid listId nodeId -> Document sid listId nodeId ->
withSession sid $ withSession sid $
\session -> forested $ documentLayout { nodeId, listId, session, corpusId: Nothing } \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Nothing }
...@@ -102,12 +104,11 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -102,12 +104,11 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
, treeReload } , treeReload }
type ForestLayoutProps = type ForestLayoutProps =
( ( child :: R.Element
child :: R.Element
, frontends :: Frontends , frontends :: Frontends
, reload :: R.State Int , reload :: R.State Int
, route :: AppRoute , route :: AppRoute
, sessions :: Sessions , sessions :: Sessions
, showLogin :: R2.Setter Boolean , showLogin :: R2.Setter Boolean
) )
......
...@@ -5,7 +5,7 @@ import Data.Maybe (Maybe(..)) ...@@ -5,7 +5,7 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel, checkbox, checkboxes, divider) import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel, checkbox, checkboxes)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTreeParamsIn) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTreeParamsIn)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
......
...@@ -89,7 +89,9 @@ settingsBox NodeUser = ...@@ -89,7 +89,9 @@ settingsBox NodeUser =
SettingsBox { show : true SettingsBox { show : true
, edit : false , edit : false
, doc : Documentation NodeUser , doc : Documentation NodeUser
, buttons : [ Delete ] , buttons : [ Delete
-- , Add [FolderPublic]
]
} }
settingsBox FolderPrivate = settingsBox FolderPrivate =
...@@ -99,6 +101,8 @@ settingsBox FolderPrivate = ...@@ -99,6 +101,8 @@ settingsBox FolderPrivate =
, buttons : [ Add [ Corpus , buttons : [ Add [ Corpus
, Folder , Folder
, Annuaire , Annuaire
, NodeFrameWrite
, NodeFrameCalc
] ]
] ]
} }
...@@ -110,9 +114,12 @@ settingsBox Team = ...@@ -110,9 +114,12 @@ settingsBox Team =
, buttons : [ Add [ Corpus , buttons : [ Add [ Corpus
, Folder , Folder
, Annuaire , Annuaire
, NodeFrameWrite
, NodeFrameCalc
] ]
, Share , Share
, Delete] , Delete
]
} }
settingsBox FolderShared = settingsBox FolderShared =
...@@ -131,7 +138,8 @@ settingsBox FolderPublic = ...@@ -131,7 +138,8 @@ settingsBox FolderPublic =
, buttons : [ Add [ Corpus , buttons : [ Add [ Corpus
, Folder , Folder
] ]
] -- , Delete
]
} }
settingsBox Folder = settingsBox Folder =
...@@ -141,6 +149,8 @@ settingsBox Folder = ...@@ -141,6 +149,8 @@ settingsBox Folder =
, buttons : [ Add [ Corpus , buttons : [ Add [ Corpus
, Folder , Folder
, Annuaire , Annuaire
, NodeFrameWrite
, NodeFrameCalc
] ]
, Move moveParameters , Move moveParameters
, Delete , Delete
...@@ -154,6 +164,8 @@ settingsBox Corpus = ...@@ -154,6 +164,8 @@ settingsBox Corpus =
, buttons : [ Add [ NodeList , buttons : [ Add [ NodeList
, Graph , Graph
, Dashboard , Dashboard
, NodeFrameWrite
, NodeFrameCalc
] ]
, SearchBox , SearchBox
, Upload , Upload
...@@ -229,6 +241,29 @@ settingsBox Annuaire = ...@@ -229,6 +241,29 @@ settingsBox Annuaire =
] ]
} }
settingsBox NodeFrameWrite =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameWrite
, buttons : [ Add [ NodeFrameWrite
, NodeFrameCalc
]
]
}
settingsBox NodeFrameCalc =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameCalc
, buttons : [ Add [ NodeFrameCalc
, NodeFrameWrite
]
]
}
settingsBox _ = settingsBox _ =
SettingsBox { show : false SettingsBox { show : false
, edit : false , edit : false
......
...@@ -263,6 +263,7 @@ nodeTextCpt = R.hooksComponent "G.C.F.T.N.B.nodeText" cpt ...@@ -263,6 +263,7 @@ nodeTextCpt = R.hooksComponent "G.C.F.T.N.B.nodeText" cpt
------------------------------------------------------------------------ ------------------------------------------------------------------------
divider :: R.Element
divider = H.div {className:"divider"} []
...@@ -53,8 +53,7 @@ dashboardLayoutCpt = R.hooksComponent "G.C.N.C.D.dashboardLayout" cpt ...@@ -53,8 +53,7 @@ dashboardLayoutCpt = R.hooksComponent "G.C.N.C.D.dashboardLayout" cpt
liftEffect $ setReload $ (+) 1 liftEffect $ setReload $ (+) 1
type LoadedProps = type LoadedProps =
( ( charts :: Array P.PredefinedChart
charts :: Array P.PredefinedChart
, corpusId :: NodeID , corpusId :: NodeID
, defaultListId :: Int , defaultListId :: Int
, key :: String , key :: String
...@@ -91,8 +90,7 @@ dashboardLayoutLoadedCpt = R.hooksComponent "G.C.N.C.D.dashboardLayoutLoaded" cp ...@@ -91,8 +90,7 @@ dashboardLayoutLoadedCpt = R.hooksComponent "G.C.N.C.D.dashboardLayoutLoaded" cp
onRemove _ = onChange $ fromMaybe charts $ A.deleteAt idx charts onRemove _ = onChange $ fromMaybe charts $ A.deleteAt idx charts
type PredefinedChartProps = type PredefinedChartProps =
( ( chart :: P.PredefinedChart
chart :: P.PredefinedChart
, corpusId :: NodeID , corpusId :: NodeID
, defaultListId :: Int , defaultListId :: Int
, onChange :: P.PredefinedChart -> Effect Unit , onChange :: P.PredefinedChart -> Effect Unit
......
...@@ -13,9 +13,8 @@ type Preferences = Maybe String ...@@ -13,9 +13,8 @@ type Preferences = Maybe String
newtype Hyperdata = newtype Hyperdata =
Hyperdata Hyperdata
{ { charts :: Array P.PredefinedChart
charts :: Array P.PredefinedChart , preferences :: Preferences
, preferences :: Preferences
} }
instance decodeHyperdata :: DecodeJson Hyperdata where instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do decodeJson json = do
...@@ -52,8 +51,8 @@ saveDashboard {hyperdata, nodeId, session} = do ...@@ -52,8 +51,8 @@ saveDashboard {hyperdata, nodeId, session} = do
id_ <- (put session (NodeAPI Node (Just nodeId) "") hyperdata) :: Aff Int id_ <- (put session (NodeAPI Node (Just nodeId) "") hyperdata) :: Aff Int
pure unit pure unit
type DashboardData = { type DashboardData =
id :: Int { id :: Int
, hyperdata :: Hyperdata , hyperdata :: Hyperdata
, parentId :: Int , parentId :: Int
} }
module Gargantext.Components.Nodes.Frame where
import Data.Maybe (Maybe(..))
import Data.Tuple (fst)
import Effect.Aff (Aff)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, get)
import Gargantext.Types (NodeType(..))
import Reactix as R
import Reactix.DOM.HTML as H
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
--import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Gargantext.Utils.Argonaut (genericSumEncodeJson)
import Data.Argonaut (decodeJson, (.:))
data Hyperdata =
Hyperdata { base :: String
, frame_id :: String
}
derive instance eqHyperdata :: Eq Hyperdata
derive instance genericHyperdata :: Generic Hyperdata _
instance showHyperdata :: Show Hyperdata where
show = genericShow
instance decodeJsonHyperdata :: Argonaut.DecodeJson Hyperdata where
-- TODO
-- decodeJson = genericSumDecodeJson
decodeJson json = do
obj <- decodeJson json
base <- obj .: "base"
frame_id <- obj .: "frame_id"
pure $ Hyperdata {base, frame_id}
instance encodeJsonHyperdata :: Argonaut.EncodeJson Hyperdata where
encodeJson = genericSumEncodeJson
type Props =
( nodeId :: Int
, session :: Session
)
type Reload = R.State Int
type KeyProps =
( key :: String
| Props
)
frameLayout :: Record KeyProps -> R.Element
frameLayout props = R.createElement frameLayoutCpt props []
frameLayoutCpt :: R.Component KeyProps
frameLayoutCpt = R.hooksComponent "G.C.N.C.writeLayout" cpt
where
cpt {nodeId, session} _ = do
reload <- R.useState' 0
useLoader {nodeId, reload: fst reload, session} loadframeWithReload $
\frame -> frameLayoutView {frame, nodeId, reload, session}
type ViewProps =
( frame :: NodePoly Hyperdata
, reload :: Reload
| Props
)
data FrameType = Calc | Write
type Base = String
type FrameId = String
hframe :: FrameType -> String
hframe ft = "https://" <> hframe' ft <> ".frame.gargantext.org/test"
where
hframe' Calc = "calc"
hframe' Write = "write"
hframeUrl :: Base -> FrameId -> String
hframeUrl base frame_id = base <> "/" <> frame_id <> "?both"
frameLayoutView :: Record ViewProps -> R.Element
frameLayoutView props = R.createElement frameLayoutViewCpt props []
frameLayoutViewCpt :: R.Component ViewProps
frameLayoutViewCpt = R.hooksComponent "G.C.N.C.frameLayoutView" cpt
where
cpt {frame: (NodePoly {hyperdata: Hyperdata {base, frame_id}}), nodeId, reload, session} _ = do
pure $ H.div { className : "istex-search" }
[ H.iframe { src: hframeUrl base frame_id
, width: "100%"
, height: "100%"
-- , ref: "https://write.frame.gargantext.org/test"
} []
]
type LoadProps =
( nodeId :: Int
, session :: Session
)
loadframe' :: Record LoadProps -> Aff (NodePoly Hyperdata)
loadframe' {nodeId, session} = get session $ NodeAPI Node (Just nodeId) ""
-- Just to make reloading effective
loadframeWithReload :: {reload :: Int | LoadProps} -> Aff (NodePoly Hyperdata)
loadframeWithReload {nodeId, session} = loadframe' {nodeId, session}
...@@ -11,9 +11,9 @@ router :: Match AppRoute ...@@ -11,9 +11,9 @@ router :: Match AppRoute
router = oneOf router = oneOf
[ Login <$ route "login" [ Login <$ route "login"
, Folder <$> (route "folder" *> sid) <*> int , Folder <$> (route "folder" *> sid) <*> int
, FolderPrivate <$> (route "folderPrivate" *> sid) <*> int , FolderPrivate <$> (route "folderPrivate" *> sid) <*> int
, FolderPublic <$> (route "folderPublic" *> sid) <*> int , FolderPublic <$> (route "folderPublic" *> sid) <*> int
, FolderShared <$> (route "folderShared" *> sid) <*> int , FolderShared <$> (route "folderShared" *> sid) <*> int
, Team <$> (route "team" *> sid) <*> int , Team <$> (route "team" *> sid) <*> int
, CorpusDocument <$> (route "corpus" *> sid) <*> int , CorpusDocument <$> (route "corpus" *> sid) <*> int
<*> (lit "list" *> int) <*> (lit "list" *> int)
...@@ -29,6 +29,9 @@ router = oneOf ...@@ -29,6 +29,9 @@ router = oneOf
<*> (lit "contact" *> int) <*> (lit "contact" *> int)
, Annuaire <$> (route "annuaire" *> sid) <*> int , Annuaire <$> (route "annuaire" *> sid) <*> int
, UserPage <$> (route "user" *> sid) <*> int , UserPage <$> (route "user" *> sid) <*> int
, RouteFrameWrite <$> (route "write" *> sid) <*> int
, RouteFrameCalc <$> (route "calc" *> sid) <*> int
, Home <$ lit "" , Home <$ lit ""
] ]
where where
......
...@@ -23,6 +23,9 @@ data AppRoute ...@@ -23,6 +23,9 @@ data AppRoute
| Annuaire SessionId Int | Annuaire SessionId Int
| UserPage SessionId Int | UserPage SessionId Int
| ContactPage SessionId Int Int | ContactPage SessionId Int Int
| RouteFrameWrite SessionId Int
| RouteFrameCalc SessionId Int
derive instance eqAppRoute :: Eq AppRoute derive instance eqAppRoute :: Eq AppRoute
...@@ -66,6 +69,9 @@ instance showAppRoute :: Show AppRoute where ...@@ -66,6 +69,9 @@ instance showAppRoute :: Show AppRoute where
show (Annuaire s i) = "Annuaire" <> show i <> " (" <> show s <> ")" show (Annuaire s i) = "Annuaire" <> show i <> " (" <> show s <> ")"
show (UserPage s i) = "User" <> show i <> " (" <> show s <> ")" show (UserPage s i) = "User" <> show i <> " (" <> show s <> ")"
show (ContactPage s a i) = "Contact" <> show a <> "::" <> show i <> " (" <> show s <> ")" show (ContactPage s a i) = "Contact" <> show a <> "::" <> show i <> " (" <> show s <> ")"
show (RouteFrameWrite s i) = "write" <> show i <> " (" <> show s <> ")"
show (RouteFrameCalc s i) = "calc" <> show i <> " (" <> show s <> ")"
appPath :: AppRoute -> String appPath :: AppRoute -> String
appPath Home = "" appPath Home = ""
...@@ -85,3 +91,6 @@ appPath (Lists s i) = "lists/" <> show s <> "/" <> show i ...@@ -85,3 +91,6 @@ appPath (Lists s i) = "lists/" <> show s <> "/" <> show i
appPath (Annuaire s i) = "annuaire/" <> show s <> "/" <> show i appPath (Annuaire s i) = "annuaire/" <> show s <> "/" <> show i
appPath (UserPage s i) = "user/" <> show s <> "/" <> show i appPath (UserPage s i) = "user/" <> show s <> "/" <> show i
appPath (ContactPage s a i) = "annuaire/" <> show s <> "/" <> show a <> "/contact/" <> show i appPath (ContactPage s a i) = "annuaire/" <> show s <> "/" <> show a <> "/contact/" <> show i
appPath (RouteFrameWrite s i) = "write/" <> show s <> "/" <> show i
appPath (RouteFrameCalc s i) = "calc/" <> show s <> "/" <> show i
...@@ -151,6 +151,9 @@ data NodeType = NodeUser ...@@ -151,6 +151,9 @@ data NodeType = NodeUser
| Tree | Tree
| NodeList | NodeList
| Texts | Texts
-- TODO Optional Nodes
| NodeFrameWrite
| NodeFrameCalc
derive instance eqNodeType :: Eq NodeType derive instance eqNodeType :: Eq NodeType
...@@ -177,6 +180,9 @@ instance showNodeType :: Show NodeType where ...@@ -177,6 +180,9 @@ instance showNodeType :: Show NodeType where
show Team = "NodeTeam" show Team = "NodeTeam"
show NodeList = "NodeList" show NodeList = "NodeList"
show Texts = "NodeTexts" show Texts = "NodeTexts"
show NodeFrameWrite = "NodeFrameWrite"
show NodeFrameCalc = "NodeFrameCalc"
instance readNodeType :: Read NodeType where instance readNodeType :: Read NodeType where
read "NodeUser" = Just NodeUser read "NodeUser" = Just NodeUser
...@@ -199,6 +205,8 @@ instance readNodeType :: Read NodeType where ...@@ -199,6 +205,8 @@ instance readNodeType :: Read NodeType where
read "NodeList" = Just NodeList read "NodeList" = Just NodeList
read "NodeTexts" = Just Texts read "NodeTexts" = Just Texts
read "Annuaire" = Just Annuaire read "Annuaire" = Just Annuaire
read "NodeFrameWrite" = Just NodeFrameWrite
read "NodeFrameCalc" = Just NodeFrameCalc
read _ = Nothing read _ = Nothing
...@@ -237,6 +245,12 @@ fldr Annuaire false = "fa fa-address-card" ...@@ -237,6 +245,12 @@ fldr Annuaire false = "fa fa-address-card"
fldr NodeContact true = "fa fa-address-card-o" fldr NodeContact true = "fa fa-address-card-o"
fldr NodeContact false = "fa fa-address-card" fldr NodeContact false = "fa fa-address-card"
fldr NodeFrameWrite true = "fa fa-file-word-o"
fldr NodeFrameWrite false = "fa fa-file-word-o"
fldr NodeFrameCalc true = "fa fa-file-excel-o"
fldr NodeFrameCalc false = "fa fa-file-excel-o"
fldr _ false = "fa fa-folder-o" fldr _ false = "fa fa-folder-o"
fldr _ true = "fa fa-folder-open" fldr _ true = "fa fa-folder-open"
...@@ -280,6 +294,9 @@ nodeTypePath Tree = "tree" ...@@ -280,6 +294,9 @@ nodeTypePath Tree = "tree"
nodeTypePath NodeList = "lists" nodeTypePath NodeList = "lists"
nodeTypePath Texts = "texts" nodeTypePath Texts = "texts"
nodeTypePath Team = "team" nodeTypePath Team = "team"
nodeTypePath NodeFrameWrite = "write"
nodeTypePath NodeFrameCalc = "calc"
------------------------------------------------------------ ------------------------------------------------------------
type ListId = Int type ListId = Int
......
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