Filemanager Error Handling

If I have an handler for copy
If I select some items and then do a paste, my web service is called
If the service request fails the items are still displayed in the target folder

I have an OnErrorResponse event handler - but the problem the problem is the items are still in the target folder.

Also - if the copy succeeds - how do I update the internal data model with the new unique ids that should be returned from the service call.

Hi,

Filemanager reloads data on error response. It is a default behaviour.

If the copy succeeds - how do I update the internal data model with the new unique ids that should be returned from the service call.

The response should be a json array with objects including “id” (the new id) and “value” (the new value) properties:

[
   {
     "id":"folder\\/new_file.html",    
     "value":"new_file.html"
    }
]

Hello,
I’ve been working on an interface using webix file manager, which is a great tool, and I’m thankful for your team’s work so far.

Everything works fine clientside (I got some major problems with my storage provider), except for how webix deals with the answers I send from the server.
I’m currently working on “move”, and I can’t find what to pass on as a response, since my files are moving in the database, but not in the file manager. I’ve tried passing a large range of everything, but nothing works.

For the “move” function, the best response that kinda worked was sending an array of all the files like this :

return res.send(JSON.stringify([
 { id: 575fcff0d2fa864417be1a25,
    value: 'b.txt',
    type: 'text',
    date: 1465896944,
    size: 6 },
  { id: 575fd068d2fa864417be1a29,
    value: 'a.txt',
    type: 'text',
    date: 1465897064,
    size: 6 },
  { id: 575fcf78d2fa864417be1a1d,
    value: 'c.txt',
    type: 'text',
    date: 1465896824,
    size: 6 }
 ]));

When I do this, I might have one of the files that disappear from the original folder, the other ones don’t change, and when I look in the target folder, the one that disappeared is “undefined”.
When I reload, everything is fine.

But if I try sending the array you mentioned, like this :

[
   {
     "id":"folder\\/new_file.html",    
     "value":"new_file.html"
    }
]

I get nothing.

Can I get some help, please ? I can’t find exactly what I’m asking in the docs…

Thank you for your time.

Hello,

If you do not want to update moved items, the response can be an empty array for example.

If you want to change ids or names, the response should be an array of objects with id and value. For example, if you moved 3 files, the response should be an array of three objects:

[{“id”: “new_id_0”, “value”:“new_name_0”},{“id”: “new_id_1”, “value”:“new_name_1”},…]

When I do this, I might have one of the files that disappear from the original folder

Could you provide an examples of a request and response ?

Thank you for your quick response !

I do want to update moved items, that’s my problem, nothing is updating.

Here is a practical example :

I load into webix (fManager.load()) this JSON array :

{"id":"Files",
"data":
[{"id":"575fcf10d2fa864417be1a17",
"path":"Documents",
"value":"Documents",
"type":"folder",
"data":
[{"id":"575fcf66d2fa864417be1a19",
"path":"Documents/Test",
"value":"Test",
"type":"folder",
"date":1465896806,
"size":0,
"data":[]},
{"id":"575fd0bfd2fa864417be1a2a",
"path":"Documents/Projets",
"value":"Projets",
"type":"folder",
"date":1465897151,
"size":0,
"data":
[{"id":"575fd26bc8171e1c13e9f074",
"path":"Documents/Projets/zBCJSMb.jpg",
"value":"zBCJSMb.jpg",
"type":"image",
"date":1465897579,
"size":540773},
{"id":"575fd068d2fa864417be1a29",
"path":"Documents/Projets/a.txt",
"value":"a.txt",
"type":"text",
"date":1465897064,
"size":6},
{"id":"575fcff0d2fa864417be1a25",
"path":"Documents/Projets/b.txt",
"value":"b.txt",
"type":"text",
"date":1465896944,
"size":6},
{"id":"575fcf78d2fa864417be1a1d",
"path":"Documents/Projets/c.txt",
"value":"c.txt",
"type":"text",
"date":1465896824,
"size":6},
(...)
{"id":"575fcf93d2fa864417be1a22",
"path":"Documents/i.txt",
"value":"i.txt",
"type":"text",
"date":1465896851,
"size":6},
(...)]}]}

It works perfectly, everything is showned as expected.

Then I try to move. Here is the request (req.body) I get in my move function :

{ action: ‘move’,
source: ‘575fd068d2fa864417be1a29,575fcff0d2fa864417be1a25,575fcf78d2fa864417be1a1d,575fcfbad2fa864417be1a23’,
temp: ‘575fd068d2fa864417be1a29,575fcff0d2fa864417be1a25,575fcf78d2fa864417be1a1d,575fcfbad2fa864417be1a23’,
target: ‘575fcf66d2fa864417be1a19’ }

I process this, move the files in my database accordingly, everything works fine. Then I send this response (which is wrong obviously) :

[ { id: '575fd068d2fa864417be1a29',
    value: 'a.txt',
    type: 'text',
    date: 1465897064,
    size: 6 },
  { id: '575fcfbad2fa864417be1a23',
    value: 'j.txt',
    type: 'text',
    date: 1465896890,
    size: 6 },
  { id: '575fcff0d2fa864417be1a25',
    value: 'b.txt',
    type: 'text',
    date: 1465896944,
    size: 6 },
  { id: '575fcf78d2fa864417be1a1d',
    value: 'c.txt',
    type: 'text',
    date: 1465896824,
    size: 6 } ]

And nothing changes.

I tried with [{id: “id”, value: “value”},…] as you suggested, but it does nothing.

I get what you’re saying, but my Ids dont change, nor does the value, since the file just change parents.

Should I change my whole array mapping process so the ids are set to the path to each objects ? I’m a little bit confused…

Thank you very much for your time.

PS: sorry for the formatting, I hope it’s clear enough… tell me if you need any other information.

The order is important. The order of items in the response should correspond the order in the request: “575fd068d2fa864417be1a29” is the 1st, “575fcff0d2fa864417be1a25” the second, …

Also the response should be a valid json (use double quotes for keys and values)

If you do not want to change ids and values, just use an empty array ( [] ) as a response

I need to change ids and values in webix, or it will crash if you try to modify twice the same file (let’s say copy a file then rename the copied file)

Here is my last unsuccessful try :

request :

{ action: 'move',
  source: '575fcf10d2fa864417be1a17/575fcf93d2fa864417be1a22,575fcf10d2fa864417be1a17/575fcf86d2fa864417be1a21',
  temp: '575fcf10d2fa864417be1a17/575fcf93d2fa864417be1a22,575fcf10d2fa864417be1a17/575fcf86d2fa864417be1a21',
  target: '57601144ad74dfd4121723a7' }

response (res.send) :

[{"id":"57601144ad74dfd4121723a7/575fcf93d2fa864417be1a22",
"value":"i.txt"},
{"id":"57601144ad74dfd4121723a7/575fcf86d2
fa864417be1a21",
"value":"h.txt"}]

As you can see, I got the response in double quotes, and in the same order as the request. Nothing changed in webix… I’m growing desperate.

Again, thank you so much for your help !

Edit : I think I should mention, I tried sending back an empty array, the view of the files did not change. Perhaps the problem is elsewhere ? Do I need to put anything in my fileManager ?

Here it is if you want a look :

webix.ready(function(){
    webix.i18n.setLocale('fr-FR');
	var fManager = new webix.ui({
        view:"filemanager",
        multiple: false,
        id:"files",
        handlers:{
            "upload": clientId + "/data/upload",
            "create": clientId + "/data/create",
            "download": "data/download",
            "rename": "data/rename",
            "copy": "data/copy",
            "move": "data/move",
            "remove": "data/remove"
        }
    });
    fManager.load('./getFiles/' + clientId);
});

Edit2: I think I should also mention that if I move only ONE file, everything works fine, the file manager is updated. All of my response problems are connected to manipulating multiple files…

Edit3 : I’ve tried again and again, searched through your website, and found one of your responses, where you linked one of your samples (http://docs.webix.com/samples/64_file_manager/01_basic/04_operations.html). It seems like when you move/delete/copy multiple files, it doesn’t show the changes most of the time (but sometimes it does…)

Hi,

I’ve just sent a PM with the demo. Hope it’ll help.