From 4854d732d4a72764f10765d509e8f4263859c2d0 Mon Sep 17 00:00:00 2001
From: sprhawk <465558+sprhawk@users.noreply.github.com>
Date: Fri, 4 Jan 2019 13:06:11 +0800
Subject: [PATCH 1/4] added restart first 10 error tasks
---
src/index-template.html | 3 ++
src/js/ctrls/nav.js | 9 ++++
src/js/services/rpc/helpers.js | 79 ++++++++++++++++++++++++++++++++++
src/js/translate/en_US.js | 4 +-
4 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/src/index-template.html b/src/index-template.html
index b5731fae..840ca16a 100644
--- a/src/index-template.html
+++ b/src/index-template.html
@@ -207,6 +207,9 @@
ng-click="removeAll()"> Remove All
-->
+
+ {{ 'Restart Error Tasks' | translate }}
+
diff --git a/src/js/ctrls/nav.js b/src/js/ctrls/nav.js
index 9c6d09b8..a95f84cf 100644
--- a/src/js/ctrls/nav.js
+++ b/src/js/ctrls/nav.js
@@ -146,5 +146,14 @@ export default angular
scope.shutDownServer = function() {
rpc.once("shutdown", []);
};
+
+ scope.restartError = function(num) {
+ console.log(num);
+ rpc.once("tellStopped", [0, 10], function(data) {
+ _.forEach(data[0], function(d) {
+ rhelpers.restart(d);
+ });
+ });
+ };
}
]).name;
diff --git a/src/js/services/rpc/helpers.js b/src/js/services/rpc/helpers.js
index 1dec4964..0e04c23c 100644
--- a/src/js/services/rpc/helpers.js
+++ b/src/js/services/rpc/helpers.js
@@ -15,6 +15,7 @@ export default angular
rpc.once("getVersion", [], function(data) {
miscellaneous = data[0];
});
+
return {
isFeatureEnabled: function(feature) {
return miscellaneous.enabledFeatures.indexOf(feature) != -1;
@@ -61,6 +62,84 @@ export default angular
// now dispatch all addUri syscalls
rpc.forceUpdate();
+ },
+ // copied from main.js
+ restart: function(d) {
+ // assumes downloads which are started by URIs, not torrents.
+ // the preferences are also not transferred, just simple restart
+ var thisService = this;
+ rpc.once("getOption", [d.gid], function(data) {
+ var prefs = data[0];
+ rpc.once("getFiles", [d.gid], function(data) {
+ var files = data[0];
+ var uris = _.chain(files)
+ .map(function(f) {
+ return f.uris;
+ })
+ .filter(function(uris) {
+ return uris && uris.length;
+ })
+ .map(function(uris) {
+ var u = _.chain(uris)
+ .map(function(u) {
+ return u.uri;
+ })
+ .uniq()
+ .value();
+ return u;
+ })
+ .value();
+
+ if (uris.length > 0) {
+ console.log("adding uris:", uris, prefs);
+ thisService.remove(
+ d,
+ function() {
+ thisService.addUris(uris, prefs);
+ },
+ true
+ );
+ }
+ });
+ });
+ },
+ canRestart: function(d) {
+ return ["active", "paused"].indexOf(d.status) == -1 && !d.bittorrent;
+ },
+ // remove the download,
+ // put it in stopped list if active,
+ // otherwise permanantly remove it
+ // d: the download ctx
+ remove: function(d, cb, noConfirm) {
+ // HACK to make sure an angular digest is not running, as only one can happen at a time, and confirm is a blocking
+ var thisService = this;
+ // call so an rpc response can also trigger a digest call
+ setTimeout(function() {
+ if (
+ !noConfirm &&
+ !confirm(
+ filter("translate")("Remove {{name}} and associated meta-data?", { name: d.name })
+ )
+ ) {
+ return;
+ }
+
+ var method = "remove";
+
+ if (thisService.getType(d) == "stopped") method = "removeDownloadResult";
+
+ if (d.followedFrom) {
+ thisService.remove(d.followedFrom, function() {}, true);
+ d.followedFrom = null;
+ }
+ rpc.once(method, [d.gid], cb);
+ }, 0);
+ },
+ getType: function(d) {
+ var type = d.status;
+ if (type == "paused") type = "waiting";
+ if (["error", "removed", "complete"].indexOf(type) != -1) type = "stopped";
+ return type;
}
};
}
diff --git a/src/js/translate/en_US.js b/src/js/translate/en_US.js
index a174f603..7a15f5b3 100644
--- a/src/js/translate/en_US.js
+++ b/src/js/translate/en_US.js
@@ -11,8 +11,8 @@ translations.en_US = {
"By Torrents": "By Torrents",
"By Metalinks": "By Metalinks",
Manage: "Manage",
- "Pause All": "Pause All",
- "Resume Paused": "Resume Paused",
+ "Pause All": "Pause aaaah All",
+ "Resume Paused": "Resume yyyy Paused",
"Purge Completed": "Purge Completed",
Settings: "Settings",
"Connection Settings": "Connection Settings",
From ca50806d23de0b79ae71ec380be8eb94a1659391 Mon Sep 17 00:00:00 2001
From: sprhawk <465558+sprhawk@users.noreply.github.com>
Date: Sat, 5 Jan 2019 02:13:45 +0800
Subject: [PATCH 2/4] search all stopped tasks to find error tasks
---
src/index-template.html | 13 ++++++++++---
src/js/ctrls/nav.js | 30 ++++++++++++++++++++++++------
src/scss/app.scss | 26 ++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/src/index-template.html b/src/index-template.html
index 840ca16a..350e0393 100644
--- a/src/index-template.html
+++ b/src/index-template.html
@@ -187,7 +187,7 @@
{{ 'Manage' | translate }}
-
-->
-
- {{ 'Restart Error Tasks' | translate }}
+
diff --git a/src/js/ctrls/nav.js b/src/js/ctrls/nav.js
index a95f84cf..857c5c7d 100644
--- a/src/js/ctrls/nav.js
+++ b/src/js/ctrls/nav.js
@@ -147,13 +147,31 @@ export default angular
rpc.once("shutdown", []);
};
- scope.restartError = function(num) {
- console.log(num);
- rpc.once("tellStopped", [0, 10], function(data) {
- _.forEach(data[0], function(d) {
- rhelpers.restart(d);
+ scope.restartError = function(offset, limit) {
+ // offset, limit, like sql
+ // count
+ var fetch = function(off, lim, count) {
+ console.log("fetching: "+ off + " limit: " + lim);
+ rpc.once("tellStopped", [off, count], function(data) {
+ var errors = _.filter(data[0], function(d) {
+ return d["status"] == "error"
+ });
+ errors = errors.slice(0, lim);
+ console.log("restart: " + errors.length);
+ _.forEach(errors, function(d) {
+ rhelpers.restart(d);
+ // console.log(d.status);
+ });
+
+ if(errors.length < lim && data[0].length == count) {
+ fetch(off + count, lim - errors.length, count);
+ }
+ else {
+ console.log("end");
+ }
});
- });
+ };
+ fetch(offset, limit, 100);
};
}
]).name;
diff --git a/src/scss/app.scss b/src/scss/app.scss
index 404d8c55..a266b833 100644
--- a/src/scss/app.scss
+++ b/src/scss/app.scss
@@ -9,3 +9,29 @@
@import "style";
@import "download";
@import "modals";
+
+.dropdown-submenu {
+ position: relative;
+}
+
+.dropdown-submenu:hover>.dropdown-menu {
+ display: block;
+}
+
+.dropdown-submenu>a:after {
+ display: block;
+ content: " ";
+ float: right;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+ border-width: 5px 0 5px 5px;
+ border-left-color: #ccc;
+ margin-top: 5px;
+ margin-right: -10px;
+}
+
+.dropdown-submenu:hover>a:after {
+ border-left-color: #fff;
+}
\ No newline at end of file
From 91eb3524fce9abe78565f1aacbef231ca1b5a387 Mon Sep 17 00:00:00 2001
From: sprhawk <465558+sprhawk@users.noreply.github.com>
Date: Sat, 5 Jan 2019 02:18:14 +0800
Subject: [PATCH 3/4] run format
---
src/js/ctrls/nav.js | 11 +++++------
src/scss/app.scss | 36 ++++++++++++++++++------------------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/src/js/ctrls/nav.js b/src/js/ctrls/nav.js
index 857c5c7d..1912810b 100644
--- a/src/js/ctrls/nav.js
+++ b/src/js/ctrls/nav.js
@@ -149,12 +149,12 @@ export default angular
scope.restartError = function(offset, limit) {
// offset, limit, like sql
- // count
+ // count
var fetch = function(off, lim, count) {
- console.log("fetching: "+ off + " limit: " + lim);
+ console.log("fetching: " + off + " limit: " + lim);
rpc.once("tellStopped", [off, count], function(data) {
var errors = _.filter(data[0], function(d) {
- return d["status"] == "error"
+ return d["status"] == "error";
});
errors = errors.slice(0, lim);
console.log("restart: " + errors.length);
@@ -163,10 +163,9 @@ export default angular
// console.log(d.status);
});
- if(errors.length < lim && data[0].length == count) {
+ if (errors.length < lim && data[0].length == count) {
fetch(off + count, lim - errors.length, count);
- }
- else {
+ } else {
console.log("end");
}
});
diff --git a/src/scss/app.scss b/src/scss/app.scss
index a266b833..69e8b60c 100644
--- a/src/scss/app.scss
+++ b/src/scss/app.scss
@@ -11,27 +11,27 @@
@import "modals";
.dropdown-submenu {
- position: relative;
+ position: relative;
}
-.dropdown-submenu:hover>.dropdown-menu {
- display: block;
+.dropdown-submenu:hover > .dropdown-menu {
+ display: block;
}
-.dropdown-submenu>a:after {
- display: block;
- content: " ";
- float: right;
- width: 0;
- height: 0;
- border-color: transparent;
- border-style: solid;
- border-width: 5px 0 5px 5px;
- border-left-color: #ccc;
- margin-top: 5px;
- margin-right: -10px;
+.dropdown-submenu > a:after {
+ display: block;
+ content: " ";
+ float: right;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+ border-width: 5px 0 5px 5px;
+ border-left-color: #ccc;
+ margin-top: 5px;
+ margin-right: -10px;
}
-.dropdown-submenu:hover>a:after {
- border-left-color: #fff;
-}
\ No newline at end of file
+.dropdown-submenu:hover > a:after {
+ border-left-color: #fff;
+}
From a52c9f6178120d5d45da4bcd59263b21464271a8 Mon Sep 17 00:00:00 2001
From: sprhawk <465558+sprhawk@users.noreply.github.com>
Date: Thu, 28 Feb 2019 11:05:59 +0800
Subject: [PATCH 4/4] remove typos
---
src/js/translate/en_US.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/js/translate/en_US.js b/src/js/translate/en_US.js
index 7a15f5b3..a174f603 100644
--- a/src/js/translate/en_US.js
+++ b/src/js/translate/en_US.js
@@ -11,8 +11,8 @@ translations.en_US = {
"By Torrents": "By Torrents",
"By Metalinks": "By Metalinks",
Manage: "Manage",
- "Pause All": "Pause aaaah All",
- "Resume Paused": "Resume yyyy Paused",
+ "Pause All": "Pause All",
+ "Resume Paused": "Resume Paused",
"Purge Completed": "Purge Completed",
Settings: "Settings",
"Connection Settings": "Connection Settings",