Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PowerBI] Decouple addin settings, default "Show zoom bar" to true #2342

Merged
merged 11 commits into from
Nov 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ var pbiAuthToken = null;
var _showBookmarkSelection = false;
var _showFilters = false;
var _showPageSelection = false;
var _showZoomBar = false;
var _showZoomBar = true;
var _forceTransparentBackground = false;
var _forceFitToPage = false;
var _addBottomPadding = false;
var _localeSettings = {};

Expand Down Expand Up @@ -147,6 +146,16 @@ function InitializeFrame(fullpage, ratio) {
}
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
// OBSOLETE
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_addBottomPadding = addBottomPadding;
}

// Exposed Functions

function EmbedPowerBIReport(reportLink, reportId, pageName) {
Expand Down Expand Up @@ -345,14 +354,24 @@ function SetToken(authToken) {
pbiAuthToken = authToken;
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_forceFitToPage = forceFitToPage;
_addBottomPadding = addBottomPadding;
function SetBookmarksVisible(visible) {
_showBookmarkSelection = visible;
}

function SetFiltersVisible(visible) {
_showFilters = visible;
}

function SetPageSelectionVisible(visible) {
_showPageSelection = visible;
}

function SetTransparentBackground(transparent) {
_forceTransparentBackground = transparent;
}

function AddBottomPadding(addPadding) {
_addBottomPadding = addPadding;
}

// Internal functions
Expand Down Expand Up @@ -411,13 +430,6 @@ function CompileSettings() {
settingsObject.background = models.BackgroundType.Transparent;
}

if (_forceFitToPage) {
encimita marked this conversation as resolved.
Show resolved Hide resolved
settingsObject.layoutType = models.LayoutType.Custom;
settingsObject.customLayout = {
displayOption: models.DisplayOption.FitToPage
}
}

return settingsObject;
}

Expand Down Expand Up @@ -504,14 +516,18 @@ function LogErrorToConsole(operation, error) {
}

function GetErrorMessage(error) {
if (error && error.message) {
return error.message;
if (error && error.detail && error.detail.detailedMessage) {
return error.detail.detailedMessage;
}

if (error && error.detail && error.detail.message) {
return error.detail.message;
}

if (error && error.message) {
return error.message;
}

return error.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ controladdin PowerBIManagement
/// <param name="NewLocale">The locale to use, for example "en-us".</param>
procedure SetLocale(NewLocale: Text);

/// <summary>
/// Controls whether the bookmark selection pane will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether bookmarks should be visible.</param>
procedure SetBookmarksVisible(Visible: Boolean);

/// <summary>
/// Controls whether the filter pane will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether filters should be visible.</param>
procedure SetFiltersVisible(Visible: Boolean);

/// <summary>
/// Controls whether the page selection bar will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether page selection should be visible.</param>
procedure SetPageSelectionVisible(Visible: Boolean);

/// <summary>
/// Controls whether the report background should be set to transparent regardless of the actual color. Defaults to false.
/// </summary>
/// <param name="Visible">Whether the background should be force to transparent.</param>
procedure SetTransparentBackground(Transparent: Boolean);

/// <summary>
/// Controls whether the addin includes a bottom padding that makes it look nicer in some embedded scenarios. Defaults to false.
/// </summary>
/// <param name="AddPadding">Whether the bottom padding should be added.</param>
procedure AddBottomPadding(AddPadding: Boolean);

#if not CLEAN26
/// <summary>
/// Sets the properties for the embed experience
/// </summary>
Expand All @@ -140,7 +171,9 @@ controladdin PowerBIManagement
///<param name="ForceTransparentBackground">Forces a transparent background to the embed.</param>
///<param name="ForceFitToPage">Forces the Fit To Page behaviour for the embed.</param>
///<param name="AddBottomPadding">Controls whether a padding is needed on the bottom of the page (useful in case the embed is the only element displayed on the page).</param>
[Obsolete('Use SetBookmarksVisible, SetFiltersVisible, AddBottomPadding, SetTransparentBackground, and SetPageSelectionVisible instead. The other options are no longer supported.', '26.0')]
procedure SetSettings(ShowBookmarkSelection: Boolean; ShowFilters: Boolean; ShowPageSelection: Boolean; ShowZoomBar: Boolean; ForceTransparentBackground: Boolean; ForceFitToPage: Boolean; AddBottomPadding: Boolean);
#endif

#if not CLEAN25
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ var pbiAuthToken = null;
var _showBookmarkSelection = false;
var _showFilters = false;
var _showPageSelection = false;
var _showZoomBar = false;
var _showZoomBar = true;
var _forceTransparentBackground = false;
var _forceFitToPage = false;
var _addBottomPadding = false;
var _localeSettings = {};

Expand Down Expand Up @@ -147,6 +146,16 @@ function InitializeFrame(fullpage, ratio) {
}
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
// OBSOLETE
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_addBottomPadding = addBottomPadding;
}

// Exposed Functions

function EmbedPowerBIReport(reportLink, reportId, pageName) {
Expand Down Expand Up @@ -345,14 +354,24 @@ function SetToken(authToken) {
pbiAuthToken = authToken;
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_forceFitToPage = forceFitToPage;
_addBottomPadding = addBottomPadding;
function SetBookmarksVisible(visible) {
_showBookmarkSelection = visible;
}

function SetFiltersVisible(visible) {
_showFilters = visible;
}

function SetPageSelectionVisible(visible) {
_showPageSelection = visible;
}

function SetTransparentBackground(transparent) {
_forceTransparentBackground = transparent;
}

function AddBottomPadding(addPadding) {
_addBottomPadding = addPadding;
}

// Internal functions
Expand Down Expand Up @@ -411,13 +430,6 @@ function CompileSettings() {
settingsObject.background = models.BackgroundType.Transparent;
}

if (_forceFitToPage) {
settingsObject.layoutType = models.LayoutType.Custom;
settingsObject.customLayout = {
displayOption: models.DisplayOption.FitToPage
}
}

return settingsObject;
}

Expand Down Expand Up @@ -504,14 +516,18 @@ function LogErrorToConsole(operation, error) {
}

function GetErrorMessage(error) {
if (error && error.message) {
return error.message;
if (error && error.detail && error.detail.detailedMessage) {
return error.detail.detailedMessage;
}

if (error && error.detail && error.detail.message) {
return error.detail.message;
}

if (error && error.message) {
return error.message;
}

return error.toString();
}

Expand Down
Loading