OData Configuration

Hello webix team…

I’m looking at your great article here http://webix.com/blog/tuning-webix-for-odata/

It’s great and work perfectly with open anonymous access database. But it won’t work with password protected databases. I’ve tried to change some of the code to work with token authentication from this http://databoom.space/odata-6.html but still no luck.

How to make the token authentication work?

Hello,

Did you try to login as it is described in the JavaScript part of the guide?

var db = databoom("database_link", 'collection');
db.login("username", "password").then( function(){
	webix.message('Successfully logged in.');
	db.load("collection").then(function(data){
            //parse data to Webix component
        });
});

Hello Helga…

I tried to use it, but I guess it will need too much more configuration than using the API method. And it will be easier to use multiple collection in one project with different authentication method (one using token, and others are open).

Do you have any working example with javascript method?

I tried to use it, it successfully connected (at last) but I don’t know how to display and save it. How to load the data to the table?

Here the snippet where I connected the database http://webix.com/snippet/3d9097a8 . user & pass included. Really appreciate your help here.

Hi,

it seems that there was no data in your persons collection.

I used your login and password to connect to the datatable and filled in the collection :slight_smile:

And I advise you to use parse method to add data array to a datatable. The add is used to add one data item.

Check the updated snippet, please: http://webix.com/snippet/db969136

Hi again Helga,

Thanks for your answer. It works perfectly, and thank you for the filling :slight_smile:

Btw, here’s the example on the same (but different?) database by using api only http://webix.com/snippet/e52d93fb

For example, I edit your snippet to editable and delete-able datatable http://webix.com/snippet/6fabc870

How to achieve such functional just like the api one? Can it just sync like the api?

Thank you very much.

And, if you want to use Webix odata proxy, you will need to modify its _load method to:

_load:function(view, callback, url){
    var db = databoom('https://t099.databoom.space', 'b099');
    db.login("t099", "4614").then( function(){
	   db.load("persons").then(function(data){
		   view.parse(data);
	   });
   });    	
}

Thank you Helga, that’s the code I’ve been searching for, I’ll try it now.

Euh… Helga, I still have a problem. How exactly you modify the _load method? can you give me example?

Maybe you can use this snippet for start http://webix.com/snippet/e52d93fb

Still it appeared to be much simpler than ever… just found in their API, that one can pass authorization tokens in headers as:

"Authorization": "Basic " + btoa("t099" + ":" + "4614")

http://databoom.space/manual.html#usermanagement

So all you need to set everything up is to send this header with each ajax request in the proxy without any other changes, e.g.

_load:function(view, callback, url){
	webix.ajax().headers({
            "Authorization": "Basic " + btoa("t529" + ":" + "4166")
	}).get(url).then(function(data){ ... });
}

Here’s the snippet: http://webix.com/snippet/9d102160

And you will have to organize storing and passing of the tokens in the right way.

Wow, thank you very much Helga. The solution is perfect. thank you very much for your hard work finding this.

Have a nice day :relaxed:

Hello Helga,

I managed to build “databoom data editor” from your snippet. The data load function properly, but the save function just doesn’t work. I tried using define and data processor, but both method didn’t function properly. Do you have proper method to save it?

Here’s the snippet http://webix.com/snippet/b620a8ca

Here http://webix.com/snippet/70ad8952 I define the save on the datatable hard coded than it works perfectly. But if I define it with function it’s not working.

I only use refresh. Is there any other way to reconstruct it properly so it will use the later save property?

Hi, check the updated snippet please: http://webix.com/snippet/3d8595ef

The right way to define dataprocessor later is:

var dp = new webix.DataProcessor({  
    master:$$("table1"), 
    url:url
 });

Thanks a lot Helga, your solution just made my day! :slight_smile: