From 8def2ec408c8c200acd35ac3db78df452b37ff36 Mon Sep 17 00:00:00 2001 From: bom Date: Mon, 14 Jun 2021 12:08:20 +0200 Subject: [PATCH] Changed from textarea to text field, added issuer --- public/index.html | 7 ++--- src/main/cljs/dda/c4k_keycloak/browser.cljs | 30 ++++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index 28a5610..748c57b 100644 --- a/public/index.html +++ b/public/index.html @@ -13,9 +13,10 @@
- + +
+ +


diff --git a/src/main/cljs/dda/c4k_keycloak/browser.cljs b/src/main/cljs/dda/c4k_keycloak/browser.cljs index c6c7eb7..7fb225d 100644 --- a/src/main/cljs/dda/c4k_keycloak/browser.cljs +++ b/src/main/cljs/dda/c4k_keycloak/browser.cljs @@ -13,6 +13,17 @@ (-> js/document (.getElementById "fqdn"))) +(defn issuer [] + (-> js/document + (.getElementById "issuer"))) + +(defn issuer-from-document [] + (let [issuer-str (-> (issuer) + (.-value))] + (if (= issuer-str "") + :staging + (keyword issuer-str)))) + (defn auth [] (-> js/document (.getElementById "auth"))) @@ -22,9 +33,9 @@ (.getElementById "form"))) (defn config-from-document [] - {:fqdn - (-> (fqdn) - (.-value))}) + {:fqdn (-> (fqdn) + (.-value)) + :issuer (issuer-from-document)}) (defn auth-from-document [] (-> (auth) @@ -45,11 +56,12 @@ (set! validation-result)) (-> (fqdn) (.setCustomValidity validation-result)) + (-> (issuer) + (.setCustomValidity validation-result)) validation-result) (defn validate-config! [] - (let [config-str (config-from-document) - config-map (edn/read-string config-str)] + (let [config-map (config-from-document)] (if (s/valid? core/config? config-map) (set-config-validation-result! "") (set-config-validation-result! @@ -73,7 +85,6 @@ (defn validate-auth! [] (let [auth-str (auth-from-document) auth-map (edn/read-string auth-str)] - (print-debug (s/valid? core/auth? auth-map)) (if (s/valid? core/auth? auth-map) (set-auth-validation-result! "") (set-auth-validation-result! @@ -97,4 +108,9 @@ (.addEventListener "blur" #(do (validate-config!) (validate-auth!) - (set-validated!))))) + (set-validated!)))) + (-> (issuer) + (.addEventListener "blur" + #(do (validate-config!) + (validate-auth!) + (set-validated!))))) \ No newline at end of file