/** * Sync Status Component * * Shows detailed sync status including pending count, * last sync time, and manual sync button. */ const { ref, computed } = Vue; export default { name: 'SyncStatus', props: { // Number of pending operations pendingOperations: { type: Number, default: 0 }, // Number of pending photos pendingPhotos: { type: Number, default: 0 }, // Number of failed operations failedCount: { type: Number, default: 0 }, // Last sync timestamp text lastSyncText: { type: String, default: 'Nie synchronisiert' }, // Whether sync is running isSyncing: { type: Boolean, default: false }, // Whether device is online isOnline: { type: Boolean, default: true }, // Sync progress info syncProgress: { type: Object, default: null } }, emits: ['sync', 'retry-failed'], setup(props, { emit }) { // Total pending count const totalPending = computed(() => { return props.pendingOperations + props.pendingPhotos; }); // Status summary text const summaryText = computed(() => { const parts = []; if (props.pendingOperations > 0) { parts.push(`${props.pendingOperations} Änderung${props.pendingOperations === 1 ? '' : 'en'}`); } if (props.pendingPhotos > 0) { parts.push(`${props.pendingPhotos} Foto${props.pendingPhotos === 1 ? '' : 's'}`); } if (parts.length === 0) { return 'Keine ausstehenden Änderungen'; } return parts.join(', ') + ' ausstehend'; }); // Progress text during sync const progressText = computed(() => { if (!props.syncProgress) return ''; const { phase, current, total, fileName } = props.syncProgress; if (phase === 'operations') { return `Synchronisiere ${current}/${total} Änderungen...`; } if (phase === 'photos') { return fileName ? `Lade ${current}/${total} hoch: ${fileName}` : `Lade ${current}/${total} Fotos hoch...`; } return 'Synchronisiere...'; }); // Handle sync button click const handleSync = () => { if (!props.isSyncing && props.isOnline) { emit('sync'); } }; // Handle retry failed click const handleRetryFailed = () => { if (!props.isSyncing) { emit('retry-failed'); } }; return { totalPending, summaryText, progressText, handleSync, handleRetryFailed }; }, template: `

Synchronisation

{{ isOnline ? 'Online' : 'Offline' }}
{{ progressText }} {{ Math.round((syncProgress.current / syncProgress.total) * 100) }}%
Ausstehend {{ summaryText }}
Fehlgeschlagen
Letzte Synchronisation {{ lastSyncText }}

Änderungen werden synchronisiert, sobald Sie wieder online sind.

` };