1

JS API: get and set customProps

(20/10/2012 14:51:43 отредактировано unitedsecurity)

Тема: JS API: get and set customProps

i want set custom props for user and after log in get this props and use that values for user interface.  please show me example how to use customProps // GET AND SET.
thanks...

Великий и ужасный Гиоргий Каладзе
2

JS API: get and set customProps

Re: JS API: get and set customProps

//Get props          
console.log(user.getName(),user.getCustomProps());            
//Set props          
var props = [{name: "John", value: "Doe"}, {name: "Foo", value: "Bar"}];        
wialon.core.Remote.getInstance().startBatch();
for(var i=0;i <props.length; i++)
    user.updateCustomProperty(props[i].name, props[i].value);//Update custom property, require ACL bit wialon.item.Item.accessFlag.editOther over item        
wialon.core.Remote.getInstance().finishBatch(function() {              
    console.log(user.getName(),user.getCustomProps());
});

Development Department
Gurtam
3

JS API: get and set customProps

Re: JS API: get and set customProps

thanks zuve for answer but how to define user?

Великий и ужасный Гиоргий Каладзе
4

JS API: get and set customProps

Re: JS API: get and set customProps

You can get user in 3 ways:
1) by id
var user =  wialon.core.Session.getInstance().getItem(id);   
console.log(user);

2) by name        
var spec = {itemsType: "user", propName: "sys_name", propValueMask: "name", sortType: ""};
wialon.core.Session.getInstance().searchItems(spec, 2, wialon.item.Item.dataFlag.base, 0, 0, qx.lang.Function.bind(function(code, result) {            
    if (code || !result || typeof result.items == "undefined" || !result.items.length)
        return;
    console.log(result.items[0]);
}, this));

3) get current user
var user = wialon.core.Session.getInstance().getCurrUser();
console.log(user);


note for 1) and 2): you can only get those users that you can access according access rights

Development Department
Gurtam
5

JS API: get and set customProps

Re: JS API: get and set customProps

Well in your other post you tell me about reading SDK carefully... OK i was try but i think  SDK have very bad logic...
for example i want learn how to use getCustomProps() i searching into SDK.... aaand its Results :

JS API: get and set customProps

Please tell me how to use This SDK Properly.

Добавлено спустя   6 минут  9 секунд:
well zuve thats answer.... thanks again. but look bro into SDK this function getCustomProps();  is Posted into Wialon.item.Item but this Wialon.item.Item Not applicable at this moment... and into SDK is not examples like your post. therefore i post here for help ...

Великий и ужасный Гиоргий Каладзе
6

JS API: get and set customProps

Re: JS API: get and set customProps

You can't write like this: wialon.item.Item.getCustomProps() because THIS METHOD ISN"T STATIC

Development Department
Gurtam
7

JS API: get and set customProps

Re: JS API: get and set customProps

yes you know about that but when developer begin learning your SDK he couldn’t understand about that...

Великий и ужасный Гиоргий Каладзе
8

JS API: get and set customProps

Re: JS API: get and set customProps

in API docs all members of class are grupped by their types. and getCustomProps situated in METHODS section

Development Department
Gurtam