dashboard_builder
dashboard_builder ¶
Dashboard builder for creating Domo pages with card layouts.
Follows the same builder pattern as kpi_builder.py and alert_builder.py.
Workflow
- Build a DashboardDefinition with card placements and optional headers
- Call build_dashboard() to get the page creation + layout body
- Use create_page() route to create the page
- Use bulk_add_cards_to_pages() to add cards
- Use create_page_layout() to create the layout
- Use update_page_layout() to set the final card positions
Or use the convenience function create_dashboard() which does all steps.
Example
from crew_dcs.classes.dashboard_builder import ( DashboardDefinition, CardPlacement, SectionHeader, create_dashboard ) from crew_dcs.auth import DomoTokenAuth
dashboard = DashboardDefinition( title="P&L Dashboard", cards=[ CardPlacement(card_id=533357453, x=0, y=0, width=60, height=30), CardPlacement(card_id=1604966475, x=0, y=30, width=30, height=30), CardPlacement(card_id=123456789, x=30, y=30, width=30, height=30), ], headers=[ SectionHeader(text="Revenue Overview", x=0, y=0, width=60, height=5), ], )
auth = DomoTokenAuth(domo_access_token="...", domo_instance="datacrew-space") result = await create_dashboard(auth=auth, dashboard=dashboard)
result.page_id, result.layout_id¶
CardPlacement
dataclass
¶
CardPlacement(
card_id: int,
x: int,
y: int,
width: int,
height: int,
hide_title: bool = False,
hide_border: bool = False,
hide_description: bool = True,
hide_footer: bool = True,
hide_timeframe: bool = False,
accept_filters: bool = True,
accept_date_filter: bool = True,
accept_segments: bool = True,
fit_to_frame: bool = False,
compact_x: int | None = None,
compact_y: int | None = None,
compact_width: int = 12,
compact_height: int = 6,
)
Placement of a card on the dashboard grid.
The Domo standard grid is 60 units wide. Height units are arbitrary (the grid auto-sizes based on aspect ratio). Common patterns: - Full width: x=0, width=60 - Half width: x=0 or x=30, width=30 - Third width: x=0/20/40, width=20 - Quarter width: x=0/15/30/45, width=15
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
card_id
|
int
|
The Domo card ID |
required |
x
|
int
|
Horizontal position (0-59) |
required |
y
|
int
|
Vertical position (0+) |
required |
width
|
int
|
Card width (1-60) |
required |
height
|
int
|
Card height (typical: 30 for standard, 7 for compact) |
required |
hide_title
|
bool
|
Hide the card title |
False
|
hide_border
|
bool
|
Hide the card border |
False
|
hide_description
|
bool
|
Hide the card description |
True
|
hide_footer
|
bool
|
Hide the card footer |
True
|
hide_timeframe
|
bool
|
Hide the timeframe selector |
False
|
accept_filters
|
bool
|
Accept dashboard filter interactions |
True
|
accept_date_filter
|
bool
|
Accept date filter interactions |
True
|
accept_segments
|
bool
|
Accept segment interactions |
True
|
fit_to_frame
|
bool
|
Fit card to frame (removes margins) |
False
|
compact_x
|
int | None
|
Override compact layout x position |
None
|
compact_y
|
int | None
|
Override compact layout y position |
None
|
compact_width
|
int
|
Override compact layout width (default: 12) |
12
|
compact_height
|
int
|
Override compact layout height (default: 6) |
6
|
DashboardCreationResult
dataclass
¶
DashboardCreationResult(
page_id: int,
layout_id: str,
page_response: dict,
layout_response: dict,
layout_update_response: dict | None,
)
Result of create_dashboard() — holds all the IDs from the workflow.
DashboardDefinition
dataclass
¶
DashboardDefinition(
title: str,
cards: list[CardPlacement] = list(),
headers: list[SectionHeader] = list(),
parent_page_id: int = 0,
background_color: str = "#FFFFFF",
text_color: str = "#4A4A4A",
locked: bool = False,
standard_width: int = 60,
standard_aspect_ratio: float = 1.67,
compact_width: int = 12,
compact_aspect_ratio: float = 1.0,
)
Complete dashboard definition: page + layout + card placements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Dashboard (page) title |
required |
cards
|
list[CardPlacement]
|
List of CardPlacement objects |
list()
|
headers
|
list[SectionHeader]
|
List of SectionHeader objects (optional) |
list()
|
parent_page_id
|
int
|
Parent page ID (0 for top-level) |
0
|
background_color
|
str
|
Background color hex (default: #FFFFFF) |
'#FFFFFF'
|
text_color
|
str
|
Text color hex (default: #4A4A4A) |
'#4A4A4A'
|
locked
|
bool
|
Lock the dashboard |
False
|
standard_width
|
int
|
Grid width (default: 60, don't change unless you know why) |
60
|
standard_aspect_ratio
|
float
|
Card aspect ratio (default: 1.67) |
1.67
|
compact_width
|
int
|
Compact grid width (default: 12) |
12
|
compact_aspect_ratio
|
float
|
Compact card aspect ratio (default: 1.0) |
1.0
|
SectionHeader
dataclass
¶
SectionHeader(
text: str,
x: int,
y: int,
width: int,
height: int = 5,
compact_x: int | None = None,
compact_y: int | None = None,
compact_width: int = 12,
compact_height: int = 2,
)
A section header on the dashboard.
Headers are text labels that group cards visually. They take up grid space but don't display data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Header text |
required |
x
|
int
|
Horizontal position |
required |
y
|
int
|
Vertical position |
required |
width
|
int
|
Header width |
required |
height
|
int
|
Header height (typically 5) |
5
|
compact_x
|
int | None
|
Override compact x |
None
|
compact_y
|
int | None
|
Override compact y |
None
|
compact_width
|
int
|
Override compact width (default: 12) |
12
|
compact_height
|
int
|
Override compact height (default: 2) |
2
|
build_dashboard_layout_body ¶
build_dashboard_layout_body(
dashboard: DashboardDefinition,
layout_id: str | None = None,
page_urn: str | None = None,
) -> dict
Build the layout body for a dashboard definition.
This produces the body for PUT /content/v4/pages/layouts/{layoutId}. The layout_id and page_urn are required for an update — they come from the create_page_layout() response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dashboard
|
DashboardDefinition
|
DashboardDefinition with card placements and headers |
required |
layout_id
|
str | None
|
Layout ID (from create_page_layout response) |
None
|
page_urn
|
str | None
|
Page ID (same as page_id) |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Layout body dict for the PUT API call |
Source code in src/crew_dcs/classes/dashboard_builder.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
create_dashboard
async
¶
create_dashboard(
auth: DomoAuth,
dashboard: DashboardDefinition,
*,
context: RouteContext | None = None,
**context_kwargs
) -> DashboardCreationResult
Create a complete dashboard: page + cards + layout.
This is the convenience function that does the full workflow: 1. Create the page (POST /content/v1/pages) 2. Bulk add cards to the page (PUT /content/v1/cards/bulk/pages) 3. Create the layout (POST /content/v4/pages/layouts) 4. Update the layout with proper card positions (PUT /content/v4/pages/layouts/{id})
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
DomoAuth object |
required |
dashboard
|
DashboardDefinition
|
DashboardDefinition with card placements |
required |
context
|
RouteContext | None
|
Optional RouteContext |
None
|
**context_kwargs
|
Additional context parameters |
{}
|
Returns:
| Type | Description |
|---|---|
DashboardCreationResult
|
DashboardCreationResult with page_id, layout_id, and raw responses |
Source code in src/crew_dcs/classes/dashboard_builder.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |