first error message
This commit is contained in:
parent
9a5071ac6a
commit
122a7ddee7
3 changed files with 51 additions and 12 deletions
|
@ -8,17 +8,18 @@
|
||||||
"license": "APACHE2",
|
"license": "APACHE2",
|
||||||
"main": "k8s-mastodon-bot.js",
|
"main": "k8s-mastodon-bot.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"mastodon-bot": "./k8s-mastodon-bot.js"
|
"k8s-mastodon-bot": "./k8s-mastodon-bot.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"cljs",
|
"cljs",
|
||||||
"mastodon-bot",
|
"mastodon-bot",
|
||||||
"k8s",
|
"k8s",
|
||||||
"deplyoment"
|
"deplyoment",
|
||||||
|
"yaml"
|
||||||
],
|
],
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot/issues"
|
"url": "https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"js-yaml": "^4.0.0"
|
"js-yaml": "^4.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container jumbotron">
|
<div class="container jumbotron">
|
||||||
|
<form class="needs-validation" id="form">
|
||||||
<label for="config" class="form-label">Your config.edn:</label>
|
<label for="config" class="form-label">Your config.edn:</label>
|
||||||
<textarea name="config" id="config" class="form-control" rows="15">
|
<textarea name="config" id="config" class="form-control" rows="15">
|
||||||
{:transform [{:source {:source-type :twitter
|
{:transform [{:source {:source-type :twitter
|
||||||
|
@ -40,7 +41,9 @@
|
||||||
:signature "#newsbot"}
|
:signature "#newsbot"}
|
||||||
}]
|
}]
|
||||||
:auth {}}}
|
:auth {}}}
|
||||||
</textarea><br><br>
|
</textarea>
|
||||||
|
<div class="invalid-feedback"><pre id="config-validation"></pre></div>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<label for="auth" class="form-label">Your auth.edn:</label>
|
<label for="auth" class="form-label">Your auth.edn:</label>
|
||||||
<textarea name="auth" id="auth" class="form-control" rows="15">
|
<textarea name="auth" id="auth" class="form-control" rows="15">
|
||||||
|
@ -67,6 +70,7 @@
|
||||||
<textarea name="output" id="output" class="form-control" rows="15">
|
<textarea name="output" id="output" class="form-control" rows="15">
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
(ns dda.k8s-mastodon-bot.browser
|
(ns dda.k8s-mastodon-bot.browser
|
||||||
(:require
|
(:require
|
||||||
|
[clojure.string :as st]
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
[expound.alpha :as expound]
|
[expound.alpha :as expound]
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
(defn config-from-document []
|
(defn print-debug [sth]
|
||||||
|
(print "debug " sth)
|
||||||
|
sth)
|
||||||
|
|
||||||
|
(defn config []
|
||||||
|
(-> js/document
|
||||||
|
(.getElementById "config")))
|
||||||
|
|
||||||
|
(defn set-config-validation! [input]
|
||||||
|
(print-debug input)
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "config")
|
(.getElementById "config-validation")
|
||||||
|
(.-innerHTML)
|
||||||
|
(set! input)))
|
||||||
|
|
||||||
|
(defn form []
|
||||||
|
(-> js/document
|
||||||
|
(.getElementById "form")))
|
||||||
|
|
||||||
|
(defn config-from-document []
|
||||||
|
(-> (config)
|
||||||
(.-value)))
|
(.-value)))
|
||||||
|
|
||||||
(defn auth-from-document []
|
(defn auth-from-document []
|
||||||
|
@ -14,7 +33,7 @@
|
||||||
(.getElementById "auth")
|
(.getElementById "auth")
|
||||||
(.-value)))
|
(.-value)))
|
||||||
|
|
||||||
(defn render-output-to-document
|
(defn set-output!
|
||||||
[input]
|
[input]
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "output")
|
(.getElementById "output")
|
||||||
|
@ -23,19 +42,34 @@
|
||||||
|
|
||||||
(defn expound-config
|
(defn expound-config
|
||||||
[config]
|
[config]
|
||||||
(expound/expound ::core/config config))
|
(st/replace
|
||||||
|
(expound/expound-str ::core/config config {:print-specs? false})
|
||||||
|
#"\n" "<br>"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn render-validation-result-to-config
|
||||||
|
[validation-result]
|
||||||
|
(print-debug validation-result)
|
||||||
|
(set-config-validation! validation-result)
|
||||||
|
(-> (config)
|
||||||
|
(.setCustomValidity validation-result))
|
||||||
|
(-> (form)
|
||||||
|
(.-classList)
|
||||||
|
(.add "was-validated"))
|
||||||
|
validation-result)
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "generate-button")
|
(.getElementById "generate-button")
|
||||||
(.addEventListener "click"
|
(.addEventListener "click"
|
||||||
#(-> (core/generate (config-from-document) (auth-from-document))
|
#(-> (core/generate (config-from-document) (auth-from-document))
|
||||||
(render-output-to-document))))
|
(set-output!))))
|
||||||
(-> js/document
|
(-> (config)
|
||||||
(.getElementById "config")
|
|
||||||
(.addEventListener "blur"
|
(.addEventListener "blur"
|
||||||
#(-> (config-from-document)
|
#(-> (config-from-document)
|
||||||
(edn/read-string)
|
(edn/read-string)
|
||||||
(expound-config)
|
(expound-config)
|
||||||
(print))))
|
(print-debug)
|
||||||
|
(render-validation-result-to-config))))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue