Files
furumi-web/templates/player/imports_wizard.html
T

134 lines
10 KiB
HTML
Raw Normal View History

<template x-if="$store.imports.wizard.open">
<dialog id="import-wizard" class="player-dialog import-wizard" aria-labelledby="import-wizard-title" style="--dialog-width: 640px"
x-data="{ get imports() { return $store.imports }, get wizard() { return $store.imports.wizard } }"
x-init="$nextTick(() => { if ($el.isConnected) { $el.showModal(); document.getElementById('import-wizard-title').focus() } })"
@dismiss-player-dialog.stop="imports.closeWizard($el)"
@cancel.prevent="imports.closeWizard($el)" @click.self="imports.closeWizard($el)" @keydown.space.stop>
<div class="player-dialog-surface">
{% let dialog_head_class = "" %}
{% let dialog_title_id = "import-wizard-title" %}
{% let dialog_title = t.player_import_new %}
{% let dialog_icon = "M12 3v12m-4-4 4 4 4-4M5 21h14" %}
{% let show_version = false %}
{% include "player/dialog_header.html" %}
<div class="import-wizard-body" :aria-busy="wizard.busy">
<p class="import-notice error" role="alert" x-show="wizard.error" x-text="wizard.error"></p>
<p class="import-notice" role="status" aria-live="polite" x-show="wizard.notice" x-text="wizard.notice"></p>
<template x-if="wizard.step === 'source'">
<div class="import-step">
<template x-if="!imports.providersLoaded && !wizard.error">
<div class="page-skeleton" role="status">
<span class="loading-label">{{ t.player_loading_content }}</span>
<div class="import-source skeleton-card" aria-hidden="true"><i class="skeleton-bar"></i><i class="skeleton-bar"></i></div>
</div>
</template>
<template x-for="provider in imports.providers.filter(entry => !wizard.provider || entry.id === wizard.provider)" :key="provider.id">
<section class="import-provider">
<h3 x-text="provider.name"></h3>
<div class="import-methods">
<button type="button" class="import-method" x-show="provider.methods.includes('file')"
@click="imports.chooseMethod(provider.id, 'file')">
<strong>{{ t.player_import_method_file }}</strong>
<small>{{ t.player_import_method_file_hint }}</small>
</button>
<button type="button" class="import-method" x-show="provider.methods.includes('api')"
@click="imports.chooseMethod(provider.id, 'api')">
<strong>{{ t.player_import_method_api }}</strong>
<small>{{ t.player_import_method_api_hint }}</small>
</button>
</div>
</section>
</template>
</div>
</template>
<template x-if="wizard.step === 'upload'">
<div class="import-step">
<p class="import-help">{{ t.player_import_upload_help }}</p>
<label class="release-action-btn primary import-file-button" :class="{disabled: wizard.busy}">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 16V4m-4 4 4-4 4 4M5 20h14"/></svg>
<span>{{ t.player_import_choose_files }}</span>
<input type="file" class="import-file-input" multiple accept=".zip,.json,application/zip,application/json"
:disabled="wizard.busy" @change="imports.readFiles($event.target.files); $event.target.value = ''">
</label>
<p class="import-privacy">{{ t.player_import_privacy }}</p>
</div>
</template>
<template x-if="wizard.step === 'connect'">
<div class="import-step">
<p class="import-help">{{ t.player_import_api_help }}</p>
<button type="button" class="release-action-btn primary" :disabled="wizard.busy" @click="imports.signIn()">
{{ t.player_import_sign_in }}
</button>
</div>
</template>
<template x-if="wizard.step === 'select' && wizard.preview">
<div class="import-step">
<p class="import-help" x-show="wizard.fileNames.length"
x-text="imports.text('filesRead', {count: wizard.fileNames.length}) + (wizard.skipped ? ' ' + imports.text('filesSkipped', {count: wizard.skipped}) : '')"></p>
<p class="import-notice" x-show="wizard.preview.all_imported">{{ t.player_import_all_imported }}</p>
<div class="import-select-head">
<strong x-text="imports.text('selectedCount', {count: imports.selection().length, total: wizard.preview.playlists.length})"></strong>
<span>
<button type="button" class="import-text-action" @click="imports.selectAll(true)">{{ t.player_import_select_all }}</button>
<button type="button" class="import-text-action" @click="imports.selectAll(false)">{{ t.player_import_select_none }}</button>
</span>
</div>
<ul class="import-select-list" aria-label="{{ t.player_import_select_playlists }}">
<template x-for="playlist in wizard.preview.playlists" :key="playlist.source_key">
<li :class="{disabled: !imports.selectable(playlist)}">
<label class="import-select-row">
<input type="checkbox" :disabled="!imports.selectable(playlist)"
x-model="wizard.selected[playlist.source_key]">
<span class="import-select-copy">
<strong x-text="playlist.kind === 'favorites' ? imports.text('favorites') : playlist.title"></strong>
<small x-text="formatArtistCount(playlist.track_count, 'tracks') + (playlist.unsupported_count ? ' · ' + imports.text('unsupportedCount', {count: playlist.unsupported_count}) : '')"></small>
</span>
</label>
<template x-if="playlist.already_imported_in">
<p class="import-select-note">
<a :href="'#imports/' + playlist.already_imported_in" @click="imports.closeWizard($el.closest('dialog'), false)"
x-text="imports.text('alreadyImported', {id: playlist.already_imported_in})"></a>
</p>
</template>
<template x-if="playlist.available === false">
<p class="import-select-note">{{ t.player_import_unavailable }}</p>
</template>
<template x-if="playlist.similar_to && imports.selectable(playlist)">
<div class="import-select-note warning">
<span x-text="imports.text('similar', {id: playlist.similar_to.import_id})"></span>
<label x-show="wizard.selected[playlist.source_key]" x-transition.opacity.duration.120ms>
<input type="checkbox" x-model="wizard.confirmed[playlist.source_key]">
{{ t.player_import_confirm_similar }}
</label>
</div>
</template>
</li>
</template>
</ul>
<div class="import-consent">
<button type="button" role="switch" class="offline-switch-row" :aria-checked="wizard.federated && imports.federatedAvailable"
:disabled="!imports.federatedAvailable" aria-labelledby="import-federated-title"
aria-describedby="import-federated-consent" @click="wizard.federated = !wizard.federated">
<span class="offline-switch" aria-hidden="true"></span>
</button>
<span>
<strong id="import-federated-title">{{ t.player_import_federated }}</strong>
<small id="import-federated-consent" x-text="imports.federatedAvailable ? imports.text('federatedConsent') : imports.text('federatedOff')"></small>
</span>
</div>
</div>
</template>
<footer class="import-wizard-footer" x-show="wizard.step !== 'source'">
<button type="button" class="release-action-btn secondary" :disabled="wizard.busy" @click="imports.back()">{{ t.player_import_back }}</button>
<button type="button" class="release-action-btn primary" x-show="wizard.step === 'select'"
:disabled="!imports.canStart() && !imports.unconfirmed().length" @click="imports.begin()">{{ t.player_import_start }}</button>
</footer>
</div>
</div>
</dialog>
</template>