1

JS API: Get Unit list

(edited by unitedsecurity 20/10/2012 14:54:37)

Topic: JS API: Get Unit list

hello developers, i have one request. i need very simple example for getting users unit list  from test wialon with javascript API. i dont know how manipulate with sid into js API. i read sdk documentations but i cant understand how i can make that. please help me smile thanks.

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

JS API: Get Unit list

Re: JS API: Get Unit list

Hello. You can visit http://sdk.wialon.com and see examples for JS API.

Mobile Development
Gurtam
3

JS API: Get Unit list

Re: JS API: Get Unit list

thanks for answer kopa but that examples for begining develope wialon is too difficult for me. in this documentation is all examples into one object.  i need code with get units not more. please wirte if you know smile

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

JS API: Get Unit list

Re: JS API: Get Unit list

First you need to authorize to service. And then use searchItem(String/Number id, Integer dataFlags, callback?) or searchItems(Object searchSpec, Integer forceRefresh, Integer dataFlags, Integer indexFrom, Integer indexTo, callback?) function in Session object to get units. This is "Item: search" sample in the samples list. http://docs.gurtam.com/api/hosting/#wialon.core.Session

Mobile Development
Gurtam
5

JS API: Get Unit list

Re: JS API: Get Unit list

thanks kopa for answer. i write that code :

var ss = mySession.searchItem(\"11691002670134\",0x00000001,function(code,item){
        if(code){
        wialon.core.Errors.getErrorText(code);
        } else{
        alert(item);
        }
        });

but its not correct. please fix my problem. i want alert search result. thanks.

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

JS API: Get Unit list

Re: JS API: Get Unit list

searchItem(ItemId, wialon.item.Item.dataFlag.base, function(code, item){alert(item.getName());});
Mobile Development
Gurtam
7

JS API: Get Unit list

Re: JS API: Get Unit list

var ItemId = '11691002670134';
mySession.searchItem(ItemId, wialon.item.Item.dataFlag.base, function(code, item){alert(item.getName());});

error:

Uncaught TypeError: Cannot call method 'getName' of null

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

JS API: Get Unit list

Re: JS API: Get Unit list

This means an item with such itemId not exists.

id- GUID or ID of item to search for

I think you're using the hw id and it's not correct.

Mobile Development
Gurtam
9

JS API: Get Unit list

Re: JS API: Get Unit list

// get available units

    // search parameters
    var searchSpec = {
      itemsType:"avl_unit",
      propName: "sys_name",
      propValueMask: "*",
      sortType: "sys_name"
    };

    var dataFlags = wialon.item.Item.dataFlag.base|wialon.item.Item.dataFlag.image|wialon.item.Unit.dataFlag.restricted|wialon.item.Unit.dataFlag.lastMessage;
    wialon.core.Session.getInstance().searchItems(searchSpec, true, dataFlags, 0, 0, function(code, data) {
      if (code) {
        alert(wialon.core.Errors.getErrorText(code));
        return;
      }

      // TODO:
    });

Denis Strakh, Gurtam
10

JS API: Get Unit list

Re: JS API: Get Unit list

If it avails you to have more practice, the Unit search example in the Wialon Java API is a good starting point. Just be sure to make sure your username and password are kitdemo and kitdemo
Here is the example: https://sdk.wialon.com/wiki/en/local/ja … les/search

11

JS API: Get Unit list

Re: JS API: Get Unit list

hello,
I hope this example will useful for you.
https://sdk.wialon.com/playground/demo/get_units

12

JS API: Get Unit list

Re: JS API: Get Unit list

Hello, I am facing a problem,
In login it needs "token" and "operateAs",
but, how can I get this?

13

JS API: Get Unit list

Re: JS API: Get Unit list

farah.aidid wrote:

Hello, I am facing a problem,
In login it needs "token" and "operateAs",
but, how can I get this?


Hello!

First token it needs to get login with username and password manually via authorization page ( form )
Then you can use received any in login request. Please look here more information about token authorization
"operateAs" as optional parameter, it only needs to use if user login under histhelf, and then needs to login under another user

Diana Cheley
Wialon Hosting Expert
Gurtam