mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-12 05:51:30 +02:00
♻️ order by id desc
This commit is contained in:
@@ -7,7 +7,7 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
import { and, asc, eq, like, or, sql } from "drizzle-orm";
|
import { and, asc, desc, eq, like, or, sql } from "drizzle-orm";
|
||||||
import type { PaginatedResponse } from "@server/types/Pagination";
|
import type { PaginatedResponse } from "@server/types/Pagination";
|
||||||
|
|
||||||
export type ListRedirectsResponse = PaginatedResponse<{
|
export type ListRedirectsResponse = PaginatedResponse<{
|
||||||
@@ -171,7 +171,7 @@ export async function listRedirects(
|
|||||||
baseQuery
|
baseQuery
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
.offset(pageSize * (page - 1))
|
.offset(pageSize * (page - 1))
|
||||||
.orderBy(asc(redirects.name))
|
.orderBy(desc(redirects.redirectId))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response<ListRedirectsResponse>(res, {
|
return response<ListRedirectsResponse>(res, {
|
||||||
|
|||||||
@@ -110,6 +110,12 @@ export default function RedirectsTable({
|
|||||||
filter({ searchParams });
|
filter({ searchParams });
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
// Prefix matches/rewrites cover everything beneath the path, so show the
|
||||||
|
// implied glob rather than the bare prefix.
|
||||||
|
function withPrefixGlob(path: string) {
|
||||||
|
return path.endsWith("/") ? `${path}*` : `${path}/*`;
|
||||||
|
}
|
||||||
|
|
||||||
async function toggleEnabled(row: RedirectRow, enabled: boolean) {
|
async function toggleEnabled(row: RedirectRow, enabled: boolean) {
|
||||||
setRows((prev) =>
|
setRows((prev) =>
|
||||||
prev.map((r) =>
|
prev.map((r) =>
|
||||||
@@ -218,10 +224,6 @@ export default function RedirectsTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log({
|
|
||||||
redirect
|
|
||||||
});
|
|
||||||
|
|
||||||
if (redirect.domainId) {
|
if (redirect.domainId) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
@@ -266,7 +268,9 @@ export default function RedirectsTable({
|
|||||||
<code className="text-sm truncate">
|
<code className="text-sm truncate">
|
||||||
{host ?? ""}
|
{host ?? ""}
|
||||||
<span className="text-muted-foreground">
|
<span className="text-muted-foreground">
|
||||||
{redirect.matchPath}
|
{redirect.pathMatchType === "prefix"
|
||||||
|
? withPrefixGlob(redirect.matchPath)
|
||||||
|
: redirect.matchPath}
|
||||||
</span>
|
</span>
|
||||||
</code>
|
</code>
|
||||||
);
|
);
|
||||||
@@ -286,7 +290,9 @@ export default function RedirectsTable({
|
|||||||
{redirect.destinationDomain}
|
{redirect.destinationDomain}
|
||||||
{redirect.rewritePath && (
|
{redirect.rewritePath && (
|
||||||
<span className="text-muted-foreground">
|
<span className="text-muted-foreground">
|
||||||
{redirect.rewritePath}
|
{redirect.rewritePathType === "prefix"
|
||||||
|
? withPrefixGlob(redirect.rewritePath)
|
||||||
|
: redirect.rewritePath}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</code>
|
</code>
|
||||||
|
|||||||
Reference in New Issue
Block a user