Bug 19420: Improve display of errors from failure of uploading file during stage import

To test:
1 - sudo chown www-data:www-data /tmp/koha_kohadev_upload/ (or your
                relevant dir and user)
2 - Attempt to stage a file
3 - Error message is: Upload status: Failed
4 - Apply patch
5 - Repeat upload
6 - Error is now: Failed - Directory is not writeable:
/tmp/koha_kohadev_upload
7 - Trigger the other errors if you can and note better responses

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2017-10-19 10:39:23 +00:00 committed by Jonathan Druart
parent 77ce1c6b7f
commit dcfe9844ec
2 changed files with 5 additions and 3 deletions

View File

@ -153,7 +153,7 @@ sub err {
my $err;
foreach my $f ( keys %{ $self->{files} } ) {
my $e = $self->{files}->{$f}->{errcode};
$err->{ $f } = $e if $e;
$err->{ $f }->{code} = $e if $e;
}
return $err;
}

View File

@ -59,7 +59,7 @@ function CancelUpload() {
$("#fileuploadfailed").show();
$("#fileuploadfailed").text( _("Upload status: Cancelled ") );
}
function cbUpload( status, fileid ) {
function cbUpload( status, fileid, errors ) {
if( status=='done' ) {
$("#uploadedfileid").val( fileid );
$('#fileToUpload').prop('disabled',true);
@ -72,12 +72,14 @@ function cbUpload( status, fileid ) {
}
$("#processfile").show();
} else {
var errMsgs = [ _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
$('#fileuploadbutton').show();
$("#fileuploadcancel").hide();
$("#fileuploadstatus").hide();
$("#fileuploadfailed").show();
$("#fileuploadfailed").text( _("Upload status: ") +
( status=='failed'? _("Failed"):
( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
( status=='denied'? _("Denied"): status ))
);
}