Created
April 6, 2014 21:40
-
-
Save gtrak/10011760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn upload [data owner] | |
(reify | |
om/IRender | |
(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") | |
.-value | |
(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") | |
"/log/upload" | |
"POST" | |
(let [toggle #(om/transact! data | |
:completed | |
not)] | |
(fn [] | |
(toggle) | |
(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