Error while using a proxy with the filemanager widget

Hello,

I’m trying to use the filemanager widget in a jet app, with a proxy to intercept all ajax calls made by the filemanager to load and update data on the server.

After many, many trials and errors, I came up with the following code, which seems to work, in the sense that the filemanager calls the proxy when loading data and when something change (ex: new folder, rename folder …).

The problem is: for loading the data, filemanager calls the “load” member function of the proxy. For changing the date (new folder, rename folder), I was expecting the filemanager to call the “save” method of the proxy, which exists. Instead it calls the “load” method.

Is this a correct behaviour ? Reading the docs it should not be like this.
Thank you everybody for any help

Regards

Antonio

THE CODE:

export default class DataView extends JetView{

config(){
	// Get the theme in use
	const theme = this.app.config.theme;
	
	// Access to the "locale plugin service
	const _ = this.app.getService("locale")._;
	
	return { 
		view:"filemanager", 
		id: "admin:files",
		autoConfig:true, 
		css: theme,
		// The url will be used to load data when the filemanager is initialized
		// We don't specify a url but use a proxy object. The load method of the proxy will be called.
		url: fileSystemProxy,  
		// We use a proxy also to update data on the server.
		handlers:{
			upload: fileSystemProxy,
			download: fileSystemProxy,
			copy: fileSystemProxy,
			move: fileSystemProxy,
			remove: fileSystemProxy,
			rename: fileSystemProxy,
			create: fileSystemProxy,
			branch: fileSystemProxy,		// for dynamic loading in the "branch" mode 
			files: fileSystemProxy,			// for dynamic loading in the "files" mode 
			search: fileSystemProxy			// for server-side searching for a file 
		} 
	}
}

Hello @antlomb,

Is this a correct behaviour ?

In this specific case this is the expected behaviour, as all of the file manager handlers will form their requests via the load() method.

Reading the docs it should not be like this.

You are probably referring to the way the other data components make calls to the save() and load() methods in different cases (i.e. in the case of a “rename” operation the save() method would get called, same with the “insert” operation - this is a different matter for the file manager widget).

O, thank you @Dzmitry, nice to know that filemanager form all the requests via the load() method.

Just one more question: is it possible that for operations like “rename” and “delete” the “source” and “target” values does not contain the full path ? That’s how the filemanager is calling my proxy, and I’m actually in trouble becouse without the full path I don’t know what to rename or delete.

Thanks again

Just one more question: is it possible that for operations like “rename” and “delete” the “source” and “target” values does not contain the full path ? That’s how the filemanager is calling my proxy, and I’m actually in trouble becouse without the full path I don’t know what to rename or delete.

The file manager widget provides the getPath() method that lets you return the full path of a specific item. More specifically, it returns an array of paths for every level preceeding the current item (including, of course, the full path to the item as well). The full path is stored as the last value of that array, which is why you will have to return the last value from that array.

As for the “source” and “target” parameters of the query, it is indeed possible to change them. However, I am wondering why you’d want to change the “source” parameter in any way for these handlers, since they already contain the full path to the item (by default)?

Here is an example for a custom proxy used in the “rename” handler: https://snippet.webix.com/ke9cquwd (unfortunately, our backend is down at the moment, apologies for the inconvenience).

Thank you @Dzmitry, I followed your indication with two adjustments:

  • I used getPathNames and not getPath, which returns ids and not values
  • I had to create a string adding all the values in the array to create the full path
    Antonio

I would suggest doing some additional debugging to see if you can figure out what is causing the filemanager to call the “load” method instead of the “save” method.