rentgen/report-window/report-window.tsx

76 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-11-08 20:14:28 +01:00
import React from "react";
2021-11-07 13:57:24 +01:00
import ReactDOM from "react-dom";
2021-11-07 17:23:48 +01:00
import { getMemory } from "../memory";
2021-11-08 20:14:28 +01:00
import EmailTemplate from "./email-template";
import HARConverter from "./har-converter";
2021-11-07 13:57:24 +01:00
function Report() {
2021-11-07 15:45:26 +01:00
const origin = new URL(document.location.toString()).searchParams.get(
"origin"
);
const clusters = getMemory().getClustersForOrigin(origin);
const marked_entries = Object.values(clusters)
.map((cluster) => cluster.getMarkedRequests())
.reduce((a, b) => a.concat(b), [])
.map((request) => request.getMarkedEntries())
.reduce((a, b) => a.concat(b), []);
2021-11-07 13:57:24 +01:00
return (
<div>
2021-11-07 15:45:26 +01:00
<h1>Generuj treść maila dla {origin}</h1>
<table>
<thead>
<tr>
<th>Adres docelowy</th>
<th>Źródło danych</th>
<th>Treść danych</th>
2021-11-07 17:44:22 +01:00
<th>Klasyfikacja</th>
2021-11-07 15:45:26 +01:00
</tr>
</thead>
<tbody>
{marked_entries.map((entry) => (
2021-11-07 17:51:30 +01:00
<tr
style={{
backgroundColor:
entry.classification == "id" ? "yellow" : "white",
}}
>
2021-11-07 15:45:26 +01:00
<td>{entry.request.shorthost}</td>
2021-11-07 17:44:22 +01:00
<td style={{ overflowWrap: "anywhere" }}>
2021-11-07 15:45:26 +01:00
{entry.source}:{entry.name}
{entry.markedKeys.join(",")}
</td>
2021-11-07 17:51:30 +01:00
<td
style={{
width: "400px",
overflowWrap: "anywhere",
backgroundColor: entry.isRelatedToID()
? "#ffff0054"
: "white",
2021-11-07 17:51:30 +01:00
}}
>
2021-11-07 17:44:22 +01:00
{entry.value}
</td>
2021-11-07 15:45:26 +01:00
<td>
2021-11-07 17:44:22 +01:00
<select value={entry.classification}>
2021-11-07 15:45:26 +01:00
{[
["history", "Historia przeglądania"],
["id", "Sztucznie nadane id"],
].map(([key, name]) => (
<option key={key} value={key}>
{name}
</option>
))}
</select>
</td>
</tr>
))}
</tbody>
</table>
2021-11-08 20:14:28 +01:00
<EmailTemplate {...{ marked_entries, clusters }} />
<HARConverter {...{ marked_entries }} />
2021-11-07 13:57:24 +01:00
</div>
);
}
ReactDOM.render(<Report />, document.getElementById("app"));