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]
(map
(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/tr
(d/td k)
(d/td v)
(d/td
(b/button {:bs-size "xsmall"
:className "pull-right"
:on-click #(groupings/delete-config uuid path)}
(r/glyphicon {:glyph "remove"})))))))
confs))
(defn render-config [element owner opts]
(reify
om/IDisplayName
......@@ -57,7 +75,7 @@
(b/button
{: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")))
(row
......@@ -71,17 +89,7 @@
(d/th "Value")
(d/th "")))
(d/tbody
(map
(fn [[c v]]
(d/tr
(d/td (name c))
(d/td v)
(d/td
(b/button {:bs-size "xsmall"
:className "pull-right"
:on-click #(groupings/delete-config uuid (name c))}
(r/glyphicon {:glyph "remove"})))))
confs))))))))))
(print-conf-rows uuid "" confs))))))))))
(defn render-home [element owner opts]
(reify
......
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