Beispiel #1
0
    def parse_widget(self, config):
        type_cls = utils.load_class_by_string(config['type'])

        if issubclass(type_cls, DynamicWidget):
            config['backend'] = utils.add_dicts(
                self.backend_dict,
                config.get('backend', {}))

        config_cls = Config.for_type(config['type'])
        return config_cls(config)
Beispiel #2
0
    def add_widget(self, config, add_to_layout=True):
        """Adds a widget to the dashboard. """
        type_cls = utils.load_class_by_string(config['type'])
        widget = type_cls(config)

        self.widgets_by_name[config['name']] = widget
        self.widgets.append(widget)

        if add_to_layout:
            last_row = self.config['rows'][-1]
            last_row['widgets'].append({'name': config['name']})
Beispiel #3
0
    def __init__(self, config):
        super(DynamicWidget, self).__init__(config)

        backend_cls = utils.load_class_by_string(config['backend']['type'])
        self.backend = backend_cls(config['backend'])
Beispiel #4
0
 def for_type(cls, type_name):
     type_cls = utils.load_class_by_string(type_name)
     return type_cls.CONFIG_CLS