feat(templates): add pagination with total counts to catalog and campaign picker
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Test Catalog's pagination showed only 'Page N' with no way to know how many pages existed, and the campaign 'Add Test' modal's template picker had no pagination at all — with 2800+ templates in the catalog, its flat 100-row fetch made most templates unreachable unless a search happened to match. Adds GET /test-templates/count (open to any authenticated user, mirrors the list endpoint's filters) and wires real 'Page N of M' + total-available counts into both.
This commit is contained in:
@@ -65,6 +65,25 @@ export async function getTemplates(
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Total count of templates matching the same filters as getTemplates() — for pagination. */
|
||||
export async function getTemplateCount(
|
||||
filters?: Omit<TemplateFilters, "offset" | "limit">,
|
||||
): Promise<number> {
|
||||
const params = new URLSearchParams();
|
||||
if (filters?.source) params.append("source", filters.source);
|
||||
if (filters?.platform) params.append("platform", filters.platform);
|
||||
if (filters?.severity) params.append("severity", filters.severity);
|
||||
if (filters?.mitre_technique_id)
|
||||
params.append("mitre_technique_id", filters.mitre_technique_id);
|
||||
if (filters?.search) params.append("search", filters.search);
|
||||
params.append("is_active", filters?.is_active !== undefined ? String(filters.is_active) : "true");
|
||||
|
||||
const { data } = await client.get<{ total: number }>(
|
||||
`/test-templates/count${params.toString() ? `?${params}` : ""}`,
|
||||
);
|
||||
return data.total;
|
||||
}
|
||||
|
||||
// ── Detail ─────────────────────────────────────────────────────────
|
||||
|
||||
/** Fetch a single test template by ID. */
|
||||
|
||||
Reference in New Issue
Block a user