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