I have a small issue with EmberData - more precisely a problem with a relationship (orderItem --> purchaseOrder) which doesn't get loaded / fetched / mapped.
Ember Version:
"DEBUG: -------------------------------" application.js:29320
"DEBUG: Ember : 1.7.0-beta.1+canary.b1a97b3b" application.js:29320
"DEBUG: Ember Data : 1.0.0-beta.8+canary.503c75c9" application.js:29320
"DEBUG: Handlebars : 1.3.0" application.js:29320
"DEBUG: jQuery : 1.11.0" application.js:29320
"DEBUG: -------------------------------"
ApplicationStore:
Dispo.ApplicationStore = DS.Store.extend({
adapter: '-active-model'
});
Here is a part of my existing application. Well... it's a rather simple App Setup with some belongsTo and hasMany relationships...
OrderItem:
Dispo.OrderItem = DS.Model.extend({
selectedQuantity: 0,
availableQuantity: 10,
baanId: DS.attr(),
purchaseOrderId: DS.attr(),
purchaseOrder: DS.belongsTo('purchaseOrder', {async: true}),
article: DS.belongsTo('article', {async: true})
});
PurchaseOrder:
Dispo.PurchaseOrder = DS.Model.extend({
baanId: DS.attr('string'),
tradingPartner: "Sanitas Troesch AG, Simonstrasse 5, CH-9016 St. Gallen",
orderItems: DS.hasMany('orderItem', {async: true}),
pallets: DS.hasMany('pallet', {async: true})
});
Article:
Dispo.Article = DS.Model.extend({
name: DS.attr(),
articleNumber: DS.attr(),
baanId: DS.attr(),
orderItem: DS.belongsTo('orderItem', {async: true})
});
I'm not sure if there is a problem with EmberData or if I just doing something wrong :/
I can't fetch the purchaseOrder from a orderItem... btw. I'm using this command to test the functionality...
var orderItem = Dispo.OrderItem.store.findById("orderItem", 1);
Wait for a few seconds...
orderItem.get('purchaseOrderId')
1
This means basicly that the connection to the api service is working but somehow the relation doesn't work...
orderItem.get('purchaseOrder')
null
I don't get why this doesn't work because the other relation on OrderItem is working without any problems...
orderItem.get('article')
[object Object]
I hope you got enough information to help me out :)
Cheers,
Michael
btw.. here is a small json response of /line_items
{"order_items":[{"id":21,"baan_id":"22711224403-1","purchase_order_id":3,"article_id":4}]}
Related
I'm working on a test for a module, which works except for the fact that I can not access, the inner object attributes properties.
tokenStorageServiceStub = { // Mock service data
getUser: () => of({
username: 'organization-a-a-normal',
roles: ['PROCESSOR'],
attributes: {
organizationId: 111,
organizationName: 'Org.name Aa',
userFullName: 'User for organization A-A',
userId: 22,
},
access_token: 'AT01',
refresh_token: 'RT01',
token_type: 'Bearer',
expires_in: 3600,
}),
};
The component code complains about the last statement:
this.activeTokens = this.token.getUser(); // OK
this.username = this.activeTokens.username; // OK
this.organization.id = this.activeTokens.attributes.organizationId; // `attributes` is undefined?
Chrome Headless 88.0.4298.0 (Linux x86_64) SettingsComponent should create FAILED
TypeError: Cannot read property 'organizationId' of undefined
at SettingsComponent.call [as ngOnInit] (src/app/organization/settings/settings.component.ts:22:61)
I think it's because of the innerworking of the RxJs.of() function. In the manual, I see things like ObservableInput. But there is no mention of Objects as such.
I also read about of() getting deprecated? What will be a good approach to pass my object data in a test service stub?
I am using simple peer for my video call web application. when I call people in the same network video call is working perfectly. But in the different networks, it is not working. I also added ICE servers(stun/turn) to simple peer. Still, the same issue is happening can anyone please help me out. I am getting this issue in the console
Error: Connection failed. at h (index.js:17)at f.value (index.js:654) at RTCPeerConnection.t._pc.onconnectionstatechange (index.js:119)
const peer = new Peer({
initiator: true,
trickle: false,
stream,
config: {
iceServers: [
{
urls: "stun:numb.viagenie.ca",
username: "************",
credential: "************"
},
{
urls: "turn:numb.viagenie.ca",
username: "************",
credential: "************"
}
]
}
});
I had facing through the same issue.
I'm not sure if that has to do with those specific iceServers but I replace them with this ones on it works
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:19302' },
{ urls: 'stun:stun3.l.google.com:19302' },
{ urls: 'stun:stun4.l.google.com:19302' },
{
url: 'turn:turn.bistri.com:80',
credential: 'homeo',
username: 'homeo',
},
{
url: 'turn:turn.anyfirewall.com:443?transport=tcp',
credential: 'webrtc',
username: 'webrtc',
},
Everything is working good but now my problem is that safari is not working just chrome with iOS
If someone knows how to handle this compatibility please contact me! :D
my issue here was with the stun/turn server.we can check the status of servers using
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
If you test a STUN server, it works if you can gather a candidate with type "srflx". If you test a TURN server, it works if you can gather a candidate with type "relay".
check you are getting this
Below sample code is not working in latest fix on Android but if we remove the password field from options then it's working fine. We are getting below error on Android but it's working fine on IOS
{"src":"initCollection","err":-3,"msg":"INVALID_KEY_ON_PROVISION","col":"people","usr":"test","doc":{},"res":{}}
function wlCommonInit(){
/*
* Use of WL.Client.connect() API before any connectivity to a MobileFirst Server is required.
* This API should be called only once, before any other WL.Client methods that communicate with the MobileFirst Server.
* Don't forget to specify and implement onSuccess and onFailure callback functions for WL.Client.connect(), e.g:
*
* WL.Client.connect({
* onSuccess: onConnectSuccess,
* onFailure: onConnectFailure
* });
*
*/
// Common initialization code goes here
}
function onClick(){
alert("Click");
var collectionName = 'people';
// Object that defines all the collections.
var collections = {
// Object that defines the 'people' collection.
people : {
// Object that defines the Search Fields for the 'people' collection.
searchFields : {name: 'string', age: 'integer'}
}
};
// Optional options object.
var options = {
username:"test",
// Optional password, default no passw`enter code here`ord.
password : '123',
};
WL.JSONStore.init(collections, options)
.then(function () {
alert("Success in jstore");
})
.fail(function (errorObject) {
// Handle failure for any of the previous JSONStore operations (init, add).
alert("Failure in jstore : "+ JSON.stringify(errorObject));
});
};
Update: The iFix is now released. Build number is 7.1.0.0-IF201610060540 .
This is a known issue with the latest available iFix. It has been recently fixed and should be available soon.
Keep an eye out for a newer iFix release in the IBM Fix Central website for a fix for this issue.
i use reste library to handle api on titanium appcelerator :
this is my config :
api.config({
debug : true,
autoValidateParams : false,
validatesSecureCertificate : false,
timeout : 4000,
url : Kb.baseUrl,
models: [{
name: "product",
id: "id",
//content: "retArray",
collections: [{
name: "products",
content: "response",
read: "get_products"
}],
}],
methods : [
{
name : "get_products",
post : "api/get_product"
}
],
...
So this how i fetch (works perfectly) :
var p = Alloy.Collections.get_products;
p.fetch({
success:function(m,r){
console.log(r)
}
});
Now i have to past object to post (this not working, why?) :
p.fetch({
data:{'id':'2'},
success:function(m,r){ console.log(r); }
});
This second fetch not working, have you an idea ?
thanks.
In your config you're not specifying what to do with the id parameter. RESTe doesn't know (or care) about your API -- i.e if it's REST / PUT, GET based or POST, GET etc. So you need to tell it.
Change your method to:
{
name : "get_products",
post : "api/get_product/<id>"
}
and it should work fine. The flexibility here allows RESTe to work with APIs that don't conform to the normal REST pattern so if it required say:
"api/get_product?id=<id>"
for example.
Is there a way to output the json-string read by my store in sencha touch 2?
My store is not reading the records so I'm trying to see where went wrong.
My store is defined as follows:
Ext.define("NotesApp.store.Online", {
extend: "Ext.data.Store",
config: {
model: 'NotesApp.model.Note',
storeId: 'Online',
proxy: {
type: 'jsonp',
url: 'http://xxxxxx.com/qa.php',
reader: {
type: 'json',
rootProperty: 'results'
}
},
autoLoad: false,
listeners: {
load: function() {
console.log("updating");
// Clear proxy from offline store
Ext.getStore('Notes').getProxy().clear();
console.log("updating1");
// Loop through records and fill the offline store
this.each(function(record) {
console.log("updating2");
Ext.getStore('Notes').add(record.data);
});
// Sync the offline store
Ext.getStore('Notes').sync();
console.log("updating3");
// Remove data from online store
this.removeAll();
console.log("updated");
}
},
fields: [
{
name: 'id'
},
{
name: 'dateCreated'
},
{
name: 'question'
},
{
name: 'answer'
},
{
name: 'type'
},
{
name: 'author'
}
]
}
});
you may get all the data returned by the server through the proxy, like this:
store.getProxy().getReader().rawData
You can get all the data (javascript objects) returned by the server through the proxy as lasaro suggests:
store.getProxy().getReader().rawData
To get the JSON string of the raw data (the reader should be a JSON reader) you can do:
Ext.encode(store.getProxy().getReader().rawData)
//or if you don't like 'shorthands':
Ext.JSON.encode(store.getProxy().getReader().rawData)
You can also get it by handling the store load event:
// add this in the store config
listeners: {
load: function(store, records, successful, operation, eOpts) {
operation.getResponse().responseText
}
}
As far as I know, there's no way to explicitly observe your response results if you are using a configured proxy (It's obviously easy if you manually send a Ext.Ajax.request or Ext.JsonP.request).
However, you can still watch your results from your browser's developer tools.
For Google Chrome:
When you start your application and assume that your request is completed. Switch to Network tab. The hightlighted link on the left-side panel is the API url from which I fetched data. And on the right panel, choose Response. The response result will appear there. If you have nothing, it's likely that you've triggered a bad request.
Hope this helps.
Your response json should be in following format in Ajax request
{results:[{"id":"1", "name":"note 1"},{"id":"2", "name":"note 2"},{"id":"3", "name":"note 3"}]}
id and name are properties of your model NOte.
For jsonp,
in your server side, get value from 'callback'. that value contains a name of callback method. Then concat that method name to your result string and write the response.
Then the json string should be in following format
callbackmethod({results:[{"id":"1", "name":"note 1"},{"id":"2", "name":"note 2"},{"id":"3", "name":"note 3"}]});