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-11 20:25:06 +01:00
|
|
|
import { Classifications } from "../stolen-data-entry";
|
2021-11-21 18:21:31 +01:00
|
|
|
import { reduceConcat, useEmitter } from "../util";
|
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"
|
|
|
|
);
|
2021-11-11 20:25:06 +01:00
|
|
|
const [counter, setCounter] = useEmitter(getMemory());
|
|
|
|
function refresh() {
|
|
|
|
setCounter((c) => c + 1);
|
|
|
|
}
|
2021-11-07 15:45:26 +01:00
|
|
|
const clusters = getMemory().getClustersForOrigin(origin);
|
2021-11-21 18:21:31 +01:00
|
|
|
const marks = Object.values(clusters)
|
2021-11-07 15:45:26 +01:00
|
|
|
.map((cluster) => cluster.getMarkedRequests())
|
2021-11-21 18:21:31 +01:00
|
|
|
.reduce(reduceConcat, [])
|
2021-11-07 15:45:26 +01:00
|
|
|
.map((request) => request.getMarkedEntries())
|
2021-11-21 18:21:31 +01:00
|
|
|
.reduce(reduceConcat, [])
|
|
|
|
.map((entry) => entry.marks)
|
|
|
|
.reduce(reduceConcat, []);
|
2021-11-07 13:57:24 +01:00
|
|
|
return (
|
2021-11-21 18:21:31 +01:00
|
|
|
<div {...{ "data-version": counter }}>
|
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>
|
2021-11-21 18:21:31 +01:00
|
|
|
{marks.map((mark) => (
|
2021-11-07 17:51:30 +01:00
|
|
|
<tr
|
2021-11-21 18:21:31 +01:00
|
|
|
key={mark.entry.request.originalURL + ";" + mark.key}
|
2021-11-07 17:51:30 +01:00
|
|
|
style={{
|
|
|
|
backgroundColor:
|
2021-11-21 18:21:31 +01:00
|
|
|
mark.classification == "id" ? "yellow" : "white",
|
2021-11-07 17:51:30 +01:00
|
|
|
}}
|
|
|
|
>
|
2021-11-21 18:21:31 +01:00
|
|
|
<td>{mark.shorthost}</td>
|
2021-11-07 17:44:22 +01:00
|
|
|
<td style={{ overflowWrap: "anywhere" }}>
|
2021-11-21 18:21:31 +01:00
|
|
|
{mark.source}:{mark.name}
|
|
|
|
{mark.key}
|
2021-11-07 15:45:26 +01:00
|
|
|
</td>
|
2021-11-07 17:51:30 +01:00
|
|
|
<td
|
|
|
|
style={{
|
|
|
|
width: "400px",
|
|
|
|
overflowWrap: "anywhere",
|
2021-11-21 18:21:31 +01:00
|
|
|
backgroundColor: mark.entry.isRelatedToID()
|
2021-11-07 17:59:16 +01:00
|
|
|
? "#ffff0054"
|
|
|
|
: "white",
|
2021-11-07 17:51:30 +01:00
|
|
|
}}
|
|
|
|
>
|
2021-11-21 18:21:31 +01:00
|
|
|
{mark.valuePreview}
|
|
|
|
{/* always gonna have
|
|
|
|
one key, because unwrapEntry is calle above */}
|
2021-11-07 17:44:22 +01:00
|
|
|
</td>
|
2021-11-07 15:45:26 +01:00
|
|
|
<td>
|
2021-11-11 20:25:06 +01:00
|
|
|
<select
|
2021-11-21 18:21:31 +01:00
|
|
|
value={mark.classification}
|
2021-11-11 20:25:06 +01:00
|
|
|
onChange={(e) => {
|
2021-11-21 18:21:31 +01:00
|
|
|
mark.classification = e.target
|
2021-11-11 20:25:06 +01:00
|
|
|
.value as keyof typeof Classifications;
|
2021-11-21 18:21:31 +01:00
|
|
|
console.log("changed classification!");
|
2021-11-11 20:25:06 +01:00
|
|
|
refresh();
|
|
|
|
}}
|
|
|
|
>
|
2021-11-07 15:45:26 +01:00
|
|
|
{[
|
|
|
|
["history", "Historia przeglądania"],
|
|
|
|
["id", "Sztucznie nadane id"],
|
2021-11-21 18:21:31 +01:00
|
|
|
["location", "Lokalizacja"],
|
2021-11-07 15:45:26 +01:00
|
|
|
].map(([key, name]) => (
|
|
|
|
<option key={key} value={key}>
|
|
|
|
{name}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2021-11-21 18:21:31 +01:00
|
|
|
<EmailTemplate {...{ marks, clusters, version: counter }} />
|
|
|
|
<HARConverter {...{ marks }} />
|
2021-11-07 13:57:24 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Report />, document.getElementById("app"));
|