MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / exportAllToCSV

Function exportAllToCSV

devtools/panel.bundle.js:2651–2708  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2649 }
2650
2651 function exportAllToCSV() {
2652 const connections = Object.values(state.connections);
2653 if (connections.length === 0) {
2654 alert('没有连接数据可导出');
2655 return;
2656 }
2657
2658 const allMessages = [];
2659 connections.forEach(conn => {
2660 getVisibleMessages(conn.messages).forEach(msg => {
2661 allMessages.push({
2662 ...msg,
2663 timestamp: formatTimestampForExport(msg.timestamp),
2664 connection: getConnectionExportInfo(conn)
2665 });
2666 });
2667 });
2668
2669 if (allMessages.length === 0) {
2670 alert('没有消息数据可导出');
2671 return;
2672 }
2673
2674 const headers = [
2675 'ConnectionID',
2676 'ConnectionURL',
2677 'RequestType',
2678 'Source',
2679 'Status',
2680 'IsIframe',
2681 'FrameURL',
2682 'ConnectionCreatedAt',
2683 'ID',
2684 'EventType',
2685 'Data',
2686 'LastEventId',
2687 'Timestamp'
2688 ];
2689 const rows = allMessages.map(msg => [
2690 escapeCSV(msg.connection.id),
2691 escapeCSV(msg.connection.url),
2692 escapeCSV(msg.connection.requestType),
2693 escapeCSV(msg.connection.source),
2694 escapeCSV(msg.connection.status),
2695 escapeCSV(msg.connection.isIframe),
2696 escapeCSV(msg.connection.frameUrl),
2697 escapeCSV(msg.connection.createdAt),
2698 escapeCSV(msg.id),
2699 escapeCSV(msg.eventType),
2700 escapeCSV(msg.data),
2701 escapeCSV(msg.lastEventId),
2702 escapeCSV(msg.timestamp)
2703 ].join(','));
2704
2705 const csvWithConnectionInfo = [headers.join(','), ...rows].join('\n');
2706 const filename = `stream-all-messages-${Date.now()}.csv`;
2707 downloadFile(csvWithConnectionInfo, filename, 'text/csv');
2708 }

Callers 1

handleExportFunction · 0.70

Calls 5

getVisibleMessagesFunction · 0.70
formatTimestampForExportFunction · 0.70
getConnectionExportInfoFunction · 0.70
escapeCSVFunction · 0.70
downloadFileFunction · 0.70

Tested by

no test coverage detected