add: job logic

This commit is contained in:
Kingtous
2022-05-12 15:55:36 +08:00
parent 2caa2db463
commit 11e0d2cbf1
5 changed files with 89 additions and 6 deletions

View File

@@ -100,6 +100,12 @@ class JobTable: Reactor.Component {
refreshDir(is_remote);
}
function clearAllJobs() {
this.jobs = [];
this.job_map = {};
this.update();
}
function send(path, is_remote) {
var to;
var show_hidden;
@@ -124,6 +130,14 @@ class JobTable: Reactor.Component {
self.timer(30ms, function() { self.update(); });
}
function addJob(id, path, to, show_hidden, is_remote) {
this.jobs.push({ type: "transfer",
id: id, path: path, to: to,
include_hidden: show_hidden,
is_remote: is_remote });
this.job_map[id] = this.jobs[this.jobs.length - 1];
}
function addDelDir(path, is_remote) {
var id = jobIdCounter;
jobIdCounter += 1;
@@ -649,6 +663,18 @@ handler.jobError = function(id, err, file_num = -1) {
file_transfer.job_table.updateJobStatus(id, file_num, err);
}
handler.clearAllJobs = function() {
file_transfer.job_table.clearAllJobs();
}
handler.addJob = function (id, path, to, file_num, show_hidden, is_remote) {
file_transfer.job_table.addJob(id,path,to,file_num,show_hidden,is_remote);
}
handler.updateTransferList = function () {
file_transfer.job_table.update();
}
function refreshDir(is_remote) {
if (is_remote) file_transfer.remote_folder_view.refreshDir();
else file_transfer.local_folder_view.refreshDir();