Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python
20.7 KB
Raw Blame
<!-- Mobile Header for Detail View.

     The global app header already shows the recording title with the
     edit + regenerate buttons on mobile, so this component owns only
     the secondary information layer:
       (a) Always-visible meta strip — participants + status + folder
           / tag / share pills, plus a single chevron to expand.
       (b) Expanded panel — secondary metadata (date / file size /
           etc.) grouped as a clean pill row, and an action toolbar
           sitting on its own bg-tertiary background so the cluster of
           icons reads as ONE bordered control bar instead of nine
           loose icons floating against the page background. -->
<div class="border-b flex-shrink-0"
     style="background: var(--bg-secondary); border-bottom-color: var(--border-primary);">

    <!-- Always-visible meta strip -->
    <div @click="isMetadataExpanded = !isMetadataExpanded"
         class="cursor-pointer px-4 py-2 flex items-center gap-3">

        <div class="flex-1 min-w-0">
            <!-- Participants, single line, truncates. The processing
                 status badge is intentionally NOT duplicated here — it
                 already shows in the title area (components/header.html). -->
            <div class="flex items-center gap-2 min-w-0">
                <i class="fas fa-users flex-shrink-0" style="color: var(--text-muted); font-size: 11px;"></i>
                <span class="text-sm truncate" style="color: var(--text-secondary);"
                      v-text="selectedRecording.participants || t('help.noParticipants')"></span>
            </div>

            <!-- Folder / tag / share pill row, only when present -->
            <div v-if="(foldersEnabled && selectedRecording.folder_id) || getRecordingTags(selectedRecording).length > 0 || selectedRecording.is_shared || selectedRecording.shared_with_count > 0 || selectedRecording.public_share_count > 0"
                 class="flex flex-wrap gap-1 mt-1.5">
                <span v-if="foldersEnabled && selectedRecording.folder_id && !selectedRecording.incognito"
                      class="chip"
                      :style="{ backgroundColor: getFolderColor(selectedRecording.folder_id), color: getContrastTextColor(getFolderColor(selectedRecording.folder_id)) }">
                    <i class="fas fa-folder"></i>
                    <span class="chip__label" v-text="getFolderName(selectedRecording.folder_id)"></span>
                </span>
                <button v-for="tag in getRecordingTags(selectedRecording)" :key="tag.id"
                        @click.stop="filterByTag(tag)"
                        class="chip chip--clickable"
                        :style="{ backgroundColor: tag.color, color: getContrastTextColor(tag.color) }"
                        :title="tag.group_id ? t('tooltips.groupLabel', { name: tag.group_name }) : tag.name">
                    <i v-if="tag.group_id" class="fas fa-users"></i>
                    <i v-else class="fas fa-tag"></i>
                    <span class="chip__label" v-text="tag.name"></span>
                </button>
                <span v-if="selectedRecording.is_shared" class="chip bg-purple-500 text-white">
                    <i class="fas fa-arrow-down"></i><span class="chip__label" v-text="t('sharing.sharedBadge')"></span>
                </span>
                <span v-if="!selectedRecording.is_shared && selectedRecording.shared_with_count > 0" class="chip bg-indigo-500 text-white">
                    <i class="fas fa-arrow-up"></i><span class="chip__label">${ selectedRecording.shared_with_count }</span>
                </span>
                <span v-if="!selectedRecording.is_shared && selectedRecording.public_share_count > 0" class="chip bg-teal-500 text-white">
                    <i class="fas fa-globe"></i><span class="chip__label">${ selectedRecording.public_share_count }</span>
                </span>
            </div>
        </div>

        <!-- Contextual toolbar — tab-specific actions move INTO the
             chevron row instead of taking a whole separate row in
             each panel. Saves a row of vertical space and gives the
             user the actions next to where their eye is anyway.
             Hidden when the active tab is in an editing mode since
             the editor's own Cancel/Save footer takes over. -->
        <div class="flex items-center gap-0.5 flex-shrink-0">
            <template v-if="mobileTab === 'summary' && !editingSummary">
                <button v-if="selectedRecording.summary" @click.stop="copySummary" class="btn btn--icon btn--sm" :title="t('buttons.copySummary')"><i class="fas fa-copy"></i></button>
                <button v-if="selectedRecording.summary" @click.stop="downloadSummary" class="btn btn--icon btn--sm" :title="t('buttons.downloadAsWord')"><i class="fas fa-download"></i></button>
                <button @click.stop="toggleEditSummary" class="btn btn--icon btn--sm" :title="t('buttons.editSummary')"><i class="fas fa-pen"></i></button>
            </template>
            <template v-else-if="mobileTab === 'notes' && !editingNotes">
                <button v-if="selectedRecording.notes" @click.stop="copyNotes" class="btn btn--icon btn--sm" :title="t('buttons.copyNotes')"><i class="fas fa-copy"></i></button>
                <button v-if="selectedRecording.notes" @click.stop="downloadNotes" class="btn btn--icon btn--sm" :title="t('buttons.downloadAsWord')"><i class="fas fa-download"></i></button>
                <button @click.stop="toggleEditNotes" class="btn btn--icon btn--sm" :title="t('buttons.editNotes')"><i class="fas fa-pen"></i></button>
            </template>
            <template v-else-if="mobileTab === 'transcript'">
                <!-- Follow-player toggle: when ON, only the icon
                     COLOUR changes (text-accent), no background
                     pill. Previously it carried bg-accent which
                     made the button visually heavier than its
                     peers in the same toolbar — caused the
                     "inconsistent box sizes" issue from the
                     follow-up message. Stays identical in
                     dimensions to copy / download / edit
                     regardless of state. -->
                <button v-if="processedTranscription.isJson && processedTranscription.hasDialogue"
                        @click.stop="toggleFollowPlayerMode"
                        class="btn btn--icon btn--sm"
                        :style="followPlayerMode ? 'color: var(--text-accent);' : ''"
                        :title="followPlayerMode ? t('tooltips.followPlayerEnabled') : t('tooltips.followPlayerDisabled')">
                    <i class="fas fa-arrows-alt-v"></i>
                </button>
                <button v-if="processedTranscription.hasDialogue"
                        @click.stop="toggleTranscriptionViewMode"
                        class="btn btn--icon btn--sm"
                        :title="transcriptionViewMode === 'simple' ? (t('tooltips.bubbleView') || 'Bubble view') : (t('tooltips.simpleView') || 'Simple view')">
                    <i :class="transcriptionViewMode === 'simple' ? 'fas fa-comments' : 'fas fa-list'"></i>
                </button>
                <button @click.stop="copyTranscription" class="btn btn--icon btn--sm" :title="t('tooltips.copyTranscript')"><i class="fas fa-copy"></i></button>
                <button v-if="selectedRecording.transcription" @click.stop="downloadTranscript" class="btn btn--icon btn--sm" :title="t('tooltips.downloadTranscriptWithTemplate')"><i class="fas fa-download"></i></button>
                <button v-if="selectedRecording.transcription" @click.stop="openTranscriptionEditor" class="btn btn--icon btn--sm" :title="t('tooltips.editTranscript')"><i class="fas fa-edit"></i></button>
            </template>
            <template v-else-if="mobileTab === 'events' && selectedRecording.events && selectedRecording.events.length > 0">
                <button @click.stop="downloadICS" class="btn btn--icon btn--sm" :title="t('buttons.exportCalendar')">
                    <i class="fas fa-calendar-plus"></i>
                </button>
            </template>
            <template v-else-if="mobileTab === 'chat' && chatMessages && chatMessages.length > 0">
                <button @click.stop="clearChat" class="btn btn--icon btn--sm" :title="t('tooltips.clearChat')">
                    <i class="fas fa-times"></i>
                </button>
            </template>

            <button @click.stop="isMetadataExpanded = !isMetadataExpanded"
                    class="btn btn--icon btn--sm"
                    :title="isMetadataExpanded ? t('tooltips.hideDetails') : t('tooltips.showDetails')">
                <i :class="['fas fa-chevron-down text-xs transition-transform', { 'rotate-180': isMetadataExpanded }]"></i>
            </button>
        </div>
    </div>

    <!-- Expanded panel -->
    <div v-if="isMetadataExpanded" class="px-3 pb-3 space-y-2">

        <!-- Metadata: chip-styled so it reads as a tidy row of facts
             instead of a comma-separated string. Each chip is the
             same height/padding so the row has visual rhythm. -->
        <div class="flex flex-wrap gap-1.5">
            <button @click.stop="openMeetingDatePicker" class="chip-meta chip-meta--clickable">
                <i class="fas fa-calendar"></i>
                <span class="chip-meta__label" v-text="selectedRecording.meeting_date ? formatDisplayDate(selectedRecording.meeting_date) : t('help.noDateSet')"></span>
            </button>
            <span v-if="selectedRecording.is_shared" class="chip-meta">
                <i class="fas fa-user"></i>
                <span class="chip-meta__label" v-text="selectedRecording.owner_username || t('sharing.unknown')"></span>
            </span>
            <template v-if="activeRecordingMetadata" v-for="(item, index) in activeRecordingMetadata" :key="index">
                <span v-if="!item.isTagItem" class="chip-meta" :title="item.fullText || item.text">
                    <i :class="item.icon"></i>
                    <span class="chip-meta__label" v-text="item.text"></span>
                </span>
            </template>
            <button v-if="selectedRecording.duplicate_info"
                    @click.stop="openDuplicatesModal(selectedRecording.duplicate_info)"
                    class="chip-meta chip-meta--warn chip-meta--clickable">
                <i class="fas fa-copy"></i>
                <span>${ selectedRecording.duplicate_info.total_copies } ${ t('upload.copies') || 'copies' }</span>
            </button>

            <!-- Transcription hints used (#309) -->
            <div v-if="selectedRecording.resolved_hotwords || selectedRecording.resolved_initial_prompt" class="relative">
                <button @click.stop="toggleHintsPopover($event)"
                        class="chip-meta chip-meta--clickable"
                        :title="t('detail.hintsUsed')">
                    <i class="fas fa-wand-magic-sparkles"></i>
                    <span>${ t('detail.hints') }</span>
                </button>
                <div v-if="showHintsPopover" @click.stop="showHintsPopover = false" class="fixed inset-0 z-40"></div>
                <div v-if="showHintsPopover" :style="hintsPopoverStyle"
                     class="hints-popover absolute left-0 top-full mt-1 z-50 w-64 max-w-[80vw] p-3 bg-[var(--bg-primary)] border border-[var(--border-primary)] rounded-md shadow-lg text-left space-y-2">
                    <div v-if="selectedRecording.resolved_hotwords">
                        <p class="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]">${ t('form.hotwords') }</p>
                        <p class="text-xs text-[var(--text-primary)] whitespace-pre-wrap break-words">${ selectedRecording.resolved_hotwords }</p>
                    </div>
                    <div v-if="selectedRecording.resolved_initial_prompt">
                        <p class="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]">${ t('form.initialPrompt') }</p>
                        <p class="text-xs text-[var(--text-primary)] whitespace-pre-wrap break-words">${ selectedRecording.resolved_initial_prompt }</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- Action toolbar — sits on its own bg-tertiary background
             so the cluster of icons reads as one bordered control bar
             instead of a row of free-floating icons. Horizontal scroll
             on overflow so adding more actions doesn't break layout. -->
        <div class="rounded-md overflow-hidden" style="background: var(--bg-tertiary);">
            <div class="flex items-center gap-0.5 overflow-x-auto px-1 py-1">
                <template v-if="!selectedRecording.incognito">
                    <!-- Inbox / highlight active state uses :style not
                         :class because primitives.css's
                         .btn--icon:not(.btn--primary):not(.btn--danger):not(.btn--ghost):not(.btn--quiet)
                         rule for default colour has higher specificity
                         than a single Tailwind text-* utility, so the
                         conditional text-blue-500 / text-yellow-500
                         classes never won — inline style sidesteps the
                         specificity contest. -->
                    <button @click.stop="toggleInbox(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :style="selectedRecording.is_inbox ? 'color: #3b82f6;' : ''"
                            :title="t('sidebar.inbox')"><i class="fas fa-inbox"></i></button>
                    <button @click.stop="toggleHighlight(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :style="selectedRecording.is_highlighted ? 'color: #eab308;' : ''"
                            :title="t('tooltips.highlight')"><i class="fas fa-star"></i></button>
                    <button @click.stop="toggleArchive(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :style="selectedRecording.is_archived ? 'color: var(--text-accent);' : ''"
                            :title="selectedRecording.is_archived ? t('archive.unarchive') : t('archive.archive')"><i class="fas fa-box-archive"></i></button>
                    <!-- Folder picker: the wrapper uses display: block
                         + position: relative so the native <select>'s
                         absolute-positioned dropdown anchors to the
                         folder icon button visually, not to (0,0) of
                         the viewport (which was the symptom on mobile
                         when the wrapper inherited inline-flex from
                         .btn). The select is visually invisible via
                         opacity but receives clicks; native OS picker
                         handles the dropdown UI. -->
                    <label v-if="foldersEnabled && selectedRecording.can_edit !== false"
                           class="btn btn--icon btn--sm flex-shrink-0 cursor-pointer"
                           style="position: relative;"
                           :title="selectedRecording.folder_id ? getFolderName(selectedRecording.folder_id) : t('tooltips.assignFolder')">
                        <select @change.stop="assignFolderToRecording(selectedRecording.id, $event.target.value || null)"
                                :value="selectedRecording.folder_id || ''"
                                style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; background: transparent;">
                            <option value="" v-text="t('folderManagement.noFolder')"></option>
                            <option v-for="folder in availableFolders" :key="folder.id" :value="folder.id">
                                ${ folder.name }
                            </option>
                        </select>
                        <i class="fas fa-folder"
                           :style="{ color: selectedRecording.folder_id ? getFolderColor(selectedRecording.folder_id) : '' }"></i>
                    </label>
                    <button @click.stop="editRecordingTags(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="t('buttons.editTags')"><i class="fas fa-tags"></i></button>
                    <!-- Subtle inline divider so the destructive / reset
                         actions read as a distinct group from the
                         everyday actions. -->
                    <span class="flex-shrink-0 mx-0.5" style="width: 1px; height: 18px; background: var(--border-primary);"></span>
                    <button @click.stop="confirmReprocess('transcription', selectedRecording)"
                            v-if="selectedRecording && selectedRecording.can_edit !== false && (selectedRecording.status === 'COMPLETED' || selectedRecording.status === 'FAILED') && !selectedRecording.audio_deleted_at"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="t('tooltips.reprocessTranscription')"><i class="fas fa-redo-alt"></i></button>
                    <button @click.stop="confirmReprocess('summary', selectedRecording)"
                            v-if="selectedRecording && selectedRecording.can_edit !== false && (selectedRecording.status === 'COMPLETED' || selectedRecording.status === 'FAILED')"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="t('summary.regenerateSummary')"><i class="fas fa-sync-alt"></i></button>
                    <button @click.stop="confirmReset(selectedRecording)"
                            v-if="['PENDING', 'QUEUED', 'PROCESSING', 'SUMMARIZING', 'FAILED'].includes(selectedRecording.status)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            style="color: var(--text-warn, #d97706);"
                            :title="t('buttons.resetStuckProcessing')"><i class="fas fa-undo"></i></button>
                    <button @click.stop="openSpeakerModal"
                            v-if="processedTranscription.hasDialogue"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="t('buttons.identifySpeakers')"><i class="fas fa-user-tag"></i></button>
                    <button v-if="!selectedRecording.is_shared || (selectedRecording.share_info && selectedRecording.share_info.can_reshare)"
                            @click.stop="openUnifiedShareModal(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="t('buttons.shareRecording')"><i class="fas fa-share-alt"></i></button>
                    <!-- Pushes delete to the right edge so it's
                         visually separate from the everyday actions
                         and harder to mis-tap. -->
                    <span class="flex-1"></span>
                    <button v-if="canDeleteRecordings && selectedRecording.can_delete !== false && !selectedRecording.audio_deleted_at && (selectedRecording.status === 'COMPLETED' || selectedRecording.status === 'FAILED')"
                            @click.stop="confirmDeleteAudio(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            :title="((selectedRecording.mime_type && selectedRecording.mime_type.startsWith('video/')) ? t('deleteAudio.actionVideo') : t('deleteAudio.action'))"><i class="fas fa-volume-xmark"></i></button>
                    <button v-if="canDeleteRecordings && selectedRecording.can_delete !== false"
                            @click.stop="confirmDelete(selectedRecording)"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            style="color: var(--text-danger);"
                            :title="t('buttons.delete')"><i class="fas fa-trash"></i></button>
                </template>

                <template v-else>
                    <span class="text-[11px] px-2 inline-flex items-center gap-1" style="color: var(--text-warn, #d97706);">
                        <i class="fas fa-user-secret"></i>
                        ${ t('incognito.mode') }
                    </span>
                    <span class="flex-1"></span>
                    <button @click.stop="clearIncognitoRecordingWithConfirm"
                            class="btn btn--icon btn--sm flex-shrink-0"
                            style="color: var(--text-danger);"
                            :title="t('tooltips.discardIncognito')"><i class="fas fa-trash"></i></button>
                </template>
            </div>
        </div>
    </div>
</div>