mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
wip: submit watchlist triggers live
This commit is contained in:
parent
130ce1bbac
commit
596b9b548d
@ -7,7 +7,7 @@ import type {Connector} from '../../../utils/api/connectors'
|
||||
import {rdapEventDetailTranslation, rdapEventNameTranslation} from '../../../utils/functions/rdapTranslation'
|
||||
import {actionToColor} from '../../../utils/functions/actionToColor'
|
||||
import {actionToIcon} from '../../../utils/functions/actionToIcon'
|
||||
import {EventAction, putWatchlistTrigger, Watchlist} from '../../../utils/api'
|
||||
import {EventAction, createWatchlistTrigger, Watchlist, deleteWatchlistTrigger} from '../../../utils/api'
|
||||
import {formItemLayoutWithOutLabel} from "../../../utils/providers"
|
||||
|
||||
type TagRender = SelectProps['tagRender']
|
||||
@ -66,12 +66,12 @@ export function WatchlistForm({form, connectors, onFinish, isCreation, watchList
|
||||
if (isCreation) return
|
||||
|
||||
setTriggersLoading(true);
|
||||
await putWatchlistTrigger(watchList!.token, { // FIXME this 500s
|
||||
await createWatchlistTrigger(watchList!.token, { // FIXME this 500s
|
||||
watchList: watchList!['@id'],
|
||||
event,
|
||||
action: 'email',
|
||||
});
|
||||
await putWatchlistTrigger(watchList!.token, {
|
||||
await createWatchlistTrigger(watchList!.token, {
|
||||
watchList: watchList!['@id'],
|
||||
event,
|
||||
action: 'chat',
|
||||
@ -83,7 +83,17 @@ export function WatchlistForm({form, connectors, onFinish, isCreation, watchList
|
||||
if (isCreation) return
|
||||
|
||||
setTriggersLoading(true);
|
||||
// TODO
|
||||
await deleteWatchlistTrigger(watchList!.token, {
|
||||
watchList: watchList!['@id'],
|
||||
event,
|
||||
action: 'email',
|
||||
});
|
||||
await deleteWatchlistTrigger(watchList!.token, {
|
||||
watchList: watchList!['@id'],
|
||||
event,
|
||||
action: 'chat',
|
||||
});
|
||||
setTriggersLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -57,11 +57,19 @@ export async function getTrackedDomainList(params: { page: number, itemsPerPage:
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function putWatchlistTrigger(watchListToken: string, watchListTrigger: WatchlistTrigger): Promise<WatchlistTrigger> {
|
||||
export async function createWatchlistTrigger(watchListToken: string, watchListTrigger: WatchlistTrigger): Promise<WatchlistTrigger> {
|
||||
const response = await request<WatchlistTrigger>({
|
||||
method: 'PUT',
|
||||
url: `watchlists/${watchListToken}/triggers`,
|
||||
method: 'POST',
|
||||
url: `watchlists/${watchListToken}/triggers/${watchListTrigger.action}/${watchListTrigger.event}`,
|
||||
data: watchListTrigger,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteWatchlistTrigger(watchListToken: string, watchListTrigger: WatchlistTrigger): Promise<void> {
|
||||
await request<void>({
|
||||
method: 'DELETE',
|
||||
url: `watchlists/${watchListToken}/triggers/${watchListTrigger.action}/${watchListTrigger.event}`,
|
||||
data: watchListTrigger
|
||||
});
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Link;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\Metadata\Put;
|
||||
use App\Config\TriggerAction;
|
||||
use App\Repository\EventTriggerRepository;
|
||||
@ -24,11 +25,8 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
'watchListId' => new Link(fromProperty: 'token', toProperty: 'watchList', fromClass: WatchList::class),
|
||||
],
|
||||
),
|
||||
new Put(
|
||||
uriTemplate: '/watchlists/{watchListId}/triggers',
|
||||
uriVariables: [
|
||||
'watchListId' => new Link(fromProperty: 'token', toProperty: 'watchList', fromClass: WatchList::class),
|
||||
],
|
||||
new Post(
|
||||
security: 'true', // FIXME check the submitted object
|
||||
),
|
||||
new Delete(),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user