I have a horizon app and try to update user data, have no errors but when I look in admin, the table is not changed. I probably miss something stupid. What I do is:
var user = this.props.data.horizon.currentUser();
user.data = {};
user.data.email = this.refs.email.value;
user.data.phone = this.refs.phone.value;
this.props.data.horizon("users").replace(user);
any ideas what am I doing wrong?
Related
I'm trying to use an existing Consul cluster as the membership provider for a test Orleans application.
I get this error when connecting my client app to the Silo
Could not find any gateway in Orleans.Runtime.Host.ConsulBasedMembershipTable. Orleans client cannot initialize.
Digging into the ConsulUtils class, the entries being retrieved have no ProxyPort defined - and are discarded - hence the empty result set.
I initialize the silo like this:
var clusterConfiguration = new ClusterConfiguration();
clusterConfiguration.Globals.DataConnectionString = "http://localhost:8500";
clusterConfiguration.Globals.DeploymentId = "OrleansPlayground";
clusterConfiguration.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.Custom;
clusterConfiguration.Globals.MembershipTableAssembly = "OrleansConsulUtils";
clusterConfiguration.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.Disabled;
var silohost = new SiloHost("Fred", clusterConfiguration);
silohost.InitializeOrleansSilo();
startup = Task.Factory.StartNew(() =>
{
return silohost.StartOrleansSilo();
});
return true;
And I set my client app up like this:
var config = new ClientConfiguration();
config.CustomGatewayProviderAssemblyName = "OrleansConsulUtils";
config.DataConnectionString = "http://localhost:8500";
config.DeploymentId = "OrleansPlayground";
config.GatewayProvider = ClientConfiguration.GatewayProviderType.Custom;
GrainClient.Initialize(config);
Looking at the code in ConsulUtils I can see that the ProxyPort isn't set (i.e. is 0) when the entry is saved. So I'm assuming I have a problem when initializing the silo - but I can't figure out what it is!
Without digging deep in, does sound like a bug. Please repost on GitHub and we will try to help you.
In my app, I have users and posts, and I am trying to instantiate my Activity class which has pointers to user and post objects. Here is my code:
var Activity = Parse.Object.extend("Activity");
var User = Parse.Object.extend("_User");
var Post = Parse.Object.extend("Posts");
var activityHandler = function(request, response){
//toUser is the objectId of the User not the object itself.
var toUserId = request.toUser;
var fromUserId = request.fromUser;
var postId = request.post;
var arg = request.argument;
var toUser = new User();
toUser.set("objectId",toUserId);
var fromUser = new User();
fromUser.set("objectId",fromUserId);
var post = new Post();
post.set("objectId",postId);
var activity = new Activity();
activity.set("activityFrom", fromUser);
activity.set("activityTo", toUser);
activity.set("argument", arg);
activity.set("post", post);
activity.save(null, {
useMasterKey: true,
success: function(o){
console.log("activity logged successfully");
response.success();
},
error: function(err){
console.log(err);
},
}
);
};
Parse.Cloud.define("createActivity", activityHandler);
The code is self-explanatory, but just to summarize, the client sends the appropriate user and post IDs, and the cloud function should instantiate a new Activity object, with pointers to the users and post. However, when I try to save, I'm getting:
{"code":141,"error":"Uncaught Tried to save an object with a pointer to a new, unsaved object."}
The problem is that, the object IDs sent to the function are completely valid, already-existing objects in the database. ACL is also not an issue as I'm on the master key.
What am I doing wrong?
It was my bad.
There were multiple problems with my code.
I was using object.set("objectId", id); syntax, which actually should be object.id = id. I'm not sure if it is necessary, maybe it would work without that change too, but I've read everywhere that it's a bad practice.
I wasn't getting the request parameters correctly. I was using request.param1 instead of request.params.param1, and the parameter variable was undefined. I haven't checked if it was undefined or not for a long time, as the error message wasn't really helpful about parameter being undefined, from my perspective back then. (now it makes sense, no ID, and it automatically tries to create a new object)
I've corrected them and it does save correctly now.
This also happens when you forget to call the method:
response.success(object);
How do you delete roles in Parse.com using Cloud Code? I checked: https://parse.com/docs/js/symbols/Parse.Role.html, and it doesn't document any destroy method.
I am creating a role for every group of members, and I'd like to get rid of the role when the group is destroyed. What is the correct way of doing so?
Have you seen:
role.getUsers().remove(user);
This one works for me:
const roles = await new Parse.Query(Parse.Role).find();
await Parse.Object.destroyAll(roles, {useMasterKey: true}};
I played around with this for hours before getting it to work by fluke (no thanks to deficient and incorrect documentation)...
This is architecturally incorrect but the only way I could hack it together was using async function with await + promise... I do not understand Parse's weird mechanics sometimes. It's a love & hate relationship!
// Get user to delete object
let userToDeleteObject = await new Parse.Query(Parse.User)
.equalTo('objectId', userToDelete)
.find({useMasterKey: true});
// Remove user from group role
let roleDeleteQuery = new Parse.Query(Parse.Role);
roleDeleteQuery.contains("name", groupName);
roleDeleteQuery.first({useMasterKey: true})
.then(function(roleObject) {
roleObject.relation("users").remove(userToDeleteObject);
roleObject.save(null, {useMasterKey: true});
});
Could anyone say how to restart it?
I found this sample and try to adapt it for me:
var appLauncher:File;
appLauncher = new File(File.applicationDirectory.nativePath).parent.parent.resolvePath("Contents").resolvePath("MacOS").resolvePath("FlashApp");
var npInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo;
npInfo.executable = appLauncher;
var _args:Vector.<String> = new Vector.<String>;
npInfo.arguments = _args;
var np:NativeProcess = new NativeProcess;
np.start(npInfo);
np.exit();
But I don't understand how it should work.. Now nothing happends when this function called frome one of my classes.
Did you try it with ADL? Or with actually packaged/installed app?
It is related its package structure.
If you try with ADL, it may not work.
Also,
"FlashApp" must be changed to the name of your application,
The last line should be exit(); of your NativeApplication, not np.exit()
Hi I need to implement keep login in my sencha touch application
Please see my code below:
Login.js - Once user click login, it will store "sessionToken" in local storage.Then it will go to main Page
onBtnLoginClick: function(){
var loginviewGetValue = Ext.getCmp('loginview').getValues();
var bbid = Ext.getCmp('bbID').getValue();
var bbpassword = Ext.getCmp('bbPassword').getValue();
var LoginLS = Ext.getStore('LoginLS');
LoginLS.add({
sessionId: 'sadsadsadasd'
,deviceId:'1'
,bb_id :bbid
});
LoginLS.sync();
var mainForm= Ext.create('bluebutton.view.Main');
Ext.Viewport.setActiveItem(mainForm);
App.js~ Everytime launch function will check sessionToken in localStorage. If Localstorage is empty then it will go to login page.Else it will go to main Page
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
var LoginLS = Ext.getStore('LoginLS');
LoginLS.load();
var record = LoginLS.getAt(0);
if(record != undefined){
var sessionId = record.get('sessionId');
if (sessionId !=undefined){
Ext.Viewport.add(Ext.create('bluebutton.view.Main'));
}
else
Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
}
else{
Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
}
// Ext.create('bluebutton.view.TopMenuList');
},
Logout.js~Logout will clear the sessionToken and go to login page again
onLogoutClick: function scan() {
var LoginLS = Ext.getStore('LoginLS');
Ext.Viewport.setMasked({
xtype: 'loadmask',
message: 'Loading...'
});
LoginLS.load();
var record = LoginLS.getAt(0);
LoginLS.removeAll();
LoginLS.sync();
//Load a new view
// Ext.getCmp('tabpanel').destroy();
var loginForm = Ext.create('bluebutton.view.Login');
Ext.Viewport.setActiveItem(loginForm);
Ext.Viewport.setMasked(false); // hide the load screen
But i having a problem now. I not able to go back login page. It go to the blank page. Please give me some solution. Thanks.
Here is the error i get
[WARN][Ext.data.Batch#runOperation] Your identifier generation strategy for the model does not ensure unique id's. Please use the UUID strategy, or implement your own identifier strategy with the flag isUnique. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`loginview`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`bbID`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`bbPassword`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`btnLogin`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[DEPRECATE][bluebutton.view.Login#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);
Looking at the error messages it is clear that you are trying to create login panel again without destroying existing component. Error comes because you are not allowed to use same id more than once in application.
To avoid this you should not create same view multiple times, you should reuse views which is good for performance also. One more thing, you should give id to n element if and only if you can't do without it.
Assuming you cannot avoid id attributes you should do one of these 2 things:
Create new view only if it doesn't exist
var loginView = Ext.getCmp("loginview");
if(!loginView){
loginView = Ext.create('bluebutton.view.Login');
}
destroy login view as soon as it is out(hide/erased) of viewport by calling:
var loginView = Ext.getCmp("loginview");
loginView.destroy();
Use itemId for your components instead of idand reference them accordingly in you Controller. Check this question out: Warning saying `Id` exist and should be destroyed