We have created a PowerBI report having both the desktop verion and mobile virson.
Its showing desktop and pone view properly when we are testing at following sample site after putting correct information.
https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html
But when we open the website on mobile It is still showing the desktop version of the report. File version used of powerbi.js file is 'powerbi-client v2.5.1'.
The HTML and javascript used is provided below
We are also appending '&isMobile=true' with embed report url.
Are we missing any reference to show the mobile version.
<html>
<head>
</head>
<body>
<div id="reportContainer" style="width: 100%; height: 610px" aria-atomic="True" aria-multiline="True" aria-multiselectable="True" aria-orientation="vertical">
</div>
<script src="~/Scripts/powerbi.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
var txtAccessToken = "#Model.EmbedToken.Token";
var txtEmbedUrl = "#Html.Raw(Model.EmbedUrl)";
var txtEmbedReportId = "#Model.Id";
var tokenType = $('input:radio[name=tokenType]:checked').val();
var models = window['powerbi-client'].models;
var permissions = models.Permissions.All;
var config = {
type: 'report',
tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
accessToken: txtAccessToken,
embedUrl: txtEmbedUrl,
id: txtEmbedReportId,
permissions: permissions,
settings: {
layoutType: models.LayoutType.MobilePortrait
}
};
// Get a reference to the embedded report HTML element
var embedContainer = $('#reportContainer')[0];
// Embed the report and display it within the div container.
var report = powerbi.embed(embedContainer, config);
// Report.off removes a given event handler if it exists.
report.off("loaded");
// Report.on will add an event handler which prints to Log window.
report.on("loaded", function() {
Log.logText("Loaded");
});
report.on("error", function(event) {
Log.log(event.detail);
report.off("error");
});
report.off("saved");
report.on("saved", function(event) {
Log.log(event.detail);
if (event.detail.saveAs) {
Log.logText('In order to interact with the new report, create a new token and load the new report');
}
});
});
</script>
</body>
</html>
Issue is resolved. I was appending isMobile=true in embededUrl property of configuration.
report.EmbedUrl = report.EmbedUrl + "&isMobile=true";
We need not to append "&isMobile=true" explicitly, this parameter will be updated in the iframe url automatically.
Related
I have seen many discussions on how to display a PDF file within a embedded form ( User Task ) But realised camunda does not support this. Are there any solutions?
I have tried using IFrame, Object, embed , and directly linking to a variable did not work ?
My solution is to fetch the variable and convert to a blob as follows:
HTML
<embed class="col-sm-12" style="height:100vh;width:100%" type="application/pdf" id="pdf-frame">
JS
<script cam-script type="text/javascript">
camForm.on('form-loaded', function () {
fetch("http://localhost:8181/camunda/api/engine/engine/default/task/" + camForm.taskId + "/variables/ACORD_FORM/data").then(function (response) {
return response.blob();
}).then(function (myBlob) {
var objectURL = URL.createObjectURL(myBlob);
document.querySelector('#pdf-frame').src = '';
document.querySelector('#pdf-frame').src = objectURL;
objectURL = URL.revokeObjectURL(myBlob);
});
});
</script>
Microsoft have announced it is possible to turn off the loading image shown when a report is loading.
Loading Image
Use the Power BI Embedded JavaScript SDK to hide the flickering Power
BI logo that appears when a report is loaded. - power-bi-embedded-feature-hide-the-power-bi-logo-during-visualization-load
However I cannot find any mention of this in any of the JS SDK documentation or any examples online.
Has anyone achieved this yet?
First add a gif which you want instead of the Power BI logo. You can add it in a div element. This element will overlap the div element containing the report. The HTML code looks like below:
<div id="container">
<div id="overlay">
<img id="spinner" alt="Alternate Text" src="image/giphy.gif"/>
</div>
<div id="embedContainer" style="height: 600px; width: 100%; max-width: 1400px;">
</div>
</div>
Once you have added your gif. Now, make changes in the JavaScript Code. So you final JavaScript embedding code will be:
<script type="text/javascript">
// Read embed token
var embedToken = "<% =this.embedToken %>";
// Read embed URL
var embedUrl = "<% = this.embedUrl %>";
// Read report Id
var reportId = "<% = this.reportId %>";
// Get models (models contains enums)
var models = window['powerbi-client'].models;
// Embed configuration is used to describe what and how to embed
// This object is used when calling powerbi.embed
// It can also include settings and options such as filters
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: false
}
};
$("#embedContainer").css("visibility", "hidden");
// Get a reference to the embedded report HTML element
var reportContainer = $('#embedContainer')[0];
// Embed the report within the div element
var report = powerbi.embed(reportContainer, config);
report.on("loaded", function (event) {
$("#overlay").hide();
$("#embedContainer").css("visibility", "visible");
report.off("loaded");
})
</script>
You can also add CSS to align you gif with your report:
<style>
#container{
position:absolute;
width: 1400px;
height:600px;
}
#overlay{
position:absolute;
width:inherit;
height:inherit;
}
#spinner{
display: block;
margin-top:10%;
margin-left: auto;
margin-right: auto;
width:10%;
height: 10%;
}
</style>
Further, you can refer to the following youtube link: https://www.youtube.com/watch?v=YhjtunTmnbw. This video is by the Power BI official YouTube account. In this video, you can learn how to get white-labelled embedded analytics in your application with Power BI Embedded. Discover how to hide the Power BI logo until the loaded or the rendered event, and how to use a personalized logo for the loading phase.
What the recommended way to do this, even in the article you referenced, is -
1. Hide the iframe (or the div containing it)
2. Listen to either the loaded event when using (phased loading)[https://github.com/Microsoft/PowerBI-JavaScript/wiki/Phased-Embedding-API] or rendered otherwise
3. Show the div you hid before and voila - the embedded power bi is already loaded..
It is not currently possible to remove the PowerBI loading symbol. It would be great idea to suggest to input your own custom logo though
Earlier I used to use 'loadReport' from javascript which is not working with new PBI Premium, e.g. the below is not working anymore & it always says "This content isn't available". BTW this is still working for PBI embedded reports.
<html>
<body>
<iframe id="iFrameEmbedReport"></iframe>
</body>
<script type="text/javascript">
window.onload = function () {
var iframe = document.getElementById('iFrameEmbedReport');
iframe.src = 'https://app.powerbi.com/reportEmbed?reportId=******-088f-4967-***-279bd5a**df&groupId=*****-****-4033-862d-1cd4f4fa72c1';
iframe.onload = function()
{
var m = {
action: 'loadReport',
accessToken: 'H4s*****'
};
message = JSON.stringify(m);
iframe = document.getElementById('iFrameEmbedReport');
iframe.contentWindow.postMessage(message, "*");
};
};
</script>
</html>
But if we use powerbi.js with the same configs its working fine (below)
<html>
<body>
<div id="reportContainer"></div>
</body>
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script>
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"></script>
<script type="text/javascript">
window.onload = function () {
var accessToken = '******************';
var embedUrl = 'https://app.powerbi.com/reportEmbed?reportId=**********&groupId=**********';
var embedReportId = '*****-088f-****-aa2d-279bd5a662df';
var models = window['powerbi-client'].models;
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
var reportContainer = $('#reportContainer')[0];
var report = powerbi.embed(reportContainer, config);
}
</script>
</html>
Not able to figure out what has changed. I really don't want to include powerbi.js in my application if not needed. I know I have a working copy but really need to understand what has changed and if there is any way I can avoid powerbi.js. End goal is to use the first approach in UWP App.
Thanks
The main thing that's changed in the 2 approaches is the property TokenType.Embed which is not available in the 'old way', i.e. 'loadReport' message format.
This is a deprecated way of communicating with embedded entities from Power BI, and all users are encouraged to write their code against the new and maintained Javascript SDK: https://microsoft.github.io/PowerBI-JavaScript/
The 'loadReport' way work for backward compatibility concerns but you won't be able to write new code in new methods using this way.
I am trying to integrate FlowJS with EmberJS. I was successful to upload data to server, so, I am good on that part.
I am unsuccessful When trying to bind flow object data with emberJS component to show data via handlebars. For some reason data binding is not working.
Here is an example of the code.
HTML
<script type="text/x-handlebars" data-template-name="index">
{{flow-uploader}}
</script>
<script type="text/x-handlebars" id="components/flow-uploader">
<div class="drop"></div>
<!-- file list -->
{{#each file in flow.files}}
<p>File name: {{file.name}}</p>
{{/each}}
</script>
JS
App = Ember.Application.create({
rootElement: '#main'
});
App.FlowUploaderComponent = Ember.Component.extend({
flow: function(){
return new Flow({
target: 'http://google.com',
testChunks: false
});
}.property(),
initDropZone: function(){
var flow = this.get('flow');
var drop = this.$('.drop')[0];
var $this = this;
flow.assignDrop(drop);
/*flow.on('fileAdded', function(file, flow){
});
flow.on('filesAdded', function(files){
});
flow.on('fileSuccess', function(file,message){
console.log('file success');
});
flow.on('fileError', function(flow, message, chunk){
console.log('file error');
});*/
flow.on('filesSubmitted', function(){
console.log($this.get('flow').files);
//flow.upload();
});
/*flow.on('complete', function(event, flow){
console.log('completed');
});
flow.on('uploadStart', function(event, flow){
console.log('uploading..');
});
flow.on('fileProgress', function(flow, file){
});*/
}.on('didInsertElement')
});
Example can be seen live at http://jsfiddle.net/sisir/qLuobq48/2/
Basically what I am doing here is to save the flow object as component property. files property of flow object is the array of file to be uploaded. Once we drag and drop or select multiple files to upload the files array gets updated. We can see it on the console. The logging code is added via filesSubmitted event.
From the handlebars expression each file is iterated from the files queue. Initially it is empty but later when it gets populated it doesn't show on the html. The data binding is not working for some reason.
In your component logic:
App.FlowUploaderComponent = Ember.Component.extend({
flow: function(){
return new Flow({
target: 'http://google.com',
testChunks: false
});
}.property(),
initDropZone: function(){
var $this = this;
var flow = this.get('flow');
var drop = this.$('.drop')[0];
flow.assignDrop(drop);
flow.on('filesSubmitted', function(){
//for setting a single property
$this.set('flowFiles', flow.files);
//for setting multiple properties
// $this.setProperties({'flowFiles': flow.files, /* etc.. */});
});
}.on('didInsertElement')
});
In your template:
<script type="text/x-handlebars" data-template-name="index">
{{flow-uploader}}
</script>
<script type="text/x-handlebars" id="components/flow-uploader">
<div class="drop"></div>
<!-- file list -->
{{#each file in flowFiles}}
File name: {{file.name}}
{{/each}}
</script>
See JSBin Example
The problem with your JSFiddle simply is(/was) that you referenced a text/plain file as JavaScript. As I asked here, not every file is usable in JSFiddle and GitHub does not like to get misused as pseudo-CDN for lazy people.
In other words: This error
Uncaught ReferenceError: Flow is not defined
is a result of this error
Refused to execute script from 'https://raw.githubusercontent.com/flowjs/flow.js/master/dist/flow.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
and can be fixed using
https://rawgithub.com
or the MaxCDN version
http://rawgit.com/
in place of the branch file URl.
Look at the new JSFiddle with all the console.log() statements. The files added, file added and submitted logs in the console are telling me that everything in your code works fine once you got the right file in use. PROTip: Always check your console for errors.
I'm unable to get the page access token for some reason I only recieve the page id...
this is my code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP-ID',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button" data-scope="email,user_checkins,manage_pages">Login with Facebook</div>
<div class="result">Start</div>
<div class="result_app_installed">Start</div>
<script>
// Get access token
$.get('https://graph.facebook.com/102561956524622?fields=access_token', function(data) {
alert(data);
});
// Get data if user is application is installed on that page or not.
$.get("https://graph.facebook.com/102561956524622/tabs/255792581098802",
function(data) {
alert(data);
});
</script>
</body>
</html>
What I am trying to do is to get the page access token and then check if application in installed on that page..
What am I doing wrong?
Try something like:
FB.api('/me/accounts',function(response) {alert(response);})
The Page token is returned in data as access_token
You will need manage_pages permission.
https://graph.facebook.com/102561956524622?fields=access_token
won't work. In order to get an access_token for any fan page You need to do the steps explained here:
writing on the wall on behalf of my fanpage
Instead of using $.get it's better to use Facebook JavaScript SDK:
https://developers.facebook.com/docs/reference/javascript/
so for the second request it would be:
FB.api('/102561956524622/tabs/255792581098802',
function(response) {
alert(response);
});
Bear in mind that in order to make this FB.api call You need to authorize the app first
Actuelly its very easy
FB.api('/'+[PAGE_ID]+'?fields=id,likes,name,access_token', function(response) {
console.log(response.access_token);
});
Dont forget to check if user is logged in.