diff options
author | David Barksdale <amatus@amatus.name> | 2015-12-30 22:05:52 -0600 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2015-12-30 22:05:52 -0600 |
commit | 1a9bc49d42cb592f3fb41fae8c6af9b1fe983c41 (patch) | |
tree | 2a326c75acf946880be2230bc9a89fdc56f6bdab /src/admin.cljs.hl | |
parent | bde7e66ce48b1db0a65ad4ccaceef96271d1b90d (diff) |
Add admin page
Diffstat (limited to 'src/admin.cljs.hl')
-rw-r--r-- | src/admin.cljs.hl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/admin.cljs.hl b/src/admin.cljs.hl new file mode 100644 index 0000000..4083190 --- /dev/null +++ b/src/admin.cljs.hl @@ -0,0 +1,52 @@ +(page "admin.html" + (:require [app.rpc :as rpc] + [app.scoreboard :as s] + [cljs.pprint :refer [pprint]])) + +(defc token nil) +(defc= logged-in? (not (nil? token))) +(defc= error rpc/error) +(defc= error-message (when error (.-message error))) + +(rpc/init) + +(html + (head + (link :rel "stylesheet" :type "text/css" :href "css/main.css") + (title "Potluck CTF Adminstration")) + (body + (h1 "Potluck CTF Administration") + (div + :id "error" + :click #(reset! rpc/error nil) + :toggle (cell= (not (nil? rpc/error))) + (text "Error: ~{error-message}")) + (let [token-input (input :name "token")] + (form + :toggle (cell= (not logged-in?)) + :submit #(do (reset! token (.-value token-input)) + (set! (.-value token-input) nil)) + (text "Admin Token:") + token-input + (input :type "submit"))) + (let [eval-input (input :name "eval" :size 100) + output (textarea + :value (cell= (with-out-str + (pprint rpc/eval-result))))] + (form + :toggle logged-in? + :submit #(rpc/admin-eval! @token (.-value eval-input)) + (text "(eval ") + eval-input + (text ")") + (br) + output)) + (form + :toggle logged-in? + :submit #(do (reset! token nil) + (reset! rpc/token-ok false)) + (input :type "submit" :value "Logout")) + (h2 "Scoreboard") + (s/scoreboard :scoreboard rpc/scoreboard))) + +;; vim: set expandtab ts=2 sw=2 filetype=clojure : |