Skip to content

Commit

Permalink
Show waiting status of downloads in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
verma committed Jul 6, 2014
1 parent bd33f24 commit bb801f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src-cljs/dakait/components.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
[jayq.util :only [log]])
(:require [cljs.core.async :as async :refer [>!]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true])
(:require-macros [cljs.core.async.macros :refer [go]]))
[om.dom :as dom :include-macros true]
[cljs.core.match])
(:require-macros [cljs.core.async.macros :refer [go]]
[cljs.core.match.macros :refer [match]]))

(defn current-path
"Manages the current path display"
Expand Down Expand Up @@ -47,9 +49,10 @@
tag-item (let [tag (:tag l)
dl (:download l)
color (if tag (:color tag) "#999")
dlinfo (if dl
(str (:percent-complete dl) ", " (:rate dl) ", eta: " (:eta dl))
"")]
dlinfo (match dl
{:available st} (str (:percent-complete st) ", " (:rate st) ", eta: " (:eta st))
{:waiting _} "Waiting..."
:else "")]
(dom/div #js {:className "col-sm-6 list-item-tag"
:style #js {:color color}}
(when tag (dom/span #js {:className "tag-info"} (:name tag)))
Expand All @@ -72,7 +75,7 @@
:type "button"
:disabled (:recent l)
:onClick (tag-handler (:name l)) } "Tag")))
(when-let [pc (:percent-complete (:download l))]
(when-let [pc (get-in l [:download :available :percent-complete])]
(dom/div #js {:className "thin-progress"}
(dom/div #js {:className "thin-progress-bar"
:style #js {:width pc}}))))))
Expand Down
7 changes: 5 additions & 2 deletions src-cljs/dakait/start.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@
l))
attach-dl (fn [l]
(if-let [dl (get dls (:name l))]
(do
(assoc l :download (:download-status dl)))
(let [ds (if (:download-status dl)
{:available (:download-status dl)}
{:waiting nil})]
(assoc l :download ds))
l))]
(.log js/console "got downloads" (pr-str dls))
(->> listing
;; Associate tag information
(map #(->> %
Expand Down
10 changes: 6 additions & 4 deletions src/dakait/downloader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@
(defn downloads-in-progress
"Gets all active downloads"
[]
(map (fn [[fut src dest & rest]]
{:from src
:to dest
:download-status (get @download-states src)}) @active-downloads))
(let [ad @active-downloads
ds @download-states]
(map (fn [[fut src dest & rest]]
{:from src
:to dest
:download-status (ds src)}) ad)))

(defn downloads-pending
"Get all the pending downloads as a seq"
Expand Down

0 comments on commit bb801f0

Please sign in to comment.