fix result

This commit is contained in:
bom 2021-03-19 15:06:09 +01:00
parent 86d001c2ce
commit 1866134d1e
2 changed files with 39 additions and 14 deletions

View file

@ -61,7 +61,9 @@
:consumer_secret "XXXX"
:token "XXXX"
:token_secret "XXXX"}}}
</textarea><br><br>
</textarea>
<div class="invalid-feedback"><pre id="auth-validation"></pre></div>
<br><br>
<button type="button" id="generate-button" class="btn btn-primary">
Generate k8s yaml
</button><br><br>

View file

@ -13,6 +13,10 @@
(-> js/document
(.getElementById "config")))
(defn auth []
(-> js/document
(.getElementById "auth")))
(defn set-config-validation! [input]
(print-debug input)
(-> js/document
@ -29,8 +33,7 @@
(.-value)))
(defn auth-from-document []
(-> js/document
(.getElementById "auth")
(-> (auth)
(.-value)))
(defn set-output!
@ -40,7 +43,7 @@
(.-value)
(set! input)))
(defn render-validation-result-to-config
(defn set-config-validation-result!
[validation-result]
(print-debug validation-result)
(set-config-validation! validation-result)
@ -51,16 +54,35 @@
(.add "was-validated"))
validation-result)
(defn expound-config [config]
(expound/expound-str ::core/config config {:print-specs? false}))
(defn validate-config! []
(let [config (config-from-document)]
(when-not (s/valid? ::core/config config)
(-> config
(edn/read-string)
(expound-config)
(render-validation-result-to-config)))))
(let [config-str (config-from-document)
config-map (edn/read-string config-str)]
(if (s/valid? ::core/config config-map)
(set-config-validation-result! "")
(set-config-validation-result!
(expound/expound-str ::core/config config-map {:print-specs? false})))))
(defn set-validated! []
(-> (form)
(.-classList)
(.add "was-validated")))
(defn set-auth-validation-result!
[validation-result]
(-> js/document
(.getElementById "auth-validation")
(.-innerHTML)
(set! validation-result))
(-> (auth)
(.setCustomValidity validation-result))
validation-result)
(defn validate-auth! []
(let [auth-str (auth-from-document)
auth-map (edn/read-string auth-str)]
(when-not (s/valid? ::core/auth auth-map)
(set-auth-validation-result!
(expound/expound-str ::core/auth auth-map {:print-specs? false})))))
(defn init []
(-> js/document
@ -70,4 +92,5 @@
(set-output!))))
(-> (config)
(.addEventListener "blur"
#(validate-config!))))
#(do (validate-config!)
(set-validated!)))))