예제 #1
0
    def insert_dashboard(self, dashboard_name, dashboard_options={}):
        """Insert a dashboard having the passed ``dashboard_name`` and ``dashboard_options`` (a JSON-serializable value).
        """
        from mqe import layouts

        row = c.dao.DashboardDAO.insert(self.owner_id, dashboard_name,
                                        serialize.mjson(dashboard_options))
        if not row:
            return None
        dashboard = Dashboard(row)

        change_dashboards_ordering(
            self.owner_id,
            self.dashboard_id_ordering + [dashboard.dashboard_id])

        empty_layout = layouts.Layout()
        empty_layout.set(self.owner_id, row['dashboard_id'], None)

        log.info('Inserted new dashboard dashboard_id=%s name=%r',
                 dashboard.dashboard_id, dashboard.dashboard_name)

        self.reload()

        fire_signal(new_dashboard, dashboard=dashboard)

        return Dashboard(row)
예제 #2
0
 def pack(self, ldict):
     return layouts.apply_mods_for_noninserted_layout(
         [layouts.pack_leftwards_mod()],
         layouts.Layout(deepcopy(ldict))).new_layout.layout_dict