From cd83830338783ce17685cf8304b581f38c45ea70 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 22 Oct 2021 15:23:39 +0200 Subject: [PATCH] mob --- public/index.html | 17 ++++++ shadow-cljs.edn | 3 +- src/main/cljs/dda/c4k_nextcloud/browser.cljs | 57 +++++++++++++------- 3 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 public/index.html diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..acfd964 --- /dev/null +++ b/public/index.html @@ -0,0 +1,17 @@ + + + + + + c4k-nextcloud + + + + + + + + + + \ No newline at end of file diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 330e8e8..5697859 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -4,7 +4,8 @@ "src/test/cljc" "src/test/cljs" "src/test/resources"] - :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "0.3.2-SNAPSHOT"]] + :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "0.4.2"] + [hickory "0.7.1"]] :builds {:frontend {:target :browser :modules {:main {:init-fn dda.c4k-nextcloud.browser/init}} :release {} diff --git a/src/main/cljs/dda/c4k_nextcloud/browser.cljs b/src/main/cljs/dda/c4k_nextcloud/browser.cljs index 94012b6..c450f3f 100644 --- a/src/main/cljs/dda/c4k_nextcloud/browser.cljs +++ b/src/main/cljs/dda/c4k_nextcloud/browser.cljs @@ -6,6 +6,34 @@ [dda.c4k-common.browser :as br] [dda.c4k-common.postgres :as pgc])) +(defn generate-content + [] + (into [] (concat [(assoc (br/generate-needs-validation) :content + (into [] (concat (br/generate-input-field "fqdn" "Your fqdn:" "nextcloud-neu.prod.meissa-gmbh.de") + (br/generate-input-field "nextcloud-data-volume-path" "(Optional) Your nextcloud-data-volume-path:" "/var/nextcloud") + (br/generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres") + (br/generate-input-field "restic-repository" "(Optional) Your restic-repository:" "restic-repository") + (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "") + [(br/generate-br)] + (br/generate-text-area "auth" "Your auth.edn:" "{:postgres-db-user \"nextcloud\" + :postgres-db-password \"nextcloud-db-password\" + :nextcloud-admin-password \"nextcloud-admin-password\" + :nextcloud-admin-user \"nextcloud-admin-user\" + :aws-access-key-id \"aws-id\" + :aws-secret-access-key \"aws-secret\" + :restic-password \"restic-password\"}" + "5") + [(br/generate-br)] + (br/generate-button "generate-button" "Generate c4k yaml"))))] + (br/generate-output "c4k-nextcloud-output" "Your c4k deployment.yaml:" "25")))) + +(defn generate-content-div + [] + {:type :element + :tag :div + :content + (generate-content)}) + (defn config-from-document [] (let [nextcloud-data-volume-path (br/get-content-from-element "nextcloud-data-volume-path" :optional true) postgres-data-volume-path (br/get-content-from-element "postgres-data-volume-path" :optional true) @@ -32,7 +60,12 @@ (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" @@ -41,22 +74,10 @@ (config-from-document) (br/get-content-from-element "auth" :deserializer edn/read-string)) (br/set-output!))))) - (-> (br/get-element-by-id "fqdn") - (.addEventListener "blur" - #(do (validate-all!)))) - (-> (br/get-element-by-id "nextcloud-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") - (.addEventListener "blur" - #(do (validate-all!)))) - (-> (br/get-element-by-id "auth") - (.addEventListener "blur" - #(do (validate-all!)))) + (add-validate-listener "fqdn") + (add-validate-listener "nextcloud-data-volume-path") + (add-validate-listener "postgres-data-volume-path") + (add-validate-listener "restic-repository") + (add-validate-listener "issuer") + (add-validate-listener "auth") ) \ No newline at end of file