diff --git a/assets/content/privacy.md b/assets/content/privacy.md deleted file mode 100644 index 0557a91..0000000 --- a/assets/content/privacy.md +++ /dev/null @@ -1 +0,0 @@ -# Privacy Policy diff --git a/assets/content/tos.md b/assets/content/tos.md deleted file mode 100644 index 1dd3a82..0000000 --- a/assets/content/tos.md +++ /dev/null @@ -1 +0,0 @@ -# Terms of Service diff --git a/assets/controllers/.gitkeep b/assets/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/assets/pages/tracking/WatchlistPage.tsx b/assets/pages/tracking/WatchlistPage.tsx index a392646..882e896 100644 --- a/assets/pages/tracking/WatchlistPage.tsx +++ b/assets/pages/tracking/WatchlistPage.tsx @@ -1,7 +1,7 @@ import React, {useEffect, useState} from "react"; -import {Button, Card, Divider, Flex, Form, Input, message, Select, Skeleton, Space} from "antd"; +import {Button, Card, Divider, Flex, Form, Input, message, Popconfirm, Select, Skeleton, Space, Typography} from "antd"; -import {CloseOutlined, DeleteFilled, MinusCircleOutlined, PlusOutlined, ThunderboltFilled} from "@ant-design/icons"; +import {DeleteFilled, MinusCircleOutlined, PlusOutlined, ThunderboltFilled} from "@ant-design/icons"; import {deleteWatchlist, EventAction, getWatchlists, postWatchlist} from "../../utils/api"; import {AxiosError} from "axios"; @@ -66,14 +66,15 @@ const trigerActionItems = [ } ] +type Watchlist = { token: string, domains: { ldhName: string }[], triggers?: { event: EventAction, action: string }[] } + export default function WatchlistPage() { const [form] = Form.useForm() const [messageApi, contextHolder] = message.useMessage() - const [watchlists, setWatchlists] = useState<{ token: string }[] | null>() + const [watchlists, setWatchlists] = useState() const onCreateWatchlist = (values: { domains: string[], triggers: { event: string, action: string }[] }) => { const domainsURI = values.domains.map(d => '/api/domains/' + d) - postWatchlist(domainsURI, values.triggers).then((w) => { form.resetFields() refreshWatchlists() @@ -159,36 +160,61 @@ export default function WatchlistPage() { )} - - {(fields, {add, remove}) => ( + { + if (!domains || domains.length < 1) { + return Promise.reject(new Error('At least one domain trigger')); + } + }, + }, + ]} + > + {(fields, {add, remove}, {errors}) => ( <> - {fields.map((field) => ( - ( + { - remove(field.name); - }} - /> - } > - - + + + - - + ) : null} + ))} - + )} @@ -215,18 +242,32 @@ export default function WatchlistPage() { - - - {watchlists && watchlists.map(watchlist => + + + {watchlists && watchlists.length > 0 && + {watchlists.map(watchlist => <> - - { - deleteWatchlist(watchlist.token).then(refreshWatchlists) - }}/>}> + deleteWatchlist(watchlist.token).then(refreshWatchlists)} + okText="Yes" + cancelText="No" + > }> + + Domains : {watchlist?.domains.map(d => d.ldhName).join(',')} + + { + watchlist.triggers && + Triggers : {watchlist.triggers.map(t => `${t.event} => ${t.action}`).join(',')} + + } + )} - - + + } + } \ No newline at end of file diff --git a/src/Entity/Domain.php b/src/Entity/Domain.php index e91f2af..bfafa75 100644 --- a/src/Entity/Domain.php +++ b/src/Entity/Domain.php @@ -47,7 +47,7 @@ class Domain { #[ORM\Id] #[ORM\Column(length: 255)] - #[Groups(['domain:item', 'domain:list', 'watchlist:item'])] + #[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])] private ?string $ldhName = null; #[ORM\Column(length: 255, nullable: true)] diff --git a/src/Entity/WatchList.php b/src/Entity/WatchList.php index 9567a60..d5be416 100644 --- a/src/Entity/WatchList.php +++ b/src/Entity/WatchList.php @@ -58,14 +58,14 @@ class WatchList #[ORM\JoinTable(name: 'watch_lists_domains', joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')], inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')])] - #[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])] + #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] private Collection $domains; /** * @var Collection */ #[ORM\OneToMany(targetEntity: WatchListTrigger::class, mappedBy: 'watchList', cascade: ['persist'], orphanRemoval: true)] - #[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])] + #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] #[SerializedName("triggers")] private Collection $watchListTriggers; diff --git a/src/Entity/WatchListTrigger.php b/src/Entity/WatchListTrigger.php index d8c9b93..a9b9746 100644 --- a/src/Entity/WatchListTrigger.php +++ b/src/Entity/WatchListTrigger.php @@ -13,7 +13,7 @@ class WatchListTrigger { #[ORM\Id] #[ORM\Column(length: 255)] - #[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])] + #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] private ?string $event = null; #[ORM\Id] @@ -23,7 +23,7 @@ class WatchListTrigger #[ORM\Id] #[ORM\Column(enumType: TriggerAction::class)] - #[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])] + #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] private ?TriggerAction $action = null; public function getEvent(): ?string