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

Merge remote-tracking branch 'origin/481-dev-node-calc-upload' into dev

parents 9c13975e d30854cd
......@@ -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"
......
......@@ -709,33 +709,89 @@ uploadFrameCalcView = R.createElement uploadFrameCalcViewCpt
uploadFrameCalcViewCpt :: R.Component Props
uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
where
cpt { dispatch } _ = do
let bodies =
[ R2.row
[ H.div { className: "col-12 flex-space-around" }
[ H.h4 {}
[ H.text "This will upload current calc as Corpus CSV" ]
]
]
]
cpt { dispatch, session } _ = do
lang' /\ langBox
<- R2.useBox' EN
selection' /\ selectionBox
<- R2.useBox' ListSelection.MyListsFirst
let bodies = [
H.div
{ className: "col-12 flex-space-around" }
[ H.h4 {}
[ H.text "This will upload current calc as Corpus CSV" ]
]
,
-- Lang
H.div
{ className: "form-group" }
[
H.div
{ className: "form-group__label" }
[
B.label_ $
"File lang"
]
,
H.div
{ className: "form-group__field" }
[
B.formSelect'
{ callback: flip T.write_ langBox
, value: lang'
, list: [ EN, FR, No_extraction, Universal ]
}
[]
]
]
,
-- List selection
H.div
{ className: "form-group" }
[
H.div
{ className: "form-group__label" }
[
B.label_ $
"List selection"
]
,
H.div
{ className: "form-group__field" }
[
ListSelection.selection
{ selection: selectionBox
, session
} []
]
]
]
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