Change return value of /api/settings

Current version returns like the following:

```
{
  "ROOT" => {
    "sources" => [],
    "filters" => [],
    "matches" => [],
  },
  "@INPUT" => {
    "sources" => [],
    "filters" => [],
    "matches" => [],
  }
}
```

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
Kenji Okimoto 2018-08-23 17:10:43 +09:00
parent 91c28f2ce8
commit 741c23f335
No known key found for this signature in database
GPG Key ID: F9E3E329A5C5E4A1
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,6 @@
json.id element_id(element)
json.id element_id(current_label, element)
json.current_label current_label || "ROOT"
json.label element["@label"] || element["label"]
json.name element.name
json.type element["@type"] || element["type"]
json.arg element.arg

View File

@ -1,3 +1,11 @@
json.array! @config.elements do |elm|
json.partial! "api/settings/element", element: elm
@config.group_by_label.each do |label_name, types|
json.set!(label_name) do
types.each do |type, elements|
json.set!(type) do
json.array!(elements) do |element|
json.partial! "api/settings/element", current_label: label_name, element: element
end
end
end
end
end