mirror of
https://github.com/idanoo/autobrr
synced 2025-07-25 01:39:13 +00:00
feat(web): move from react-router to @tanstack/router (#1338)
* fix(auth): invalid cookie handling and wrongful basic auth invalidation * fix(auth): fix test to reflect new HTTP status code * fix(auth/web): do not throw on error * fix(http): replace http codes in middleware to prevent basic auth invalidation fix typo in comment * fix test * fix(web): api client handle 403 * refactor(http): auth_test use testify.assert * refactor(http): set session opts after valid login * refactor(http): send more client headers * fix(http): test * refactor(web): move router to tanstack/router * refactor(web): use route loaders and suspense * refactor(web): useSuspense for settings * refactor(web): invalidate cookie in middleware * fix: loclfile * fix: load filter/id * fix(web): login, onboard, types, imports * fix(web): filter load * fix(web): build errors * fix(web): ts-expect-error * fix(tests): filter_test.go * fix(filters): tests * refactor: remove duplicate spinner components refactor: ReleaseTable.tsx loading animation refactor: remove dedicated `pendingComponent` for `settingsRoute` * fix: refactor missed SectionLoader to RingResizeSpinner * fix: substitute divides with borders to account for unloaded elements * fix(api): action status URL param * revert: action status URL param add comment * fix(routing): notfound handling and split files * fix(filters): notfound get params * fix(queries): colon * fix(queries): comments ts-ignore * fix(queries): extract queryKeys * fix(queries): remove err * fix(routes): move zob schema inline * fix(auth): middleware and redirect to login * fix(auth): failing test * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix: JSX element stealing focus from searchbar * reimplement empty release table state text * fix(context): use deep-copy * fix(releases): empty state and filter input warnings * fix(releases): empty states * fix(auth): onboarding * fix(cache): invalidate queries --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
cc9656cd41
commit
1a23b69bcf
64 changed files with 2543 additions and 2091 deletions
|
@ -3,23 +3,28 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { APIClient } from "@api/APIClient";
|
||||
import { useQuery} from "@tanstack/react-query";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { classNames } from "@utils";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { LinkIcon } from "@heroicons/react/24/solid";
|
||||
import { ReleasesStatsQueryOptions } from "@api/queries";
|
||||
|
||||
interface StatsItemProps {
|
||||
name: string;
|
||||
value?: number;
|
||||
placeholder?: string;
|
||||
onClick?: () => void;
|
||||
name: string;
|
||||
value?: number;
|
||||
placeholder?: string;
|
||||
to?: string;
|
||||
eventType?: string;
|
||||
}
|
||||
|
||||
const StatsItem = ({ name, placeholder, value, onClick }: StatsItemProps) => (
|
||||
<div
|
||||
const StatsItem = ({ name, placeholder, value, to, eventType }: StatsItemProps) => (
|
||||
<Link
|
||||
className="group relative px-4 py-3 cursor-pointer overflow-hidden rounded-lg shadow-lg bg-white dark:bg-gray-800 hover:scale-110 hover:shadow-xl transition-all duration-200 ease-in-out"
|
||||
onClick={onClick}
|
||||
to={to}
|
||||
search={{
|
||||
action_status: eventType
|
||||
}}
|
||||
params={{}}
|
||||
>
|
||||
<dt>
|
||||
<div className="flex items-center text-sm font-medium text-gray-500 group-hover:dark:text-gray-475 group-hover:text-gray-600 transition-colors duration-200 ease-in-out">
|
||||
|
@ -36,24 +41,11 @@ const StatsItem = ({ name, placeholder, value, onClick }: StatsItemProps) => (
|
|||
<p>{value}</p>
|
||||
</dd>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
|
||||
export const Stats = () => {
|
||||
const navigate = useNavigate();
|
||||
const handleStatClick = (filterType: string) => {
|
||||
if (filterType) {
|
||||
navigate(`/releases?filter=${filterType}`);
|
||||
} else {
|
||||
navigate("/releases");
|
||||
}
|
||||
};
|
||||
|
||||
const { isLoading, data } = useSuspenseQuery({
|
||||
queryKey: ["dash_release_stats"],
|
||||
queryFn: APIClient.release.stats,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
const { isLoading, data } = useQuery(ReleasesStatsQueryOptions());
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -62,11 +54,11 @@ export const Stats = () => {
|
|||
</h1>
|
||||
|
||||
<dl className={classNames("grid grid-cols-2 gap-2 sm:gap-5 mt-5 sm:grid-cols-2 lg:grid-cols-4", isLoading ? "animate-pulse" : "")}>
|
||||
<StatsItem name="Filtered Releases" onClick={() => handleStatClick("")} value={data?.filtered_count ?? 0} />
|
||||
<StatsItem name="Filtered Releases" to="/releases" value={data?.filtered_count ?? 0} />
|
||||
{/* <StatsItem name="Filter Rejected Releases" stat={data?.filter_rejected_count} /> */}
|
||||
<StatsItem name="Approved Pushes" onClick={() => handleStatClick("PUSH_APPROVED")} value={data?.push_approved_count ?? 0} />
|
||||
<StatsItem name="Rejected Pushes" onClick={() => handleStatClick("PUSH_REJECTED")} value={data?.push_rejected_count ?? 0 } />
|
||||
<StatsItem name="Errored Pushes" onClick={() => handleStatClick("PUSH_ERROR")} value={data?.push_error_count ?? 0} />
|
||||
<StatsItem name="Approved Pushes" to="/releases" eventType="PUSH_APPROVED" value={data?.push_approved_count ?? 0} />
|
||||
<StatsItem name="Rejected Pushes" to="/releases" eventType="PUSH_REJECTED" value={data?.push_rejected_count ?? 0 } />
|
||||
<StatsItem name="Errored Pushes" to="/releases" eventType="PUSH_ERROR" value={data?.push_error_count ?? 0} />
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue