prometheus/promdash — pull request #229 by juliusv (2014-11-07 01:53:16+00:00)
Title: Support for uploading dashboard definitions.

This enables JSON-schema-validated PUT-ing and GET-ing of full dashboard
definitions through /.json. In the external part of this API, the
'dashboards_json' database field is converted from a JSON-encoded string
to a native JSON subobject of the Rails Dashboard model JSON
representation. The full externally exposed JSON for a dashboard looks
like this:

{
"name": "Test Dashboard",
"created_at": "2014-11-07T00:25:57.000Z",
"updated_at": "2014-11-07T00:38:23.000Z",
"dashboard_json": {
"globalConfig": {
// ...global configuration...
},
"widgets": [
// ...widget definitions...
]
}
}

Upon PUT, the 'dashboards_json' field is validated against the
JSON-schema definition in the file 'dashboard_schema.json' and then
saved again as a serialized string in a single database field.

Since Rails converts empty JSON arrays to "nil" values by default, this
also upgrades PromDash to Rails 4.1.1, which supports an option to turn
off this automatic conversion. See the following issues about this
regarding security implications (which for now we shouldn't need to
worry about in PromDash):

https://github.com/rails/rails/issues/8832
https://github.com/rails/rails/issues/13420

Further, as we're exposing the dashboard_json as an external API for the
first time, this also includes a lot of naming cleanups in the JSON
fields and the related code.