Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tavern/internal/www/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.c8dfb028.css",
"main.js": "/static/js/main.029dcbbc.js",
"main.js": "/static/js/main.ab864788.js",
"react-syntax-highlighter/refractor-core-import.js": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js",
"react-syntax-highlighter_languages_refractor_abap.js": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js",
"react-syntax-highlighter_languages_refractor_actionscript.js": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js",
Expand Down Expand Up @@ -158,7 +158,7 @@
"static/media/eldrich.png": "/static/media/eldrich.a80c74e8249d2461e174.png",
"index.html": "/index.html",
"main.c8dfb028.css.map": "/static/css/main.c8dfb028.css.map",
"main.029dcbbc.js.map": "/static/js/main.029dcbbc.js.map",
"main.ab864788.js.map": "/static/js/main.ab864788.js.map",
"refractor-core-import.d0cd1e85.chunk.js.map": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js.map",
"react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map",
"react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map",
Expand Down Expand Up @@ -315,6 +315,6 @@
},
"entrypoints": [
"static/css/main.c8dfb028.css",
"static/js/main.029dcbbc.js"
"static/js/main.ab864788.js"
]
}
2 changes: 1 addition & 1 deletion tavern/internal/www/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.029dcbbc.js"></script><link href="/static/css/main.c8dfb028.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.ab864788.js"></script><link href="/static/css/main.c8dfb028.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 0 additions & 3 deletions tavern/internal/www/build/static/js/main.029dcbbc.js

This file was deleted.

3 changes: 3 additions & 0 deletions tavern/internal/www/build/static/js/main.ab864788.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tavern/internal/www/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from "@chakra-ui/react";
import './style.css';

import { QuestList } from "./pages/quest-list";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { CreateQuest } from "./pages/create-quest";
import 'react-virtualized/styles.css';
Expand All @@ -16,6 +15,7 @@ import HostList from "./pages/host-list/HostList";
import HostDetails from "./pages/host-details/HostDetails";
import { Dashboard } from "./pages/dashboard";
import { Tomes } from "./pages/tomes";
import Quests from "./pages/quest-list/Quests";


const router = createBrowserRouter([
Expand All @@ -37,7 +37,7 @@ const router = createBrowserRouter([
},
{
path: "/quests",
element: <QuestList />,
element: <Quests />,
},
{
path: "/tasks/:questId",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import React, { useContext } from "react"
import { BeaconFilterBar } from "../../components/beacon-filter-bar";
import { TagContext } from "../../context/TagContext";
import FreeTextSearch from "../../components/tavern-base-ui/DebouncedFreeTextSearch";
import { FilterBarOption } from "../../utils/consts";
import { BeaconFilterBar } from "./beacon-filter-bar";
import { TagContext } from "../context/TagContext";
import FreeTextSearch from "./tavern-base-ui/DebouncedFreeTextSearch";
import { FilterBarOption } from "../utils/consts";

type Props = {
setSearch: (arg: string) => void;
Expand Down
19 changes: 9 additions & 10 deletions tavern/internal/www/src/pages/quest-list/QuestList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import { EmptyState, EmptyStateType } from "../../components/tavern-base-ui/Empt
import FreeTextSearch from "../../components/tavern-base-ui/FreeTextSearch";
import { PageNavItem } from "../../utils/enums";
import { QuestTable } from "./components/QuestTable";
import { useQuests } from "./hooks/useQuest";

export const QuestList = () => {
const navigate = useNavigate();
const {
hasData,
data,
loading,
error,
setSearch
} = useQuests();
// const {
// hasData,
// data,
// loading,
// error,
// setSearch
// } = useQuests();

return (
<PageWrapper currNavItem={PageNavItem.quests}>
Expand All @@ -36,7 +35,7 @@ export const QuestList = () => {
</div>
</div>
<div className="flex flex-col justify-center items-center">
{loading ?
{/* {loading ?
<EmptyState type={EmptyStateType.loading} label="Loading quests..." />
: error ?
<EmptyState type={EmptyStateType.error} label="Error loading quests" />
Expand All @@ -55,7 +54,7 @@ export const QuestList = () => {
</>
:
<EmptyStateNoQuests />
}
} */}
</div>
</PageWrapper>
);
Expand Down
49 changes: 49 additions & 0 deletions tavern/internal/www/src/pages/quest-list/Quests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from "react";
import EmptyStateNoQuests from "../../components/empty-states/EmptyStateNoQuests";
import { PageWrapper } from "../../components/page-wrapper";
import { EmptyState, EmptyStateType } from "../../components/tavern-base-ui/EmptyState";
import FreeTextSearch from "../../components/tavern-base-ui/FreeTextSearch";
import { PageNavItem } from "../../utils/enums";
import QuestFormatWrapper from "./components/QuestFormatWrapper";
import QuestHeader from "./components/QuestHeader";
import { useQuests } from "./hooks/useQuests";

const Quests = () => {
const {
data,
loading,
error,
page,
filtersSelected,
setPage,
setSearch,
setFiltersSelected,
updateQuestList
} = useQuests();

return (
<PageWrapper currNavItem={PageNavItem.quests}>
<QuestHeader />
<div className="p-4 bg-white rounded-lg shadow-lg mt-2">
<FreeTextSearch setSearch={setSearch} placeholder="Search by tome name, quest name, or output" />
</div>
{(loading) ?
<EmptyState type={EmptyStateType.loading} label="Loading quests..." />
: error ?
<EmptyState type={EmptyStateType.error} label="Error loading quests" />
: data?.quests?.edges.length > 0 ?
<QuestFormatWrapper
data={data?.quests?.edges}
totalCount={data?.quests?.totalCount}
pageInfo={data?.quests?.pageInfo}
page={page}
setPage={setPage}
updateQuestList={updateQuestList}
/>
:
<EmptyStateNoQuests />
}
</PageWrapper>
);
}
export default Quests;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { FC } from "react";
import TablePagination from "../../../components/tavern-base-ui/TablePagination";
import { PaginationPageInfo, QuestProps } from "../../../utils/consts";
import { TableRowLimit } from "../../../utils/enums";
import { useFormatQuests } from "../hooks/useFormatQuests";
import { QuestTable } from "./QuestTable";

type QuestFormatWrapperProps = {
totalCount: number;
pageInfo: PaginationPageInfo;
data: Array<QuestProps>;
page: number;
setPage: (num: number) => void
updateQuestList: (afterCursor?: string | undefined, beforeCursor?: string | undefined) => void
};

const QuestFormatWrapper: FC<QuestFormatWrapperProps> = ({
data,
totalCount,
pageInfo,
page,
setPage,
updateQuestList
}) => {
const { data: formattedData } = useFormatQuests(data);
return (
<div className="py-4 bg-white rounded-lg shadow-lg mt-2 flex flex-col gap-1 w-full">
<QuestTable quests={formattedData} />
<TablePagination totalCount={totalCount} pageInfo={pageInfo} refetchTable={updateQuestList} page={page} setPage={setPage} rowLimit={TableRowLimit.QuestRowLimit} />
</div>
);
}
export default QuestFormatWrapper;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { Button } from "@chakra-ui/react";
import { useNavigate } from "react-router-dom";

const QuestHeader = () => {
const navigate = useNavigate();

return (
<div className="border-b border-gray-200 pb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div className="flex-1 flex flex-col gap-2">
<h3 className="text-xl font-semibold leading-6 text-gray-900">Quests</h3>
<div className="max-w-2xl text-sm">
Quests enable multi-beacon managment by taking a list of beacons and executing a tome with customized parameters against them. A quest is made up of tasks assocaited with a single beacon.
</div>
</div>
<div>
<Button size={"sm"}
onClick={() => navigate("/createQuest")}
>
Create new quest
</Button>
</div>
</div>
);
}
export default QuestHeader;
22 changes: 7 additions & 15 deletions tavern/internal/www/src/pages/quest-list/components/QuestTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import { ColumnDef } from "@tanstack/react-table";
import { formatDistance } from "date-fns";
import Table from "../../../components/tavern-base-ui/Table";
import { useNavigate } from "react-router-dom";
import { QuestTableRowType } from "../../../utils/consts";

type QuestTableProps = {
id: string,
name: string,
finished: number,
inprogress: number,
queued: number,
outputCount: number,
lastUpdated: string | null,
errorCount: number,
}

type Props = {
quests: Array<QuestTableProps>;
quests: Array<QuestTableRowType>;
}
export const QuestTable = (props: Props) => {
const { quests } = props;
Expand Down Expand Up @@ -47,7 +38,7 @@ export const QuestTable = (props: Props) => {
</div>
</div>
);
}
},
},
{
id: "lastUpdated",
Expand All @@ -63,7 +54,8 @@ export const QuestTable = (props: Props) => {
const numB = new Date(rowB?.original?.lastUpdated as string);

return numA < numB ? 1 : numA > numB ? -1 : 0;
}
},
enableSorting: false,
},
{
id: "finished",
Expand Down Expand Up @@ -115,7 +107,7 @@ export const QuestTable = (props: Props) => {
);
},
footer: (props: any) => props.column.id,
sortingFn: "alphanumeric"
enableSorting: false,
},
{
id: "error",
Expand All @@ -140,7 +132,7 @@ export const QuestTable = (props: Props) => {
);
},
footer: (props: any) => props.column.id,
sortingFn: "alphanumeric"
enableSorting: false,
},
{
id: "creator",
Expand Down
52 changes: 52 additions & 0 deletions tavern/internal/www/src/pages/quest-list/hooks/useAltQuest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useQuery } from "@apollo/client";
import { useCallback, useState } from "react";
import { TableRowLimit } from "../../../utils/enums";
import { GET_QUEST_QUERY } from "../../../utils/queries";

export const useAltQuest = () => {
const [page, setPage] = useState<number>(1);
const [search, setSearch] = useState("");
const [filtersSelected, setFiltersSelected] = useState<Array<any>>([]);

const handleFilterChange = (filters: Array<any>)=> {
setPage(1);
setFiltersSelected(filters);
}

const handleSearchChange = (search: string)=> {
setPage(1);
setSearch(search);
}

const constructDefaultQuery = useCallback((searchText?: string, afterCursor?: string | undefined, beforeCursor?: string | undefined) => {

const defaultRowLimit = TableRowLimit.TaskRowLimit;
const query = {
"where": {
"and": [] as Array<any>
},
"first": beforeCursor ? null : defaultRowLimit,
"last": beforeCursor ? defaultRowLimit : null,
"after": afterCursor ? afterCursor : null,
"before": beforeCursor ? beforeCursor : null,
"orderBy": [{
"direction": "DESC",
"field": "CREATED_AT"
}]
} as any;

return query
},[]);
const { loading, data, error } = useQuery(GET_QUEST_QUERY,{variables: constructDefaultQuery(), notifyOnNetworkStatusChange: true});

return {
data,
loading,
error,
page,
filtersSelected,
setPage,
setSearch: handleSearchChange,
setFiltersSelected: handleFilterChange,
}
}
Loading