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]
|
||||
:opt-un [::kc/issuer]))
|
||||
|
||||
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password
|
||||
::postgres/postgres-db-user ::postgres/postgres-db-password]))
|
||||
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password]))
|
||||
|
||||
(defn-spec k8s-objects any?
|
||||
[config (s/merge config? auth?)]
|
||||
|
|
|
@ -1,12 +1,39 @@
|
|||
(ns dda.c4k-keycloak.browser
|
||||
(:require
|
||||
[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.keycloak :as kc]
|
||||
[dda.c4k-common.browser :as br]))
|
||||
[dda.c4k-keycloak.keycloak :as kc]))
|
||||
|
||||
(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 []
|
||||
(let [issuer (br/get-content-from-element "issuer" :optional true :deserializer keyword)]
|
||||
(let [issuer (br/get-content-from-element "issuer" :optional true)]
|
||||
(merge
|
||||
{:fqdn (br/get-content-from-element "fqdn")}
|
||||
(when (some? issuer)
|
||||
|
@ -14,26 +41,26 @@
|
|||
|
||||
(defn validate-all! []
|
||||
(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/set-validated!))
|
||||
|
||||
(defn add-validate-listener [name]
|
||||
(-> (br/get-element-by-id name)
|
||||
(.addEventListener "blur" #(do (validate-all!)))))
|
||||
|
||||
(defn init []
|
||||
(br/append-hickory (generate-content-div))
|
||||
(-> js/document
|
||||
(.getElementById "generate-button")
|
||||
(.addEventListener "click"
|
||||
#(do (validate-all!)
|
||||
(-> (core/generate
|
||||
(-> (cm/generate-common
|
||||
(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/get-element-by-id "fqdn")
|
||||
(.addEventListener "blur"
|
||||
#(do (validate-all!))))
|
||||
(-> (br/get-element-by-id "issuer")
|
||||
(.addEventListener "blur"
|
||||
#(do (validate-all!))))
|
||||
(-> (br/get-element-by-id "auth")
|
||||
(.addEventListener "blur"
|
||||
#(do (validate-all!))))
|
||||
)
|
||||
(add-validate-listener "fqdn")
|
||||
(add-validate-listener "issuer")
|
||||
(add-validate-listener "auth"))
|
Loading…
Reference in a new issue