forked from Furumi/furumi-web
Import library sits between Followed and Settings in the account menu and opens #imports: the sources, the history with statistics and links to the created playlists, and #imports/N with progress, per-playlist results, a deleted-playlist notice with Create again, and the entries with status and playlist filters, search, paging and the candidates of doubtful entries to choose from. Retry unmatched (with the federated search consent), Cancel, Delete history and a new Spotify sign-in for waiting imports call the existing /api/imports endpoints. The page polls every 3 s while an import runs. It follows the player's views, skeletons, dialogs, switches and phrase table in English and Russian. The New import wizard picks a source, then the data export or the Spotify sign-in, then the playlists: imported ones cannot be selected, similar ones need an explicit confirmation, and federated search is off until the user turns it on. A ZIP export is opened in the browser with fflate 0.8.2, vendored with its MIT licence and served at /vendor/fflate-0.8.2.js only when an archive is picked. Only Playlist*.json and YourLibrary.json are extracted; archives over 256 MiB, with more than 2,000 entries, more than 256 playlist files or more than 32 MiB declared for them are refused before anything is decompressed, and a request over 32 MiB is not sent. Federated tracks can now be removed from a playlist in edit mode: DELETE /api/player/tracks/content/playlist checks the owner and records the existing PlaylistTrackRemoved operation. The body-level dialogs get an Alpine root, which also makes Get app open again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
264 lines
20 KiB
HTML
264 lines
20 KiB
HTML
<template x-if="$store.library.view === 'imports'">
|
|
<section class="library-imports" x-data="{ get imports() { return $store.imports } }"
|
|
@keydown.space="if ($event.target.closest('button,a,input,select,label')) $event.stopPropagation()">
|
|
<header class="import-heading">
|
|
<h1 class="section-title">{{ t.player_import_library }}</h1>
|
|
<button type="button" class="release-action-btn primary" data-online-only @click="imports.startWizard()"
|
|
aria-haspopup="dialog" aria-controls="import-wizard">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
|
|
{{ t.player_import_new }}
|
|
</button>
|
|
</header>
|
|
<p class="import-notice" role="status" aria-live="polite" x-show="imports.message" x-text="imports.message"></p>
|
|
<div class="import-notice error" role="alert" x-show="imports.error" x-cloak>
|
|
<span x-text="imports.error"></span>
|
|
<button type="button" class="import-text-action" @click="imports.enter()">{{ t.player_import_retry }}</button>
|
|
</div>
|
|
<template x-if="!imports.loaded && !imports.error">
|
|
<div class="page-skeleton" role="status">
|
|
<span class="loading-label">{{ t.player_loading_content }}</span>
|
|
<div aria-hidden="true">
|
|
<div class="import-source-grid">
|
|
<div class="import-source skeleton-card"><i class="skeleton-bar"></i><i class="skeleton-bar"></i></div>
|
|
</div>
|
|
</div>
|
|
{% include "player/skeleton_tracks.html" %}
|
|
</div>
|
|
</template>
|
|
<template x-if="imports.loaded">
|
|
<div>
|
|
<h2 class="import-subtitle">{{ t.player_import_sources }}</h2>
|
|
<div class="import-source-grid">
|
|
<template x-for="provider in imports.providers" :key="provider.id">
|
|
<button type="button" class="import-source" data-online-only @click="imports.startWizard(provider.id)"
|
|
aria-haspopup="dialog" aria-controls="import-wizard">
|
|
<strong x-text="provider.name"></strong>
|
|
<small x-text="provider.methods.map(method => imports.text(method === 'api' ? 'methodApi' : 'methodFile')).join(' · ')"></small>
|
|
</button>
|
|
</template>
|
|
</div>
|
|
<h2 class="import-subtitle">{{ t.player_import_history }}</h2>
|
|
<p class="empty-state" x-show="!imports.imports.length">{{ t.player_import_history_empty }}</p>
|
|
<ul class="import-history" x-show="imports.imports.length">
|
|
<template x-for="record in imports.imports" :key="record.id">
|
|
<li class="import-history-row">
|
|
<a class="import-history-link" :href="'#imports/' + record.id">
|
|
<span class="import-history-title">
|
|
<strong x-text="imports.title(record)"></strong>
|
|
<small x-text="imports.date(record.created_at)"></small>
|
|
</span>
|
|
<span class="import-status" :data-status="record.status" x-text="imports.statusText(record)"></span>
|
|
<span class="import-history-count"
|
|
x-text="imports.text('foundOf', {found: imports.number(imports.found(record)), total: imports.number(imports.stats(record).total)})"></span>
|
|
</a>
|
|
<div class="import-history-playlists" x-show="imports.playlistLinks(record).length">
|
|
<template x-for="link in imports.playlistLinks(record).slice(0, 3)" :key="link.id">
|
|
<a :href="'#playlist/' + link.target_playlist_id" x-text="link.title"></a>
|
|
</template>
|
|
<span x-show="imports.playlistLinks(record).length > 3"
|
|
x-text="imports.text('playlistsMore', {count: imports.playlistLinks(record).length - 3})"></span>
|
|
</div>
|
|
<div class="import-history-actions" data-online-only>
|
|
<button type="button" class="import-text-action" x-show="imports.isFinished(record)"
|
|
:disabled="imports.busy" @click="imports.retry(record)">{{ t.player_import_retry_unmatched }}</button>
|
|
<button type="button" class="import-text-action" x-show="record.status === 'needs_reauth'"
|
|
@click="imports.reauthorize(record)">{{ t.player_import_sign_in_again }}</button>
|
|
</div>
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
</div>
|
|
</template>
|
|
</section>
|
|
</template>
|
|
<template x-if="$store.library.view === 'import_detail'">
|
|
<section class="library-imports" x-data="{ get imports() { return $store.imports }, get detail() { return $store.imports.detail } }"
|
|
@keydown.space="if ($event.target.closest('button,a,input,select,label')) $event.stopPropagation()">
|
|
<nav class="breadcrumb" aria-label="{{ t.player_import_library }}">
|
|
<a href="#imports">{{ t.player_import_library }}</a>
|
|
</nav>
|
|
<div class="import-notice error" role="alert" x-show="imports.detailError" x-cloak>
|
|
<span x-text="imports.detailError"></span>
|
|
<button type="button" class="import-text-action" @click="imports.open(imports.detailId)">{{ t.player_import_retry }}</button>
|
|
</div>
|
|
<template x-if="!detail && !imports.detailError">
|
|
<div class="page-skeleton" role="status">
|
|
<span class="loading-label">{{ t.player_loading_content }}</span>
|
|
<div aria-hidden="true">
|
|
<i class="skeleton-bar skeleton-title"></i>
|
|
<i class="skeleton-bar skeleton-byline"></i>
|
|
<div class="import-stats import-stats-skeleton">
|
|
{% for _ in 0..4 %}<div><i class="skeleton-bar"></i><i class="skeleton-bar"></i></div>{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% include "player/skeleton_tracks.html" %}
|
|
</div>
|
|
</template>
|
|
<template x-if="detail">
|
|
<div>
|
|
<header class="import-heading">
|
|
<div class="import-heading-copy">
|
|
<h1 class="section-title" x-text="imports.title(detail)"></h1>
|
|
<p>
|
|
<span class="import-status" :data-status="detail.status" x-text="imports.statusText(detail)"></span>
|
|
<span x-text="imports.date(detail.created_at)"></span>
|
|
</p>
|
|
</div>
|
|
<div class="import-actions" data-online-only>
|
|
<button type="button" class="release-action-btn primary" x-show="detail.status === 'needs_reauth'"
|
|
@click="imports.reauthorize()">{{ t.player_import_sign_in_again }}</button>
|
|
<button type="button" class="release-action-btn secondary" x-show="imports.isFinished(detail)"
|
|
:disabled="imports.busy" :aria-expanded="imports.retryPanel" aria-controls="import-retry-panel"
|
|
@click="imports.openRetry()">{{ t.player_import_retry_unmatched }}</button>
|
|
<button type="button" class="release-action-btn secondary" x-show="imports.isActive(detail) || detail.status === 'needs_reauth'"
|
|
:disabled="imports.busy || detail.cancel_requested" @click="imports.cancel()">{{ t.player_import_cancel }}</button>
|
|
<button type="button" class="release-action-btn secondary" x-show="!imports.isActive(detail)"
|
|
:disabled="imports.busy" @click="imports.remove()">{{ t.player_import_delete_history }}</button>
|
|
</div>
|
|
</header>
|
|
<div id="import-retry-panel" class="import-retry-panel" x-show="imports.retryPanel" x-cloak
|
|
x-transition.opacity.duration.140ms>
|
|
<div class="import-consent">
|
|
<button type="button" role="switch" class="offline-switch-row" :aria-checked="imports.retryFederated"
|
|
:disabled="!imports.federatedAvailable" aria-labelledby="import-retry-federated"
|
|
aria-describedby="import-retry-consent" @click="imports.retryFederated = !imports.retryFederated">
|
|
<span class="offline-switch" aria-hidden="true"></span>
|
|
</button>
|
|
<span>
|
|
<strong id="import-retry-federated">{{ t.player_import_federated }}</strong>
|
|
<small id="import-retry-consent" x-text="imports.federatedAvailable ? imports.text('federatedConsent') : imports.text('federatedOff')"></small>
|
|
</span>
|
|
</div>
|
|
<button type="button" class="release-action-btn primary" :disabled="imports.busy"
|
|
@click="imports.retry(detail, imports.federatedAvailable ? imports.retryFederated : undefined)">{{ t.player_import_retry }}</button>
|
|
</div>
|
|
<p class="import-notice" role="status" aria-live="polite" x-show="imports.message || imports.notice"
|
|
x-text="imports.message || imports.notice"></p>
|
|
<p class="import-notice" x-show="detail.status === 'needs_reauth'">{{ t.player_import_reauth_needed }}</p>
|
|
<p class="import-notice error" x-show="detail.error" x-text="detail.error"></p>
|
|
<div class="import-progress" x-show="imports.isActive(detail)" x-cloak>
|
|
<span x-text="imports.phaseText(detail)"></span>
|
|
<template x-if="imports.progress(detail).max">
|
|
<progress :max="imports.progress(detail).max" :value="imports.progress(detail).value"
|
|
:aria-label="imports.phaseText(detail)"></progress>
|
|
</template>
|
|
<template x-if="!imports.progress(detail).max">
|
|
<progress :aria-label="imports.phaseText(detail)"></progress>
|
|
</template>
|
|
</div>
|
|
<dl class="import-stats">
|
|
<div><dt>{{ t.player_import_stat_total }}</dt><dd x-text="imports.number(imports.stats(detail).total)"></dd></div>
|
|
<div>
|
|
<dt>{{ t.player_import_stat_found }}</dt>
|
|
<dd x-text="imports.number(imports.found(detail))"></dd>
|
|
<small x-text="imports.text('local') + ' ' + imports.number(imports.stats(detail).matched_local) + ' · ' + imports.text('federation') + ' ' + imports.number(imports.stats(detail).matched_federation)"></small>
|
|
</div>
|
|
<div><dt>{{ t.player_import_stat_published }}</dt><dd x-text="imports.number(imports.stats(detail).published)"></dd></div>
|
|
<div><dt>{{ t.player_import_stat_ambiguous }}</dt><dd x-text="imports.number(imports.stats(detail).ambiguous)"></dd></div>
|
|
<div><dt>{{ t.player_import_stat_unmatched }}</dt><dd x-text="imports.number(imports.stats(detail).unmatched)"></dd></div>
|
|
<div><dt>{{ t.player_import_stat_unsupported }}</dt><dd x-text="imports.number(imports.stats(detail).unsupported)"></dd></div>
|
|
</dl>
|
|
<ul class="import-extra-stats" x-show="imports.extraStats().length">
|
|
<template x-for="stat in imports.extraStats()" :key="stat.key">
|
|
<li><span x-text="stat.label"></span> <strong x-text="imports.number(stat.value)"></strong></li>
|
|
</template>
|
|
</ul>
|
|
<h2 class="import-subtitle">{{ t.player_import_playlists }}</h2>
|
|
<ul class="import-playlists">
|
|
<template x-for="playlist in detail.source_playlists" :key="playlist.id">
|
|
<li class="collection-row">
|
|
<template x-if="playlist.target_playlist_id && !playlist.target_deleted">
|
|
<a class="collection-link" :href="'#playlist/' + playlist.target_playlist_id">
|
|
<span class="collection-art" :class="{likes: playlist.kind === 'favorites'}" aria-hidden="true"
|
|
x-text="playlist.kind === 'favorites' ? '♥' : '♫'"></span>
|
|
<span><strong x-text="playlist.title"></strong>
|
|
<small x-text="imports.text('foundOf', {found: imports.number(playlist.matched), total: imports.number(playlist.total)}) + ' · ' + imports.text('statPublished') + ' ' + imports.number(playlist.published)"></small></span>
|
|
</a>
|
|
</template>
|
|
<template x-if="!playlist.target_playlist_id || playlist.target_deleted">
|
|
<div class="collection-link">
|
|
<span class="collection-art" aria-hidden="true" x-text="playlist.kind === 'favorites' ? '♥' : '♫'"></span>
|
|
<span><strong x-text="playlist.title"></strong>
|
|
<small x-text="playlist.target_deleted ? imports.text('playlistDeleted') : imports.text('playlistPending')"></small></span>
|
|
</div>
|
|
</template>
|
|
<button type="button" class="import-text-action" data-online-only x-show="playlist.target_deleted && !imports.isActive(detail)"
|
|
:disabled="imports.busy" @click="imports.recreate(playlist)">{{ t.player_import_recreate }}</button>
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
<h2 class="import-subtitle">{{ t.player_import_entries }}</h2>
|
|
<div class="import-filters">
|
|
<div class="collection-tabs" role="group" aria-label="{{ t.player_import_entries }}">
|
|
<template x-for="option in imports.statusFilters()" :key="option.status">
|
|
<button type="button" :aria-pressed="imports.filter.status === option.status"
|
|
@click="imports.setStatus(option.status)"
|
|
x-text="option.label + ' ' + imports.number(option.count)"></button>
|
|
</template>
|
|
</div>
|
|
<div class="import-filter-fields">
|
|
<select aria-label="{{ t.player_import_playlists }}" x-show="detail.source_playlists.length > 1"
|
|
:value="imports.filter.playlist" @change="imports.setPlaylist($event.target.value)">
|
|
<option value="">{{ t.player_import_all_playlists }}</option>
|
|
<template x-for="playlist in detail.source_playlists" :key="playlist.id">
|
|
<option :value="String(playlist.id)" x-text="playlist.title"></option>
|
|
</template>
|
|
</select>
|
|
<input type="search" placeholder="{{ t.player_import_search }}" aria-label="{{ t.player_import_search }}"
|
|
maxlength="200" x-model="imports.filter.q" @input="imports.searchChanged()">
|
|
</div>
|
|
</div>
|
|
<template x-if="!imports.itemsLoaded">
|
|
<div class="page-skeleton" role="status">
|
|
<span class="loading-label">{{ t.player_loading_content }}</span>
|
|
{% include "player/skeleton_tracks.html" %}
|
|
</div>
|
|
</template>
|
|
<p class="empty-state" x-show="imports.itemsLoaded && !imports.items.length">{{ t.player_import_no_entries }}</p>
|
|
<ol class="import-items" x-show="imports.items.length" :aria-busy="imports.itemsLoading">
|
|
<template x-for="item in imports.items" :key="item.id">
|
|
<li class="import-item" :data-status="item.resolution_status">
|
|
<span class="import-item-position" x-text="item.position + 1"></span>
|
|
<div class="import-item-copy">
|
|
<strong x-text="imports.meta(item).title || '—'"></strong>
|
|
<small x-text="[imports.artists(imports.meta(item).artists), imports.meta(item).album].filter(Boolean).join(' · ')"></small>
|
|
<small class="import-item-note" x-show="!imports.filter.playlist && detail.source_playlists.length > 1"
|
|
x-text="imports.playlistTitle(item.playlist_id)"></small>
|
|
</div>
|
|
<span class="import-item-duration" x-text="imports.duration(imports.meta(item).duration_ms)"></span>
|
|
<span class="import-item-status">
|
|
<span class="import-status" :data-status="item.resolution_status" x-text="imports.resolutionText(item)"></span>
|
|
<small x-show="imports.noteText(item) || imports.publicationText(item)"
|
|
x-text="imports.noteText(item) || imports.publicationText(item)"></small>
|
|
</span>
|
|
<template x-if="item.resolution_status === 'ambiguous' && item.candidates?.length">
|
|
<div class="import-candidates">
|
|
<span class="import-candidates-title">{{ t.player_import_candidates }}</span>
|
|
<template x-for="(candidate, index) in item.candidates" :key="index">
|
|
<div class="import-candidate">
|
|
<div class="import-item-copy">
|
|
<strong x-text="candidate.title"></strong>
|
|
<small x-text="[imports.artists(candidate.artists), candidate.album].filter(Boolean).join(' · ')"></small>
|
|
</div>
|
|
<span class="import-item-duration" x-text="candidate.duration_seconds ? formatTime(candidate.duration_seconds) : ''"></span>
|
|
<span class="import-origin" x-text="imports.text(candidate.origin === 'federation' ? 'federation' : 'local')"></span>
|
|
<button type="button" class="import-text-action" data-online-only
|
|
:disabled="!!imports.choosing || imports.isActive(detail)"
|
|
@click="imports.choose(item, index)">{{ t.player_import_choose }}</button>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
</li>
|
|
</template>
|
|
</ol>
|
|
<div class="import-more" x-show="imports.itemsNext">
|
|
<button type="button" class="release-action-btn secondary" :disabled="imports.itemsLoading"
|
|
@click="imports.loadItems(true).catch(error => { imports.message = error.message })"
|
|
x-text="imports.itemsLoading ? imports.text('loading') : imports.text('loadMore')"></button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</section>
|
|
</template>
|