Changed from textarea to text field, added issuer

This commit is contained in:
bom 2021-06-14 12:08:20 +02:00
parent 30ddfd295c
commit 8def2ec408
2 changed files with 27 additions and 10 deletions

View file

@ -13,9 +13,10 @@
<div class="container jumbotron"> <div class="container jumbotron">
<form class="needs-validation" id="form"> <form class="needs-validation" id="form">
<label for="config" class="form-label">Your fqdn:</label> <label for="config" class="form-label">Your fqdn:</label>
<textarea name="fqdn" id="fqdn" class="form-control" rows="1"> <input class="form-control" type="text" name="fqdn" id="fqdn" value="your.domain.com">
your.domain.com <br>
</textarea> <label for="config" class="form-label">(Optional) Your issuer prod/staging:</label>
<input class="form-control" type="text" name="issuer" id="issuer" value="">
<div class="invalid-feedback"><pre id="config-validation"></pre></div> <div class="invalid-feedback"><pre id="config-validation"></pre></div>
<br><br> <br><br>

View file

@ -13,6 +13,17 @@
(-> js/document (-> js/document
(.getElementById "fqdn"))) (.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 [] (defn auth []
(-> js/document (-> js/document
(.getElementById "auth"))) (.getElementById "auth")))
@ -22,9 +33,9 @@
(.getElementById "form"))) (.getElementById "form")))
(defn config-from-document [] (defn config-from-document []
{:fqdn {:fqdn (-> (fqdn)
(-> (fqdn) (.-value))
(.-value))}) :issuer (issuer-from-document)})
(defn auth-from-document [] (defn auth-from-document []
(-> (auth) (-> (auth)
@ -45,11 +56,12 @@
(set! validation-result)) (set! validation-result))
(-> (fqdn) (-> (fqdn)
(.setCustomValidity validation-result)) (.setCustomValidity validation-result))
(-> (issuer)
(.setCustomValidity validation-result))
validation-result) validation-result)
(defn validate-config! [] (defn validate-config! []
(let [config-str (config-from-document) (let [config-map (config-from-document)]
config-map (edn/read-string config-str)]
(if (s/valid? core/config? config-map) (if (s/valid? core/config? config-map)
(set-config-validation-result! "") (set-config-validation-result! "")
(set-config-validation-result! (set-config-validation-result!
@ -73,7 +85,6 @@
(defn validate-auth! [] (defn validate-auth! []
(let [auth-str (auth-from-document) (let [auth-str (auth-from-document)
auth-map (edn/read-string auth-str)] auth-map (edn/read-string auth-str)]
(print-debug (s/valid? core/auth? auth-map))
(if (s/valid? core/auth? auth-map) (if (s/valid? core/auth? auth-map)
(set-auth-validation-result! "") (set-auth-validation-result! "")
(set-auth-validation-result! (set-auth-validation-result!
@ -94,6 +105,11 @@
(validate-auth!) (validate-auth!)
(set-validated!)))) (set-validated!))))
(-> (auth) (-> (auth)
(.addEventListener "blur"
#(do (validate-config!)
(validate-auth!)
(set-validated!))))
(-> (issuer)
(.addEventListener "blur" (.addEventListener "blur"
#(do (validate-config!) #(do (validate-config!)
(validate-auth!) (validate-auth!)