'Build the dashboard and all its contents
@param attr: keyword arguments from the controller
@return: the output dict for the view'

def build(self, **attr):

    config = self.config
    context = self.context
    dashboard_id = attr.get('_id', 'dashboard')
    hide = ('    hide' if (not config.configurable) else '')
    switch = SPAN(ICON('settings', _class=('db-config-on%s' % hide)), ICON('done', _class='db-config-off    hide'), _class='db-config', data={'mode': 'off'})
    output = {'title': config.title, 'contents': '', 'dashboard_id': dashboard_id, 'switch': switch}
    ajax_url = URL(args=[], vars={})
    script_options = {'ajaxURL': ajax_url, 'version': config.version}
    self.inject_script(dashboard_id, options=script_options)
    layout = self.get_active_layout(config)
    for agent in self.agents.values():
        agent.add_widget(layout, context)
    current.response.view = 'dashboard.html'
    contents = layout.build(context)
    if isinstance(contents, dict):
        output.update(contents)
    else:
        output['contents'] = contents
    return output
