9740bc64c9
Continuous Deployment / Deploy to Production (push) Blocked by required conditions
Continuous Deployment / Rollback Deployment (push) Blocked by required conditions
Continuous Deployment / Post-deployment Monitoring (push) Blocked by required conditions
Continuous Deployment / Notify Deployment Status (push) Blocked by required conditions
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier1) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (full-adr060) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (tdm-3node) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / Swarm Test (ADR-062) (push) Has been skipped
npm packages / tools/ruview-mcp (node 22) (push) Failing after 1s
nvsim-server → ghcr.io / build-and-publish (push) Failing after 1s
ruview-swarm CI guard / tests (full+train) (push) Failing after 2s
Bench Regression Guard / bench compile-verify (--no-run) (push) Failing after 0s
Bench Regression Guard / bench fast-run (informational, non-gating) (push) Has been skipped
Firmware CI / Verify version.txt matches release tag (push) Has been skipped
Dashboard a11y + cross-browser / a11y (push) Failing after 0s
nvsim Dashboard → GitHub Pages / build-and-deploy (push) Failing after 2s
Firmware CI / Build firmware (esp32s3 / 4mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / Build Espressif QEMU (push) Failing after 1s
Firmware QEMU Tests (ADR-061) / Fuzz Testing (ADR-061 Layer 6) (push) Failing after 1s
Continuous Deployment / Pre-deployment Checks (push) Has been skipped
Continuous Deployment / Deploy to Staging (push) Waiting to run
Firmware CI / Build firmware (esp32c6 / c6-4mb) (push) Failing after 15s
Firmware CI / Build firmware (esp32s3 / 8mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-max) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-min) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (default) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier0) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / NVS Matrix Generation (push) Failing after 1s
Security Scanning / Security Policy Compliance (push) Failing after 0s
Security Scanning / Security Report (push) Waiting to run
Security Scanning / Dependency Vulnerability Scan (push) Failing after 0s
Security Scanning / Static Application Security Testing (push) Failing after 1s
Security Scanning / Infrastructure Security Scan (push) Failing after 1s
Security Scanning / Secret Scanning (push) Failing after 1s
npm packages / harness/ruview (node 22) (push) Failing after 17s
Security Scanning / License Compliance Scan (push) Failing after 1s
Security Scanning / Container Security Scan (push) Failing after 4s
three.js demos → GitHub Pages / build-and-deploy (push) Failing after 1s
Verify Pipeline Determinism / Verify Pipeline Determinism (3.11) (push) Failing after 1s
Fix-Marker Regression Guard / Verify fix markers (push) Failing after 1s
ADR-115 MQTT integration tests / mqtt-integration (push) Failing after 1s
npm packages / harness/ruview (node 20) (push) Failing after 1s
npm packages / tools/ruview-mcp (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 22) (push) Failing after 1s
BFLD MQTT Integration / cargo test --features mqtt (live mosquitto) (push) Failing after 29s
ruview-swarm CI guard / build train_marl bin (push) Failing after 2s
ruview-swarm CI guard / clippy (-D warnings, --no-deps) (push) Failing after 3s
ruview-swarm CI guard / tests (ruflo) (push) Failing after 1s
ruview-swarm CI guard / tests (train) (push) Failing after 2s
ruview-swarm CI guard / tests (default) (push) Failing after 2s
Point Cloud Viewer → GitHub Pages / build-and-deploy (push) Failing after 8s
ruview-swarm CI guard / ITAR / publish guard (push) Failing after 0s
wifi-densepose sensing-server → Docker Hub + ghcr.io / build · push · smoke-test (push) Failing after 1s
161 lines
5.2 KiB
JavaScript
161 lines
5.2 KiB
JavaScript
// Screenshot Tool - Capture current tab view as PNG
|
|
// Uses html2canvas-like approach with native Canvas API
|
|
|
|
import { toastManager } from './toast.js';
|
|
|
|
export class ScreenshotTool {
|
|
constructor() {
|
|
this.capturing = false;
|
|
}
|
|
|
|
init() {
|
|
document.addEventListener('take-screenshot', () => this.capture());
|
|
}
|
|
|
|
async capture() {
|
|
if (this.capturing) return;
|
|
this.capturing = true;
|
|
|
|
const activeTab = document.querySelector('.tab-content.active');
|
|
if (!activeTab) {
|
|
toastManager.warning('No active tab to capture');
|
|
this.capturing = false;
|
|
return;
|
|
}
|
|
|
|
try {
|
|
// Flash effect
|
|
this.flashEffect();
|
|
|
|
// Try native ClipboardItem API first (modern browsers)
|
|
if (typeof ClipboardItem !== 'undefined') {
|
|
await this.captureToClipboard(activeTab);
|
|
toastManager.success('Screenshot copied to clipboard', { duration: 3000 });
|
|
} else {
|
|
// Fallback: download as file
|
|
await this.captureToFile(activeTab);
|
|
toastManager.success('Screenshot saved as file', { duration: 3000 });
|
|
}
|
|
} catch (err) {
|
|
console.error('Screenshot failed:', err);
|
|
// Fallback: capture visible canvases + basic layout
|
|
try {
|
|
await this.captureCanvasFallback(activeTab);
|
|
toastManager.success('Screenshot saved (canvas only)', { duration: 3000 });
|
|
} catch {
|
|
toastManager.error('Screenshot failed. Try using browser\'s built-in screenshot tool.');
|
|
}
|
|
}
|
|
|
|
this.capturing = false;
|
|
}
|
|
|
|
async captureToClipboard(element) {
|
|
const canvas = await this.renderToCanvas(element);
|
|
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
|
|
await navigator.clipboard.write([
|
|
new ClipboardItem({ 'image/png': blob })
|
|
]);
|
|
}
|
|
|
|
async captureToFile(element) {
|
|
const canvas = await this.renderToCanvas(element);
|
|
const dataUrl = canvas.toDataURL('image/png');
|
|
const link = document.createElement('a');
|
|
link.href = dataUrl;
|
|
link.download = `ruview-screenshot-${this.timestamp()}.png`;
|
|
link.click();
|
|
}
|
|
|
|
async captureCanvasFallback(element) {
|
|
// Find any canvas elements and merge them
|
|
const canvases = element.querySelectorAll('canvas');
|
|
if (canvases.length === 0) throw new Error('No canvas elements found');
|
|
|
|
const firstCanvas = canvases[0];
|
|
const mergedCanvas = document.createElement('canvas');
|
|
mergedCanvas.width = firstCanvas.width || 800;
|
|
mergedCanvas.height = firstCanvas.height || 600;
|
|
const ctx = mergedCanvas.getContext('2d');
|
|
|
|
// Dark background
|
|
ctx.fillStyle = '#1f2121';
|
|
ctx.fillRect(0, 0, mergedCanvas.width, mergedCanvas.height);
|
|
|
|
canvases.forEach(c => {
|
|
try { ctx.drawImage(c, 0, 0); } catch { /* tainted canvas */ }
|
|
});
|
|
|
|
// Add timestamp watermark
|
|
ctx.fillStyle = 'rgba(255,255,255,0.3)';
|
|
ctx.font = '12px monospace';
|
|
ctx.fillText(`RuView - ${new Date().toLocaleString()}`, 10, mergedCanvas.height - 10);
|
|
|
|
const dataUrl = mergedCanvas.toDataURL('image/png');
|
|
const link = document.createElement('a');
|
|
link.href = dataUrl;
|
|
link.download = `ruview-screenshot-${this.timestamp()}.png`;
|
|
link.click();
|
|
}
|
|
|
|
async renderToCanvas(element) {
|
|
// Simple DOM-to-canvas renderer for basic content
|
|
const rect = element.getBoundingClientRect();
|
|
const canvas = document.createElement('canvas');
|
|
const scale = window.devicePixelRatio || 1;
|
|
canvas.width = rect.width * scale;
|
|
canvas.height = rect.height * scale;
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.scale(scale, scale);
|
|
|
|
// Render background
|
|
const styles = getComputedStyle(element);
|
|
ctx.fillStyle = styles.backgroundColor || '#1f2121';
|
|
ctx.fillRect(0, 0, rect.width, rect.height);
|
|
|
|
// Render existing canvases
|
|
const canvases = element.querySelectorAll('canvas');
|
|
canvases.forEach(c => {
|
|
const cRect = c.getBoundingClientRect();
|
|
const x = cRect.left - rect.left;
|
|
const y = cRect.top - rect.top;
|
|
try { ctx.drawImage(c, x, y, cRect.width, cRect.height); } catch { /* tainted */ }
|
|
});
|
|
|
|
// Render text content
|
|
ctx.fillStyle = styles.color || '#e0e0e0';
|
|
ctx.font = `14px ${styles.fontFamily || 'sans-serif'}`;
|
|
let textY = 30;
|
|
element.querySelectorAll('h2, h3, .stat-value, .metric-label').forEach(el => {
|
|
const text = el.textContent.trim();
|
|
if (text && textY < rect.height - 20) {
|
|
const elStyles = getComputedStyle(el);
|
|
ctx.font = `${elStyles.fontWeight} ${elStyles.fontSize} ${styles.fontFamily || 'sans-serif'}`;
|
|
ctx.fillStyle = elStyles.color;
|
|
ctx.fillText(text, 20, textY);
|
|
textY += parseInt(elStyles.fontSize) + 8;
|
|
}
|
|
});
|
|
|
|
// Watermark
|
|
ctx.fillStyle = 'rgba(255,255,255,0.15)';
|
|
ctx.font = '11px monospace';
|
|
ctx.fillText(`RuView - ${new Date().toLocaleString()}`, 10, rect.height - 10);
|
|
|
|
return canvas;
|
|
}
|
|
|
|
flashEffect() {
|
|
const flash = document.createElement('div');
|
|
flash.className = 'screenshot-flash';
|
|
document.body.appendChild(flash);
|
|
flash.addEventListener('animationend', () => flash.remove());
|
|
}
|
|
|
|
timestamp() {
|
|
return new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
}
|
|
|
|
dispose() {}
|
|
}
|