"""Bundled dashboard: system vitals."""
import json


def register(ctx):
    from dashboard_bundled.feeds import feed_system_vitals

    ctx.register_dashboard_tile(
        {
            "id": "system",
            "title": "System",
            "path": "/tile",
            "refresh_seconds": 5,
            "priority": 0,
            "layout": "hero",
        }
    )

    def route_handler(req):
        body = json.dumps(feed_system_vitals(), ensure_ascii=False)
        return {
            "status": 200,
            "headers": {"Content-Type": "application/json; charset=utf-8"},
            "body": body,
        }

    ctx.register_route_handler(route_handler)
