[WebUI] Handle torrent add failures

Closes #2253.
This commit is contained in:
DjLegolas 2019-06-21 09:09:12 +03:00
parent 3365201011
commit 24b094a04a
5 changed files with 43 additions and 2 deletions

View File

@ -2,6 +2,10 @@
## 2.0.4 (WIP)
### WebUI
- Handle torrent add failures
### Documentation
- Add How-to guides about services.

View File

@ -235,6 +235,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.url = new Deluge.add.UrlWindow();
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
this.url.on('add', this.onTorrentAdd, this);
this.url.on('addfailed', this.onTorrentAddFailed, this);
}
this.optionsPanel.form.getDefaults();
@ -258,6 +259,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
url: deluge.config.base + 'upload',
waitMsg: _('Uploading your torrent...'),
success: this.onUploadSuccess,
failure: this.onUploadFailure,
scope: this,
torrentIds: torrentIds,
});
@ -283,6 +285,19 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.fileUploadForm.reset();
},
onUploadFailure: function(form, action) {
this.hide();
Ext.MessageBox.show({
title: _('Error'),
msg: _('Failed to upload torrent'),
buttons: Ext.MessageBox.OK,
modal: false,
icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error',
});
this.fireEvent('addfailed', this.torrentId);
},
onGotInfo: function(info, obj, response, request) {
info.filename = request.options.filename;
torrentId = request.options.torrentId;
@ -315,6 +330,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
}
},
onTorrentAddFailed: function(torrentId) {
var store = this.list.getStore();
var torrentRecord = store.getById(torrentId);
if (torrentRecord) {
store.remove(torrentRecord);
}
},
onUrl: function(button, event) {
this.url.show();
},

View File

@ -72,6 +72,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
} else {
deluge.client.web.download_torrent_from_url(url, cookies, {
success: this.onDownload,
failure: this.onDownloadFailed,
scope: this,
torrentId: torrentId,
});
@ -85,12 +86,25 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
onDownload: function(filename, obj, resp, req) {
deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo,
failure: this.onDownloadFailed,
scope: this,
filename: filename,
torrentId: req.options.torrentId,
});
},
onDownloadFailed: function(obj, resp, req) {
Ext.MessageBox.show({
title: _('Error'),
msg: _('Failed to download torrent'),
buttons: Ext.MessageBox.OK,
modal: false,
icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error',
});
this.fireEvent('addfailed', req.options.torrentId);
},
onGotInfo: function(info, obj, response, request) {
info['filename'] = request.options.filename;
this.fireEvent('add', request.options.torrentId, info);

View File

@ -17,7 +17,7 @@ Ext.ns('Deluge.add');
Deluge.add.Window = Ext.extend(Ext.Window, {
initComponent: function() {
Deluge.add.Window.superclass.initComponent.call(this);
this.addEvents('beforeadd', 'add');
this.addEvents('beforeadd', 'add', 'addfailed');
},
/**

View File

@ -1 +1 @@
../../CHANGELOG.md
../../CHANGELOG.md