opt: add resume btn

This commit is contained in:
Kingtous
2022-05-14 11:58:47 +08:00
parent d186dd26a2
commit 39eb1b7211
6 changed files with 126 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ var svg_refresh = <svg viewBox="0 0 551.13 551.13">
<path d="m482.24 310.01c0 113.97-92.707 206.67-206.67 206.67s-206.67-92.708-206.67-206.67c0-102.21 74.639-187.09 172.23-203.56v65.78l86.114-86.114-86.114-86.115v71.641c-116.65 16.802-206.67 117.14-206.67 238.37 0 132.96 108.16 241.12 241.12 241.12s241.12-108.16 241.12-241.12z"/>
</svg>;
var svg_cancel = <svg .cancel viewBox="0 0 612 612"><polygon points="612 36.004 576.52 0.603 306 270.61 35.478 0.603 0 36.004 270.52 306.01 0 576 35.478 611.4 306 341.41 576.52 611.4 612 576 341.46 306.01"/></svg>;
var svg_continue = <svg .continue t="1652493728825" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="793" ne="0.8429451094012732" width="200" height="200"><path d="M458.69056 948.9408v74.39872c-102.4512-10.22464-196.25472-51.00544-272.1024-113.024l52.2752-52.2752c62.09024 48.87552 137.58464 81.39776 219.8272 90.89536z m562.47296-434.70848c0 263.99744-202.6496 482.9696-460.06784 509.0304v-74.5472c216.6272-25.99424 385.95584-211.73248 385.95584-435.072 0-223.27296-169.32352-409.00096-385.95584-434.9952V5.19168c257.42336 26.07104 460.06784 245.0432 460.06784 509.04064zM166.24128 785.83296l-52.13696 52.14208C50.82112 760.9088 9.51808 665.20576 0 560.67584h73.36448c9.1136 84.41856 42.44992 161.85344 92.8768 225.15712zM113.77664 190.88384l51.65056 51.6608C117.12 303.5392 84.64384 377.56928 74.3424 458.2656H0.95744C12.032 357.632 52.60288 265.53344 113.77664 190.88384zM458.69056 5.12v73.30304c-82.69312 9.55392-158.5664 42.37824-220.8512 91.6992L186.17856 118.4768C262.10304 56.2688 356.06528 15.36 458.69568 5.12z" p-id="794"></path><path d="M652.8 512l-276.48 166.4v-332.8z" p-id="795"></path></svg>;
var svg_computer = <svg .computer viewBox="0 0 480 480">
<g>
<path fill="#2C8CFF" d="m276 395v11.148c0 2.327-1.978 4.15-4.299 3.985-21.145-1.506-42.392-1.509-63.401-0.011-2.322 0.166-4.3-1.657-4.3-3.985v-11.137c0-2.209 1.791-4 4-4h64c2.209 0 4 1.791 4 4zm204-340v288c0 17.65-14.35 32-32 32h-416c-17.65 0-32-14.35-32-32v-288c0-17.65 14.35-32 32-32h416c17.65 0 32 14.35 32 32zm-125.62 386.36c-70.231-21.843-158.71-21.784-228.76 0-4.22 1.31-6.57 5.8-5.26 10.02 1.278 4.085 5.639 6.591 10.02 5.26 66.093-20.58 151.37-21.125 219.24 0 4.22 1.31 8.71-1.04 10.02-5.26s-1.04-8.71-5.26-10.02z"/>
@@ -100,6 +101,13 @@ class JobTable: Reactor.Component {
refreshDir(is_remote);
}
event click $(svg.continue) (_, me) {
var job = this.jobs[me.parent.parent.parent.index];
var id = job.id;
this.continueJob(id);
this.update();
}
function clearAllJobs() {
this.jobs = [];
this.job_map = {};
@@ -123,7 +131,9 @@ class JobTable: Reactor.Component {
this.jobs.push({ type: "transfer",
id: id, path: path, to: to,
include_hidden: show_hidden,
is_remote: is_remote });
is_remote: is_remote,
is_last: false
});
this.job_map[id] = this.jobs[this.jobs.length - 1];
handler.send_files(id, path, to, 0, show_hidden, is_remote);
var self = this;
@@ -134,14 +144,23 @@ class JobTable: Reactor.Component {
var job = { type: "transfer",
id: id, path: path, to: to,
include_hidden: show_hidden,
is_remote: is_remote };
is_remote: is_remote, is_last: true, file_num: file_num };
this.jobs.push(job);
this.job_map[id] = this.jobs[this.jobs.length - 1];
jobIdCounter = id + 1;
handler.send_files(id, path, to, file_num, show_hidden, is_remote);
handler.add_job(id, path, to, file_num, show_hidden, is_remote);
stdout.println(JSON.stringify(job));
}
function continueJob(id) {
var job = this.job_map[id];
if (job == null || !job.is_last){
return;
}
job.is_last = false;
handler.resume_job(job.id, job.is_remote);
}
function addDelDir(path, is_remote) {
var id = jobIdCounter;
jobIdCounter += 1;
@@ -276,6 +295,9 @@ class JobTable: Reactor.Component {
<div .path>{job.path}</div>
<div id={"s" + job.id}>{this.getStatus(job)}</div>
</div>
<div class="svg_continue" style={job.is_last ? "" : "visibility: hidden"}>
{svg_continue}
</div>
{svg_cancel}
</td></tr>;
}
@@ -673,7 +695,7 @@ handler.clearAllJobs = function() {
}
handler.addJob = function (id, path, to, file_num, show_hidden, is_remote) {
stdout.println("restore job: " + is_remote);
// stdout.println("restore job: " + is_remote);
file_transfer.job_table.addJob(id,path,to,file_num,show_hidden,is_remote);
}