Update frontend script
This commit is contained in:
parent
349eb9dfc5
commit
1f459b1cde
2 changed files with 44 additions and 18 deletions
|
@ -15,8 +15,7 @@
|
||||||
(def config? (s/keys :req-un [::kc/fqdn]
|
(def config? (s/keys :req-un [::kc/fqdn]
|
||||||
:opt-un [::kc/issuer]))
|
:opt-un [::kc/issuer]))
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password
|
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password]))
|
||||||
::postgres/postgres-db-user ::postgres/postgres-db-password]))
|
|
||||||
|
|
||||||
(defn-spec k8s-objects any?
|
(defn-spec k8s-objects any?
|
||||||
[config (s/merge config? auth?)]
|
[config (s/merge config? auth?)]
|
||||||
|
|
|
@ -1,12 +1,39 @@
|
||||||
(ns dda.c4k-keycloak.browser
|
(ns dda.c4k-keycloak.browser
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
|
[dda.c4k-common.common :as cm]
|
||||||
|
[dda.c4k-common.browser :as br]
|
||||||
[dda.c4k-keycloak.core :as core]
|
[dda.c4k-keycloak.core :as core]
|
||||||
[dda.c4k-keycloak.keycloak :as kc]
|
[dda.c4k-keycloak.keycloak :as kc]))
|
||||||
[dda.c4k-common.browser :as br]))
|
|
||||||
|
(defn generate-content []
|
||||||
|
(cm/concat-vec
|
||||||
|
[(assoc
|
||||||
|
(br/generate-needs-validation) :content
|
||||||
|
(cm/concat-vec
|
||||||
|
(br/generate-group
|
||||||
|
"domain"
|
||||||
|
(cm/concat-vec
|
||||||
|
(br/generate-input-field "fqdn" "Your fqdn:" "keycloak.prod.meissa.de")
|
||||||
|
(br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "")))
|
||||||
|
(br/generate-group
|
||||||
|
"credentials"
|
||||||
|
(br/generate-text-area "auth" "Your auth.edn:" ":keycloak-admin-user \"keycloak\"
|
||||||
|
:keycloak-admin-password \"adminpassword\""
|
||||||
|
"5"))
|
||||||
|
[(br/generate-br)]
|
||||||
|
(br/generate-button "generate-button" "Generate c4k yaml")))]
|
||||||
|
(br/generate-output "c4k-keycloak-output" "Your c4k deployment.yaml:" "25")))
|
||||||
|
|
||||||
|
(defn generate-content-div
|
||||||
|
[]
|
||||||
|
{:type :element
|
||||||
|
:tag :div
|
||||||
|
:content
|
||||||
|
(generate-content)})
|
||||||
|
|
||||||
(defn config-from-document []
|
(defn config-from-document []
|
||||||
(let [issuer (br/get-content-from-element "issuer" :optional true :deserializer keyword)]
|
(let [issuer (br/get-content-from-element "issuer" :optional true)]
|
||||||
(merge
|
(merge
|
||||||
{:fqdn (br/get-content-from-element "fqdn")}
|
{:fqdn (br/get-content-from-element "fqdn")}
|
||||||
(when (some? issuer)
|
(when (some? issuer)
|
||||||
|
@ -14,26 +41,26 @@
|
||||||
|
|
||||||
(defn validate-all! []
|
(defn validate-all! []
|
||||||
(br/validate! "fqdn" ::kc/fqdn)
|
(br/validate! "fqdn" ::kc/fqdn)
|
||||||
(br/validate! "issuer" ::kc/issuer :optional true :deserializer keyword)
|
(br/validate! "issuer" ::kc/issuer :optional true)
|
||||||
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
||||||
(br/set-validated!))
|
(br/set-validated!))
|
||||||
|
|
||||||
|
(defn add-validate-listener [name]
|
||||||
|
(-> (br/get-element-by-id name)
|
||||||
|
(.addEventListener "blur" #(do (validate-all!)))))
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
|
(br/append-hickory (generate-content-div))
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "generate-button")
|
(.getElementById "generate-button")
|
||||||
(.addEventListener "click"
|
(.addEventListener "click"
|
||||||
#(do (validate-all!)
|
#(do (validate-all!)
|
||||||
(-> (core/generate
|
(-> (cm/generate-common
|
||||||
(config-from-document)
|
(config-from-document)
|
||||||
(br/get-content-from-element "auth" :deserializer edn/read-string))
|
(br/get-content-from-element "auth" :deserializer edn/read-string)
|
||||||
|
{}
|
||||||
|
core/k8s-objects)
|
||||||
(br/set-output!)))))
|
(br/set-output!)))))
|
||||||
(-> (br/get-element-by-id "fqdn")
|
(add-validate-listener "fqdn")
|
||||||
(.addEventListener "blur"
|
(add-validate-listener "issuer")
|
||||||
#(do (validate-all!))))
|
(add-validate-listener "auth"))
|
||||||
(-> (br/get-element-by-id "issuer")
|
|
||||||
(.addEventListener "blur"
|
|
||||||
#(do (validate-all!))))
|
|
||||||
(-> (br/get-element-by-id "auth")
|
|
||||||
(.addEventListener "blur"
|
|
||||||
#(do (validate-all!))))
|
|
||||||
)
|
|
Loading…
Reference in a new issue