mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat: return action rejections from arrs (#103)
* refactor: push status * feat: return push status for arr actions
This commit is contained in:
parent
20138030e1
commit
373c85f060
16 changed files with 294 additions and 255 deletions
|
@ -1,4 +1,4 @@
|
|||
import { ExclamationCircleIcon } from "@heroicons/react/outline"
|
||||
import { BanIcon, ExclamationCircleIcon } from "@heroicons/react/outline"
|
||||
import ClockIcon from "@heroicons/react/outline/ClockIcon"
|
||||
import { ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, CheckIcon } from "@heroicons/react/solid"
|
||||
import { formatDistanceToNowStrict } from "date-fns"
|
||||
|
@ -7,7 +7,7 @@ import { useQuery } from "react-query"
|
|||
import { useTable, useSortBy, usePagination } from "react-table"
|
||||
import APIClient from "../api/APIClient"
|
||||
import { EmptyListState } from "../components/emptystates"
|
||||
import { classNames } from "../utils"
|
||||
import { classNames, simplifyDate } from "../utils"
|
||||
|
||||
export function Releases() {
|
||||
return (
|
||||
|
@ -127,19 +127,22 @@ interface ReleaseStatusCellProps {
|
|||
|
||||
export function ReleaseStatusCell({ value, column, row }: ReleaseStatusCellProps) {
|
||||
const statusMap: any = {
|
||||
"PUSH_REJECTED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-pink-100 text-pink-800 hover:bg-pink-300">
|
||||
"PUSH_ERROR": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-pink-100 text-pink-800 hover:bg-pink-300 cursor-pointer">
|
||||
<ExclamationCircleIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>,
|
||||
"PUSH_APPROVED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-green-100 text-green-800 hover:bg-green-300">
|
||||
"PUSH_REJECTED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-blue-200 dark:bg-blue-100 text-blue-400 dark:text-blue-800 hover:bg-blue-300 dark:hover:bg-blue-400 cursor-pointer">
|
||||
<BanIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>,
|
||||
"PUSH_APPROVED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-green-100 text-green-800 hover:bg-green-300 cursor-pointer">
|
||||
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>,
|
||||
"PENDING": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-yellow-100 text-yellow-800 hover:bg-yellow-200">
|
||||
"PENDING": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-yellow-100 text-yellow-800 hover:bg-yellow-200 cursor-pointer">
|
||||
<ClockIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>,
|
||||
}
|
||||
return (
|
||||
<div className="flex text-sm font-medium text-gray-900 dark:text-gray-300">
|
||||
{value.map((v, idx) => <div key={idx} title={`action: ${v.action}, type: ${v.type}, status: ${v.status}, ;time: ${v.timestamp}`}>{statusMap[v.status]}</div>)}
|
||||
{value.map((v, idx) => <div key={idx} title={`action: ${v.action}, type: ${v.type}, status: ${v.status}, time: ${simplifyDate(v.timestamp)}, rejections: ${v?.rejections}`}>{statusMap[v.status]}</div>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
2
web/src/types/Release.d.ts
vendored
2
web/src/types/Release.d.ts
vendored
|
@ -18,7 +18,7 @@ interface ReleaseActionStatus {
|
|||
action: string;
|
||||
type: string;
|
||||
rejections: string[];
|
||||
timestamp: Date
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
interface ReleaseFindResponse {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { formatDistanceToNowStrict, formatISO9075 } from "date-fns";
|
||||
|
||||
// sleep for x ms
|
||||
export function sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
@ -56,4 +58,23 @@ export function classNames(...classes: string[]) {
|
|||
}
|
||||
|
||||
// column widths for inputs etc
|
||||
export type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
||||
export type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
||||
|
||||
// simplify date
|
||||
export function simplifyDate(date: string) {
|
||||
if (date !== "0001-01-01T00:00:00Z") {
|
||||
return formatISO9075(new Date(date))
|
||||
}
|
||||
return "n/a"
|
||||
}
|
||||
|
||||
// if empty date show as n/a
|
||||
export function IsEmptyDate(date: string) {
|
||||
if (date !== "0001-01-01T00:00:00Z") {
|
||||
return formatDistanceToNowStrict(
|
||||
new Date(date),
|
||||
{ addSuffix: true }
|
||||
)
|
||||
}
|
||||
return "n/a"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue