π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add Show Context feature to web log viewer
Neeraj6a1dfa0ccf3b
diff --git a/infra/experiments/logs-viewer/index.html b/infra/experiments/logs-viewer/index.htmlindex bfdde62972..c3867ccb03 100644--- a/infra/experiments/logs-viewer/index.html+++ b/infra/experiments/logs-viewer/index.html@@ -206,6 +206,10 @@</div></div><div class="dialog-actions">+ <button id="show-context" class="primary-btn">+ <span class="material-icons">timeline</span>+ Show Context+ </button><button id="copy-log" class="secondary-btn">Copy</button><button id="close-detail-btn" class="secondary-btn">Close</button></div>diff --git a/infra/experiments/logs-viewer/script.js b/infra/experiments/logs-viewer/script.jsindex 8d1e803c77..bfcea60ee8 100644--- a/infra/experiments/logs-viewer/script.js+++ b/infra/experiments/logs-viewer/script.js@@ -18,6 +18,11 @@ class LogViewer {this.currentOffset = 0;this.pageSize = 100;this.isLoading = false;++ // Context mode state+ this.isContextMode = false;+ this.contextTargetLog = null;+ this.contextLogs = [];this.initializeEventListeners();}@@ -94,10 +99,12 @@ class LogViewer {const closeDetail = document.getElementById('close-detail');const closeDetailBtn = document.getElementById('close-detail-btn');const copyLog = document.getElementById('copy-log');+ const showContext = document.getElementById('show-context');closeDetail.addEventListener('click', this.hideDetailDialog.bind(this));closeDetailBtn.addEventListener('click', this.hideDetailDialog.bind(this));copyLog.addEventListener('click', this.copyLogDetail.bind(this));+ showContext.addEventListener('click', this.showLogContext.bind(this));// Export and clearconst exportBtn = document.getElementById('export-btn');@@ -660,20 +667,22 @@ class LogViewer {}, 100);}- createLogEntryHTML(log) {+ createLogEntryHTML(log, isHighlighted = false) {const levelClass = log.level.toLowerCase();const processDisplay = this.getProcessDisplayName(log.processPrefix);const formattedTime = this.formatTime(log.timestamp);const truncatedMessage = this.truncateMessage(log.message);+ const highlightClass = isHighlighted ? 'highlighted' : '';return `- <div class="log-entry ${levelClass}" data-level="${log.level}">+ <div class="log-entry ${levelClass} ${highlightClass}" data-level="${log.level}"><div class="log-level ${log.level}"></div><div class="log-content"><div class="log-header"><span class="log-time">${formattedTime}</span><span class="log-logger">${log.loggerName}</span>${processDisplay !== 'Foreground' ? `<span class="log-process">${processDisplay}</span>` : ''}+ ${isHighlighted ? '<span class="material-icons highlight-icon">my_location</span>' : ''}</div><div class="log-message">${this.escapeHtml(truncatedMessage)}</div>${log.error ? `<div class="log-error">${this.escapeHtml(log.error)}</div>` : ''}@@ -1004,6 +1013,106 @@ class LogViewer {}}+ showLogContext() {+ if (this.currentDetailLog) {+ this.isContextMode = true;+ this.contextTargetLog = this.currentDetailLog;++ // Get logs around the target log (Β±50 logs)+ const targetIndex = this.logs.findIndex(log =>+ log.timestamp === this.contextTargetLog.timestamp &&+ log.message === this.contextTargetLog.message+ );++ if (targetIndex !== -1) {+ const contextSize = 50;+ const startIndex = Math.max(0, targetIndex - contextSize);+ const endIndex = Math.min(this.logs.length, targetIndex + contextSize + 1);++ this.contextLogs = this.logs.slice(startIndex, endIndex);++ // Update UI to show context mode+ this.updateContextModeUI();+ this.displayContextLogs();++ // Close detail dialog+ this.hideDetailDialog();+ }+ }+ }++ updateContextModeUI() {+ const headerTitle = document.querySelector('.header-content h1');+ const searchSection = document.querySelector('.search-section');+ const timelineSection = document.getElementById('timeline-section');+ const activeFilters = document.getElementById('active-filters');++ if (this.isContextMode) {+ headerTitle.innerHTML = `+ <div class="context-header">+ <span class="material-icons">timeline</span>+ <span>Log Context - ${new Date(this.contextTargetLog.timestamp).toISOString().replace('T', ' ').slice(0, 19)}</span>+ <button id="exit-context" class="mui-button secondary" style="margin-left: 16px;">+ <span class="material-icons">close</span>+ Exit Context+ </button>+ </div>+ `;++ // Add exit context button listener+ document.getElementById('exit-context').addEventListener('click', this.exitContextMode.bind(this));++ // Hide search and timeline sections+ searchSection.style.display = 'none';+ timelineSection.style.display = 'none';+ activeFilters.style.display = 'none';+ } else {+ headerTitle.textContent = 'π Ente Log Viewer';+ searchSection.style.display = 'block';+ timelineSection.style.display = this.logs.length > 0 ? 'block' : 'none';+ }+ }++ displayContextLogs() {+ const logList = document.getElementById('log-list');+ const targetIndex = this.contextLogs.findIndex(log =>+ log.timestamp === this.contextTargetLog.timestamp &&+ log.message === this.contextTargetLog.message+ );++ logList.innerHTML = this.contextLogs.map((log, index) => {+ const isTarget = index === targetIndex;+ const entryHtml = this.createLogEntryHTML(log, isTarget);+ return entryHtml;+ }).join('');++ // Add click listeners+ logList.querySelectorAll('.log-entry').forEach((entry, index) => {+ entry.addEventListener('click', () => this.showLogDetail(this.contextLogs[index]));+ });++ // Scroll to target log+ if (targetIndex !== -1) {+ const targetEntry = logList.children[targetIndex];+ if (targetEntry) {+ targetEntry.scrollIntoView({ behavior: 'smooth', block: 'center' });+ }+ }++ // Update stats+ const logCount = document.getElementById('log-count');+ logCount.textContent = `Showing context: ${this.contextLogs.length} logs around target`;+ }++ exitContextMode() {+ this.isContextMode = false;+ this.contextTargetLog = null;+ this.contextLogs = [];++ this.updateContextModeUI();+ this.displayLogs();+ }+// AnalyticsshowAnalytics() {const analyticsContent = document.getElementById('analytics-content');diff --git a/infra/experiments/logs-viewer/styles.css b/infra/experiments/logs-viewer/styles.cssindex 6a1578365e..00f3e48026 100644--- a/infra/experiments/logs-viewer/styles.css+++ b/infra/experiments/logs-viewer/styles.css@@ -639,6 +639,48 @@ body {border-left: 4px solid var(--ente-warning);}+/* Context mode highlighting */+.log-entry.highlighted {+ background: var(--ente-background-secondary);+ border: 2px solid var(--ente-color-accent-photos);+ border-radius: 8px;+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);+ transform: translateX(0px);+ position: relative;+ animation: pulseHighlight 2s ease-in-out;+}++.log-entry.highlighted:hover {+ background: var(--ente-background-secondary);+ transform: translateX(0px);+}++.highlight-icon {+ color: var(--ente-color-accent-photos);+ font-size: 18px;+ margin-left: auto;+}++/* Context header styles */+.context-header {+ display: flex;+ align-items: center;+ gap: var(--ente-spacing-sm);+ font-size: 20px;+}++@keyframes pulseHighlight {+ 0% {+ box-shadow: 0 0 0 0 rgba(var(--ente-color-accent-photos-rgb), 0.4);+ }+ 70% {+ box-shadow: 0 0 0 10px rgba(var(--ente-color-accent-photos-rgb), 0);+ }+ 100% {+ box-shadow: 0 0 0 0 rgba(var(--ente-color-accent-photos-rgb), 0);+ }+}+.log-level {width: 12px;height: 12px;