Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn upload [data owner]
(render [this]
(html [:div {:class "upload"}
[:form {:enc-type "multipart/form-data"
:ref "fileUpload"
:role "form"
:class "form-inline"}
[:div {:class "form-group"}
[:span {:class "btn btn-default btn-file"}
[:input {:id "file"
:name "file"
:type "file"
:ref "fileSelect"
:on-change (fn [e]
(->> (om/get-node owner "fileSelect")
(om/update! data :selected-file)))}]
(if-let [selected (:selected-file data)]
(extract-name selected)
"Select Apache Log File")]]
[:div {:class "form-group"}
[:input {:value "upload"
:type "submit"
:class "btn btn-default"
:on-click (fn [e]
(.preventDefault e)
(upload-form-file (om/get-node owner "fileUpload")
(let [toggle #(om/transact! data
(fn []
(timeout toggle 2000)))))}]]
[:div {:class "form-group pull-right"}
[:button {:type "button"
:class "btn btn-default pull-right"
:on-click (fn [_] (xhr "POST" "/log/default"))}
[:span "Load Default Log"]]]
(if (:completed data) [:div {:class "panel panel-default"}
[:div {:class "panel-body bg-success"} "Upload Completed Successfully"]])]]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.