Power Bi Embedded Javascript api getVisuals - powerbi-embedded

let reportContainer = <HTMLElement>document.getElementById('reportContainer');
this.report = this.powerbi.load(reportContainer, this.config);
let reportObject = <pbi.Report>this.report;
this.report.on("loaded", (result) => {
console.log("loaded");
reportObject.getPages().then(result => {
console.log("sucessfully got pages");
this.pages = result;
result.forEach(element => {
var page = <pbi.Page>element;
console.log("A Page:" + page.displayName);
page.getVisuals().then(visualSucessResult => {
console.log("get Visuals sucess");
visualSucessResult.forEach(aVisualElement => {
var aVisual = <pbi.VisualDescriptor>aVisualElement;
console.log("aVisual.name:" + aVisual.name);
});
}, visualFailureResult => {
console.log("Get Visual Failed");
})
});
}, error => {
console.log("Error getting Pages");
})
});
I am trying to load a report and get Pages for the report and then get Visuals for each page.
When I get Visuals , its failing to get Visuals. It seems as if the report visuals doesn't contains some properties which code is trying to get, but I couldn't find anything wrong in the report. I have spent few hours now, it seems like some silly mistake which I am not able to figure out.
I am writing this in angular 5
reportembed.externals.bundle.min.js:632 TypeError: Cannot read property 'entities' of undefined
at Function.t.getDisplayNameForSQAggregate (powerbiportal.explore.bundle.min.js:12)
at t.visitColumnAggr (powerbiportal.explore.bundle.min.js:12)
at o (powerbiportal.dependencies.bundle.min.js:22)
at Object.n [as visit] (powerbiportal.dependencies.bundle.min.js:22)
at r.getOriginalDisplayName (powerbiportal.explore.bundle.min.js:12)
at r.getDisplayName (powerbiportal.explore.bundle.min.js:12)
at r.populateDisplayNamesByDataRole (powerbiportal.explore.bundle.min.js:12)
at r.getRawTitleComponents (powerbiportal.explore.bundle.min.js:12)
at r.getTitleText (powerbiportal.explore.bundle.min.js:12)
at reportembed.bundle.min.js:21
TypeError: Cannot read property 'findProperty' of undefined
at Function.t.getDisplayNameForProperty(powerbiportal.explore.bundle.min.js:12)
at t.visitColumn (powerbiportal.explore.bundle.min.js:12)
at a (powerbiportal.dependencies.bundle.min.js:22)
at Object.n [as visit] (powerbiportal.dependencies.bundle.min.js:22)
at r.getOriginalDisplayName (powerbiportal.explore.bundle.min.js:12)
at r.getDisplayName (powerbiportal.explore.bundle.min.js:12)
at r.populateDisplayNamesByDataRole (powerbiportal.explore.bundle.min.js:12)
at r.getRawTitleComponents (powerbiportal.explore.bundle.min.js:12)
at r.getTitleText (powerbiportal.explore.bundle.min.js:12)
at reportembed.bundle.min.js:21

This is indeed a limitation of GetVisuals API. I added this to Wiki page and I will post here once this limitation is removed.
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Get-Visuals#limitations

Related

Writing nested object to local Apollo cache

I have already looked at: Writing nested object to Apollo client cache
And I guess everywhere else on the internet.
So what I want to do is to write an object to the Apollo cache, to store it locally. This is my setup:
const cache = new InMemoryCache()
const client = new ApolloClient({
uri: '/hasura/v1/graphql',
cache,
credentials: 'include',
})
Then I write this to initialize the cache, taken from: https://www.apollographql.com/docs/react/data/local-state/#querying-local-state
cache.writeData({
data: {
todos: [],
visibilityFilter: 'SHOW_ALL',
networkStatus: {
__typename: 'NetworkStatus',
id: 1,
isConnected: false,
},
},
})
Now, when I want to query the cache using this query:
const lolquery = gql`{
visibilityFilter #client
}`
const result = cache.readQuery({ query: lolquery })
console.log(result)
I can get the visibilityFilter and todos, but when I try to query for networkStatus i.e.,
const lolquery = gql`{
networkStatus #client
}`
I get the following error:
Uncaught Invariant Violation: Invariant Violation: 10
Googling this error doesn't give me much of an answer.
Am I the only one experiencing this? Am I missing something really obvious?
networkStatus was initialized as an object, so you have to query it with a subselection of one or more fields.
{
networkStatus #client {
isConnected
}
}

Invalid or unexpected token when referencing #odata.count

I am currently working with an Odata endpoint and am having an issue referencing JSON values with tags including #. The console shows “SyntaxError | Invalid or unexpected token”
JSON Response Body
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.#odata.count).to.eql(73);
});
Can someone explain how I reference that value?
pm.test("Your test name", function() {
var jsonData = pm.response.json();
pm.expect(jsonData['#odata.count']).to.eql(73);
});

Ionic2: Property 'present' does not exist on type 'NavController'

I am using Ionic 2 rc4. I am following the advise here and am trying to do the following:
import { NavController } from 'ionic-angular';
...
this.nav.present(this.loading).then(() => {
However, to me it looks like the NavController does not have a present function, because I get:
[ts] Property 'present' does not exist on type 'NavController'.
any
Am I correct, or am I doing something wrong? How do they get to access this "phantom" function?
Any advise appreciated.
UPDATE
Here is my code that results in the following error (on this.loading.present().then(() => {):
"Cannot read property 'nativeElement' of null"
It presents loading the first time. but after the alert is presented if submit() is run again, it gets this error.
submit() {
this.loading.present().then(() => {
let alert = this.alertCtrl.create({
title: 'Verify Email',
subTitle: 'Please verify your email address before you log in.',
message: 'Check your Spam folder if you cannot find the email.',
buttons: [
{
text: 'Resend',
handler: data => {
firebaseUser.sendEmailVerification().then((data) => {
this.doAlert('Verify Email', 'Verification Email Sent.').then((data) => {
//navCtrl.setRoot(navCtrl.getActive());
});
});
}
},
{
text: 'Okay',
handler: data => {
//navCtrl.setRoot(navCtrl.getActive());
}
}
]
});
alert.present();
this.loading.dismiss();
});
}
Looking at this changelog for Beta 11
They have removed present function from Navcontroller.
You need to refactor your code and use some other function based on your requirement.
this.loading.present()
For the error, check the Loading controller docs.
Note that after the component is dismissed, it will not be usable
anymore and another one must be created. This can be avoided by
wrapping the creation and presentation of the component in a reusable
function
Just do :
this.loading = this.loadingCtrl.create({
//loading properties
});
inside submit() before this.loading.present()

Using Ember.set to change a value, getting error that I have to use Ember.set

In my application, I have to update a record (eventToUpdate) with the data from another object (updatedEvent). To do this, I use the following code:
editEvent (updatedEvent, eventToUpdate) {
eventToUpdate.set('name', updatedEvent.name);
eventToUpdate.set('matching', updatedEvent.matching);
eventToUpdate.set('dcfEvent', updatedEvent.dcfEvent);
eventToUpdate.save().then(() => {
toastr.success('Event updated');
}).catch((error) => {
toastr.error('There occured an error while trying to update the event');
console.log(error);
});
},
When I try to update the event, I get the following error:
Assertion Failed: You must use Ember.set() to set the `name` property (of [object Object]) to `DCF tests`."
I have also tried setting the values with Ember.set, like this:
Ember.set(eventToUpdate, 'name', updatedEvent.name);
But that gives the same result..
I use Ember.js 1.13
It seems that eventToUpdate is not an Ember Object and someone is watching this property. So use Ember.set to set values:
editEvent (updatedEvent, eventToUpdate) {
Ember.set(eventToUpdate, 'name', updatedEvent.name);
Ember.set(eventToUpdate, 'matching', updatedEvent.matching);
Ember.set(eventToUpdate, 'dcfEvent', updatedEvent.dcfEvent);
eventToUpdate.save().then(() => {
toastr.success('Event updated');
}).catch((error) => {
toastr.error('There occured an error while trying to update the event');
console.log(error);
});
},
The problem lied in the structure of my data. I was trying to edit sub events, which are part of a root event. The problem was solved by first loading the single subevent from the backend and then editing that single subevent. It looks somewhat like this:
var event = this.store.findRecord('event', subevent.id);
event.set('name', updatedEvent.name);
event.set('matching', updatedEvent.matching);
event.save().then(() => {
toastr.success('element successfully updated');
}).catch((error) => {
console.log(error);
});

Facebook Graph apprequest JSON response

Getting an invalid JSON response using the Phonegap FB integration + Sencha Touch:
{"request":"12345678","to%5B0%5D":"12345678"}
Looks like some botched encoding trying to return the 'to' array.
FB.ui({
method: 'apprequests',
message: (msg) ? msg : 'Start using MyApp',
display: 'touch'
},
function(response) {
console.log(JSON.stringify(response));
if(response) {
} else {
console.log('Error parsing FB request response');
}
});
Thanks,
Steve
After trying a couple different short-term patches, I settled on a simple iterating of the object to parse out the userIds. Posting in case this helps somebody to get moving until there's a fix.
response.to = [];
for(var prop in response){
if(prop != 'request'){
response.to.push(response[prop]);
}
}