Commit d6bf15bb authored by Heinz N. Gies's avatar Heinz N. Gies

Allow for nested config variables

parent 491f7f5d
......@@ -24,12 +24,18 @@
(api/delete data root [uuid] (alerts "Grouping removed." "Failed to remove grouping.")))
(defn set-config [uuid conf val]
(api/put root [uuid :config] {conf val}
(a-get uuid "Configuration updated." "Failed to update configuration.")))
(let [[path key] (if (string? conf)
[[uuid :config] conf]
[(concat [uuid :config] (butlast conf)) (last conf)])]
(api/put root path {key val}
(a-get uuid "Configuration updated." "Failed to update configuration."))))
(defn delete-config [uuid conf]
(api/delete root [uuid :config conf]
(a-get uuid "Configuration deleted." "Failed to delete configuration.")))
(let [path (if (string? conf)
[uuid :config conf]
(concat [uuid :config] conf))]
(api/delete root path
(a-get uuid "Configuration deleted." "Failed to delete configuration."))))
(defn add-element [uuid grouping]
(api/put root [uuid :elements grouping] {}
......@@ -22,6 +22,24 @@
[cerberus.metrics :as metrics]
[cerberus.fields :refer [fmt-bytes fmt-percent]]))
(defn print-conf-rows [uuid pfx confs]
(fn [[c v]]
(if (map? v)
(print-conf-rows uuid (str pfx (name c) ".") v)
(let [k (str pfx (name c))
path (cstr/split k #"\.")]
(pr path)
(d/td k)
(d/td v)
(b/button {:bs-size "xsmall"
:className "pull-right"
:on-click #(groupings/delete-config uuid path)}
(r/glyphicon {:glyph "remove"})))))))
(defn render-config [element owner opts]
......@@ -57,7 +75,7 @@
{:bs-style "primary"
:className "pull-right"
:on-click #(groupings/set-config uuid (cstr/trim (:conf state)) (cstr/trim (:val state)))
:on-click #(groupings/set-config uuid (cstr/split (cstr/trim (:conf state)) #"\.") (cstr/trim (:val state)))
:disabled? invalid?}
"Set Configuration")))
......@@ -71,17 +89,7 @@
(d/th "Value")
(d/th "")))
(fn [[c v]]
(d/td (name c))
(d/td v)
(b/button {:bs-size "xsmall"
:className "pull-right"
:on-click #(groupings/delete-config uuid (name c))}
(r/glyphicon {:glyph "remove"})))))
(print-conf-rows uuid "" confs))))))))))
(defn render-home [element owner opts]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment