I have a server backend for the filemanager, but when I return the json for a filename I don’t want to allow during the makefile call, it never shows the end user the message, and just fails silently
I disallow spaces in the filename btw
{
invalid: true,
err: "Some error message here"
}
the docs here Working with Server of UI Complex Widgets, File Manager Webix Docs don’t make it clear if a certain httpstatus is required, but I have tried 200, 400, 500 and all have no effect
Hello @jabberwock ,
To make it clear, by default the file is either added or nothing happens.
So, in your case you may need to customize the methods below to add errors handling.
-
makefile(id, name) (Backend service) . Here, you could add en error handler. For example:
makefile(id, name) {
const baseRequest = webix.ajax().post(this.url("makefile"), { id, name });
baseRequest.catch(e => { /* do something custom */ })
// keep default logic
return baseRequest.then(r => r.json());
}
This will work for request errors (404, 500, etc.) .
- Or, if your JSON response from the server looks like the example in the documentation (with invalid:true), then you will need to customize the makeFile(name) method in Operations service. In addition to the default logic, you may add your own error message.
Hi Mariya, that’s great thanks! I didn’t realise that you could override. In fact I still had to do some digging to see how to do it, and for others coming here I did
class CustomBackend extends fileManager.services.Backend {
makefile(id, name) {
const baseRequest = webix.ajax().post(this.url("makefile"), { id, name });
baseRequest.catch(e => { alert(e.responseText) })
// keep default logic
return baseRequest.then(r => r.json());
}
}
and then
webix.ui({
view: "filemanager",
container: "fileManagerContainer",
url: backendUrl,
override: new Map([
[fileManager.services.Backend, CustomBackend]
])
});