Skip to content

Commit

Permalink
webapp: formatting with prettier
Browse files Browse the repository at this point in the history
Prettier must have had an update.
  • Loading branch information
jasonish committed Feb 25, 2025
1 parent 62bc3eb commit ea76140
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 163 deletions.
2 changes: 1 addition & 1 deletion webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
28 changes: 14 additions & 14 deletions webapp/src/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function Alerts() {
break;
default:
console.log(
`Location path ${location.pathname} not supported here, redirecting to /inbox`
`Location path ${location.pathname} not supported here, redirecting to /inbox`,
);
navigate("/inbox");
break;
Expand Down Expand Up @@ -288,7 +288,7 @@ export function Alerts() {
const logger = new Logger("Alerts.createEffect: visible events", true);
batch(() => {
setVisibleEvents(
eventStore.events.slice(getOffset(), getOffset() + getRowCount())
eventStore.events.slice(getOffset(), getOffset() + getRowCount()),
);
if (visibleEvents().length === 0 && getOffset() > 0) {
logger.log("No more visible events, moving to previous page");
Expand Down Expand Up @@ -441,7 +441,7 @@ export function Alerts() {
function sortAlerts(
alerts: EventWrapper[],
sortBy: string,
order: string
order: string,
): void {
console.log(`sortAlerts: sortBy=${sortBy}, order=${order}`);

Expand All @@ -459,7 +459,7 @@ export function Alerts() {
alerts.sort((a: any, b: any) => {
return compare(
a._source.alert.signature.toUpperCase(),
b._source.alert.signature.toUpperCase()
b._source.alert.signature.toUpperCase(),
);
});
break;
Expand Down Expand Up @@ -744,7 +744,7 @@ export function Alerts() {
archiveByEvent(event);
}
addNotification(
`Auto-archive filter successfully added and ${matchingEvents.length} events archived.`
`Auto-archive filter successfully added and ${matchingEvents.length} events archived.`,
);
};

Expand All @@ -766,7 +766,7 @@ export function Alerts() {
"eventStore.cursor": eventStore.cursor,
},
null,
1
1,
)}
</Col>
</Row>
Expand Down Expand Up @@ -1145,7 +1145,7 @@ export function Alerts() {
e.preventDefault();
e.stopPropagation();
filterForSignatureId(
alert.signature_id
alert.signature_id,
);
}}
>
Expand All @@ -1160,7 +1160,7 @@ export function Alerts() {
e.preventDefault();
e.stopPropagation();
filterOutSignatureId(
alert.signature_id
alert.signature_id,
);
}}
>
Expand All @@ -1177,7 +1177,7 @@ export function Alerts() {
addFilter(
"@from",
"",
event._source.timestamp
event._source.timestamp,
);
}}
>
Expand All @@ -1194,7 +1194,7 @@ export function Alerts() {
addFilter(
"@to",
"",
event._source.timestamp
event._source.timestamp,
);
}}
>
Expand All @@ -1212,7 +1212,7 @@ export function Alerts() {
addFilter(
"host",
"",
event._source.host
event._source.host,
);
}}
>
Expand All @@ -1229,7 +1229,7 @@ export function Alerts() {
addFilter(
"host",
"-",
event._source.host
event._source.host,
);
}}
>
Expand Down Expand Up @@ -1375,10 +1375,10 @@ function PagerRow(props: {

createEffect(() => {
const tooltipTriggerList = document.querySelectorAll(
'[data-bs-toggle="tooltip"]'
'[data-bs-toggle="tooltip"]',
);
const tooltipList = [...tooltipTriggerList].map(
(tooltipTriggerEl) => new bootstrap.Tooltip(tooltipTriggerEl)
(tooltipTriggerEl) => new bootstrap.Tooltip(tooltipTriggerEl),
);
});

Expand Down
10 changes: 5 additions & 5 deletions webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ function AuthenticationRequired(props: any) {
createEffect(() => {
if (!IS_AUTHENTICATED() && mounted) {
console.log(
"App is mounted but not authenticated, redirecting to login."
"App is mounted but not authenticated, redirecting to login.",
);
navigate(
`/login?redirectTo=${encodeURIComponent(
location.pathname + "?" + location.search
)}`
location.pathname + "?" + location.search,
)}`,
);
}
});
Expand All @@ -122,8 +122,8 @@ function AuthenticationRequired(props: any) {
console.log(`Failed to get user: ${error}`);
navigate(
`/login?redirectTo=${encodeURIComponent(
location.pathname + "?" + location.search
)}`
location.pathname + "?" + location.search,
)}`,
);
});
mounted = true;
Expand Down
24 changes: 12 additions & 12 deletions webapp/src/EventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ export function EventView() {
const _srcIpDns = srcIpDns();
const _destIpDns = destIpDns();
const popoverTriggerList = document.querySelectorAll(
'[data-bs-toggle="popover"]'
'[data-bs-toggle="popover"]',
);
const popoverList = [...popoverTriggerList].map(
(popoverTriggerEl) => new bootstrap.Popover(popoverTriggerEl)
(popoverTriggerEl) => new bootstrap.Popover(popoverTriggerEl),
);
});

Expand Down Expand Up @@ -254,12 +254,12 @@ export function EventView() {
switch (typeof props.value) {
case "number":
q = encodeURIComponent(
`${props.field ? props.field + ":" : ""}${props.value}`
`${props.field ? props.field + ":" : ""}${props.value}`,
);
break;
default:
q = encodeURIComponent(
`${props.field ? props.field + ":" : ""}"${props.value}"`
`${props.field ? props.field + ":" : ""}"${props.value}"`,
);
break;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ export function EventView() {

function copyRawJson() {
const e: HTMLInputElement | null = document.getElementById(
"raw-json"
"raw-json",
) as HTMLInputElement;
if (e) {
e.select();
Expand Down Expand Up @@ -421,7 +421,7 @@ export function EventView() {

function selectRawJson() {
const e: HTMLInputElement | null = document.getElementById(
"formatted-json"
"formatted-json",
) as HTMLInputElement;
if (e) {
selectElementText(e);
Expand Down Expand Up @@ -604,7 +604,7 @@ export function EventView() {
}
let url = service.url.replace(
"{{raw}}",
encodeURIComponent(JSON.stringify(event._source))
encodeURIComponent(JSON.stringify(event._source)),
);
if (serviceLinks.length > 0) {
serviceLinks.push(" | ");
Expand Down Expand Up @@ -1227,7 +1227,7 @@ function toPrettyHex(data: string): [string, string][] {
function formatTitle(event: Event): string {
try {
return `${event._source.event_type.toUpperCase()}: ${formatEventDescription(
event
event,
)}`;
} catch (err) {
return JSON.stringify(event);
Expand All @@ -1253,7 +1253,7 @@ function formatTimestamp(timestamp: string) {
function flattenJson(
object: any,
prefix: string[] = [],
output: { key: string; val: any }[] = []
output: { key: string; val: any }[] = [],
): { key: string; val: any }[] {
if (object === null) {
return output;
Expand Down Expand Up @@ -1372,19 +1372,19 @@ function HighlightedRule(props: { rule: string }) {
<span class="rule-header-port">$4</span>
<span class="rule-header-direction">$5</span>
<span class="rule-header-addr">$6</span>
<span class="rule-header-port">$7</span> `
<span class="rule-header-port">$7</span> `,
);

html = html.replace(
/:([^;]+)/g,
`:<span class="rule-keyword-value">$1</span>`
`:<span class="rule-keyword-value">$1</span>`,
);
html = html.replace(/(\w+\:)/g, `<span class="rule-keyword">$1</span>`);

// Catch keywords without a value.
html = html.replace(
/(;\s*)(\w+;)/g,
`$1<span class="rule-keyword">$2</span>`
`$1<span class="rule-keyword">$2</span>`,
);

// Replace referece URLs with the URL.
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function Events() {
const timestamp = events()
[events().length - 1]._source["@timestamp"].replace(
/(\d{4})-(\d{2})-(\d{2})/,
"$1$2$3"
"$1$2$3",
)
.replaceAll(":", "");
setSearchParams({
Expand Down Expand Up @@ -511,7 +511,7 @@ export function Events() {
addFilter(
"event_type",
"+",
event._source.event_type
event._source.event_type,
);
}}
title={`Filter for event_type: ${event._source.event_type}`}
Expand All @@ -525,7 +525,7 @@ export function Events() {
addFilter(
"event_type",
"-",
event._source.event_type
event._source.event_type,
);
}}
title={`Filter out event_type: ${event._source.event_type}`}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Login = () => {
let redirectTo = searchParams.redirectTo || "/inbox";
if (!options.authentication.required) {
console.log(
`No authentication required, navigating back to ${redirectTo}`
`No authentication required, navigating back to ${redirectTo}`,
);
navigate(redirectTo);
}
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { BiQuestionCircle } from "./icons";
export function Settings() {
createEffect(() => {
const popoverTriggerList = document.querySelectorAll(
'[data-bs-toggle="popover"]'
'[data-bs-toggle="popover"]',
);
[...popoverTriggerList].map(
(popoverTriggerEl) =>
new bootstrap.Popover(popoverTriggerEl, { html: true })
new bootstrap.Popover(popoverTriggerEl, { html: true }),
);
});

Expand Down Expand Up @@ -174,7 +174,7 @@ export function Settings() {
let value: undefined | number = +e.target.value;
if (isNaN(value) || value < 0) {
console.log(
`Invalid query timeout value: ${e.target.value}, will use default.`
`Invalid query timeout value: ${e.target.value}, will use default.`,
);
value = undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function Stats(): JSX.Element {
chart.field,
chart.differential,
timeRange,
sensor
sensor,
).then((response) => {
const labels: any[] = [];
const values: any[] = [];
Expand All @@ -101,7 +101,7 @@ export function Stats(): JSX.Element {
chart.canvasId,
chart.title,
labels,
values
values,
);
charts.push(canvas);
});
Expand Down Expand Up @@ -152,7 +152,7 @@ function buildChart(
elementId: string,
title: string,
labels: Date[],
values: number[]
values: number[],
): Chart<any> {
const ctx = (
document.getElementById(elementId) as HTMLCanvasElement
Expand Down
Loading

0 comments on commit ea76140

Please sign in to comment.