Skip to content

Commit

Permalink
Merge pull request #36 from intelequia/issue#35-change-mobile-report-…
Browse files Browse the repository at this point in the history
…rendering

Change rendering layout in mobile devices
  • Loading branch information
davidjrh authored Jun 18, 2024
2 parents 2671a37 + 7551a4e commit 62d9d5e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/DotNetNuke.PowerBI/DotNetNuke.PowerBI.dnn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="PowerBIEmbeddedList" type="Module" version="01.02.02">
<package name="PowerBIEmbeddedList" type="Module" version="01.02.03">
<friendlyName>PowerBI Embedded Content List</friendlyName>
<description>A set of modules to embed PowerBI Embedded dashboards and reports into a DNN Platform installation.</description>
<iconFile>~/DesktopModules/MVC/PowerBIEmbedded/images/powerbi.png</iconFile>
Expand Down Expand Up @@ -176,7 +176,7 @@
</component>
</components>
</package>
<package name="PowerBIEmbeddedContent" type="Module" version="01.02.02">
<package name="PowerBIEmbeddedContent" type="Module" version="01.02.03">
<friendlyName>PowerBI Embedded Content View</friendlyName>
<description>A set of modules to embed PowerBI Embedded dashboards and reports into a DNN Platform installation.</description>
<iconFile>~/DesktopModules/MVC/PowerBIEmbedded/images/powerbi.png</iconFile>
Expand Down Expand Up @@ -231,7 +231,7 @@
</component>
</components>
</package>
<package name="PowerBIEmbeddedCalendar" type="Module" version="01.02.02">
<package name="PowerBIEmbeddedCalendar" type="Module" version="01.02.03">
<friendlyName>PowerBI Embedded Calendar View</friendlyName>
<description>A set of modules to embed PowerBI Embedded dashboards and reports into a DNN Platform installation.</description>
<iconFile>~/DesktopModules/MVC/PowerBIEmbedded/images/powerbi.png</iconFile>
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetNuke.PowerBI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("01.02.02.*")]
[assembly: AssemblyVersion("01.02.03.*")]
#pragma warning disable CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision
[assembly: AssemblyFileVersion("01.02.02.*")]
[assembly: AssemblyFileVersion("01.02.03.*")]
#pragma warning restore CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision
3 changes: 3 additions & 0 deletions src/DotNetNuke.PowerBI/ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@

<b>Version 1.2.1</b>
<p>fix: improved permissions methods.</p>

<b>Version 1.2.3</b>
<p>fix: changed rendering method for mobile devices</p>

</div>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

66 changes: 50 additions & 16 deletions src/DotNetNuke.PowerBI/scripts/ContentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,12 @@
language: context.Locale,
formatLocale: context.Locale
},
layoutType: that.isMobile ? (that.isLandscape ? that.models.LayoutType.MobileLandscape : that.models.LayoutType.MobilePortrait) : null
},
pageName: context.PageName
};

if (this.overrideVisualHeaderVisibility) {
this.config.settings.visualSettings = {
that.config.settings.visualSettings = {
visualHeaders: [
{
settings: {
Expand All @@ -398,32 +397,29 @@

//override filter pane
if (context.overrideFilterPaneVisibility) {
this.config.settings.filterPaneEnabled = context.FilterPaneVisible && !that.isMobile;
that.config.settings.filterPaneEnabled = context.FilterPaneVisible && !that.isMobile;
}

// Get a reference to the embedded report HTML element
this.reportContainer = $('#embedContainer_' + context.ModuleId)[0];

if (!that.isMobile && that.isLandscape) {
var h = that.defaultHeight !== '' ? that.defaultHeight : window.innerHeight - 50 - 20 - 39 - 20 - 10;
var h = that.defaultHeight !== '' ? that.defaultHeight : window.innerHeight - 50 - 20 - 39 - 20 - 10;

$('#embedContainer_' + context.ModuleId).css("height", h + "px");
}

// Embed the report and display it within the div container.
this.report = powerbi.embed(that.reportContainer, that.config);



if (this.overrideFilterPaneVisibility) {
const newSettings = {
panes: {
filters: {
visible: context.FilterPaneVisible && !that.isMobile, // hide filter pane
}
that.config.settings.panes = {
filters: {
visible: context.FilterPaneVisible && !that.isMobile, // hide filter pane
}
}
that.report.updateSettings(newSettings)
.catch(error => { console.log(error) });
}

// Embed the report and display it within the div container.
this.report = powerbi.load(that.reportContainer, that.config);

//Getreport bookmarks
this.report.bookmarksManager.getBookmarks()
.then(function (bookmarks) {
Expand Down Expand Up @@ -468,7 +464,40 @@
});
});

this.setCustomLayout = function () {
that.config.settings.layoutType = that.models.LayoutType.Custom;
that.config.settings.customLayout = {
displayOption: that.models.DisplayOption.FitToWidth,
width: "100%",
height: "100%"
}
that.config.settings.panes = {
pageNavigation: {
visible: false
},
}
}

this.report.on("loaded", async function () {
if (that.isMobile && that.config.settings.layoutType != that.models.LayoutType.MobilePortrait) {
var page = await that.report.getActivePage()
const hasLayout = await page.hasLayout(that.models.LayoutType.MobilePortrait);
if (hasLayout) {
that.config.settings.layoutType = that.models.LayoutType.MobilePortrait;
await powerbi.reset(that.reportContainer);
that.report = powerbi.embed(that.reportContainer, that.config);
} else {
if (that.config.settings.layoutType != that.models.LayoutType.Custom) {
that.setCustomLayout();
await powerbi.reset(that.reportContainer);
that.report = powerbi.embed(that.reportContainer, that.config);
}
}
}
else {
await that.report.render();
}
})

this.createBookmarksList = function () {
let params = {
Expand Down Expand Up @@ -693,6 +722,9 @@
filters: {
visible: true
},
pageNavigation: {
visible: true
},
visualizations: {
visible: !context.HideVisualizationData
},
Expand Down Expand Up @@ -722,9 +754,11 @@

window.onresize = function () {
that.isMobile = window.innerWidth < 425 || window.innerHeight < 425;

isLandscape = window.innerWidth > window.innerHeight;
if (!that.isMobile && isLandscape) {
var h = that.defaultHeight !== '' ? that.defaultHeight : window.innerHeight - 50 - 20 - 39 - 20 - 10;

$('#embedContainer_' + context.ModuleId).css("height", h + "px");
}
}
Expand Down

0 comments on commit 62d9d5e

Please sign in to comment.