예제 #1
0
def _create_unicode_dashboard(slice_title: str, position: str) -> Dashboard:
    table = create_table_metadata(UNICODE_TBL_NAME, get_example_database())
    table.fetch_metadata()

    if slice_title:
        slice = _create_and_commit_unicode_slice(table, slice_title)

    return create_dashboard("unicode-test", "Unicode Test", position, [slice])
예제 #2
0
def tabbed_dashboard():
    position_json = {
        "DASHBOARD_VERSION_KEY": "v2",
        "GRID_ID": {
            "children": ["TABS-IpViLohnyP"],
            "id": "GRID_ID",
            "parents": ["ROOT_ID"],
            "type": "GRID",
        },
        "HEADER_ID": {
            "id": "HEADER_ID",
            "meta": {
                "text": "tabbed dashboard"
            },
            "type": "HEADER",
        },
        "ROOT_ID": {
            "children": ["GRID_ID"],
            "id": "ROOT_ID",
            "type": "ROOT"
        },
        "TAB-j53G4gtKGF": {
            "children": [],
            "id": "TAB-j53G4gtKGF",
            "meta": {
                "defaultText": "Tab title",
                "placeholder": "Tab title",
                "text": "Tab 1",
            },
            "parents": ["ROOT_ID", "GRID_ID", "TABS-IpViLohnyP"],
            "type": "TAB",
        },
        "TAB-nerWR09Ju": {
            "children": [],
            "id": "TAB-nerWR09Ju",
            "meta": {
                "defaultText": "Tab title",
                "placeholder": "Tab title",
                "text": "Tab 2",
            },
            "parents": ["ROOT_ID", "GRID_ID", "TABS-IpViLohnyP"],
            "type": "TAB",
        },
        "TABS-IpViLohnyP": {
            "children": ["TAB-j53G4gtKGF", "TAB-nerWR09Ju"],
            "id": "TABS-IpViLohnyP",
            "meta": {},
            "parents": ["ROOT_ID", "GRID_ID"],
            "type": "TABS",
        },
    }
    with app.app_context():
        dash = create_dashboard("tabbed-dash-test", "Tabbed Dash Test",
                                json.dumps(position_json), [])
    yield dash
def _create_unicode_dashboard(
    df: DataFrame, table_name: str, slice_title: str, position: str
) -> Dashboard:
    database = get_example_database()
    dtype = {
        "phrase": String(500),
    }
    table = create_table_for_dashboard(df, table_name, database, dtype)
    table.fetch_metadata()

    if slice_title:
        slice = _create_and_commit_unicode_slice(table, slice_title)

    return create_dashboard("unicode-test", "Unicode Test", position, [slice])
def _create_world_bank_dashboard(table: SqlaTable) -> Dashboard:
    from superset.examples.helpers import update_slice_ids
    from superset.examples.world_bank import dashboard_positions

    pos = dashboard_positions
    slices = update_slice_ids(pos)

    table.fetch_metadata()

    dash = create_dashboard("world_health", "World Bank's Data",
                            json.dumps(pos), slices)
    dash.json_metadata = '{"mock_key": "mock_value"}'
    db.session.commit()
    return dash