aboutsummaryrefslogtreecommitdiff
path: root/src/admin.cljs.hl
diff options
context:
space:
mode:
Diffstat (limited to 'src/admin.cljs.hl')
-rw-r--r--src/admin.cljs.hl52
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 :