added error status messages

This commit is contained in:
hamza zia 2015-04-19 15:35:13 +08:00
parent 8ff7145597
commit 2e26cabb8a
3 changed files with 84 additions and 6 deletions

View File

@ -52,6 +52,8 @@
<script src="js/services/modals.js"></script>
<script src="js/services/alerts.js"></script>
<script src="js/services/errors.js"></script>
<script src="js/services/settings/settings.js"></script>
<script src="js/services/settings/filters.js"></script>
@ -536,16 +538,17 @@
</ul>
<ul class="stats pull-left" ng-switch-when="error">
<!-- {{{ error download statistics -->
<li class="label label-important">
<span title="Download Status"><span class="fa fa-fw fa-times-circle">&nbsp;</span> {{download.status}}</span>
<li class="label label-danger">
<span title="Error "><span class="fa fa-fw fa-times-circle">&nbsp;</span> {{getErrorStatus(download.errorCode)}}</span>
</li>
<li class="label label-important">
<li class="label label-default">
<span title="Download Size"><span class="fa fa-fw fa-cloud-download">&nbsp;</span> {{download.fmtTotalLength}}</span>
</li>
<li class="label label-important hidden-phone">
<li class="label label-default hidden-phone">
<span title="Download Path"><span class="fa fa-fw fa-folder-open">&nbsp;</span> {{download.dir}}</span>
</li>

View File

@ -3,15 +3,16 @@ angular
"ui.bootstrap",
'webui.services.utils', 'webui.services.rpc', 'webui.services.rpc.helpers', 'webui.services.alerts',
'webui.services.settings', 'webui.services.modals', 'webui.services.configuration',
'webui.services.errors',
])
.controller('MainCtrl', [
'$scope', '$name', '$enable', '$rpc', '$rpchelpers', '$utils', '$alerts', '$modals',
'$fileSettings', '$activeInclude', '$waitingExclude', '$pageSize',
'$fileSettings', '$activeInclude', '$waitingExclude', '$pageSize', '$getErrorStatus',
// for document title
'$rootScope',
function(
scope, name, enable, rpc, rhelpers, utils, alerts, modals,
fsettings, activeInclude, waitingExclude, pageSize,
fsettings, activeInclude, waitingExclude, pageSize, getErrorStatus,
rootScope
) {
@ -298,6 +299,10 @@ function(
+ scope.stopped.length;
}
scope.getErrorStatus = function(errorCode) {
return getErrorStatus(+errorCode);
}
// actual downloads used by the view
scope.getDownloads = function() {
var downloads = [];
@ -366,6 +371,7 @@ function(
numPieces: d.numPieces,
connections: d.connections,
bitfield: d.bitfield,
errorCode: d.errorCode,
totalLength: d.totalLength,
fmtTotalLength: utils.fmtsize(d.totalLength),
completedLength: d.completedLength,
@ -386,6 +392,7 @@ function(
else {
ctx.dir = d.dir;
ctx.status = d.status;
ctx.errorCode = d.errorCode;
ctx.gid = d.gid;
ctx.followedBy = (d.followedBy && d.followedBy.length == 1
? d.followedBy[0] : null);

68
js/services/errors.js Normal file
View File

@ -0,0 +1,68 @@
angular
.module('webui.services.errors', [])
.value('$getErrorStatus', function(errorCode) {
// normalize it to 0
errorCode = errorCode - 1;
switch(errorCode) {
case 0:
return "download was successful";
case 1:
return "unknown error occurred";
case 2:
return "time out occurred";
case 3:
return "resource was not found";
case 4:
return 'aria2 saw the specified number of "resource not found" error. See --max-file-not-found option';
case 5:
return "download aborted because download speed was too slow. See --lowest-speed-limit option";
case 6:
return "there were unfinished downloads";
case 7:
return "remote server did not support resume when resume was required to complete download";
case 8:
return "not enough disk space available";
case 9:
return "piece length was different from one in .aria2 control";
case 10:
return "downloading same file at that moment";
case 11:
return "downloading same info hash torrent at that moment";
case 12:
return "file already existed";
case 13:
return "renaming file failed";
case 14:
return "could not open existing file";
case 15:
return "could not create new file or truncate existing file";
case 16:
return "file I/O error occurred";
case 17:
return "could not create directory";
case 18:
return "name resolution failed";
case 19:
return "could not parse Metalink document";
case 20:
return "FTP command failed";
case 21:
return "HTTP response header was bad or unexpected";
case 22:
return "too many redirects occurred";
case 23:
return "HTTP authorization failed";
case 24:
return "could not parse bencoded file";
case 25:
return ' ".torrent" file was corrupted or missing information ';
case 26:
return "Magnet URI was bad";
case 27:
return "bad/unrecognized option was given or unexpected option argument was given";
case 28:
return "remote server was unable to handle the request due to a temporary overloading or maintenance";
case 29:
return "could not parse JSON-RPC request";
}
});