Skip to content

Commit

Permalink
feat: purge all paused, ziahamza/webui-aria2#501
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Oct 27, 2024
1 parent a58fbb6 commit 1cd9f52
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
<li>
<a href="#" ng-click="unpauseAll()"><svg class="icon icon-fw"><use xlink:href="#icon-play"></use></svg> {{ 'Resume Paused' | translate }}</a>
</li>
<li>
<a href="#" ng-click="purgeAllPaused()"><svg class="icon icon-fw"><use xlink:href="#icon-close-circle"></use></svg> {{ 'Purge Paused' | translate }}</a>
</li>
<li>
<a href="#" ng-click="purgeDownloadResult()"><svg class="icon icon-fw"><use xlink:href="#icon-close-circle"></use></svg> {{ 'Purge Completed' | translate }}</a>
</li>
Expand Down
28 changes: 28 additions & 0 deletions src/js/ctrls/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,34 @@ export default angular
translate.use(langkey);
};

scope.purgeAllPaused = function() {
// offset, limit, like sql
// count
var fetch = function(off, count) {
rpc.once("tellWaiting", [off, count], function(data) {
var errors = _.filter(data[0], function(d) {
return d["status"] == "paused";
});
console.log("remove paused: " + errors.length);
_.forEach(errors, function(d) {
rpc.once('remove', [d.gid]);
});

var offset = off;
if (errors.length == 0) {
offset = off + count;
}

if (data[0].length == count) {
fetch(offset, count);
} else {
console.log("end");
}
});
};
fetch(0, 100);
};

scope.shutDownServer = function() {
rpc.once("shutdown", []);
};
Expand Down

0 comments on commit 1cd9f52

Please sign in to comment.