Skip to content

Commit

Permalink
Display attendance time
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed Nov 6, 2015
1 parent 35665f5 commit 712dc0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/attendance-check/project.clj
Expand Up @@ -35,7 +35,8 @@
[manifold "0.1.0"]
[com.novemberain/langohr "3.3.0"]
[crypto-password "0.1.3"]
[org.clojure/data.json "0.2.6"]]
[org.clojure/data.json "0.2.6"]
[com.andrewmcveigh/cljs-time "0.3.14"]]

:min-lein-version "2.0.0"
:uberjar-name "attendance-check.jar"
Expand Down
15 changes: 11 additions & 4 deletions examples/attendance-check/src-cljs/attendance_check/dashboard.cljs
@@ -1,12 +1,15 @@
(ns attendance-check.dashboard
(:require [ajax.core :refer [GET POST]]
[cljs.core.async :refer [chan put! <! close!]]
[cljs-time.core :refer [now]]
[cljs-time.format :refer [formatter unparse]]
[reagent.core :as reagent]
[sory.socket :refer [initialize-socket]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))


(defonce sory-socket (initialize-socket))
(defonce time-formatter (formatter "yyyy-MM-dd HH:mm:ss"))


(defn <get-courses []
Expand Down Expand Up @@ -76,12 +79,12 @@


(defn students-section [props]
(let [checked-students (reagent/atom #{})
(let [checked-students (reagent/atom {})
timer-id (reagent/atom nil)
event-source (atom nil)
stream (atom nil)]
(letfn [(start-check [course-id]
(reset! checked-students #{})
(reset! checked-students {})
(let [check-url (str "/dashboard/courses/"
course-id
"/attendance-checks/")]
Expand All @@ -101,7 +104,9 @@
(.-data)
(.parse js/JSON)
(.-student))]
(swap! checked-students conj (.-_id student))
(swap! checked-students assoc
(.-_id student)
(now))
(recur)))))))
(stop-check []
(.clearInterval js/window @timer-id)
Expand All @@ -125,7 +130,9 @@
^{:key s}
[:tr
[:td (:name s)]
[:td (if (@checked-students (:_id s)) "출석" "미확인")]]))
[:td
(when-let [attendance-at (get @checked-students (:_id s))]
(unparse time-formatter attendance-at))]]))
[:tr
[:td
{:colSpan "2"
Expand Down

0 comments on commit 712dc0e

Please sign in to comment.