112 lines
9.6 KiB
HTML
112 lines
9.6 KiB
HTML
<template x-if="manager.sourceTab === 'torrents'">
|
|
<section id="downloads-torrents" class="download-torrent-panel" role="tabpanel" aria-labelledby="downloads-tab-torrents"
|
|
x-data="{ get torrent() { return $store.torrents } }">
|
|
<template x-if="torrent.isImporting()">
|
|
<form class="torrent-source-form" @submit.prevent="torrent.preview()">
|
|
<label class="torrent-input-label" for="torrent-magnet-input">{{ t.player_magnet_link }}</label>
|
|
<input class="download-field" id="torrent-magnet-input" type="text" autocomplete="off" spellcheck="false" x-model="torrent.magnet"
|
|
:disabled="torrent.loading" @input="torrent.file = null" placeholder="magnet:?xt=urn:btih:…">
|
|
<label class="torrent-file-source" :class="{picked:torrent.file}">
|
|
<input type="file" id="torrent-file-input" accept=".torrent,application/x-bittorrent" :disabled="torrent.loading"
|
|
@change="if ($el.files.length) { torrent.file = $el.files[0]; torrent.magnet = ''; $el.value = '' }">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14 2H5v20h14V7ZM14 2v6h5M8 15h8m-4-4v8"/></svg>
|
|
<span x-text="torrent.file?.name || '{{ t.player_torrent_file }}'"></span>
|
|
<small>.torrent</small>
|
|
</label>
|
|
<button type="submit" class="download-button primary torrent-preview-submit" :disabled="torrent.loading || !(torrent.file || torrent.magnet.trim())">{{ t.player_upload_content }}</button>
|
|
</form>
|
|
</template>
|
|
<template x-if="torrent.workspaceMode === 'opening' || (torrent.isImporting() && torrent.loading)">
|
|
<div class="page-skeleton torrent-loading" role="status"><span class="loading-label">{{ t.player_loading_content }}</span>
|
|
{% include "player/skeleton_tracks.html" %}
|
|
</div>
|
|
</template>
|
|
|
|
<template x-if="torrent.workspaceMode === 'session' && torrent.previewData">
|
|
<div class="torrent-session-detail" x-data="{choosing:false}">
|
|
<div class="download-preview-title">
|
|
<h4 x-text="torrent.previewData.name" :title="torrent.previewData.name"></h4>
|
|
<button type="button" class="download-button" :disabled="torrent.loading"
|
|
@click="torrent.addNew(); $nextTick(() => document.getElementById('torrent-magnet-input')?.focus())">{{ t.player_download_another }}</button>
|
|
</div>
|
|
<template x-if="torrent.currentJob">
|
|
<div class="torrent-transfer-summary">
|
|
<span class="torrent-status-badge" :class="torrent.statusBadgeClass(torrent.currentJob)" x-text="torrent.statusLabel(torrent.currentJob)"></span>
|
|
<small x-text="torrent.progressDetailText(torrent.currentJob)"></small>
|
|
<span class="torrent-live-progress" x-show="torrent.isCurrentDownloading()">
|
|
<progress max="100" :value="torrent.progressValue(torrent.currentJob)" :aria-label="torrent.statusLabel(torrent.currentJob)"></progress>
|
|
<small x-text="torrent.progressValue(torrent.currentJob).toFixed(0) + '%'"></small>
|
|
</span>
|
|
<details class="torrent-transfer-info" @click.outside="$el.open = false"
|
|
@keydown.escape="if ($el.open) { $event.stopPropagation(); $event.preventDefault(); $el.open = false; $refs.info.focus() }">
|
|
<summary class="download-icon-button" x-ref="info" title="{{ t.player_info }}" aria-label="{{ t.player_info }}">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-10v1"/></svg>
|
|
</summary>
|
|
<dl>
|
|
<div><dt>{{ t.player_status }}</dt><dd x-text="torrent.statusText(torrent.currentJob)"></dd></div>
|
|
<div><dt>{{ t.player_size }}</dt><dd x-text="torrent.bytes(torrent.previewData.total_size)"></dd></div>
|
|
<div x-show="!torrent.isCurrentCompleted()"><dt>{{ t.player_speed }}</dt><dd x-text="torrent.speedText(torrent.currentJob)"></dd></div>
|
|
<div x-show="!torrent.isCurrentCompleted()"><dt>{{ t.player_peers }}</dt><dd x-text="torrent.peerText(torrent.currentJob)"></dd></div>
|
|
<div x-show="torrent.etaText(torrent.currentJob)"><dt>{{ t.player_eta }}</dt><dd x-text="torrent.etaText(torrent.currentJob)"></dd></div>
|
|
</dl>
|
|
</details>
|
|
</div>
|
|
</template>
|
|
<div class="torrent-selection-summary" x-show="torrent.previewData.files.length">
|
|
<span x-text="torrent.selected.size + ' / ' + torrent.previewData.files.length + ' · ' + torrent.bytes(torrent.selectedBytes())"></span>
|
|
<button type="button" class="download-button torrent-choose-files" :aria-expanded="choosing" aria-controls="torrent-file-picker"
|
|
@click="if (!torrent.treeRoot) torrent.treeRoot=torrent._buildTree(torrent.previewData.files); choosing=!choosing">{{ t.player_choose_audio_files }}</button>
|
|
</div>
|
|
<template x-if="!torrent.previewData.files.length && torrent.normalizedStatus(torrent.currentJob) === 'resolving'">
|
|
<div class="page-skeleton" role="status"><span class="loading-label">{{ t.player_resolving }}</span>{% include "player/skeleton_tracks.html" %}</div>
|
|
</template>
|
|
<p class="torrent-pane-empty" x-show="!torrent.previewData.files.length && torrent.normalizedStatus(torrent.currentJob) !== 'resolving'">{{ t.player_no_torrent_files }}</p>
|
|
<div id="torrent-file-picker" x-show="choosing" x-transition.opacity.duration.130ms>
|
|
<template x-if="torrent.treeRoot"><div class="torrent-file-picker">
|
|
<div class="torrent-selection-tools">
|
|
<label class="torrent-master-check">
|
|
<input type="checkbox" :checked="torrent.selected.size > 0 && torrent.selected.size === torrent.previewData.files.length"
|
|
x-effect="$el.indeterminate = torrent.selected.size > 0 && torrent.selected.size < torrent.previewData.files.length"
|
|
@change="torrent.selectAll($el.checked)" aria-label="{{ t.player_youtube_select_all }}">
|
|
<span>{{ t.player_youtube_select_all }}</span>
|
|
</label>
|
|
<div class="torrent-tree-controls" x-show="torrent.treeRoot?.children.some(node => node.type === 'folder')">
|
|
<button type="button" class="download-icon-button" @click="torrent.expandAll(true)" title="{{ t.player_expand_all }}" aria-label="{{ t.player_expand_all }}">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m7 8 5-5 5 5m-5-5v7m-5 6 5 5 5-5m-5 5v-7"/></svg>
|
|
</button>
|
|
<button type="button" class="download-icon-button" @click="torrent.expandAll(false)" title="{{ t.player_collapse }}" aria-label="{{ t.player_collapse }}">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m7 5 5 5 5-5m-5 5V2m-5 17 5-5 5 5m-5-5v8"/></svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="torrent-file-tree" tabindex="0" role="region" aria-label="{{ t.player_files }}">
|
|
<template x-for="node in torrent.visibleNodes()" :key="node.key">
|
|
<div class="torrent-tree-row" :style="{'--depth': Math.min(node.depth, 5)}">
|
|
<button type="button" class="torrent-folder-toggle" :style="node.type === 'folder' ? null : 'visibility:hidden'"
|
|
:aria-label="(torrent.expanded.has(node.key) ? '{{ t.player_collapse }}' : '{{ t.player_expand }}') + ' · ' + node.name"
|
|
:aria-expanded="torrent.expanded.has(node.key)" @click="torrent.toggleExpand(node)">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 5 7 7-7 7"/></svg>
|
|
</button>
|
|
<label class="torrent-node" :title="node.name">
|
|
<input type="checkbox" :checked="torrent.nodeState(node) === 'checked'" x-effect="$el.indeterminate = torrent.nodeState(node) === 'partial'"
|
|
@change="torrent.toggleNode(node)">
|
|
<svg x-show="node.type === 'folder'" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 6h7l2 3h9v11H3Z"/></svg>
|
|
<span x-text="node.name"></span>
|
|
<small x-text="torrent.bytes(node.size)"></small>
|
|
</label>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div></template>
|
|
</div>
|
|
<footer class="torrent-start-bar">
|
|
{% let kind = "torrent" %}{% include "player/download_destination.html" %}
|
|
<button type="button" class="download-button torrent-start" :class="{primary:!torrent.isCurrentDownloading() && !torrent.isCurrentCompletedLocked()}"
|
|
@click="await torrent.toggleDownloadAction(); if (torrent.isCurrentDownloading()) choosing=false"
|
|
:disabled="torrent.actionButtonDisabled()" x-text="torrent.actionButtonText()"></button>
|
|
</footer>
|
|
</div>
|
|
</template>
|
|
</section>
|
|
</template>
|