summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDjLegolas <DjLegolas@users.noreply.github.com>2019-06-21 09:09:12 +0300
committerDjLegolas <DjLegolas@users.noreply.github.com>2019-06-21 09:09:12 +0300
commit24b094a04a754ddd6405a274f93c536fa5612105 (patch)
tree5dec5a5058f0ebdf5e63d5c41e656a7495b2f26c
parent3365201011f9f23f48dcaf09d82eab8668c36c73 (diff)
downloaddeluge-24b094a04a754ddd6405a274f93c536fa5612105.tar.gz
deluge-24b094a04a754ddd6405a274f93c536fa5612105.tar.bz2
deluge-24b094a04a754ddd6405a274f93c536fa5612105.zip
[WebUI] Handle torrent add failures
Closes #2253.
-rw-r--r--CHANGELOG.md4
-rw-r--r--deluge/ui/web/js/deluge-all/add/AddWindow.js23
-rw-r--r--deluge/ui/web/js/deluge-all/add/UrlWindow.js14
-rw-r--r--deluge/ui/web/js/deluge-all/add/Window.js2
l---------docs/source/changelog.md2
5 files changed, 43 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58e0a882c..d4555df06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## 2.0.4 (WIP)
+### WebUI
+
+- Handle torrent add failures
+
### Documentation
- Add How-to guides about services.
diff --git a/deluge/ui/web/js/deluge-all/add/AddWindow.js b/deluge/ui/web/js/deluge-all/add/AddWindow.js
index 89803f3bf..a9db791f1 100644
--- a/deluge/ui/web/js/deluge-all/add/AddWindow.js
+++ b/deluge/ui/web/js/deluge-all/add/AddWindow.js
@@ -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();
},
diff --git a/deluge/ui/web/js/deluge-all/add/UrlWindow.js b/deluge/ui/web/js/deluge-all/add/UrlWindow.js
index d3a9a697c..88988bd04 100644
--- a/deluge/ui/web/js/deluge-all/add/UrlWindow.js
+++ b/deluge/ui/web/js/deluge-all/add/UrlWindow.js
@@ -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);
diff --git a/deluge/ui/web/js/deluge-all/add/Window.js b/deluge/ui/web/js/deluge-all/add/Window.js
index 206b3eece..d2d576982 100644
--- a/deluge/ui/web/js/deluge-all/add/Window.js
+++ b/deluge/ui/web/js/deluge-all/add/Window.js
@@ -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');
},
/**
diff --git a/docs/source/changelog.md b/docs/source/changelog.md
index 699cc9e7b..03cb73106 120000
--- a/docs/source/changelog.md
+++ b/docs/source/changelog.md
@@ -1 +1 @@
-../../CHANGELOG.md \ No newline at end of file
+../../CHANGELOG.md