|
beforeSend(args) {
var data = JSON.parse(args.ajaxSettings.data);
if (args.action == 'read') {
// Allow custom data for upload operations
data['User_name'] = 'User1';
}
// Add custom parameter in ajax settings
args.ajaxSettings.data = JSON.stringify(data);
} |
|
[Route("FileOperations")]
public object FileOperations([FromBody] FileManagerDirectoryContent1 args)
{
// Set rules for the user
this.operation.SetRules(GetRules(args.User_name));
...
...
public AccessDetails GetRules(string user_value)
{
AccessDetails accessDetails = new AccessDetails();
List<AccessRule> accessRules = new List<AccessRule> {
// Access Rules for folder available in root folder
new AccessRule { Path = "/*.*", Role = "Adminstrator", Read = Permission.Deny, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Deny, Upload = Permission.Deny, Download = Permission.Deny},
//Access Rules for files available in root folder
new AccessRule { Path = "/*.*", Role = "Adminstrator", Read = Permission.Allow, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Deny, Upload = Permission.Deny, Download = Permission.Deny, IsFile=true},
};
accessDetails.AccessRules = accessRules;
if (user_value == "User1")
{
// Here, you need to set the role for File Manager component.
accessDetails.Role = "Adminstrator";
}
else
{
accessDetails.Role = "Document Manager";
}
return accessDetails;
} |
Hi,
We are using the permission object for restricting the file operations in FileManager control.
1)For Delete an error popup is coming up with null message. Is this message from the 'message' property of permission object in the file data or it is returned from somewhere else.
(Want to know how the Access Denied popup comes up for all operations and from where the message is fetched.)
2)Also for Copy,Cut operation, it's allowing to make the API call for copy action.(I have mage args.cancel=true for the default error popup and showing error message in another custom dialog)
How Can I get proper error mesaage for access denied (which approach)
3) If we are returning the Access denied error message from the API calls ( copy, cut) then how can we get those error messages. In the Failure event args We get some generalized error message which is shown in a dialog
By what way we can get the error messages provided by the REST APIs to show in the error notification on failure event.
Thanks
|
S.No |
Action |
Code |
Error Message | |
|
1. |
Read |
|
| |
|
2. |
Download |
|
| |
|
3. |
Upload |
|
| |
|
4. |
Delete |
|
| |
|
5. |
Copy |
|
|
// FileRules For Administrator
new AccessRule { Path = "/*.*", Role = "Administrator", Read = Permission.Allow, Write = Permission.Allow, Copy = Permission.Deny, Download = Permission.Allow, IsFile = true }, |
|
beforePopupOpen(args) {
//Prints the error message in console
console.log(
args.popupModule.element.querySelector('.e-fe-errorcontent').innerText
);
} |
Hi,
beforePopupOpen(args) { //Prints the error message in console console.log( args.popupModule.element.querySelector('.e-fe-errorcontent').innerText ); } |
In our implementation the APIs give custom error response for no file permission scenario.
1)The above mentioned error can be seen in our implemented dialogs but we can see the network error and not the API response error. For clearer notifications , we particularly want to show the error (in dialog /notification toast) which comes as response from the API controller when the API gives 400 or 401 or 500 errors with custom error response. As shown below for Copy operation (with false permission)
{
"errorCode" : "ER927",
"errorMessage" : "You do not have privileges to view or delete documents."
}
Can we fetch these errors from the control's failure event.
2) In the control I am using for Cut,Copy operations, the Control doesn't show any dialog for access denied , it directly make API calls for copy and cut operations. Hence we have thrown errors from API controller.
Contrarily for Delete operation if I don't have permission, I get a Access denied popup with message provided in permission object.
Could you please explain more about this.
Thanks.
|
beforeSend(args) {
var data = JSON.parse(args.ajaxSettings.data);
// Allow custom data for all file operations
data['User_name'] = 'User1';
// Add custom parameter in ajax settings
args.ajaxSettings.data = JSON.stringify(data);
}
failure(args) {
//Print the error message in console
console.log(args.error.message);
} |
|
//Rules for the files inside specific folder
new AccessRule { Path = "/Downloads/*.*", Role = "Adminstrator", Read = Permission.Allow, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Allow, Upload = Permission.Allow, Download = Permission.Deny, IsFile = true },
//Rules for the folders inside specific folder
new AccessRule { Path = "/Downloads/*", Role = "Adminstrator", Read = Permission.Allow, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Allow, Upload = Permission.Allow, Download = Permission.Deny, IsFile = false }, |
Hi Indhumathy ,
Our requirement for customization of error messages is not limited to Access Permission. Whenever the API fails, we need to show error message which comes from API and not a generic message like 404.
For eg: File Operation API for Search is written such that, it will give results only when user types more than 3 character. If user types 2 chars and click on search, API fails with response below:
{
}
We want to show this message to the user, instead of a generic message which comes built in like "404- -NetworkError: Failed to send on XMLHTTPRequest: ..."
We wanted to know how we can extract this message from API response. It would be really helpful.
|
public virtual FileManagerResponse Search(string path, string searchString, bool showHiddenItems = false, bool caseSensitive = false, params FileManagerDirectoryContent[] data)
{
…
…
if(searchString.Length < 5)
{
ErrorDetails er = new ErrorDetails();
er.Code = "ER002";
er.Message = "Search term should be at least 3 characters.";
searchResponse.Error = er;
}
else
{
searchResponse.Files = (IEnumerable<FileManagerDirectoryContent>)foundedFiles;
}
return searchResponse;
} |
Hi,
We are already using the failure event to retrieve the errors for all operations, But In the failure event, we are not able to get the Custom messages provides by the REST service APIs. Instead, we get the generic error as below:
"404- -NetworkError: Failed to send on XMLHTTPRequest: ..."
In our implementation , the REST service is throwing error response as below:
{
"errorCode" : "ER927",
"errorMessage" : "You do not have privileges to view or delete documents."
}
Please provide assistance to fetch these errors from the Code as we don't get any details about the API request made in the events.
Thanks
Hi,
We are using the ejs-uploader component as well and get the error response in failure event of upload operation as below:
With File manager the behavior is not the same , we get error details as:
We want error details in File manager's all operations similar to uploader component's failure event.
Could you please provide the solution as soon as possible.
|
|
|
failure(args) {
if (args.error.code == '404') {
//Modify the error message
args.error.message = 'Failed to send request to an invalid Url';
}
console.log(args);
//Append the modified error message in dialog
document.querySelector('.e-fe-errorcontent').innerText = args.error.message;
} |
|
|
Hi Indumathy,
We are looking for custom error handling for all the operations like READ,CUT,COPY,DELETE,DOWNLOAD.
It will be really helpful If we can have a quick discussion on call to get clear understanding of the issue.
Thanks.
|
public virtual FileManagerResponse Delete(string path, string[] names, params FileManagerDirectoryContent[] data)
{
FileManagerResponse DeleteResponse = new FileManagerResponse();
. . .
for (int i = 0; i < names.Length; i++)
{
bool IsFile = !IsDirectory(physicalPath, names[i]);
if(!IsFile)
{
ErrorDetails er = new ErrorDetails();
er.Message = "Folders cannot be deleted";
er.Code = "402";
DeleteResponse.Error = er;
return DeleteResponse;
} |
|
failure(args) {
if (args.error.code == '404') {
args.error.message = 'Failed to send request to an invalid Url';
}
if (args.action == 'delete') {
console.log(args.error.message);
}
console.log(args);
document.querySelector('.e-fe-errorcontent').innerText = args.error.message;
}
|