fix result
This commit is contained in:
parent
86d001c2ce
commit
1866134d1e
2 changed files with 39 additions and 14 deletions
|
@ -61,7 +61,9 @@
|
||||||
:consumer_secret "XXXX"
|
:consumer_secret "XXXX"
|
||||||
:token "XXXX"
|
:token "XXXX"
|
||||||
:token_secret "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">
|
<button type="button" id="generate-button" class="btn btn-primary">
|
||||||
Generate k8s yaml
|
Generate k8s yaml
|
||||||
</button><br><br>
|
</button><br><br>
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "config")))
|
(.getElementById "config")))
|
||||||
|
|
||||||
|
(defn auth []
|
||||||
|
(-> js/document
|
||||||
|
(.getElementById "auth")))
|
||||||
|
|
||||||
(defn set-config-validation! [input]
|
(defn set-config-validation! [input]
|
||||||
(print-debug input)
|
(print-debug input)
|
||||||
(-> js/document
|
(-> js/document
|
||||||
|
@ -29,8 +33,7 @@
|
||||||
(.-value)))
|
(.-value)))
|
||||||
|
|
||||||
(defn auth-from-document []
|
(defn auth-from-document []
|
||||||
(-> js/document
|
(-> (auth)
|
||||||
(.getElementById "auth")
|
|
||||||
(.-value)))
|
(.-value)))
|
||||||
|
|
||||||
(defn set-output!
|
(defn set-output!
|
||||||
|
@ -40,7 +43,7 @@
|
||||||
(.-value)
|
(.-value)
|
||||||
(set! input)))
|
(set! input)))
|
||||||
|
|
||||||
(defn render-validation-result-to-config
|
(defn set-config-validation-result!
|
||||||
[validation-result]
|
[validation-result]
|
||||||
(print-debug validation-result)
|
(print-debug validation-result)
|
||||||
(set-config-validation! validation-result)
|
(set-config-validation! validation-result)
|
||||||
|
@ -51,16 +54,35 @@
|
||||||
(.add "was-validated"))
|
(.add "was-validated"))
|
||||||
validation-result)
|
validation-result)
|
||||||
|
|
||||||
(defn expound-config [config]
|
|
||||||
(expound/expound-str ::core/config config {:print-specs? false}))
|
|
||||||
|
|
||||||
(defn validate-config! []
|
(defn validate-config! []
|
||||||
(let [config (config-from-document)]
|
(let [config-str (config-from-document)
|
||||||
(when-not (s/valid? ::core/config config)
|
config-map (edn/read-string config-str)]
|
||||||
(-> config
|
(if (s/valid? ::core/config config-map)
|
||||||
(edn/read-string)
|
(set-config-validation-result! "")
|
||||||
(expound-config)
|
(set-config-validation-result!
|
||||||
(render-validation-result-to-config)))))
|
(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 []
|
(defn init []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
|
@ -70,4 +92,5 @@
|
||||||
(set-output!))))
|
(set-output!))))
|
||||||
(-> (config)
|
(-> (config)
|
||||||
(.addEventListener "blur"
|
(.addEventListener "blur"
|
||||||
#(validate-config!))))
|
#(do (validate-config!)
|
||||||
|
(set-validated!)))))
|
||||||
|
|
Loading…
Reference in a new issue