MicroStrategyDossier
API reference for the MicroStrategyDossier interface in the embed-dossier-mstr-react package.
Type Definition
interface MicroStrategyDossier {
close: () => void
refresh: () => void
resize: (width: string, height: string) => void
getDossierInstanceId: () => Promise<string>
// Filter methods
getFilterList: () => Promise<FilterListType[]>
filterSelectAllAttributes: (params: FilterJson) => void
filterDeselectAllAttributes: (params: FilterJson) => void
filterSelectSingleAttribute: (params: FilterJson) => void
filterSelectMultiAttributes: (params: FilterJson) => void
filterSearchSingleAttribute: (params: FilterJson) => void
filterSearchMultiAttributes: (params: FilterJson) => void
filterAttributeSingleSlider: (params: FilterJson) => void
filterAttributeMultiSlider: (params: FilterJson) => void
filterSetDateRange: (params: FilterJson) => void
filterSetMetricQualByValue: (params: FilterJson) => void
filterSetMetricQualByRank: (params: FilterJson) => void
filterSetMetricSliderByValue: (params: FilterJson) => void
filterSetMetricSliderByRank: (params: FilterJson) => void
filterClearAll: () => void
filterClear: (params: FilterJson) => void
filterSetInclude: (params: FilterJson) => void
filterSetExclude: (params: FilterJson) => void
filterApplyAll: () => void
// Mode switching
switchToMode?: (mode: "consumption" | "authoring") => Promise<void>
// Navigation methods
getTableOfContents: () => TableOfContents
goToPrevPage: () => Promise<{ valid: boolean; message: string } | void>
goToNextPage: () => Promise<{ valid: boolean; message: string } | void>
navigateToPage: (
page: DossierPage
) => Promise<{ valid: boolean; message: string } | void>
getCurrentChapter: () => DossierChapter
getCurrentPage: () => DossierPage
getPageByNodeKey: (nodeKey: string) => DossierPage
getChapterList: () => DossierChapter[]
getCurrentPageVisualizationList: () => Promise<
[{ key: string; name: string }]
>
openFilterSummaryBar: () => void | null
closeFilterSummaryBar: () => void | null
getPageList: () => DossierPage[]
// Event handling methods
registerEventHandler: (event: EventTypes, handler: EventHandler) => void
removeEventHandler: (event: EventTypes, handler: EventHandler) => void
registerGraphicsSelectEventHandlerToViz: (
vizKey: string,
handler: EventHandler
) => void
registerFilterUpdateHandler: (handler: EventHandler) => void
registerPageSwitchHandler: (handler: EventHandler) => void
registerDossierInstanceIDChangeHandler: (handler: EventHandler) => void
// Error handling methods
removeCustomErrorHandler?: (error: ErrorHandlerInterface) => void
removeSessionHandler: () => void
addCustomErrorHandler: (
handler: (error: ErrorHandlerInterface) => void,
showErrorPopup: boolean
) => void
addSessionErrorHandler: (
handler: (error: ErrorHandlerInterface) => void,
showErrorPopup: boolean
) => void
}
Basic Methods
close
close: () => void
Closes the dossier and cleans up resources.
refresh
refresh: () => void
Refreshes the dossier, reloading data from the server.
resize
resize: (width: string, height: string) => void
Resizes the dossier container.
Parameters:
width:string- The new width (e.g., "800px", "100%").height:string- The new height (e.g., "600px", "100%").
getDossierInstanceId
getDossierInstanceId: () => Promise<string>
Gets the unique instance ID of the dossier.
Returns:
Promise<string>: A promise that resolves to the dossier instance ID.
Filter Methods
getFilterList
getFilterList: () => Promise<FilterListType[]>
Gets the list of available filters in the dossier.
Returns:
Promise<FilterListType[]>: A promise that resolves to an array of filter information.
filterSelectAllAttributes
filterSelectAllAttributes: (params: FilterJson) => void
Selects all attributes in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterDeselectAllAttributes
filterDeselectAllAttributes: (params: FilterJson) => void
Deselects all attributes in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterSelectSingleAttribute
filterSelectSingleAttribute: (params: FilterJson) => void
Selects a single attribute in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterSelectMultiAttributes
filterSelectMultiAttributes: (params: FilterJson) => void
Selects multiple attributes in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterSearchSingleAttribute
filterSearchSingleAttribute: (params: FilterJson) => void
Searches for and selects a single attribute in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterSearchMultiAttributes
filterSearchMultiAttributes: (params: FilterJson) => void
Searches for and selects multiple attributes in a filter.
Parameters:
params:FilterJson- The filter parameters.
filterAttributeSingleSlider
filterAttributeSingleSlider: (params: FilterJson) => void
Sets a single slider value for an attribute filter.
Parameters:
params:FilterJson- The filter parameters.
filterAttributeMultiSlider
filterAttributeMultiSlider: (params: FilterJson) => void
Sets multiple slider values for an attribute filter.
Parameters:
params:FilterJson- The filter parameters.
filterSetDateRange
filterSetDateRange: (params: FilterJson) => void
Sets a date range for a date filter.
Parameters:
params:FilterJson- The filter parameters.
filterSetMetricQualByValue
filterSetMetricQualByValue: (params: FilterJson) => void
Sets a metric qualification filter by value.
Parameters:
params:FilterJson- The filter parameters.
filterSetMetricQualByRank
filterSetMetricQualByRank: (params: FilterJson) => void
Sets a metric qualification filter by rank.
Parameters:
params:FilterJson- The filter parameters.
filterSetMetricSliderByValue
filterSetMetricSliderByValue: (params: FilterJson) => void
Sets a metric slider filter by value.
Parameters:
params:FilterJson- The filter parameters.
filterSetMetricSliderByRank
filterSetMetricSliderByRank: (params: FilterJson) => void
Sets a metric slider filter by rank.
Parameters:
params:FilterJson- The filter parameters.
filterClearAll
filterClearAll: () => void
Clears all filters in the dossier.
filterClear
filterClear: (params: FilterJson) => void
Clears a specific filter.
Parameters:
params:FilterJson- The filter parameters.
filterSetInclude
filterSetInclude: (params: FilterJson) => void
Sets a filter to include mode.
Parameters:
params:FilterJson- The filter parameters.
filterSetExclude
filterSetExclude: (params: FilterJson) => void
Sets a filter to exclude mode.
Parameters:
params:FilterJson- The filter parameters.
filterApplyAll
filterApplyAll: () => void
Applies all pending filter changes.
Mode Switching
switchToMode
switchToMode?: (mode: "consumption" | "authoring") => Promise<void>
Switches the dossier between consumption and authoring modes.
Parameters:
mode:"consumption" | "authoring"- The mode to switch to.
Returns:
Promise<void>: A promise that resolves when the mode switch is complete.
Navigation Methods
getTableOfContents
getTableOfContents: () => TableOfContents
Gets the table of contents for the dossier.
Returns:
TableOfContents: The table of contents structure.
goToPrevPage
goToPrevPage: () => Promise<{ valid: boolean; message: string } | void>
Navigates to the previous page in the dossier.
Returns:
Promise<{ valid: boolean; message: string } | void>: A promise that resolves with the result of the navigation.
goToNextPage
goToNextPage: () => Promise<{ valid: boolean; message: string } | void>
Navigates to the next page in the dossier.
Returns:
Promise<{ valid: boolean; message: string } | void>: A promise that resolves with the result of the navigation.
navigateToPage
navigateToPage: (page: DossierPage) =>
Promise<{ valid: boolean; message: string } | void>
Navigates to a specific page in the dossier.
Parameters:
page:DossierPage- The page to navigate to.
Returns:
Promise<{ valid: boolean; message: string } | void>: A promise that resolves with the result of the navigation.
getCurrentChapter
getCurrentChapter: () => DossierChapter
Gets the current chapter in the dossier.
Returns:
DossierChapter: The current chapter.
getCurrentPage
getCurrentPage: () => DossierPage
Gets the current page in the dossier.
Returns:
DossierPage: The current page.
getPageByNodeKey
getPageByNodeKey: (nodeKey: string) => DossierPage
Gets a page by its node key.
Parameters:
nodeKey:string- The unique key of the page node.
Returns:
DossierPage: The requested page.
getChapterList
getChapterList: () => DossierChapter[]
Gets the list of chapters in the dossier.
Returns:
DossierChapter[]: An array of dossier chapters.
getCurrentPageVisualizationList
getCurrentPageVisualizationList: () => Promise<[{ key: string; name: string }]>
Gets the list of visualizations on the current page.
Returns:
Promise<[{ key: string; name: string }]>: A promise that resolves to an array of visualization info.
openFilterSummaryBar
openFilterSummaryBar: () => void | null
Opens the filter summary bar.
closeFilterSummaryBar
closeFilterSummaryBar: () => void | null
Closes the filter summary bar.
getPageList
getPageList: () => DossierPage[]
Gets the list of all pages in the dossier.
Returns:
DossierPage[]: An array of dossier pages.
Event Handling Methods
registerEventHandler
registerEventHandler: (event: EventTypes, handler: EventHandler) => void
Registers an event handler for a specific event type.
Parameters:
event:EventTypes- The type of event to listen for.handler:EventHandler- The handler function to call when the event occurs.
removeEventHandler
removeEventHandler: (event: EventTypes, handler: EventHandler) => void
Removes an event handler.
Parameters:
event:EventTypes- The type of event to remove the handler from.handler:EventHandler- The handler function to remove.
registerGraphicsSelectEventHandlerToViz
registerGraphicsSelectEventHandlerToViz: (vizKey: string, handler: EventHandler) => void
Registers an event handler for graphics selection events on a specific visualization.
Parameters:
vizKey:string- The key of the visualization.handler:EventHandler- The handler function to call when the event occurs.
registerFilterUpdateHandler
registerFilterUpdateHandler: (handler: EventHandler) => void
Registers an event handler for filter update events.
Parameters:
handler:EventHandler- The handler function to call when a filter is updated.
registerPageSwitchHandler
registerPageSwitchHandler: (handler: EventHandler) => void
Registers an event handler for page switch events.
Parameters:
handler:EventHandler- The handler function to call when the page changes.
registerDossierInstanceIDChangeHandler
registerDossierInstanceIDChangeHandler: (handler: EventHandler) => void
Registers an event handler for dossier instance ID change events.
Parameters:
handler:EventHandler- The handler function to call when the instance ID changes.
Error Handling Methods
removeCustomErrorHandler
removeCustomErrorHandler?: (error: ErrorHandlerInterface) => void
Removes a custom error handler.
Parameters:
error:ErrorHandlerInterface- The error handler to remove.
removeSessionHandler
removeSessionHandler: () => void
Removes the session error handler.
addCustomErrorHandler
addCustomErrorHandler: (handler: (error: ErrorHandlerInterface) => void, showErrorPopup: boolean) => void
Adds a custom error handler.
Parameters:
handler:(error: ErrorHandlerInterface) => void- The handler function to call when an error occurs.showErrorPopup:boolean- Whether to show the default error popup.
addSessionErrorHandler
addSessionErrorHandler: (handler: (error: ErrorHandlerInterface) => void, showErrorPopup: boolean) => void
Adds a session error handler.
Parameters:
handler:(error: ErrorHandlerInterface) => void- The handler function to call when a session error occurs.showErrorPopup:boolean- Whether to show the default error popup.
Usage Example
// After creating a dossier instance
const dossier = await window.microstrategy.dossier.create({
placeholder: document.getElementById("dossier-container"),
url: "https://your-mstr-server/MicroStrategyLibrary/app/PROJECT_ID/DOSSIER_ID",
})
// Get current page
const currentPage = dossier.getCurrentPage()
console.log("Current page:", currentPage.name)
// Navigate to another page
const pages = dossier.getPageList()
if (pages.length > 1) {
await dossier.navigateToPage(pages[1])
}
// Add a page switch handler
dossier.registerPageSwitchHandler((event) => {
console.log("Page switched:", event.data)
})
// Get and modify filters
const filters = await dossier.getFilterList()
if (filters.length > 0) {
dossier.filterClear({
key: filters[0].key,
})
}
// Switch to authoring mode
if (dossier.switchToMode) {
await dossier.switchToMode("authoring")
}
// Clean up when done
dossier.close()