add up2k cleanup button

This commit is contained in:
ed 2021-02-22 00:47:21 +01:00
parent fa656577d1
commit 8081f9ddfd
4 changed files with 28 additions and 3 deletions

View file

@ -986,6 +986,8 @@ function apply_perms(perms) {
goto(); goto();
} }
document.body.setAttribute('perms', perms.join(' '));
var have_write = has(perms, "write"); var have_write = has(perms, "write");
var tds = document.querySelectorAll('#u2conf td'); var tds = document.querySelectorAll('#u2conf td');
for (var a = 0; a < tds.length; a++) { for (var a = 0; a < tds.length; a++) {
@ -993,7 +995,7 @@ function apply_perms(perms) {
(have_write || tds[a].getAttribute('data-perm') == 'read') ? (have_write || tds[a].getAttribute('data-perm') == 'read') ?
'table-cell' : 'none'; 'table-cell' : 'none';
} }
if (!have_write) if (!have_write && up2k)
up2k.set_fsearch(); up2k.set_fsearch();
} }

View file

@ -368,6 +368,7 @@ function up2k_init(have_crypto) {
"size": fobj.size, "size": fobj.size,
"lmod": lmod / 1000, "lmod": lmod / 1000,
"purl": get_vpath(), "purl": get_vpath(),
"done": false,
"hash": [] "hash": []
}; };
@ -400,6 +401,19 @@ function up2k_init(have_crypto) {
} }
more_one_file(); more_one_file();
function u2cleanup(e) {
ev(e);
for (var a = 0; a < st.files.length; a++) {
var t = st.files[a];
if (t.done && t.name) {
var tr = ebi('f{0}p'.format(t.n)).parentNode;
tr.parentNode.removeChild(tr);
t.name = undefined;
}
}
}
ebi('u2cleanup').onclick = u2cleanup;
///// /////
//// ////
/// actuator /// actuator
@ -819,6 +833,7 @@ function up2k_init(have_crypto) {
st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1); st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1);
if (done) { if (done) {
t.done = true;
st.bytes.uploaded += t.size - t.bytes_uploaded; st.bytes.uploaded += t.size - t.bytes_uploaded;
var spd1 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.); var spd1 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
var spd2 = (t.size / ((t.t3 - t.t2) / 1000.)) / (1024 * 1024.); var spd2 = (t.size / ((t.t3 - t.t2) / 1000.)) / (1024 * 1024.);
@ -1112,6 +1127,10 @@ function up2k_init(have_crypto) {
for (var a = nodes.length - 1; a >= 0; a--) for (var a = nodes.length - 1; a >= 0; a--)
nodes[a].addEventListener('touchend', nop, false); nodes[a].addEventListener('touchend', nop, false);
var perms = document.body.getAttribute('perms');
if (perms && perms.indexOf('write') === -1)
set_fsearch();
bumpthread({ "target": 1 }) bumpthread({ "target": 1 })
return { "init_deps": init_deps, "set_fsearch": set_fsearch } return { "init_deps": init_deps, "set_fsearch": set_fsearch }

View file

@ -212,3 +212,7 @@
color: #fff; color: #fff;
padding-left: .2em; padding-left: .2em;
} }
#u2cleanup {
float: right;
margin-bottom: -.3em;
}

View file

@ -81,7 +81,7 @@
<tr> <tr>
<td>filename</td> <td>filename</td>
<td>status</td> <td>status</td>
<td>progress</td> <td>progress<a href="#" id="u2cleanup">cleanup</a></td>
</tr> </tr>
</table> </table>