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

[FEAT] NodeFrameCode

parent 391380e9
......@@ -94,8 +94,9 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session }
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session }
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameWrite}
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCalc }
RouteFrameCode sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCode }
RouteFile sid nodeId -> withSession sid $ \session -> forested $ fileLayout { nodeId, session }
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends }
......
......@@ -126,6 +126,7 @@ settingsBox Team =
, Annuaire
, NodeFrameWrite
, NodeFrameCalc
, NodeFrameCode
]
, Share
, Delete
......@@ -316,6 +317,22 @@ settingsBox NodeFrameCalc =
]
}
settingsBox NodeFrameCode =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameCode
, buttons : [ Add [ NodeFrameCalc
, NodeFrameWrite
, NodeFrameCode
]
, Move moveFrameParameters
, Delete
]
}
settingsBox NodeFile =
SettingsBox { show: true
......
......@@ -23,7 +23,7 @@ import Gargantext.Utils.Reactix as R2
thisModule = "Gargantext.Components.Nodes.Frame"
data Hyperdata =
Hyperdata { base :: String
Hyperdata { base :: String
, frame_id :: String
}
......@@ -38,8 +38,8 @@ instance decodeJsonHyperdata :: Argonaut.DecodeJson Hyperdata where
-- TODO
-- decodeJson = genericSumDecodeJson
decodeJson json = do
obj <- decodeJson json
base <- obj .: "base"
obj <- decodeJson json
base <- obj .: "base"
frame_id <- obj .: "frame_id"
pure $ Hyperdata {base, frame_id}
......@@ -49,8 +49,9 @@ instance encodeJsonHyperdata :: Argonaut.EncodeJson Hyperdata where
type Props =
( nodeId :: Int
, session :: Session
( nodeId :: Int
, session :: Session
, nodeType :: NodeType
)
type Reload = R.State Int
......@@ -66,10 +67,10 @@ frameLayout props = R.createElement frameLayoutCpt props []
frameLayoutCpt :: R.Component Props
frameLayoutCpt = R.hooksComponentWithModule thisModule "frameLayout" cpt
where
cpt {nodeId, session} _ = do
cpt {nodeId, session, nodeType} _ = do
let sid = sessionId session
pure $ frameLayoutWithKey { key: show sid <> "-" <> show nodeId, nodeId, session }
pure $ frameLayoutWithKey { key: show sid <> "-" <> show nodeId, nodeId, session, nodeType}
frameLayoutWithKey :: Record KeyProps -> R.Element
frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props []
......@@ -77,11 +78,11 @@ frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props []
frameLayoutWithKeyCpt :: R.Component KeyProps
frameLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "frameLayoutWithKey" cpt
where
cpt { nodeId, session } _ = do
cpt { nodeId, session, nodeType} _ = do
reload <- R.useState' 0
useLoader {nodeId, reload: fst reload, session} loadframeWithReload $
\frame -> frameLayoutView {frame, nodeId, reload, session}
\frame -> frameLayoutView {frame, nodeId, reload, session, nodeType}
type ViewProps =
( frame :: NodePoly Hyperdata
......@@ -90,12 +91,12 @@ type ViewProps =
)
data FrameType = Calc | Write
type Base = String
type FrameId = String
hframeUrl :: Base -> FrameId -> String
hframeUrl base frame_id = base <> "/" <> frame_id <> "?both"
hframeUrl :: NodeType -> Base -> FrameId -> String
hframeUrl NodeFrameCode _ frame_id = frame_id -- Temp fix : frame_id is currently the whole url created
hframeUrl _ base frame_id = base <> "/" <> frame_id <> "?both"
frameLayoutView :: Record ViewProps -> R.Element
frameLayoutView props = R.createElement frameLayoutViewCpt props []
......@@ -103,9 +104,9 @@ frameLayoutView props = R.createElement frameLayoutViewCpt props []
frameLayoutViewCpt :: R.Component ViewProps
frameLayoutViewCpt = R.hooksComponentWithModule thisModule "frameLayoutView" cpt
where
cpt {frame: (NodePoly {hyperdata: Hyperdata {base, frame_id}}), nodeId, reload, session} _ = do
cpt {frame: (NodePoly {hyperdata: Hyperdata {base, frame_id}}), nodeId, reload, session, nodeType} _ = do
pure $ H.div { className : "frame" }
[ H.iframe { src: hframeUrl base frame_id
[ H.iframe { src: hframeUrl nodeType base frame_id
, width: "100%"
, height: "100%"
} []
......
......@@ -33,6 +33,7 @@ router = oneOf
, RouteFrameWrite <$> (route "write" *> sid) <*> int
, RouteFrameCalc <$> (route "calc" *> sid) <*> int
, RouteFrameCode <$> (route "code" *> sid) <*> int
, RouteFile <$> (route "file" *> sid) <*> int
, Home <$ lit ""
]
......
......@@ -29,6 +29,7 @@ data AppRoute
| ContactPage SessionId Int Int
| RouteFrameWrite SessionId Int
| RouteFrameCalc SessionId Int
| RouteFrameCode SessionId Int
| RouteFile SessionId Int
......@@ -77,6 +78,7 @@ instance showAppRoute :: Show AppRoute where
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 <> ")"
show (RouteFrameCode s i) = "code" <> show i <> " (" <> show s <> ")"
show (RouteFile s i) = "file" <> show i <> " (" <> show s <> ")"
......@@ -100,6 +102,7 @@ appPath (UserPage s i) = "user/" <> show s <> "/" <> 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
appPath (RouteFrameCode s i) = "code/" <> show s <> "/" <> show i
appPath (RouteFile s i) = "file/" <> show s <> "/" <> show i
nodeTypeAppRoute :: NodeType -> SessionId -> Int -> Maybe AppRoute
......
......@@ -156,6 +156,7 @@ data NodeType = NodeUser
-- TODO Optional Nodes
| NodeFrameWrite
| NodeFrameCalc
| NodeFrameCode
| NodePublic NodeType
| NodeFile
......@@ -187,6 +188,7 @@ instance showNodeType :: Show NodeType where
show Texts = "NodeDocs"
show NodeFrameWrite = "NodeFrameWrite"
show NodeFrameCalc = "NodeFrameCalc"
show NodeFrameCode = "NodeFrameCode"
show (NodePublic nt) = "NodePublic" <> show nt
show NodeFile = "NodeFile"
......@@ -214,6 +216,7 @@ instance readNodeType :: Read NodeType where
read "Annuaire" = Just Annuaire
read "NodeFrameWrite" = Just NodeFrameWrite
read "NodeFrameCalc" = Just NodeFrameCalc
read "NodeFrameCode" = Just NodeFrameCode
read "NodeFile" = Just NodeFile
-- TODO NodePublic read ?
read _ = Nothing
......@@ -261,6 +264,10 @@ fldr NodeFrameWrite false = "fa fa-file-text"
fldr NodeFrameCalc true = "fa fa-calculator"
fldr NodeFrameCalc false = "fa fa-calculator"
fldr NodeFrameCode true = "fa fa-terminal"
fldr NodeFrameCode false = "fa fa-terminal"
fldr (NodePublic nt) b = fldr nt b
fldr _ true = "fa fa-folder-open"
......@@ -316,6 +323,7 @@ nodeTypePath Texts = "texts"
nodeTypePath Team = "team"
nodeTypePath NodeFrameWrite = "write"
nodeTypePath NodeFrameCalc = "calc"
nodeTypePath NodeFrameCode = "code"
nodeTypePath (NodePublic nt) = nodeTypePath nt
nodeTypePath NodeFile = "file"
......
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