From 9f81fae747f74329a047e04b79104636c98c7bae Mon Sep 17 00:00:00 2001 From: Arkadiusz Wieczorek Date: Wed, 27 Apr 2022 18:32:54 +0200 Subject: [PATCH] Add list hosts before survey --- .../problems/unlawful-cookies.tsx | 4 + components/report-window/report-window.html | 2 +- components/report-window/report-window.tsx | 96 +++++++++++++------ components/sidebar/sidebar.html | 1 + 4 files changed, 73 insertions(+), 30 deletions(-) diff --git a/components/report-window/problems/unlawful-cookies.tsx b/components/report-window/problems/unlawful-cookies.tsx index 53e98b7..43aecc6 100644 --- a/components/report-window/problems/unlawful-cookies.tsx +++ b/components/report-window/problems/unlawful-cookies.tsx @@ -13,6 +13,10 @@ export class UnlawfulCookieAccess extends Problem { static qualifies(answers: ParsedAnswers, clusters: RequestCluster[]): boolean { // są cookiesy, nie było zgody, nie są konieczne do działania strony const cookie_clusters = Object.values(clusters).filter((c) => c.hasMarkedCookies()); + + console.log(answers, cookie_clusters, clusters); + // tutaj jest problem z answerami vs to co jest w clusters + return cookie_clusters.some((cluster) => { const hostAnswers = answers.hosts[cluster.id]; return ( diff --git a/components/report-window/report-window.html b/components/report-window/report-window.html index 8425879..b357e98 100644 --- a/components/report-window/report-window.html +++ b/components/report-window/report-window.html @@ -3,7 +3,7 @@ - Treść maila do zgłoszenia + Rentgen — Generowanie raportu ({}); + const [surveyMode, setSurveyMode] = React.useState(false); + try { const url = new URL(document.location.toString()); const origin = url.searchParams.get('origin'); @@ -18,21 +25,6 @@ function Report() { ); const [mode, setMode] = React.useState(url.searchParams.get('mode') || 'survey'); const clusters = getMemory().getClustersForOrigin(origin); - /* const [entries, setEntries] = React.useState([]); */ - /* React.useEffect(() => { - * setEntries( - * Object.values(clusters) - * .map((cluster) => { - * cluster.calculateRepresentativeStolenData(); - * return cluster.representativeStolenData; - * }) - * .reduce(reduceConcat, []) - * .filter((entry) => entry.isMarked) - * ); - * }, []); */ - /* if (entries.length == 0) { - * return <>Wczytywanie...; - * } */ React.useEffect(() => { const url = new URL(document.location.toString()); @@ -40,7 +32,15 @@ function Report() { url.searchParams.set('answers', JSON.stringify(answers)); url.searchParams.set('mode', mode); history.pushState({}, 'Rentgen', url.toString()); + setHosts( + Object.fromEntries( + Object.values(clusters) + .filter((cluster) => cluster.getMarkedRequests().length > 0) + .map((cluster) => [cluster.id, true]) + ) + ); }, [mode, answers, origin]); + const visited_url = Object.values(clusters) .find((cluster) => cluster.getMarkedRequests().length > 0) ?.getMarkedRequests()[0].originalURL; @@ -49,9 +49,12 @@ function Report() {
{mode === 'survey' ? ( cluster.getMarkedRequests().length > 0) - .map((cluster) => cluster.id)} + // hosts={Object.values(clusters) + // .filter((cluster) => cluster.getMarkedRequests().length > 0) + // .map((cluster) => cluster.id)} + hosts={Object.entries(hosts) + .filter((host) => host[1]) + .map((host) => host[0])} onComplete={(answers) => { setAnswers(parseAnswers(answers)); setMode('preview'); @@ -64,23 +67,58 @@ function Report() { {/* */}
); + + function markHost(name: string) { + const clone_hosts = Object.assign({}, hosts); + clone_hosts[name] = !clone_hosts[name]; + setHosts(clone_hosts); + console.log(hosts); + } + return ( - +
- {origin ? ( - <> - Generowanie raportu - {origin} - - ) : ( - Przejdź do wybranej strony internetowej - )} + Generowanie raportu + {origin}
-
{result}
- + {surveyMode ? ( +
{result}
+ ) : ( +
+ Wybór hostów +
    + { + // Object.values(clusters) + // .filter((cluster) => cluster.getMarkedRequests().length > 0) + // .map((cluster) => cluster.id) + + Object.keys(hosts).map((host) => { + return ( +
  • + +
  • + ); + }) + } + + {/* */} +
+ +
+ )} +
); } catch (e) { console.error(e); diff --git a/components/sidebar/sidebar.html b/components/sidebar/sidebar.html index fe53422..7feb4f2 100644 --- a/components/sidebar/sidebar.html +++ b/components/sidebar/sidebar.html @@ -2,6 +2,7 @@ + Rentgen — Widok szczegółowy