mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(irc): manually re-process announces (#1419)
* fix(releases): add manual processing * feat(irc): add re-process button to channel msg * feat(irc): add missing client method * feat(web): change reprocess icon placement --------- Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
parent
d9fc163655
commit
be05ffba73
15 changed files with 306 additions and 18 deletions
|
@ -278,6 +278,9 @@ export const APIClient = {
|
|||
sendCmd: (cmd: SendIrcCmdRequest) => appClient.Post(`api/irc/network/${cmd.network_id}/cmd`, {
|
||||
body: cmd
|
||||
}),
|
||||
reprocessAnnounce: (networkId: number, channel: string, msg: string) => appClient.Post(`api/irc/network/${networkId}/channel/${channel}/announce/process`, {
|
||||
body: { msg: msg }
|
||||
}),
|
||||
events: (network: string) => new EventSource(
|
||||
`${sseBaseUrl()}api/irc/events?stream=${encodeRFC3986URIComponent(network)}`,
|
||||
{ withCredentials: true }
|
||||
|
|
|
@ -139,7 +139,7 @@ export const Logs = () => {
|
|||
>
|
||||
<span
|
||||
title={entry.time}
|
||||
className="font-mono text-gray-500 dark:text-gray-600 mr-2 h-full"
|
||||
className="font-mono text-gray-500 dark:text-gray-600 h-full"
|
||||
>
|
||||
{format(new Date(entry.time), "HH:mm:ss")}
|
||||
</span>
|
||||
|
@ -150,10 +150,10 @@ export const Logs = () => {
|
|||
"font-mono font-semibold h-full"
|
||||
)}
|
||||
>
|
||||
{entry.level}
|
||||
{` ${entry.level} `}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="ml-2 text-black dark:text-gray-300">
|
||||
<span className="text-black dark:text-gray-300">
|
||||
{entry.message}
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Fragment, MouseEvent, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useMutation, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { LockClosedIcon, LockOpenIcon, PlusIcon } from "@heroicons/react/24/solid";
|
||||
import { ArrowPathIcon, LockClosedIcon, LockOpenIcon, PlusIcon } from "@heroicons/react/24/solid";
|
||||
import { Menu, Transition } from "@headlessui/react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import {
|
||||
|
@ -31,6 +31,7 @@ import { SettingsContext } from "@utils/Context";
|
|||
import { Checkbox } from "@components/Checkbox";
|
||||
|
||||
import { Section } from "./_components";
|
||||
import { RingResizeSpinner } from "@components/Icons.tsx";
|
||||
|
||||
interface SortConfig {
|
||||
key: keyof ListItemProps["network"] | "enabled";
|
||||
|
@ -575,6 +576,49 @@ const ListItemDropdown = ({
|
|||
);
|
||||
};
|
||||
|
||||
interface ReprocessAnnounceProps {
|
||||
networkId: number;
|
||||
channel: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
const ReprocessAnnounceButton = ({ networkId, channel, msg }: ReprocessAnnounceProps) => {
|
||||
const mutation = useMutation({
|
||||
mutationFn: (req: IrcProcessManualRequest) => APIClient.irc.reprocessAnnounce(req.network_id, req.channel, req.msg),
|
||||
onSuccess: () => {
|
||||
toast.custom((t) => (
|
||||
<Toast type="success" body={`Announce sent to re-process!`} t={t} />
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
const reprocessAnnounce = () => {
|
||||
const req: IrcProcessManualRequest = {
|
||||
network_id: networkId,
|
||||
msg: msg,
|
||||
channel: channel,
|
||||
}
|
||||
|
||||
if (channel.startsWith("#")) {
|
||||
req.channel = channel.replace("#", "")
|
||||
}
|
||||
|
||||
mutation.mutate(req);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="block">
|
||||
<button className="flex items-center justify-center size-5 mr-1 p-1 rounded transition border-gray-500 bg-gray-250 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600" onClick={reprocessAnnounce} title="Re-process announce">
|
||||
{mutation.isPending
|
||||
? <RingResizeSpinner className="text-blue-500 iconHeight" aria-hidden="true" />
|
||||
: <ArrowPathIcon />
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
type IrcEvent = {
|
||||
channel: string;
|
||||
nick: string;
|
||||
|
@ -684,10 +728,16 @@ export const Events = ({ network, channel }: EventsProps) => {
|
|||
key={idx}
|
||||
className={classNames(
|
||||
settings.indentLogLines ? "grid justify-start grid-flow-col" : "",
|
||||
settings.hideWrappedText ? "truncate hover:text-ellipsis hover:whitespace-normal" : ""
|
||||
settings.hideWrappedText ? "truncate hover:text-ellipsis hover:whitespace-normal" : "",
|
||||
"flex items-center hover:bg-gray-200 hover:dark:bg-gray-800"
|
||||
)}
|
||||
>
|
||||
<span className="font-mono text-gray-500 dark:text-gray-500 mr-1"><span className="dark:text-gray-600"><span className="dark:text-gray-700">[{simplifyDate(entry.time)}]</span> {entry.nick}:</span> {entry.msg}</span>
|
||||
<ReprocessAnnounceButton networkId={network.id} channel={channel} msg={entry.msg} />
|
||||
<div className="flex-1">
|
||||
<span className="font-mono text-gray-500 dark:text-gray-500 mr-1">
|
||||
<span className="dark:text-gray-600"><span className="dark:text-gray-700">[{simplifyDate(entry.time)}]</span> {entry.nick}:</span> {entry.msg}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
|
7
web/src/types/Irc.d.ts
vendored
7
web/src/types/Irc.d.ts
vendored
|
@ -89,3 +89,10 @@ interface SendIrcCmdRequest {
|
|||
nick: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
interface IrcProcessManualRequest {
|
||||
network_id: number;
|
||||
channel: string;
|
||||
nick?: string;
|
||||
msg: string;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue