send & receive multiple files

This commit is contained in:
Starccy 2021-10-17 21:27:10 +08:00
parent b16b2bc1b4
commit eea85b9b5a
3 changed files with 43 additions and 4 deletions

View File

@ -30,6 +30,7 @@ table > thead {
} }
table > tbody { table > tbody {
behavior: select-multiple;
overflow-y: scroll-indicator; overflow-y: scroll-indicator;
size: *; size: *;
background: white; background: white;
@ -85,6 +86,15 @@ table.has_current tr:current /* current row */
background-color: color(accent); background-color: color(accent);
} }
table.has_current tbody tr:checked
{
background-color: color(accent);
}
table.has_current tbody tr:checked td {
color: highlighttext;
}
table td table td
{ {
padding: 4px; padding: 4px;

View File

@ -25,6 +25,12 @@ var svg_computer = <svg .computer viewBox="0 0 480 480">
</g> </g>
</svg>; </svg>;
const TYPE_DIR = 1;
const TYPE_DIR_LINK = 2;
const TYPE_DIR_DRIVE = 3;
const TYPE_FILE = 4;
const TYPE_FILE_LINK = 5;
function getSize(type, size) { function getSize(type, size) {
if (!size) { if (!size) {
if (type <= 3) return ""; if (type <= 3) return "";
@ -374,7 +380,7 @@ class FolderView : Reactor.Component {
path = this.joinPath(entry.name); path = this.joinPath(entry.name);
} }
var tm = entry.time ? new Date(entry.time.toFloat() * 1000.).toLocaleString() : 0; var tm = entry.time ? new Date(entry.time.toFloat() * 1000.).toLocaleString() : 0;
return <tr> return <tr role="option">
<td type={entry.type} filename={path}></td> <td type={entry.type} filename={path}></td>
<td>{entry.name}</td> <td>{entry.name}</td>
<td value={entry.time || 0}>{tm || ""}</td> <td value={entry.time || 0}>{tm || ""}</td>
@ -463,10 +469,28 @@ class FolderView : Reactor.Component {
return [this.joinPath(name), type]; return [this.joinPath(name), type];
} }
function getCurrentRows() {
var rows = this.table.getCurrentRows();
if (!rows || rows.length== 0) return;
var records = new Array();
for (var i = 0; i < rows.length; ++i) {
var name = rows[i][1].text;
if (!name || name == "..") continue;
var type = rows[i][0].attributes["type"];
records.push([this.joinPath(name), type]);
}
return records;
}
event click $(.send) () { event click $(.send) () {
var cur = this.getCurrentRow(); var rows = this.getCurrentRows();
if (!cur) return; if (!rows || rows.length == 0) return;
file_transfer.job_table.send(cur[0], this.is_remote); for (var i = 0; i < rows.length; ++i) {
file_transfer.job_table.send(rows[i][0], this.is_remote);
}
} }
event change $(.select-dir) (_, el) { event change $(.select-dir) (_, el) {

View File

@ -24,6 +24,11 @@ class Grid: Behavior {
{ {
return this.$(tbody>tr:current); return this.$(tbody>tr:current);
} }
function getCurrentRows()
{
return this.$$(tbody>tr:checked);
}
function getCurrentColumn() function getCurrentColumn()
{ {