card#
- class predict_backend.page.card.Card(title, content, subtitle='', description='', _id=None, show_title=True, show_description=True, page_update=None, update_elems=None, updater_text=None, as_columns=False, filters=None, filter_update=None)#
Bases:
object
A container for elements on a Page. A Section is made up of Cards.
- Parameters:
title (
str
) – The title for this Card.content (
List
[Union
[Element
,Row
,Column
]]) – The elements contained in this Card.subtitle (
str
) – The subtitle for this Card, defaults to “”.description (
str
) – The description fort this Card, defaults to “”._id (
str
) – ID of the card. Defaults to autogenerated UUID.show_title (
bool
) – Whether to show the title on the page when rendered, defaults to True.show_description (
bool
) – Whether to show the description to the page when rendered, defaults to True.page_update (
Optional
[Callable
]) – Updater function. Allows for handling dynamic page update on a page Takes a StoreInterface and optionally client runners as arguments, defaults to None.as_columns (
bool
) – If true, reads input to dashboard as list of columns instead of rows, defaults to False.
- Params update_elems:
A list of element titles for required inputs the card updater function needs to run. If only a single element is required, this argument can be a string. Defaults to None.
- Params updater_text:
The text to show on the update button. If this value is not set, the frontend will default to showing the text, “Update”
- Params filters:
A list of input elements that can be used as input to the card’s filter function, defaults to None.
- Params filter_update:
Another updater function to call in combination with filter inputs
- add_comment(comment)#
- add_content(content, ratio=None, index=None)#
Add content to a Card.
- Parameters:
content (
Union
[Row
,List
[Element
],Element
]) – The element(s) to add to the Card.ratio (
Optional
[List
[Union
[int
,float
]]]) – The relative widths of the elements inside theRow
,index (
Optional
[int
]) – The index to add the content to. If None, it will default to appending the content to the end of the card
defaults to all elements having the same width.
- delete_comment(comment_id)#
- edit_comment(comment_id, new_comment_message, editor)#
- Return type:
Comment
- get_comment(comment_id)#
- Return type:
Comment
- get_filters()#
- Return type:
Iterator
[InputElement
]
- remove_item(element_title, quiet=False)#
This function removes an element in a dashboard, which can be used in conjunction with the card’s updater of filter_update function to provide dynamic page updates.
- Parameters:
element_title (
str
) – The title of the element to be updated.new_element – The new element that will replace currently existing element.
quiet (
bool
) – If True, do not return an error if there is no element with that title found on the page. Defaults to False
- save_col(col, link, is_ssf=False)#
- save_row(row, link, is_ssf=False)#
- update_item(element_title, new_element)#
This function updates an element in a dashboard, which can be used in conjunction with the card’s updater or filter_update function to provide dynamic page updates.
- Parameters:
element_title (
str
) – The title of the element to be updated.new_element (
Element
) – The new element that will replace currently existing element.
- predict_backend.page.card.extract_inner_dashboards(card_content)#
This method takes in card content that may include a dashboard and returns: 1. A new list of rows with the rows of internal dashboards flattened into the card 2. A list of the filter elements from all of the internal dashboards 3. The filter updater function from the last Dashboard in the list
- Return type:
Tuple
[List
[Row
],List
[InputElement
],Callable
]