Commit d30854cd authored by Karen Konou's avatar Karen Konou

[Node Calc upload] Update upload functions

parent 82d630c7
Pipeline #3520 failed with stage
in 0 seconds
......@@ -359,8 +359,8 @@ uploadArbitraryFile' fileFormat mName blob p@{ boxes: { errors, tasks }, session
GAT.insert id task tasks
here.log2 "[uploadArbitraryFile'] UploadArbitraryFile, uploaded, task:" task
uploadFrameCalc' p@{ boxes: { errors, tasks }, session, tree: (NTree (LNode { id }) _) } = do
eTask <- uploadFrameCalc session id
uploadFrameCalc' lang p@{ boxes: { errors, tasks }, session, tree: (NTree (LNode { id }) _) } selection = do
eTask <- uploadFrameCalc session id lang selection
handleRESTError errors eTask $ \task -> liftEffect $ do
GAT.insert id task tasks
here.log2 "[performAction] UploadFrameCalc, uploaded, task:" task
......@@ -400,7 +400,7 @@ performAction (ShareTeam username) p = shareTeam userna
performAction (SharePublic { params }) p = sharePublic params p
performAction (AddContact params) p = addContact params p
performAction (AddNode name nodeType) p = addNode' name nodeType p
performAction UploadFrameCalc p = uploadFrameCalc' p
performAction (UploadFrameCalc lang selection) p = uploadFrameCalc' lang p selection
performAction (UploadFile nodeType fileType fileFormat lang mName contents selection) p =
uploadFile' nodeType fileType fileFormat lang mName contents p selection
performAction (UploadArbitraryFile fileFormat mName blob selection) p =
......
......@@ -44,7 +44,7 @@ icon (SharePublic _ ) = glyphiconNodeAction (Publish { subTreePara
icon (DoSearch _) = glyphiconNodeAction SearchBox
icon (UploadFile _ _ _ _ _ _ _) = glyphiconNodeAction Upload
icon (UploadArbitraryFile _ _ _ _ ) = glyphiconNodeAction Upload
icon UploadFrameCalc = glyphiconNodeAction Upload
icon (UploadFrameCalc _ _) = glyphiconNodeAction Upload
icon RefreshTree = glyphiconNodeAction Refresh
icon CloseBox = glyphiconNodeAction CloseNodePopover
icon DownloadNode = glyphiconNodeAction Download
......@@ -68,7 +68,7 @@ text (SharePublic _ ) = "Publish !"
text (DoSearch _ ) = "Launch search !"
text (UploadFile _ _ _ _ _ _ _) = "Upload File !"
text (UploadArbitraryFile _ _ _ _) = "Upload arbitrary file !"
text UploadFrameCalc = "Upload frame calc"
text (UploadFrameCalc _ _) = "Upload frame calc"
text RefreshTree = "Refresh Tree !"
text CloseBox = "Close Box !"
text DownloadNode = "Download !"
......
......@@ -18,7 +18,7 @@ data Action = AddNode String GT.NodeType
| DoSearch GT.AsyncTaskWithType
| UploadFile GT.NodeType FileType FileFormat Lang (Maybe String) String Selection
| UploadArbitraryFile FileFormat (Maybe String) UploadFileBlob Selection
| UploadFrameCalc
| UploadFrameCalc Lang Selection
| DownloadNode
| RefreshTree
| CloseBox
......@@ -45,7 +45,7 @@ instance Eq Action where
eq (UploadFile nt1 ft1 ff1 l1 s1 _ _) (UploadFile nt2 ft2 ff2 l2 s2 _ _) =
(eq nt1 nt2) && (eq ft1 ft2) && (eq ff1 ff2) && (eq l1 l2) && (eq s1 s2)
eq (UploadArbitraryFile ff1 s1 _ _) (UploadArbitraryFile ff2 s2 _ _) = (eq ff1 ff2) && (eq s1 s2)
eq UploadFrameCalc UploadFrameCalc = true
eq (UploadFrameCalc l1 s1) (UploadFrameCalc l2 s2) = (eq l1 l2) && (eq s1 s2)
eq DownloadNode DownloadNode = true
eq RefreshTree RefreshTree = true
eq CloseBox CloseBox = true
......@@ -70,7 +70,7 @@ instance Show Action where
show (DoSearch _ ) = "SearchQuery"
show (UploadFile _ _ _ _ _ _ _) = "UploadFile"
show (UploadArbitraryFile _ _ _ _) = "UploadArbitraryFile"
show UploadFrameCalc = "UploadFrameCalc"
show (UploadFrameCalc _ _ ) = "UploadFrameCalc"
show RefreshTree = "RefreshTree"
show CloseBox = "CloseBox"
show DownloadNode = "Download"
......
......@@ -710,10 +710,10 @@ uploadFrameCalcViewCpt :: R.Component Props
uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
where
cpt { dispatch, session } _ = do
lang /\ langBox
lang' /\ langBox
<- R2.useBox' EN
selection
<- T.useBox ListSelection.MyListsFirst
selection' /\ selectionBox
<- R2.useBox' ListSelection.MyListsFirst
let bodies = [
H.div
......@@ -738,7 +738,7 @@ uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
[
B.formSelect'
{ callback: flip T.write_ langBox
, value: lang
, value: lang'
, list: [ EN, FR, No_extraction, Universal ]
}
[]
......@@ -760,7 +760,7 @@ uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
{ className: "form-group__field" }
[
ListSelection.selection
{ selection
{ selection: selectionBox
, session
} []
]
......@@ -769,22 +769,29 @@ uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
let footer = H.div {}
[ H.button { className: "btn btn-primary"
, on: { click: onClick } }
, on: { click: onClick lang' selection' } }
[ H.text "Upload!" ]
]
pure $ panel bodies footer
where
onClick _ = do
onClick lang' selection' _ = do
void $ launchAff do
dispatch UploadFrameCalc
dispatch $ UploadFrameCalc lang' selection'
uploadFrameCalc :: Session
-> ID
-> Lang
-> ListSelection.Selection
-> AffRESTError GT.AsyncTaskWithType
uploadFrameCalc session id = do
uploadFrameCalc session id lang selection = do
let p = GR.NodeAPI GT.Node (Just id) $ GT.asyncTaskTypePath GT.UploadFrameCalc
let body = [
Tuple "_wf_lang" (Just $ show lang)
, Tuple "_wf_selection" (Just $ show selection)
]
eTask <- post session p ([] :: Array String)
eTask <- postWwwUrlencoded session p body
pure $ (\task -> GT.AsyncTaskWithType { task, typ: GT.UploadFrameCalc }) <$> eTask
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