This commit is contained in:
Jan Krebs 2021-08-05 12:17:57 +02:00
parent 2155075ba0
commit 58a35dbdaf
2 changed files with 25 additions and 5 deletions

View file

@ -18,17 +18,17 @@
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="fqdn-validation"></pre> <pre id="fqdn-validation"></pre>
</div> </div>
<label for="jira-data-volume-path" class="form-label">Your jira-data-volume-path:</label> <label for="jira-data-volume-path" class="form-label">(Optional) Your jira-data-volume-path:</label>
<input class="form-control" type="text" name="jira-data-volume-path" id="jira-data-volume-path" value="/var/jira"> <input class="form-control" type="text" name="jira-data-volume-path" id="jira-data-volume-path" value="/var/jira">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="jira-data-volume-path-validation"></pre> <pre id="jira-data-volume-path-validation"></pre>
</div> </div>
<label for="postgres-data-volume-path" class="form-label">Your postgres-data-volume-path:</label> <label for="postgres-data-volume-path" class="form-label">(Optional) Your postgres-data-volume-path:</label>
<input class="form-control" type="text" name="postgres-data-volume-path" id="postgres-data-volume-path" value="/var/postgres"> <input class="form-control" type="text" name="postgres-data-volume-path" id="postgres-data-volume-path" value="/var/postgres">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="postgres-data-volume-path"></pre> <pre id="postgres-data-volume-path"></pre>
</div> </div>
<label for="restic-repository" class="form-label">Your restic-repository:</label> <label for="restic-repository" class="form-label">(Optional) Your restic-repository:</label>
<input class="form-control" type="text" name="restic-repository" id="restic-repository" value="restic-repository"> <input class="form-control" type="text" name="restic-repository" id="restic-repository" value="restic-repository">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="restic-repository"></pre> <pre id="restic-repository"></pre>

View file

@ -6,14 +6,25 @@
[dda.c4k-common.browser :as br])) [dda.c4k-common.browser :as br]))
(defn config-from-document [] (defn config-from-document []
(let [issuer (br/get-content-from-element "issuer" :optional true :deserializer keyword)] (let [jira-data-volume-path (br/get-content-from-element "jira-data-volume-path" :optional true :deserializer keyword)
postgres-data-volume-path (br/get-content-from-element "postgres-data-volume-path" :optional true :deserializer keyword)
restic-repository (br/get-content-from-element "restic-repository" :optional true :deserializer keyword)
issuer (br/get-content-from-element "issuer" :optional true :deserializer keyword)]
(merge (merge
{:fqdn (br/get-content-from-element "fqdn")} {:fqdn (br/get-content-from-element "fqdn")}
(when (some? postgres-data-volume-path)
{:postgres-data-volume-path postgres-data-volume-path})
(when (some? restic-repository)
{:restic-repository restic-repository})
(when (some? issuer) (when (some? issuer)
{:issuer issuer})))) {:issuer issuer})
)))
(defn validate-all! [] (defn validate-all! []
(br/validate! "fqdn" ::jira/fqdn) (br/validate! "fqdn" ::jira/fqdn)
(br/validate! "jira-data-volume-path" ::jira/jira-data-volume-path :optional true :deserializer keyword)
(br/validate! "postgres-data-volume-path" ::jira/jira-data-volume-path :optional true :deserializer keyword)
(br/validate! "restic-repository" ::jira/restic-repository :optional true :deserializer keyword)
(br/validate! "issuer" ::jira/issuer :optional true :deserializer keyword) (br/validate! "issuer" ::jira/issuer :optional true :deserializer keyword)
(br/validate! "auth" core/auth? :deserializer edn/read-string) (br/validate! "auth" core/auth? :deserializer edn/read-string)
(br/set-validated!)) (br/set-validated!))
@ -30,6 +41,15 @@
(-> (br/get-element-by-id "fqdn") (-> (br/get-element-by-id "fqdn")
(.addEventListener "blur" (.addEventListener "blur"
#(do (validate-all!)))) #(do (validate-all!))))
(-> (br/get-element-by-id "jira-data-volume-path")
(.addEventListener "blur"
#(do (validate-all!))))
(-> (br/get-element-by-id "postgres-data-volume-path")
(.addEventListener "blur"
#(do (validate-all!))))
(-> (br/get-element-by-id "restic-repository")
(.addEventListener "blur"
#(do (validate-all!))))
(-> (br/get-element-by-id "issuer") (-> (br/get-element-by-id "issuer")
(.addEventListener "blur" (.addEventListener "blur"
#(do (validate-all!)))) #(do (validate-all!))))